Skip to content

Commit c062840

Browse files
Merge branch 'main' into lz/5098
2 parents f2cfe50 + 1c1e36e commit c062840

13 files changed

Lines changed: 178 additions & 82 deletions

File tree

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
# Initializes the CodeQL tools for scanning.
4646
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # pin@v3.29.5
47+
uses: github/codeql-action/init@3c3833e0f8c1c83d449a7478aa59c036a9165498 # pin@v3.29.5
4848
with:
4949
languages: ${{ matrix.language }}
5050
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -55,7 +55,7 @@ jobs:
5555
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5656
# If this step fails, then you should remove it and run the build manually (see below)
5757
- name: Autobuild
58-
uses: github/codeql-action/autobuild@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # pin@v3.29.5
58+
uses: github/codeql-action/autobuild@3c3833e0f8c1c83d449a7478aa59c036a9165498 # pin@v3.29.5
5959

6060
# ℹ️ Command-line programs to run using the OS shell.
6161
# 📚 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
@@ -66,4 +66,4 @@ jobs:
6666
# make bootstrap
6767
# make release
6868
- name: Perform CodeQL Analysis
69-
uses: github/codeql-action/analyze@76621b61decf072c1cee8dd1ce2d2a82d33c17ed # pin@v3.29.5
69+
uses: github/codeql-action/analyze@3c3833e0f8c1c83d449a7478aa59c036a9165498 # pin@v3.29.5

.github/workflows/e2e-v2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ jobs:
313313
runs-on: macos-14
314314
- platform: ios
315315
rn-version: '0.65.3'
316-
runs-on: macos-15
316+
runs-on: macos-14
317317
- platform: android
318318
runs-on: ubuntu-latest
319319
exclude:

.github/workflows/native-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
test-ios:
2020
name: ios
21-
runs-on: macos-15
21+
runs-on: macos-14
2222
needs: [diff_check]
2323
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
2424
steps:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- name: Get auth token
2121
id: token
22-
uses: actions/create-github-app-token@0f859bf9e69e887678d5bbfbee594437cb440ffe # v2.1.0
22+
uses: actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b # v2.1.1
2323
with:
2424
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
2525
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}

.github/workflows/testflight.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414

1515
upload_to_testflight:
1616
name: Build and Upload React Native Sample to Testflight
17-
runs-on: macos-15
17+
runs-on: macos-14
1818
needs: [diff_check]
1919
if: ${{ needs.diff_check.outputs.skip_ci != 'true' }}
2020
steps:

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,26 @@
88
99
## Unreleased
1010

