Skip to content

Commit 34008f8

Browse files
authored
Merge branch 'main' into alwx/improvement/5868
2 parents 9c01257 + 57c9284 commit 34008f8

13 files changed

Lines changed: 170 additions & 115 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: 'Platform Check'
2+
description: 'Decides whether to skip a build/test based on detect-changes outputs'
3+
4+
inputs:
5+
platform:
6+
description: 'Target platform (ios, macos, android, web)'
7+
required: true
8+
sample_changed:
9+
description: 'Whether the sample app itself changed (true/false)'
10+
required: true
11+
needs_ios:
12+
description: 'detect-changes needs_ios output'
13+
required: false
14+
default: 'false'
15+
needs_android:
16+
description: 'detect-changes needs_android output'
17+
required: false
18+
default: 'false'
19+
needs_web:
20+
description: 'detect-changes needs_web output'
21+
required: false
22+
default: 'false'
23+
24+
outputs:
25+
skip:
26+
description: 'Whether to skip this platform (true/false)'
27+
value: ${{ steps.check.outputs.skip }}
28+
29+
runs:
30+
using: 'composite'
31+
steps:
32+
- name: Check if platform is needed
33+
id: check
34+
shell: bash
35+
run: |
36+
PLATFORM="${{ inputs.platform }}"
37+
SAMPLE_CHANGED="${{ inputs.sample_changed }}"
38+
39+
if [[ "$SAMPLE_CHANGED" == "true" ]]; then
40+
echo "skip=false" >> "$GITHUB_OUTPUT"
41+
echo "Sample app changed — building/testing $PLATFORM."
42+
exit 0
43+
fi
44+
45+
# macOS uses the iOS change-detection flag
46+
case "$PLATFORM" in
47+
ios|macos) NEEDS="${{ inputs.needs_ios }}" ;;
48+
android) NEEDS="${{ inputs.needs_android }}" ;;
49+
web) NEEDS="${{ inputs.needs_web }}" ;;
50+
*)
51+
echo "::warning::Unknown platform '$PLATFORM' — not skipping."
52+
echo "skip=false" >> "$GITHUB_OUTPUT"
53+
exit 0
54+
;;
55+
esac
56+
57+
if [[ "$NEEDS" != "true" ]]; then
58+
echo "skip=true" >> "$GITHUB_OUTPUT"
59+
echo "Skipping $PLATFORM — no relevant changes detected."
60+
else
61+
echo "skip=false" >> "$GITHUB_OUTPUT"
62+
fi

.github/workflows/sample-application-expo.yml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,17 @@ jobs:
5959
- platform: 'android'
6060
ios-use-frameworks: 'dynamic-frameworks'
6161
steps:
62+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
63+
6264
- name: Check if platform is needed
6365
id: platform-check
64-
run: |
65-
SAMPLE_CHANGED="${{ needs.detect-changes.outputs.sample_expo }}"
66-
67-
if [[ "$SAMPLE_CHANGED" == "true" ]]; then
68-
echo "skip=false" >> "$GITHUB_OUTPUT"
69-
echo "Sample app changed — building ${{ matrix.platform }}."
70-
elif [[ "${{ matrix.platform }}" == "ios" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then
71-
echo "skip=true" >> "$GITHUB_OUTPUT"
72-
echo "Skipping iOS — no relevant changes detected."
73-
elif [[ "${{ matrix.platform }}" == "android" && "${{ needs.detect-changes.outputs.needs_android }}" != "true" ]]; then
74-
echo "skip=true" >> "$GITHUB_OUTPUT"
75-
echo "Skipping Android — no relevant changes detected."
76-
elif [[ "${{ matrix.platform }}" == "web" && "${{ needs.detect-changes.outputs.needs_web }}" != "true" ]]; then
77-
echo "skip=true" >> "$GITHUB_OUTPUT"
78-
echo "Skipping Web — no relevant changes detected."
79-
fi
80-
81-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
82-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
66+
uses: ./.github/actions/platform-check
67+
with:
68+
platform: ${{ matrix.platform }}
69+
sample_changed: ${{ needs.detect-changes.outputs.sample_expo }}
70+
needs_ios: ${{ needs.detect-changes.outputs.needs_ios }}
71+
needs_android: ${{ needs.detect-changes.outputs.needs_android }}
72+
needs_web: ${{ needs.detect-changes.outputs.needs_web }}
8373

8474
- name: Enable Corepack (NPM)
8575
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform != 'ios' }}

