-
Notifications
You must be signed in to change notification settings - Fork 53
[RUM-8382] Introduce Datadog Metro Config for Debug ID injection in RUM Errors #857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4719737 to
5ec48f6
Compare
Datadog ReportBranch report: ✅ 0 Failed, 680 Passed, 1 Skipped, 5.53s Total Time |
92872e6 to
987afd8
Compare
987afd8 to
096e6e8
Compare
096e6e8 to
44d684d
Compare
44d684d to
91bf204
Compare
| const debugIds = (globalThis as any)._datadogDebugIds; | ||
| if (!debugIds || Object.keys(debugIds).length === 0) { | ||
| console.warn( | ||
| '[Datadog SDK] Debug ID not found. Are you using @datadog/mobile-react-native/metro config?' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps when we have a defined documentation page for this feature we should modify this to point users in the right direction 📖
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, thanks! 👍
sbarrio
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some minor comments, it looks great 👏
|
There is a problem on iOS new architecture caused by the new explicit exports in package.json: "exports": {
".": {
"import": "./lib/module/index.js",
"require": "./lib/commonjs/index.js",
"types": "./lib/typescript/index.d.ts"
},
"./metro": {
"import": "./lib/module/metro.js",
"require": "./lib/commonjs/metro.js",
"types": "./lib/typescript/metro.d.ts"
}
}I have looked into it, and it is caused by how the podfile const configFilePath = require.resolve(
path.join(dependency, 'package.json'),
{paths: [projectRoot]},
);By adding a debug log we get: [DD-DEBUG] Error: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by <redacted>/dd-sdk-reactnative/example-new-architecture/node_modules/@datadog/mobile-react-native/package.jsonI have modified the exports to explicitly include |
| "exports": { | ||
| ".": { | ||
| "import": "./lib/module/index.js", | ||
| "require": "./lib/commonjs/index.js", | ||
| "types": "./lib/typescript/index.d.ts" | ||
| }, | ||
| "./metro": { | ||
| "import": "./lib/module/metro.js", | ||
| "require": "./lib/commonjs/metro.js", | ||
| "types": "./lib/typescript/metro.d.ts" | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marco-saia-datadog I believe this broke jest mock.
Cannot find module '@datadog/mobile-react-native/jest/mock' from 'src/test/globalMocks.tsx'
Require stack:
node_modules/@datadog/mobile-react-navigation/lib/commonjs/rum/instrumentation/DdRumReactNavigationTracking.js
node_modules/@datadog/mobile-react-navigation/lib/commonjs/index.js
src/providers/ReactNavigationContainer.tsx
src/providers/PostHogProvider.tsx
src/hooks/useIsFeatureEnabled.ts
src/hooks/useIsDevMode.ts
src/components/LoanPreview/LoanTinyPreview.tsx
src/components/LoanPreview/LoanTinyPreview.test.tsx
166 |
167 | jest.mock('@datadog/mobile-react-native', () =>
> 168 | require('@datadog/mobile-react-native/jest/mock'),
| ^
169 | );
170 |
171 | jest.mock('react-native-persona', () => {
at Resolver._throwModNotFoundError (node_modules/jest-resolve/build/resolver.js:427:11)
at require (src/test/globalMocks.tsx:168:3)
at Object.require (node_modules/@datadog/mobile-react-navigation/src/rum/instrumentation/DdRumReactNavigationTracking.tsx:7:1)
at Object.require (node_modules/@datadog/mobile-react-navigation/src/index.tsx:8:1)
at Object.require (src/providers/ReactNavigationContainer.tsx:2:1)
at Object.require (src/providers/PostHogProvider.tsx:6:1)
at Object.require (src/hooks/useIsFeatureEnabled.ts:4:1)
at Object.require (src/hooks/useIsDevMode.ts:1:1)
at Object.require (src/components/LoanPreview/LoanTinyPreview.tsx:7:1)
at Object.require (src/components/LoanPreview/LoanTinyPreview.test.tsx:7:1)
Overview
This PR introduces a Metro configuration that automates the generation of unique Debug IDs for RN bundles. The main objective is to enable more consistent unminification of stack traces on the backend.
What's included
Automatic Debug ID Generation:
Each bundle is assigned a unique Debug ID at build time.
Runtime Debug ID Injection:
A code snippet is injected into the bundle, exposing the Debug ID at runtime so it can be attached to the RUM Error Context as
_dd.debug_id.Bundle Debug ID Comment:
The Debug ID is added as a comment at the end of the bundle file:
//# debugId=[DEBUG-ID]Source Map Injection:
The Debug ID is added as a top-level
debugIdproperty in the generated sourcemaps.Runtime Debug ID injection in Expo:
Introduced Expo config with
getDatadogExpoConfigto inject the Debug ID code snippet for runtime consumption.Usage in Metro Config
Vanilla React Native
Expo
Additional Notes
//# sourceMappingURL=...comment is found in the bundle, thedebugIdcomment will be inserted right before itgetDatadogExpoConfigaccepts custom options, and the default Expo config can be overridenPR Checklist