11-
### Fixes
11+
### Important Changes
12+
13+
- **fix(browser): Ensure IP address is only inferred by Relay if `sendDefaultPii` is `true`** ([#5092](https://github.com/getsentry/sentry-react-native/pull/5092))
14+
15+
This release includes a fix for a [behaviour change](https://docs.sentry.io/platforms/javascript/migration/v8-to-v9/#behavior-changes)
16+
that was originally introduced with v9 of the JavaScript SDK: User IP Addresses should only be added to Sentry events automatically,
17+
if `sendDefaultPii` was set to `true`.
18+
19+
However, the change in v9 required further internal adjustment, which should have been included in v10 of the SDK.
20+
To avoid making a major bump, the fix was patched on the current version and not by bumping to V10.
21+
There is _no API_ breakage involved and hence it is safe to update.
22+
However, after updating the SDK, events (errors, traces, replays, etc.) sent from the browser, will only include
23+
user IP addresses, if you set `sendDefaultPii: true` in your `Sentry.init` options.
24+
25+
We apologize for any inconvenience caused!
26+
27+
## Fixes
1228

1329
- Fix Expo prebuild failed on cached builds ([#5098](https://github.com/getsentry/sentry-react-native/pull/5098))
30+
- Remove the warning that used to indicate that Time To Initial Display and Time To Full Display are not supported ([#5081](https://github.com/getsentry/sentry-react-native/pull/5081))
1431

1532
## 6.20.0
1633

packages/core/plugin/src/withSentryAndroid.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import * as path from 'path';
55
import { warnOnce, writeSentryPropertiesTo } from './utils';
66

77
export const withSentryAndroid: ConfigPlugin<string> = (config, sentryProperties: string) => {
8-
const cfg = withAppBuildGradle(config, config => {
9-
if (config.modResults.language === 'groovy') {
10-
config.modResults.contents = modifyAppBuildGradle(config.modResults.contents);
8+
const cfg = withAppBuildGradle(config, appBuildGradle => {
9+
if (appBuildGradle.modResults.language === 'groovy') {
10+
appBuildGradle.modResults.contents = modifyAppBuildGradle(appBuildGradle.modResults.contents);
1111
} else {
1212
throw new Error('Cannot configure Sentry in the app gradle because the build.gradle is not groovy');
1313
}
14-
return config;
14+
return appBuildGradle;
1515
});
1616
return withDangerousMod(cfg, [
1717
'android',
18-
config => {
19-
writeSentryPropertiesTo(path.resolve(config.modRequest.projectRoot, 'android'), sentryProperties);
20-
return config;
18+
dangerousMod => {
19+
writeSentryPropertiesTo(path.resolve(dangerousMod.modRequest.projectRoot, 'android'), sentryProperties);
20+
return dangerousMod;
2121
},
2222
]);
2323
};

packages/core/plugin/src/withSentryAndroidGradlePlugin.ts

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { withAppBuildGradle, withProjectBuildGradle } from '@expo/config-plugins';
2+
import type { ExpoConfig } from '@expo/config-types';
23

34
import { warnOnce } from './utils';
45

@@ -20,7 +21,7 @@ export const sentryAndroidGradlePluginVersion = '5.9.0';
2021
* https://docs.sentry.io/platforms/react-native/manual-setup/manual-setup/#enable-sentry-agp
2122
*/
2223
export function withSentryAndroidGradlePlugin(
23-
config: any,
24+
config: ExpoConfig,
2425
{
2526
includeProguardMapping = true,
2627
dexguardEnabled = false,
@@ -30,40 +31,34 @@ export function withSentryAndroidGradlePlugin(
3031
includeNativeSources = true,
3132
includeSourceContext = false,
3233
}: SentryAndroidGradlePluginOptions = {},
33-
): any {
34+
): ExpoConfig {
3435
// Modify android/build.gradle
35-
const withSentryProjectBuildGradle = (config: any): any => {
36-
return withProjectBuildGradle(config, (projectBuildGradle: any) => {
37-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
36+
const withSentryProjectBuildGradle = (config: ExpoConfig): ExpoConfig => {
37+
return withProjectBuildGradle(config, projectBuildGradle => {
3838
if (!projectBuildGradle.modResults || !projectBuildGradle.modResults.contents) {
3939
warnOnce('android/build.gradle content is missing or undefined.');
40-
return config;
40+
return projectBuildGradle;
4141
}
42-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
4342
if (projectBuildGradle.modResults.language !== 'groovy') {
4443
warnOnce('Cannot configure Sentry in android/build.gradle because it is not in Groovy.');
45-
return config;
44+
return projectBuildGradle;
4645
}
4746

4847
const dependency = `classpath("io.sentry:sentry-android-gradle-plugin:${sentryAndroidGradlePluginVersion}")`;
4948

50-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5149
if (projectBuildGradle.modResults.contents.includes(dependency)) {
5250
warnOnce('sentry-android-gradle-plugin dependency in already in android/build.gradle.');
53-
return config;
51+
return projectBuildGradle;
5452
}
5553

5654
try {
57-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
5855
const updatedContents = projectBuildGradle.modResults.contents.replace(
5956
/dependencies\s*{/,
6057
`dependencies {\n ${dependency}`,
6158
);
62-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6359
if (updatedContents === projectBuildGradle.modResults.contents) {
6460
warnOnce('Failed to inject the dependency. Could not find `dependencies` in build.gradle.');
6561
} else {
66-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
6762
projectBuildGradle.modResults.contents = updatedContents;
6863
}
6964
} catch (error) {
@@ -74,12 +69,11 @@ export function withSentryAndroidGradlePlugin(
7469
};
7570

7671
// Modify android/app/build.gradle
77-
const withSentryAppBuildGradle = (config: any): any => {
78-
return withAppBuildGradle(config, (config: any) => {
79-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
80-
if (config.modResults.language !== 'groovy') {
72+
const withSentryAppBuildGradle = (config: ExpoConfig): ExpoConfig => {
73+
return withAppBuildGradle(config, appBuildGradle => {
74+
if (appBuildGradle.modResults.language !== 'groovy') {
8175
warnOnce('Cannot configure Sentry in android/app/build.gradle because it is not in Groovy.');
82-
return config;
76+
return appBuildGradle;
8377
}
8478
const sentryPlugin = `apply plugin: "io.sentry.android.gradle"`;
8579
const sentryConfig = `
@@ -99,22 +93,18 @@ export function withSentryAndroidGradlePlugin(
9993
}
10094
}`;
10195

102-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
103-
let contents = config.modResults.contents;
96+
let contents = appBuildGradle.modResults.contents;
10497

105-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
10698
if (!contents.includes(sentryPlugin)) {
10799
contents = `${sentryPlugin}\n${contents}`;
108100
}
109101

110-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
111102
if (!contents.includes('sentry {')) {
112103
contents = `${contents}\n${sentryConfig}`;
113104
}
114105

115-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
116-
config.modResults.contents = contents;
117-
return config;
106+
appBuildGradle.modResults.contents = contents;
107+
return appBuildGradle;
118108
});
119109
};
120110

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

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import { isExpoGo, notWeb } from '../utils/environment';
55
import { SDK_NAME, SDK_PACKAGE_NAME, SDK_VERSION } from '../version';
66
import { NATIVE } from '../wrapper';
77

8+
// TODO: Remove this on JS V10.
9+
interface IpPatchedSdkInfo extends SdkInfoType {
10+
settings?: {
11+
infer_ip?: 'auto' | 'never';
12+
};
13+
}
14+
815
const INTEGRATION_NAME = 'SdkInfo';
916

1017
type DefaultSdkInfo = Pick<Required<SdkInfoType>, 'name' | 'packages' | 'version'>;
@@ -19,13 +26,25 @@ export const defaultSdkInfo: DefaultSdkInfo = {
1926
],
2027
version: SDK_VERSION,
2128
};
29+
let DefaultPii: boolean | undefined = undefined;
2230

2331
/** Default SdkInfo instrumentation */
2432
export const sdkInfoIntegration = (): Integration => {
2533
const fetchNativeSdkInfo = createCachedFetchNativeSdkInfo();
2634

2735
return {
2836
name: INTEGRATION_NAME,
37+
setup(client) {
38+
const options = client.getOptions();
39+
DefaultPii = options.sendDefaultPii;
40+
if (DefaultPii) {
41+
client.on('beforeSendEvent', event => {
42+
if (event.user?.ip_address === '{{auto}}') {
43+
delete event.user.ip_address;
44+
}
45+
});
46+
}
47+
},
2948
setupOnce: () => {
3049
// noop
3150
},
@@ -37,15 +56,24 @@ async function processEvent(event: Event, fetchNativeSdkInfo: () => Promise<Pack
3756
const nativeSdkPackage = await fetchNativeSdkInfo();
3857

3958
event.platform = event.platform || 'javascript';
40-
event.sdk = event.sdk || {};
41-
event.sdk.name = event.sdk.name || defaultSdkInfo.name;
42-
event.sdk.version = event.sdk.version || defaultSdkInfo.version;
43-
event.sdk.packages = [
59+
const sdk = (event.sdk || {}) as IpPatchedSdkInfo;
60+
sdk.name = sdk.name || defaultSdkInfo.name;
61+
sdk.version = sdk.version || defaultSdkInfo.version;
62+
sdk.packages = [
4463
// default packages are added by baseclient and should not be added here
45-
...(event.sdk.packages || []),
64+
...(sdk.packages || []),
4665
...((nativeSdkPackage && [nativeSdkPackage]) || []),
4766
];
4867

68+
// Patch missing infer_ip.
69+
sdk.settings = {
70+
infer_ip: DefaultPii ? 'auto' : 'never',
71+
// purposefully allowing already passed settings to override the default
72+
...sdk.settings,
73+
};
74+
75+
event.sdk = sdk;
76+
4977
return event;
5078
}
5179

packages/core/src/js/tracing/timetodisplay.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ import { fill, getActiveSpan, getSpanDescendants, logger, SEMANTIC_ATTRIBUTE_SEN
33
import * as React from 'react';
44
import { useState } from 'react';
55

6-
import { isTurboModuleEnabled } from '../utils/environment';
76
import { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from './origin';
8-
import { getRNSentryOnDrawReporter, nativeComponentExists } from './timetodisplaynative';
7+
import { getRNSentryOnDrawReporter } from './timetodisplaynative';
98
import { setSpanDurationAsMeasurement, setSpanDurationAsMeasurementOnSpan } from './utils';
109

11-
let nativeComponentMissingLogged = false;
12-
1310
/**
1411
* Flags of active spans with manual initial display.
1512
*/
@@ -62,17 +59,6 @@ function TimeToDisplay(props: {
6259
parentSpanId?: string;
6360
}): React.ReactElement {
6461
const RNSentryOnDrawReporter = getRNSentryOnDrawReporter();
65-
const isNewArchitecture = isTurboModuleEnabled();
66-
67-
if (__DEV__ && (isNewArchitecture || (!nativeComponentExists && !nativeComponentMissingLogged))){
68-
nativeComponentMissingLogged = true;
69-
// Using setTimeout with a delay of 0 milliseconds to defer execution and avoid printing the React stack trace.
70-
setTimeout(() => {
71-
logger.warn(
72-
'TimeToInitialDisplay and TimeToFullDisplay are not supported on the web, Expo Go and New Architecture. Run native build or report an issue at https://github.com/getsentry/sentry-react-native');
73-
}, 0);
74-
}
75-
7662
return (
7763
<>
7864
<RNSentryOnDrawReporter

0 commit comments

Comments
 (0)