.github/workflows/sample-application.yml

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -74,32 +74,16 @@ jobs:
7474
- ios-use-frameworks: 'dynamic-frameworks'
7575
platform: 'macos'
7676
steps:
77+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
78+
7779
- name: Check if platform is needed
7880
id: platform-check
79-
run: |
80-
# Sample app changes should always build all platforms (that's the
81-
# whole point of this workflow). The needs_ios/needs_android flags
82-
# only track SDK source & native code — not sample app files.
83-
SAMPLE_CHANGED="${{ needs.detect-changes.outputs.sample_react_native }}"
84-
85-
if [[ "$SAMPLE_CHANGED" == "true" ]]; then
86-
echo "skip=false" >> "$GITHUB_OUTPUT"
87-
echo "Sample app changed — building ${{ matrix.platform }}."
88-
elif [[ "${{ matrix.platform }}" == "ios" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then
89-
echo "skip=true" >> "$GITHUB_OUTPUT"
90-
echo "Skipping iOS — no relevant changes detected."
91-
elif [[ "${{ matrix.platform }}" == "macos" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then
92-
echo "skip=true" >> "$GITHUB_OUTPUT"
93-
echo "Skipping macOS — no relevant changes detected."
94-
elif [[ "${{ matrix.platform }}" == "android" && "${{ needs.detect-changes.outputs.needs_android }}" != "true" ]]; then
95-
echo "skip=true" >> "$GITHUB_OUTPUT"
96-
echo "Skipping Android — no relevant changes detected."
97-
else
98-
echo "skip=false" >> "$GITHUB_OUTPUT"
99-
fi
100-
101-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
102-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
81+
uses: ./.github/actions/platform-check
82+
with:
83+
platform: ${{ matrix.platform }}
84+
sample_changed: ${{ needs.detect-changes.outputs.sample_react_native }}
85+
needs_ios: ${{ needs.detect-changes.outputs.needs_ios }}
86+
needs_android: ${{ needs.detect-changes.outputs.needs_android }}
10387

10488
- name: Enable Corepack (NPM)
10589
if: ${{ steps.platform-check.outputs.skip != 'true' && matrix.platform == 'android' }}
@@ -264,26 +248,16 @@ jobs:
264248
build-type: 'production'
265249

266250
steps:
251+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
252+
267253
- name: Check if platform is needed
268254
id: platform-check
269-
run: |
270-
SAMPLE_CHANGED="${{ needs.detect-changes.outputs.sample_react_native }}"
271-
272-
if [[ "$SAMPLE_CHANGED" == "true" ]]; then
273-
echo "skip=false" >> "$GITHUB_OUTPUT"
274-
echo "Sample app changed — testing ${{ matrix.platform }}."
275-
elif [[ "${{ matrix.platform }}" == "ios" && "${{ needs.detect-changes.outputs.needs_ios }}" != "true" ]]; then
276-
echo "skip=true" >> "$GITHUB_OUTPUT"
277-
echo "Skipping iOS — no relevant changes detected."
278-
elif [[ "${{ matrix.platform }}" == "android" && "${{ needs.detect-changes.outputs.needs_android }}" != "true" ]]; then
279-
echo "skip=true" >> "$GITHUB_OUTPUT"
280-
echo "Skipping Android — no relevant changes detected."
281-
else
282-
echo "skip=false" >> "$GITHUB_OUTPUT"
283-
fi
284-
285-
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
286-
if: ${{ steps.platform-check.outputs.skip != 'true' }}
255+
uses: ./.github/actions/platform-check
256+
with:
257+
platform: ${{ matrix.platform }}
258+
sample_changed: ${{ needs.detect-changes.outputs.sample_react_native }}
259+
needs_ios: ${{ needs.detect-changes.outputs.needs_ios }}
260+
needs_android: ${{ needs.detect-changes.outputs.needs_android }}
287261

288262
- name: Install Maestro
289263
if: ${{ steps.platform-check.outputs.skip != 'true' }}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
- Bump JavaScript SDK from v10.44.0 to v10.45.0 ([#5848](https://github.com/getsentry/sentry-react-native/pull/5848))
2424
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#10450)
2525
- [diff](https://github.com/getsentry/sentry-javascript/compare/10.44.0...10.45.0)
26+
- Bump CLI from v3.3.3 to v3.3.4 ([#5891](https://github.com/getsentry/sentry-react-native/pull/5891))
27+
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#334)
28+
- [diff](https://github.com/getsentry/sentry-cli/compare/3.3.3...3.3.4)
2629

2730
## 8.5.0
2831

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
},
3030
"devDependencies": {
3131
"@naturalcycles/ktlint": "^1.13.0",
32-
"@sentry/cli": "3.3.3",
32+
"@sentry/cli": "3.3.4",
3333
"downlevel-dts": "^0.11.0",
3434
"google-java-format": "^1.4.0",
3535
"lerna": "^8.1.8",

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"dependencies": {
7575
"@sentry/babel-plugin-component-annotate": "5.1.1",
7676
"@sentry/browser": "10.45.0",
77-
"@sentry/cli": "3.3.3",
77+
"@sentry/cli": "3.3.4",
7878
"@sentry/core": "10.45.0",
7979
"@sentry/react": "10.45.0",
8080
"@sentry/types": "10.45.0"

packages/core/src/js/integrations/default.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function getDefaultIntegrations(options: ReactNativeClientOptions): Integ
148148
(options._experiments && typeof options._experiments.replaysSessionSampleRate === 'number');
149149

150150
if (!hasReplayOptions && hasExperimentsReplayOptions) {
151-
// Remove in the next major version (v7)
151+
// Remove in the next major version (v9)
152152
options.replaysOnErrorSampleRate = options._experiments?.replaysOnErrorSampleRate;
153153
options.replaysSessionSampleRate = options._experiments?.replaysSessionSampleRate;
154154
}

packages/core/src/js/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export interface BaseReactNativeOptions {
125125

126126
/**
127127
* Set data to the inital scope
128-
* @deprecated Use `Sentry.configureScope(...)`
128+
* @deprecated Use `Sentry.getGlobalScope().setTag(...)`, `Sentry.getGlobalScope().setUser(...)`, etc. instead.
129129
*/
130130
initialScope?: CaptureContext;
131131

packages/core/src/js/sdk.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,9 +140,11 @@ export function init(passedOptions: ReactNativeOptions): void {
140140
initialScope: safeFactory(userOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),
141141
};
142142

143-
if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
144-
// Options file is present, native SDK is expected to be initialized
143+
if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ && !__DEV__) {
144+
// Options file is present in a release build, native SDK is expected to be initialized
145145
// before JS from the native app entry point (e.g. AppDelegate, MainApplication).
146+
// In dev builds, we always re-initialize from JS to set up the native log bridge
147+
// and provide runtime values (devServerUrl, defaultSidecarUrl, etc.).
146148
// eslint-disable-next-line no-console
147149
console.info('[Sentry] Using options file. Native SDK is expected to be initialized before JS, skipping automatic native initialization from JS.');
148150
options.autoInitializeNativeSdk = false;

packages/core/test/sdk.test.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,34 @@ describe('Tests the SDK functionality', () => {
135135
expect(usedOptions()?.dsn).toBe('https://key@example.io/code');
136136
});
137137

138-
it('initializing with __SENTRY_OPTIONS__ disabled native auto initialization', () => {
139-
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
140-
init({});
141-
expect(usedOptions()?.autoInitializeNativeSdk).toBe(false);
138+
it('does not disable native auto initialization in dev builds even with __SENTRY_OPTIONS__', () => {
139+
// @ts-expect-error __DEV__ is a global
140+
const originalDev = globalThis.__DEV__;
141+
// @ts-expect-error __DEV__ is a global
142+
globalThis.__DEV__ = true;
143+
try {
144+
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
145+
init({});
146+
expect(usedOptions()?.autoInitializeNativeSdk).toBe(true);
147+
} finally {
148+
// @ts-expect-error __DEV__ is a global
149+
globalThis.__DEV__ = originalDev;
150+
}
151+
});
152+
153+
it('disables native auto initialization in release builds with __SENTRY_OPTIONS__', () => {
154+
// @ts-expect-error __DEV__ is a global
155+
const originalDev = globalThis.__DEV__;
156+
// @ts-expect-error __DEV__ is a global
157+
globalThis.__DEV__ = false;
158+
try {
159+
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
160+
init({});
161+
expect(usedOptions()?.autoInitializeNativeSdk).toBe(false);
162+
} finally {
163+
// @ts-expect-error __DEV__ is a global
164+
globalThis.__DEV__ = originalDev;
165+
}
142166
});
143167

144168
it('initializing without __SENTRY_OPTIONS__ enables native auto initialization', () => {
@@ -155,7 +179,7 @@ describe('Tests the SDK functionality', () => {
155179
expect(usedOptions()?.autoInitializeNativeSdk).toBe(true);
156180
});
157181

158-
it('initializing with __SENTRY_OPTIONS__ keeps native auto initialization false if set', () => {
182+
it('respects explicit autoInitializeNativeSdk false even with __SENTRY_OPTIONS__', () => {
159183
RN_GLOBAL_OBJ.__SENTRY_OPTIONS__ = {};
160184
init({
161185
autoInitializeNativeSdk: false,

0 commit comments

Comments
 (0)