Skip to content

Commit 34ffe98

Browse files
authored
Merge pull request #9057 from Couchers-org/mobile/bugfix/sentry-native-scope-tags
Mobile: Sync Sentry tags/contexts to native scope so app hang/crash events carry them
2 parents ccda4ed + e8bbabd commit 34ffe98

1 file changed

Lines changed: 36 additions & 36 deletions

File tree

app/mobile/service/sentry.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -37,42 +37,6 @@ if (sentryEnabled) {
3737
// matching the values its source-map upload uses. The store-binary and OTA
3838
// identities below are surfaced as tags/contexts (which don't affect
3939
// symbolication) for searching and filtering.
40-
initialScope: {
41-
tags: {
42-
appVariant,
43-
// Embedded store-binary identity (fixed across OTAs)
44-
embeddedDisplayVersion,
45-
embeddedDebugVersion,
46-
// Running bundle identity (varies per OTA)
47-
runningDisplayVersion,
48-
runningDebugVersion,
49-
runningDebugVersionOTA,
50-
runtimeVersion,
51-
launchSource: isEmbeddedLaunch ? "embedded" : "ota",
52-
// Backend/web wiring
53-
apiBaseUrl,
54-
webBaseUrl,
55-
},
56-
contexts: {
57-
config: {
58-
apiBaseUrl,
59-
webBaseUrl,
60-
},
61-
store_build: {
62-
displayVersion: embeddedDisplayVersion,
63-
debugVersion: embeddedDebugVersion,
64-
},
65-
ota: {
66-
displayVersion: runningDisplayVersion,
67-
debugVersion: runningDebugVersion,
68-
debugVersionOTA: runningDebugVersionOTA,
69-
updateId,
70-
runtimeVersion,
71-
isEmbeddedLaunch,
72-
createdAt,
73-
},
74-
},
75-
},
7640

7741
// Adds more context data to events (IP address, cookies, user, etc.)
7842
// For more information, visit: https://docs.sentry.io/platforms/react-native/data-management/data-collected/
@@ -89,4 +53,40 @@ if (sentryEnabled) {
8953
Sentry.feedbackIntegration(),
9054
],
9155
});
56+
57+
// Set via the bridged setters rather than initialScope, which never reaches
58+
// the native scope (getsentry/sentry-react-native#1661) and so would be
59+
// missing from natively-captured events like app hangs and crashes.
60+
Sentry.setTags({
61+
appVariant,
62+
// Embedded store-binary identity (fixed across OTAs)
63+
embeddedDisplayVersion,
64+
embeddedDebugVersion,
65+
// Running bundle identity (varies per OTA)
66+
runningDisplayVersion,
67+
runningDebugVersion,
68+
runningDebugVersionOTA,
69+
runtimeVersion,
70+
launchSource: isEmbeddedLaunch ? "embedded" : "ota",
71+
// Backend/web wiring
72+
apiBaseUrl,
73+
webBaseUrl,
74+
});
75+
Sentry.setContext("config", {
76+
apiBaseUrl,
77+
webBaseUrl,
78+
});
79+
Sentry.setContext("store_build", {
80+
displayVersion: embeddedDisplayVersion,
81+
debugVersion: embeddedDebugVersion,
82+
});
83+
Sentry.setContext("ota", {
84+
displayVersion: runningDisplayVersion,
85+
debugVersion: runningDebugVersion,
86+
debugVersionOTA: runningDebugVersionOTA,
87+
updateId,
88+
runtimeVersion,
89+
isEmbeddedLaunch,
90+
createdAt,
91+
});
9292
}

0 commit comments

Comments
 (0)