@sentry/react-native 7.12.0 → 8.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/RNSentry.podspec +9 -4
  2. package/android/libs/replay-stubs.jar +0 -0
  3. package/android/src/main/java/io/sentry/react/RNSentryCompositeOptionsConfiguration.java +25 -0
  4. package/android/src/main/java/io/sentry/react/RNSentryJsonConverter.java +76 -0
  5. package/android/src/main/java/io/sentry/react/RNSentryJsonUtils.java +41 -0
  6. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +2 -395
  7. package/android/src/main/java/io/sentry/react/RNSentrySDK.java +68 -0
  8. package/android/src/main/java/io/sentry/react/RNSentryStart.java +413 -0
  9. package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
  10. package/dist/js/replay/mobilereplay.d.ts +0 -26
  11. package/dist/js/replay/mobilereplay.d.ts.map +1 -1
  12. package/dist/js/replay/mobilereplay.js.map +1 -1
  13. package/dist/js/sdk.d.ts.map +1 -1
  14. package/dist/js/sdk.js +21 -10
  15. package/dist/js/sdk.js.map +1 -1
  16. package/dist/js/tools/metroconfig.d.ts +9 -1
  17. package/dist/js/tools/metroconfig.d.ts.map +1 -1
  18. package/dist/js/tools/metroconfig.js +9 -2
  19. package/dist/js/tools/metroconfig.js.map +1 -1
  20. package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
  21. package/dist/js/tools/sentryMetroSerializer.js +1 -0
  22. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  23. package/dist/js/tools/sentryOptionsSerializer.d.ts +6 -0
  24. package/dist/js/tools/sentryOptionsSerializer.d.ts.map +1 -0
  25. package/dist/js/tools/sentryOptionsSerializer.js +92 -0
  26. package/dist/js/tools/sentryOptionsSerializer.js.map +1 -0
  27. package/dist/js/tools/utils.d.ts +2 -1
  28. package/dist/js/tools/utils.d.ts.map +1 -1
  29. package/dist/js/tools/utils.js.map +1 -1
  30. package/dist/js/utils/worldwide.d.ts +2 -0
  31. package/dist/js/utils/worldwide.d.ts.map +1 -1
  32. package/dist/js/utils/worldwide.js.map +1 -1
  33. package/dist/js/version.d.ts +1 -1
  34. package/dist/js/version.d.ts.map +1 -1
  35. package/dist/js/version.js +1 -1
  36. package/dist/js/version.js.map +1 -1
  37. package/ios/RNSentry+fetchNativeStack.m +1 -0
  38. package/ios/RNSentry.h +3 -0
  39. package/ios/RNSentry.mm +12 -45
  40. package/ios/RNSentryDependencyContainer.h +2 -1
  41. package/ios/RNSentryDependencyContainer.m +1 -0
  42. package/ios/RNSentryEmitNewFrameEvent.h +3 -0
  43. package/ios/RNSentryExperimentalOptions.m +1 -1
  44. package/ios/RNSentryFramesTrackerListener.h +2 -2
  45. package/ios/RNSentryFramesTrackerListener.m +2 -0
  46. package/ios/RNSentryOnDrawReporter.h +2 -1
  47. package/ios/RNSentryOnDrawReporter.m +2 -0
  48. package/ios/RNSentryRNSScreen.m +3 -4
  49. package/ios/RNSentryReplay.mm +0 -5
  50. package/ios/RNSentryReplayBreadcrumbConverter.m +12 -12
  51. package/ios/RNSentrySDK.h +31 -0
  52. package/ios/RNSentrySDK.m +78 -0
  53. package/ios/RNSentryStart.h +25 -0
  54. package/ios/RNSentryStart.m +228 -0
  55. package/ios/RNSentryVersion.m +1 -1
  56. package/ios/SentrySDKWrapper.m +2 -2
  57. package/ios/SentryScreenFramesWrapper.h +14 -0
  58. package/ios/SentryScreenFramesWrapper.m +39 -0
  59. package/package.json +2 -2
  60. package/plugin/build/logger.d.ts +24 -0
  61. package/plugin/build/logger.js +44 -0
  62. package/plugin/build/utils.d.ts +0 -18
  63. package/plugin/build/utils.js +1 -34
  64. package/plugin/build/version.d.ts +2 -0
  65. package/plugin/build/version.js +6 -0
  66. package/plugin/build/withSentry.d.ts +1 -0
  67. package/plugin/build/withSentry.js +11 -10
  68. package/plugin/build/withSentryAndroid.d.ts +6 -1
  69. package/plugin/build/withSentryAndroid.js +52 -8
  70. package/plugin/build/withSentryAndroidGradlePlugin.d.ts +1 -1
  71. package/plugin/build/withSentryAndroidGradlePlugin.js +8 -8
  72. package/plugin/build/withSentryIOS.d.ts +6 -1
  73. package/plugin/build/withSentryIOS.js +55 -7
  74. package/scripts/sentry-xcode.sh +20 -0
  75. package/sentry.gradle +51 -0
  76. package/ts3.8/dist/js/replay/mobilereplay.d.ts +0 -26
  77. package/ts3.8/dist/js/utils/worldwide.d.ts +2 -0
  78. package/ts3.8/dist/js/version.d.ts +1 -1
package/dist/js/sdk.js CHANGED
@@ -23,6 +23,7 @@ import { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/na
23
23
  import { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer, isWeb } from './utils/environment';
24
24
  import { getDefaultRelease } from './utils/release';
25
25
  import { safeFactory, safeTracesSampler } from './utils/safe';
26
+ import { RN_GLOBAL_OBJ } from './utils/worldwide';
26
27
  import { NATIVE } from './wrapper';
27
28
  const DEFAULT_OPTIONS = {
28
29
  enableNativeCrashHandling: true,
@@ -50,8 +51,9 @@ export function init(passedOptions) {
50
51
  if (isRunningInMetroDevServer()) {
51
52
  return;
52
53
  }
53
- const maxQueueSize = (_c = (_a = passedOptions.maxQueueSize) !== null && _a !== void 0 ? _a : (_b = passedOptions.transportOptions) === null || _b === void 0 ? void 0 : _b.bufferSize) !== null && _c !== void 0 ? _c : DEFAULT_OPTIONS.maxQueueSize;
54
- const enableNative = passedOptions.enableNative === undefined || passedOptions.enableNative
54
+ const userOptions = Object.assign(Object.assign({}, RN_GLOBAL_OBJ.__SENTRY_OPTIONS__), passedOptions);
55
+ const maxQueueSize = (_c = (_a = userOptions.maxQueueSize) !== null && _a !== void 0 ? _a : (_b = userOptions.transportOptions) === null || _b === void 0 ? void 0 : _b.bufferSize) !== null && _c !== void 0 ? _c : DEFAULT_OPTIONS.maxQueueSize;
56
+ const enableNative = userOptions.enableNative === undefined || userOptions.enableNative
55
57
  ? NATIVE.isNativeAvailable()
56
58
  : false;
57
59
  useEncodePolyfill();
@@ -71,10 +73,10 @@ export function init(passedOptions) {
71
73
  const port = dsnComponents.port ? `:${dsnComponents.port}` : '';
72
74
  return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;
73
75
  };
74
- const userBeforeBreadcrumb = safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });
76
+ const userBeforeBreadcrumb = safeFactory(userOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });
75
77
  // Exclude Dev Server and Sentry Dsn request from Breadcrumbs
76
78
  const devServerUrl = (_d = getDevServer()) === null || _d === void 0 ? void 0 : _d.url;
77
- const dsn = getURLFromDSN(passedOptions.dsn);
79
+ const dsn = getURLFromDSN(userOptions.dsn);
78
80
  const defaultBeforeBreadcrumb = (breadcrumb, _hint) => {
79
81
  var _a;
80
82
  const type = breadcrumb.type || '';
@@ -95,24 +97,30 @@ export function init(passedOptions) {
95
97
  }
96
98
  return defaultBeforeBreadcrumb(modifiedBreadcrumb, hint);
97
99
  };
98
- const options = Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS), passedOptions), { release: (_e = passedOptions.release) !== null && _e !== void 0 ? _e : getDefaultRelease(), enableNative, enableNativeNagger: shouldEnableNativeNagger(passedOptions.enableNativeNagger),
100
+ const options = Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS), userOptions), { release: (_e = userOptions.release) !== null && _e !== void 0 ? _e : getDefaultRelease(), enableNative, enableNativeNagger: shouldEnableNativeNagger(userOptions.enableNativeNagger),
99
101
  // If custom transport factory fails the SDK won't initialize
100
- transport: passedOptions.transport
102
+ transport: userOptions.transport
101
103
  || makeNativeTransportFactory({
102
104
  enableNative,
103
105
  })
104
- || makeFetchTransport, transportOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_f = passedOptions.transportOptions) !== null && _f !== void 0 ? _f : {})), { bufferSize: maxQueueSize }), maxQueueSize, integrations: [], stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser), beforeBreadcrumb: chainedBeforeBreadcrumb, initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }) });
106
+ || makeFetchTransport, transportOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_f = userOptions.transportOptions) !== null && _f !== void 0 ? _f : {})), { bufferSize: maxQueueSize }), maxQueueSize, integrations: [], stackParser: stackParserFromStackParserOptions(userOptions.stackParser || defaultStackParser), beforeBreadcrumb: chainedBeforeBreadcrumb, initialScope: safeFactory(userOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }) });
107
+ if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
108
+ // We expect users to use the file options only in combination with manual native initialization
109
+ // eslint-disable-next-line no-console
110
+ console.info('Initializing Sentry JS with the options file. Expecting manual native initialization before JS. Native will not be initialized automatically.');
111
+ options.autoInitializeNativeSdk = false;
112
+ }
105
113
  if ('tracesSampler' in options) {
106
114
  options.tracesSampler = safeTracesSampler(options.tracesSampler);
107
115
  }
108
116
  if (!('environment' in options)) {
109
117
  options.environment = getDefaultEnvironment();
110
118
  }
111
- const defaultIntegrations = passedOptions.defaultIntegrations === undefined
119
+ const defaultIntegrations = userOptions.defaultIntegrations === undefined
112
120
  ? getDefaultIntegrations(options)
113
- : passedOptions.defaultIntegrations;
121
+ : userOptions.defaultIntegrations;
114
122
  options.integrations = getIntegrationsToSetup({
115
- integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),
123
+ integrations: safeFactory(userOptions.integrations, { loggerMessage: 'The integrations threw an error' }),
116
124
  defaultIntegrations,
117
125
  });
118
126
  initAndBind(ReactNativeClient, options);
@@ -120,6 +128,9 @@ export function init(passedOptions) {
120
128
  debug.log('Offline caching, native errors features are not available in Expo Go.');
121
129
  debug.log('Use EAS Build / Native Release Build to test these features.');
122
130
  }
131
+ if (RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {
132
+ debug.log('Sentry JS initialized with options from the options file.');
133
+ }
123
134
  }
124
135
  /**
125
136
  * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,KAAK,EACL,SAAS,EACT,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,iCAAiC,EACjC,SAAS,IAAI,aAAa,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,QAAQ,EAAE,yBAAyB,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACxG,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EA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C;AAED;;;GAGG;AACH,MAAM,UAAgB,KAAK;;QACzB,IAAI;YACF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAE3B,IAAI,MAAM,EAAE;gBACV,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;gBAEpC,OAAO,MAAM,CAAC;aACf;YACD,oCAAoC;SACrC;QAAC,OAAO,CAAC,EAAE,GAAG;QAEf,KAAK,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAEhD,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAgB,KAAK;;QACzB,IAAI;YACF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAE3B,IAAI,MAAM,EAAE;gBACV,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACtB;SACF;QAAC,OAAO,CAAC,EAAE;YACV,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACxC;IACH,CAAC;CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAI,QAA6B;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAiB,EAAE;QACnD,IAAI;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACV,KAAK,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,CAAC;IACF,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAgB,cAAc;;QAClC,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CAAA","sourcesContent":["/* eslint-disable complexity */\nimport type { Breadcrumb, BreadcrumbHint, Integration, Scope } from '@sentry/core';\nimport {\n debug,\n getClient,\n getGlobalScope,\n getIntegrationsToSetup,\n getIsolationScope,\n initAndBind,\n makeDsn,\n stackParserFromStackParserOptions,\n withScope as coreWithScope,\n} from '@sentry/core';\nimport { defaultStackParser, makeFetchTransport, Profiler } from '@sentry/react';\nimport * as React from 'react';\nimport { ReactNativeClient } from './client';\nimport { FeedbackWidgetProvider } from './feedback/FeedbackWidgetProvider';\nimport { getDevServer } from './integrations/debugsymbolicatorutils';\nimport { getDefaultIntegrations } from './integrations/default';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { shouldEnableNativeNagger } from './options';\nimport { enableSyncToNative } from './scopeSync';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler } from './tracing';\nimport { useEncodePolyfill } from './transports/encodePolyfill';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer, isWeb } from './utils/environment';\nimport { getDefaultRelease } from './utils/release';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\nimport { NATIVE } from './wrapper';\n\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n enableCaptureFailedRequests: false,\n enableNdk: true,\n enableAppStartTracking: true,\n enableNativeFramesTracking: true,\n enableStallTracking: true,\n enableUserInteractionTracing: false,\n propagateTraceparent: false,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n if (isRunningInMetroDevServer()) {\n return;\n }\n\n const maxQueueSize = passedOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? passedOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n\n const enableNative = passedOptions.enableNative === undefined || passedOptions.enableNative\n ? NATIVE.isNativeAvailable()\n : false;\n\n useEncodePolyfill();\n if (enableNative) {\n enableSyncToNative(getGlobalScope());\n enableSyncToNative(getIsolationScope());\n }\n\n const getURLFromDSN = (dsn: string | undefined): string | undefined => {\n if (!dsn) {\n return undefined;\n }\n const dsnComponents = makeDsn(dsn);\n if (!dsnComponents) {\n debug.error('Failed to extract url from DSN: ', dsn);\n return undefined;\n }\n const port = dsnComponents.port ? `:${dsnComponents.port}` : '';\n return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;\n };\n\n const userBeforeBreadcrumb = safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });\n\n // Exclude Dev Server and Sentry Dsn request from Breadcrumbs\n const devServerUrl = getDevServer()?.url;\n const dsn = getURLFromDSN(passedOptions.dsn);\n const defaultBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint): Breadcrumb | null => {\n const type = breadcrumb.type || '';\n const url = typeof breadcrumb.data?.url === 'string' ? breadcrumb.data.url : '';\n if (type === 'http' && ((devServerUrl && url.startsWith(devServerUrl)) || (dsn && url.startsWith(dsn)))) {\n return null;\n }\n return breadcrumb;\n };\n\n const chainedBeforeBreadcrumb = (breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null => {\n let modifiedBreadcrumb = breadcrumb;\n if (userBeforeBreadcrumb) {\n const result = userBeforeBreadcrumb(breadcrumb, hint);\n if (result === null) {\n return null;\n }\n modifiedBreadcrumb = result;\n }\n return defaultBeforeBreadcrumb(modifiedBreadcrumb, hint);\n };\n\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n release: passedOptions.release ?? getDefaultRelease(),\n enableNative,\n enableNativeNagger: shouldEnableNativeNagger(passedOptions.enableNativeNagger),\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport\n || makeNativeTransportFactory({\n enableNative,\n })\n || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: chainedBeforeBreadcrumb,\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n };\n if ('tracesSampler' in options) {\n options.tracesSampler = safeTracesSampler(options.tracesSampler);\n }\n\n if (!('environment' in options)) {\n options.environment = getDefaultEnvironment();\n }\n\n const defaultIntegrations: false | Integration[] = passedOptions.defaultIntegrations === undefined\n ? getDefaultIntegrations(options)\n : passedOptions.defaultIntegrations;\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n\n if (isExpoGo()) {\n debug.log('Offline caching, native errors features are not available in Expo Go.');\n debug.log('Use EAS Build / Native Release Build to test these features.');\n }\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P extends Record<string, unknown>>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const profilerProps = {\n ...(options?.profilerProps),\n name: RootComponent.displayName ?? 'Root',\n updateProps: {}\n };\n\n const ProfilerComponent = isWeb() ? Profiler : ReactNativeProfiler;\n\n const RootApp: React.FC<P> = appProps => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ProfilerComponent {...profilerProps}>\n <FeedbackWidgetProvider>\n <RootComponent {...appProps} />\n </FeedbackWidgetProvider>\n </ProfilerComponent>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n NATIVE.nativeCrash();\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getClient();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n debug.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getClient();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n debug.error('Failed to close the SDK');\n }\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope<T>(callback: (scope: Scope) => T): T | undefined {\n const safeCallback = (scope: Scope): T | undefined => {\n try {\n return callback(scope);\n } catch (e) {\n debug.error('Error while running withScope callback', e);\n return undefined;\n }\n };\n return coreWithScope(safeCallback);\n}\n\n/**\n * Returns if the app crashed in the last run.\n */\nexport async function crashedLastRun(): Promise<boolean | null> {\n return NATIVE.crashedLastRun();\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EACL,KAAK,EACL,SAAS,EACT,cAAc,EACd,sBAAsB,EACtB,iBAAiB,EACjB,WAAW,EACX,OAAO,EACP,iCAAiC,EACjC,SAAS,IAAI,aAAa,GAC3B,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,E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AEhD,OAAO,KAAK,CAAC;IACf,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAgB,KAAK;;QACzB,IAAI;YACF,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;YAE3B,IAAI,MAAM,EAAE;gBACV,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACtB;SACF;QAAC,OAAO,CAAC,EAAE;YACV,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACxC;IACH,CAAC;CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAI,QAA6B;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAiB,EAAE;QACnD,IAAI;YACF,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;SACxB;QAAC,OAAO,CAAC,EAAE;YACV,KAAK,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;YACzD,OAAO,SAAS,CAAC;SAClB;IACH,CAAC,CAAC;IACF,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAgB,cAAc;;QAClC,OAAO,MAAM,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC;CAAA","sourcesContent":["/* eslint-disable complexity */\nimport type { Breadcrumb, BreadcrumbHint, Integration, Scope } from '@sentry/core';\nimport {\n debug,\n getClient,\n getGlobalScope,\n getIntegrationsToSetup,\n getIsolationScope,\n initAndBind,\n makeDsn,\n stackParserFromStackParserOptions,\n withScope as coreWithScope,\n} from '@sentry/core';\nimport { defaultStackParser, makeFetchTransport, Profiler } from '@sentry/react';\nimport * as React from 'react';\nimport { ReactNativeClient } from './client';\nimport { FeedbackWidgetProvider } from './feedback/FeedbackWidgetProvider';\nimport { getDevServer } from './integrations/debugsymbolicatorutils';\nimport { getDefaultIntegrations } from './integrations/default';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { shouldEnableNativeNagger } from './options';\nimport { enableSyncToNative } from './scopeSync';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler } from './tracing';\nimport { useEncodePolyfill } from './transports/encodePolyfill';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { getDefaultEnvironment, isExpoGo, isRunningInMetroDevServer, isWeb } from './utils/environment';\nimport { getDefaultRelease } from './utils/release';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\nimport { RN_GLOBAL_OBJ } from './utils/worldwide';\nimport { NATIVE } from './wrapper';\n\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n enableCaptureFailedRequests: false,\n enableNdk: true,\n enableAppStartTracking: true,\n enableNativeFramesTracking: true,\n enableStallTracking: true,\n enableUserInteractionTracing: false,\n propagateTraceparent: false,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n if (isRunningInMetroDevServer()) {\n return;\n }\n\n const userOptions = {\n ...RN_GLOBAL_OBJ.__SENTRY_OPTIONS__,\n ...passedOptions,\n };\n\n const maxQueueSize = userOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? userOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n\n const enableNative = userOptions.enableNative === undefined || userOptions.enableNative\n ? NATIVE.isNativeAvailable()\n : false;\n\n useEncodePolyfill();\n if (enableNative) {\n enableSyncToNative(getGlobalScope());\n enableSyncToNative(getIsolationScope());\n }\n\n const getURLFromDSN = (dsn: string | undefined): string | undefined => {\n if (!dsn) {\n return undefined;\n }\n const dsnComponents = makeDsn(dsn);\n if (!dsnComponents) {\n debug.error('Failed to extract url from DSN: ', dsn);\n return undefined;\n }\n const port = dsnComponents.port ? `:${dsnComponents.port}` : '';\n return `${dsnComponents.protocol}://${dsnComponents.host}${port}`;\n };\n\n const userBeforeBreadcrumb = safeFactory(userOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' });\n\n // Exclude Dev Server and Sentry Dsn request from Breadcrumbs\n const devServerUrl = getDevServer()?.url;\n const dsn = getURLFromDSN(userOptions.dsn);\n const defaultBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint): Breadcrumb | null => {\n const type = breadcrumb.type || '';\n const url = typeof breadcrumb.data?.url === 'string' ? breadcrumb.data.url : '';\n if (type === 'http' && ((devServerUrl && url.startsWith(devServerUrl)) || (dsn && url.startsWith(dsn)))) {\n return null;\n }\n return breadcrumb;\n };\n\n const chainedBeforeBreadcrumb = (breadcrumb: Breadcrumb, hint?: BreadcrumbHint): Breadcrumb | null => {\n let modifiedBreadcrumb = breadcrumb;\n if (userBeforeBreadcrumb) {\n const result = userBeforeBreadcrumb(breadcrumb, hint);\n if (result === null) {\n return null;\n }\n modifiedBreadcrumb = result;\n }\n return defaultBeforeBreadcrumb(modifiedBreadcrumb, hint);\n };\n\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...userOptions,\n release: userOptions.release ?? getDefaultRelease(),\n enableNative,\n enableNativeNagger: shouldEnableNativeNagger(userOptions.enableNativeNagger),\n // If custom transport factory fails the SDK won't initialize\n transport: userOptions.transport\n || makeNativeTransportFactory({\n enableNative,\n })\n || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(userOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(userOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: chainedBeforeBreadcrumb,\n initialScope: safeFactory(userOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n };\n\n if (!('autoInitializeNativeSdk' in userOptions) && RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {\n // We expect users to use the file options only in combination with manual native initialization\n // eslint-disable-next-line no-console\n console.info('Initializing Sentry JS with the options file. Expecting manual native initialization before JS. Native will not be initialized automatically.');\n options.autoInitializeNativeSdk = false;\n }\n\n if ('tracesSampler' in options) {\n options.tracesSampler = safeTracesSampler(options.tracesSampler);\n }\n\n if (!('environment' in options)) {\n options.environment = getDefaultEnvironment();\n }\n\n const defaultIntegrations: false | Integration[] = userOptions.defaultIntegrations === undefined\n ? getDefaultIntegrations(options)\n : userOptions.defaultIntegrations;\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(userOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n\n if (isExpoGo()) {\n debug.log('Offline caching, native errors features are not available in Expo Go.');\n debug.log('Use EAS Build / Native Release Build to test these features.');\n }\n\n if (RN_GLOBAL_OBJ.__SENTRY_OPTIONS__) {\n debug.log('Sentry JS initialized with options from the options file.');\n }\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P extends Record<string, unknown>>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const profilerProps = {\n ...(options?.profilerProps),\n name: RootComponent.displayName ?? 'Root',\n updateProps: {}\n };\n\n const ProfilerComponent = isWeb() ? Profiler : ReactNativeProfiler;\n\n const RootApp: React.FC<P> = appProps => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ProfilerComponent {...profilerProps}>\n <FeedbackWidgetProvider>\n <RootComponent {...appProps} />\n </FeedbackWidgetProvider>\n </ProfilerComponent>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n NATIVE.nativeCrash();\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getClient();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n debug.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getClient();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n debug.error('Failed to close the SDK');\n }\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope<T>(callback: (scope: Scope) => T): T | undefined {\n const safeCallback = (scope: Scope): T | undefined => {\n try {\n return callback(scope);\n } catch (e) {\n debug.error('Error while running withScope callback', e);\n return undefined;\n }\n };\n return coreWithScope(safeCallback);\n}\n\n/**\n * Returns if the app crashed in the last run.\n */\nexport async function crashedLastRun(): Promise<boolean | null> {\n return NATIVE.crashedLastRun();\n}\n"]}
@@ -20,6 +20,14 @@ export interface SentryMetroConfigOptions {
20
20
  * @default true
21
21
  */
22
22
  enableSourceContextInDevelopment?: boolean;
23
+ /**
24
+ * Load Sentry Options from a file. If `true` it will use the default path.
25
+ * If `false` it will not load any options from a file. Only options provided in the code will be used.
26
+ * If `string` it will use the provided path.
27
+ *
28
+ * @default '{projectRoot}/sentry.options.json'
29
+ */
30
+ optionsFile?: string | boolean;
23
31
  }
24
32
  export interface SentryExpoConfigOptions {
25
33
  /**
@@ -39,7 +47,7 @@ export interface SentryExpoConfigOptions {
39
47
  * Adds Debug ID to the output bundle and source maps.
40
48
  * Collapses Sentry frames from the stack trace view in LogBox.
41
49
  */
42
- export declare function withSentryConfig(config: MetroConfig, { annotateReactComponents, includeWebReplay, enableSourceContextInDevelopment, }?: SentryMetroConfigOptions): MetroConfig;
50
+ export declare function withSentryConfig(config: MetroConfig, { annotateReactComponents, includeWebReplay, enableSourceContextInDevelopment, optionsFile, }?: SentryMetroConfigOptions): MetroConfig;
43
51
  /**
44
52
  * This function returns Default Expo configuration with Sentry plugins.
45
53
  */
@@ -1 +1 @@
1
- {"version":3,"file":"metroconfig.d.ts","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAsC,MAAM,OAAO,CAAC;AAY7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAErE,cAAc,yBAAyB,CAAC;AAIxC,MAAM,WAAW,wBAAwB;IACvC;;;OAGG;IACH,uBAAuB,CAAC,EACpB,OAAO,GACP;QACE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;KAC9B,CAAC;IACN;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,gCAAgC,CAAC,EAAE,OAAO,CAAC;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEvG;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,EACE,uBAA+B,EAC/B,gBAAuB,EACvB,gCAAuC,GACxC,GAAE,wBAA6B,GAC/B,WAAW,CAkBb;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,oBAAoB,GAAG,uBAAuB,GAAG,wBAA6B,GACtF,WAAW,CA2Bb;AAsBD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,WAAW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AAE,wBAA6B,GAC/B,WAAW,CAqBb;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,oBAAoB,GAAG,uBAAuB,GAAG,wBAA6B,GACtF,WAAW,CA+Bb;AAsBD;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,WAAW,EACnB,uBAAuB,EAAE,IAAI,GAAG;IAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,GAC/D,WAAW,CA8Bb;AA0BD;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,OAAO,GAAG,SAAS,GAAG,WAAW,CA+C1G;AAQD;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,GAAG,WAAW,CAiC1E"}
@@ -22,6 +22,7 @@ const enableLogger_1 = require("./enableLogger");
22
22
  const metroMiddleware_1 = require("./metroMiddleware");
23
23
  const sentryBabelTransformerUtils_1 = require("./sentryBabelTransformerUtils");
24
24
  const sentryMetroSerializer_1 = require("./sentryMetroSerializer");
25
+ const sentryOptionsSerializer_1 = require("./sentryOptionsSerializer");
25
26
  const sentryReleaseInjector_1 = require("./sentryReleaseInjector");
26
27
  __exportStar(require("./sentryMetroSerializer"), exports);
27
28
  (0, enableLogger_1.enableLogger)();
@@ -31,7 +32,7 @@ __exportStar(require("./sentryMetroSerializer"), exports);
31
32
  * Adds Debug ID to the output bundle and source maps.
32
33
  * Collapses Sentry frames from the stack trace view in LogBox.
33
34
  */
34
- function withSentryConfig(config, { annotateReactComponents = false, includeWebReplay = true, enableSourceContextInDevelopment = true, } = {}) {
35
+ function withSentryConfig(config, { annotateReactComponents = false, includeWebReplay = true, enableSourceContextInDevelopment = true, optionsFile = true, } = {}) {
35
36
  setSentryMetroDevServerEnvFlag();
36
37
  let newConfig = config;
37
38
  newConfig = withSentryDebugId(newConfig);
@@ -45,6 +46,9 @@ function withSentryConfig(config, { annotateReactComponents = false, includeWebR
45
46
  if (enableSourceContextInDevelopment) {
46
47
  newConfig = (0, metroMiddleware_1.withSentryMiddleware)(newConfig);
47
48
  }
49
+ if (optionsFile) {
50
+ newConfig = (0, sentryOptionsSerializer_1.withSentryOptionsFromFile)(newConfig, optionsFile);
51
+ }
48
52
  return newConfig;
49
53
  }
50
54
  exports.withSentryConfig = withSentryConfig;
@@ -52,7 +56,7 @@ exports.withSentryConfig = withSentryConfig;
52
56
  * This function returns Default Expo configuration with Sentry plugins.
53
57
  */
54
58
  function getSentryExpoConfig(projectRoot, options = {}) {
55
- var _a, _b;
59
+ var _a, _b, _c, _d;
56
60
  setSentryMetroDevServerEnvFlag();
57
61
  const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;
58
62
  const config = getDefaultConfig(projectRoot, Object.assign(Object.assign({}, options), { unstable_beforeAssetSerializationPlugins: [
@@ -70,6 +74,9 @@ function getSentryExpoConfig(projectRoot, options = {}) {
70
74
  if ((_b = options.enableSourceContextInDevelopment) !== null && _b !== void 0 ? _b : true) {
71
75
  newConfig = (0, metroMiddleware_1.withSentryMiddleware)(newConfig);
72
76
  }
77
+ if ((_c = options.optionsFile) !== null && _c !== void 0 ? _c : true) {
78
+ newConfig = (0, sentryOptionsSerializer_1.withSentryOptionsFromFile)(newConfig, (_d = options.optionsFile) !== null && _d !== void 0 ? _d : true);
79
+ }
73
80
  return newConfig;
74
81
  }
75
82
  exports.getSentryExpoConfig = getSentryExpoConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"metroconfig.js","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAqC;AAGrC,mCAAmC;AACnC,qCAA8B;AAC9B,iDAA8C;AAC9C,uDAAyD;AACzD,+EAGuC;AACvC,mEAAqH;AACrH,mEAAyE;AAGzE,0DAAwC;AAExC,IAAA,2BAAY,GAAE,CAAC;AAuCf;;;;;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;QAED,OAAO,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,uCACK,MAAM,KACT,YAAY,kCACP,MAAM,CAAC,YAAY,KACtB,cAAc,OAEhB;AACJ,CAAC;AAjCD,8DAiCC;AAED;;;;GAIG;AACH,SAAS,8BAA8B;IACrC,aAAG,CAAC,6BAA6B,GAAG,MAAM,CAAC;AAC7C,CAAC","sourcesContent":["import { debug } from '@sentry/core';\nimport type { MetroConfig, MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { CustomResolutionContext, CustomResolver, Resolution } from 'metro-resolver';\nimport * as process from 'process';\nimport { env } from 'process';\nimport { enableLogger } from './enableLogger';\nimport { withSentryMiddleware } from './metroMiddleware';\nimport {\n setSentryBabelTransformerOptions,\n setSentryDefaultBabelTransformerPathEnv,\n} from './sentryBabelTransformerUtils';\nimport { createSentryMetroSerializer, unstableBeforeAssetSerializationDebugIdPlugin } from './sentryMetroSerializer';\nimport { unstableReleaseConstantsPlugin } from './sentryReleaseInjector';\nimport type { DefaultConfigOptions } from './vendor/expo/expoconfig';\n\nexport * from './sentryMetroSerializer';\n\nenableLogger();\n\nexport interface SentryMetroConfigOptions {\n /**\n * Annotates React components with Sentry data.\n * @default false\n */\n annotateReactComponents?:\n | boolean\n | {\n ignoredComponents?: string[];\n };\n /**\n * Adds the Sentry replay package for web.\n * @default true\n */\n includeWebReplay?: boolean;\n /**\n * Add Sentry Metro Server Middleware which\n * enables the app to fetch stack frames source context.\n * @default true\n */\n enableSourceContextInDevelopment?: boolean;\n}\n\nexport interface SentryExpoConfigOptions {\n /**\n * Pass a custom `getDefaultConfig` function to override the default Expo configuration getter.\n */\n getDefaultConfig?: (projectRoot: string, options?: Record<string, unknown>) => Record<string, unknown>;\n\n /**\n * For Expo Web, inject `release` and `version` options from `app.json`, the Expo Application Config.\n *\n * @default true\n */\n injectReleaseForWeb?: boolean;\n}\n\n/**\n * Adds Sentry to the Metro config.\n *\n * Adds Debug ID to the output bundle and source maps.\n * Collapses Sentry frames from the stack trace view in LogBox.\n */\nexport function withSentryConfig(\n config: MetroConfig,\n {\n annotateReactComponents = false,\n includeWebReplay = true,\n enableSourceContextInDevelopment = true,\n }: SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n let newConfig = config;\n\n newConfig = withSentryDebugId(newConfig);\n newConfig = withSentryFramesCollapsed(newConfig);\n if (annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig, annotateReactComponents);\n }\n if (includeWebReplay === false) {\n newConfig = withSentryResolver(newConfig, includeWebReplay);\n }\n if (enableSourceContextInDevelopment) {\n newConfig = withSentryMiddleware(newConfig);\n }\n\n return newConfig;\n}\n\n/**\n * This function returns Default Expo configuration with Sentry plugins.\n */\nexport function getSentryExpoConfig(\n projectRoot: string,\n options: DefaultConfigOptions & SentryExpoConfigOptions & SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;\n const config = getDefaultConfig(projectRoot, {\n ...options,\n unstable_beforeAssetSerializationPlugins: [\n ...(options.unstable_beforeAssetSerializationPlugins || []),\n ...(options.injectReleaseForWeb ?? true ? [unstableReleaseConstantsPlugin(projectRoot)] : []),\n unstableBeforeAssetSerializationDebugIdPlugin,\n ],\n });\n\n let newConfig = withSentryFramesCollapsed(config);\n if (options.annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig, options.annotateReactComponents);\n }\n\n if (options.includeWebReplay === false) {\n newConfig = withSentryResolver(newConfig, options.includeWebReplay);\n }\n\n if (options.enableSourceContextInDevelopment ?? true) {\n newConfig = withSentryMiddleware(newConfig);\n }\n\n return newConfig;\n}\n\nfunction loadExpoMetroConfigModule(): {\n getDefaultConfig: (\n projectRoot: string,\n options: {\n unstable_beforeAssetSerializationPlugins?: ((serializationInput: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n }) => Module[])[];\n },\n ) => MetroConfig;\n} {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n return require('expo/metro-config');\n } catch (e) {\n throw new Error('Unable to load `expo/metro-config`. Make sure you have Expo installed.');\n }\n}\n\n/**\n * Adds Sentry Babel transformer to the Metro config.\n */\nexport function withSentryBabelTransformer(\n config: MetroConfig,\n annotateReactComponents: true | { ignoredComponents?: string[] },\n): MetroConfig {\n const defaultBabelTransformerPath = config.transformer?.babelTransformerPath;\n debug.log('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath);\n\n if (!defaultBabelTransformerPath) {\n // This has to be console.warn because the options is enabled but won't be used\n // eslint-disable-next-line no-console\n console.warn('`transformer.babelTransformerPath` is undefined.');\n // eslint-disable-next-line no-console\n console.warn('Sentry Babel transformer cannot be used. Not adding it...');\n return config;\n }\n\n if (defaultBabelTransformerPath) {\n setSentryDefaultBabelTransformerPathEnv(defaultBabelTransformerPath);\n }\n\n if (typeof annotateReactComponents === 'object') {\n setSentryBabelTransformerOptions({\n annotateReactComponents,\n });\n }\n\n return {\n ...config,\n transformer: {\n ...config.transformer,\n babelTransformerPath: require.resolve('./sentryBabelTransformer'),\n },\n };\n}\n\ntype MetroCustomSerializer = Required<Required<MetroConfig>['serializer']>['customSerializer'] | undefined;\n\nfunction withSentryDebugId(config: MetroConfig): MetroConfig {\n const customSerializer = createSentryMetroSerializer(\n config.serializer?.customSerializer || undefined,\n ) as MetroCustomSerializer;\n // MetroConfig types customSerializers as async only, but sync returns are also supported\n // The default serializer is sync\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer,\n },\n };\n}\n\n// Based on: https://github.com/facebook/metro/blob/c21daba415ea26511e157f794689caab9abe8236/packages/metro-resolver/src/resolve.js#L86-L91\ntype CustomResolverBeforeMetro068 = (\n context: CustomResolutionContext,\n realModuleName: string,\n platform: string | null,\n moduleName?: string,\n) => Resolution;\n\n/**\n * Includes `@sentry/replay` packages based on the `includeWebReplay` flag and current bundle `platform`.\n */\nexport function withSentryResolver(config: MetroConfig, includeWebReplay: boolean | undefined): MetroConfig {\n const originalResolver = config.resolver?.resolveRequest as CustomResolver | CustomResolverBeforeMetro068 | undefined;\n\n const sentryResolverRequest: CustomResolver = (\n context: CustomResolutionContext,\n moduleName: string,\n platform: string | null,\n oldMetroModuleName?: string,\n ) => {\n if (\n (includeWebReplay === false ||\n (includeWebReplay === undefined && (platform === 'android' || platform === 'ios'))) &&\n !!(oldMetroModuleName ?? moduleName).match(/@sentry(?:-internal)?\\/replay/)\n ) {\n return { type: 'empty' } as Resolution;\n }\n if (originalResolver) {\n return oldMetroModuleName\n ? originalResolver(context, moduleName, platform, oldMetroModuleName)\n : originalResolver(context, moduleName, platform);\n }\n\n // Prior 0.68, resolve context.resolveRequest is sentryResolver itself, where on later version it is the default resolver.\n if (context.resolveRequest === sentryResolverRequest) {\n // eslint-disable-next-line no-console\n console.error(\n `Error: [@sentry/react-native/metro] Can not resolve the defaultResolver on Metro older than 0.68.\nPlease follow one of the following options:\n- Include your resolverRequest on your metroconfig.\n- Update your Metro version to 0.68 or higher.\n- Set includeWebReplay as true on your metro config.\n- If you are still facing issues, report the issue at http://www.github.com/getsentry/sentry-react-native/issues`,\n );\n // Return required for test.\n return process.exit(-1);\n }\n\n return context.resolveRequest(context, moduleName, platform);\n };\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest: sentryResolverRequest,\n },\n };\n}\n\ntype MetroFrame = Parameters<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>[0];\ntype MetroCustomizeFrame = { readonly collapse?: boolean };\ntype MetroCustomizeFrameReturnValue =\n | ReturnType<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>\n | undefined;\n\n/**\n * Collapses Sentry internal frames from the stack trace view in LogBox.\n */\nexport function withSentryFramesCollapsed(config: MetroConfig): MetroConfig {\n const originalCustomizeFrame = config.symbolicator?.customizeFrame;\n const collapseSentryInternalFrames = (frame: MetroFrame): boolean =>\n typeof frame.file === 'string' &&\n (frame.file.includes('node_modules/@sentry/core/cjs/instrument.js') ||\n frame.file.includes('node_modules/@sentry/core/cjs/debug.js'));\n\n const customizeFrame = (frame: MetroFrame): MetroCustomizeFrameReturnValue => {\n const originalOrSentryCustomizeFrame = (\n originalCustomization: MetroCustomizeFrame | undefined,\n ): MetroCustomizeFrame => ({\n ...originalCustomization,\n collapse: originalCustomization?.collapse || collapseSentryInternalFrames(frame),\n });\n\n const maybePromiseCustomization = originalCustomizeFrame?.(frame) || undefined;\n\n if (maybePromiseCustomization !== undefined && 'then' in maybePromiseCustomization) {\n return maybePromiseCustomization.then<MetroCustomizeFrame>(originalCustomization =>\n originalOrSentryCustomizeFrame(originalCustomization),\n );\n }\n\n return originalOrSentryCustomizeFrame(maybePromiseCustomization);\n };\n\n return {\n ...config,\n symbolicator: {\n ...config.symbolicator,\n customizeFrame,\n },\n };\n}\n\n/**\n * Sets the `___SENTRY_METRO_DEV_SERVER___` environment flag.\n * This is used to determine if the SDK is running in Node in Metro Dev Server.\n * For example during static routes generation in `expo-router`.\n */\nfunction setSentryMetroDevServerEnvFlag(): void {\n env.___SENTRY_METRO_DEV_SERVER___ = 'true';\n}\n"]}
1
+ {"version":3,"file":"metroconfig.js","sourceRoot":"","sources":["../../../src/js/tools/metroconfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,uCAAqC;AAGrC,mCAAmC;AACnC,qCAA8B;AAC9B,iDAA8C;AAC9C,uDAAyD;AACzD,+EAGuC;AACvC,mEAAqH;AACrH,uEAAsE;AACtE,mEAAyE;AAIzE,0DAAwC;AAExC,IAAA,2BAAY,GAAE,CAAC;AA+Cf;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC9B,MAAmB,EACnB,EACE,uBAAuB,GAAG,KAAK,EAC/B,gBAAgB,GAAG,IAAI,EACvB,gCAAgC,GAAG,IAAI,EACvC,WAAW,GAAG,IAAI,MACU,EAAE;IAEhC,8BAA8B,EAAE,CAAC;IA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B,CAAC,IAAI,CAAsB,qBAAqB,CAAC,EAAE,CACjF,8BAA8B,CAAC,qBAAqB,CAAC,CACtD,CAAC;SACH;QAED,OAAO,8BAA8B,CAAC,yBAAyB,CAAC,CAAC;IACnE,CAAC,CAAC;IAEF,uCACK,MAAM,KACT,YAAY,kCACP,MAAM,CAAC,YAAY,KACtB,cAAc,OAEhB;AACJ,CAAC;AAjCD,8DAiCC;AAED;;;;GAIG;AACH,SAAS,8BAA8B;IACrC,aAAG,CAAC,6BAA6B,GAAG,MAAM,CAAC;AAC7C,CAAC","sourcesContent":["import { debug } from '@sentry/core';\nimport type { MetroConfig, MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { CustomResolutionContext, CustomResolver, Resolution } from 'metro-resolver';\nimport * as process from 'process';\nimport { env } from 'process';\nimport { enableLogger } from './enableLogger';\nimport { withSentryMiddleware } from './metroMiddleware';\nimport {\n setSentryBabelTransformerOptions,\n setSentryDefaultBabelTransformerPathEnv,\n} from './sentryBabelTransformerUtils';\nimport { createSentryMetroSerializer, unstableBeforeAssetSerializationDebugIdPlugin } from './sentryMetroSerializer';\nimport { withSentryOptionsFromFile } from './sentryOptionsSerializer';\nimport { unstableReleaseConstantsPlugin } from './sentryReleaseInjector';\nimport type { MetroCustomSerializer } from './utils';\nimport type { DefaultConfigOptions } from './vendor/expo/expoconfig';\n\nexport * from './sentryMetroSerializer';\n\nenableLogger();\n\nexport interface SentryMetroConfigOptions {\n /**\n * Annotates React components with Sentry data.\n * @default false\n */\n annotateReactComponents?:\n | boolean\n | {\n ignoredComponents?: string[];\n };\n /**\n * Adds the Sentry replay package for web.\n * @default true\n */\n includeWebReplay?: boolean;\n /**\n * Add Sentry Metro Server Middleware which\n * enables the app to fetch stack frames source context.\n * @default true\n */\n enableSourceContextInDevelopment?: boolean;\n /**\n * Load Sentry Options from a file. If `true` it will use the default path.\n * If `false` it will not load any options from a file. Only options provided in the code will be used.\n * If `string` it will use the provided path.\n *\n * @default '{projectRoot}/sentry.options.json'\n */\n optionsFile?: string | boolean;\n}\n\nexport interface SentryExpoConfigOptions {\n /**\n * Pass a custom `getDefaultConfig` function to override the default Expo configuration getter.\n */\n getDefaultConfig?: (projectRoot: string, options?: Record<string, unknown>) => Record<string, unknown>;\n\n /**\n * For Expo Web, inject `release` and `version` options from `app.json`, the Expo Application Config.\n *\n * @default true\n */\n injectReleaseForWeb?: boolean;\n}\n\n/**\n * Adds Sentry to the Metro config.\n *\n * Adds Debug ID to the output bundle and source maps.\n * Collapses Sentry frames from the stack trace view in LogBox.\n */\nexport function withSentryConfig(\n config: MetroConfig,\n {\n annotateReactComponents = false,\n includeWebReplay = true,\n enableSourceContextInDevelopment = true,\n optionsFile = true,\n }: SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n let newConfig = config;\n\n newConfig = withSentryDebugId(newConfig);\n newConfig = withSentryFramesCollapsed(newConfig);\n if (annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig, annotateReactComponents);\n }\n if (includeWebReplay === false) {\n newConfig = withSentryResolver(newConfig, includeWebReplay);\n }\n if (enableSourceContextInDevelopment) {\n newConfig = withSentryMiddleware(newConfig);\n }\n if (optionsFile) {\n newConfig = withSentryOptionsFromFile(newConfig, optionsFile);\n }\n\n return newConfig;\n}\n\n/**\n * This function returns Default Expo configuration with Sentry plugins.\n */\nexport function getSentryExpoConfig(\n projectRoot: string,\n options: DefaultConfigOptions & SentryExpoConfigOptions & SentryMetroConfigOptions = {},\n): MetroConfig {\n setSentryMetroDevServerEnvFlag();\n\n const getDefaultConfig = options.getDefaultConfig || loadExpoMetroConfigModule().getDefaultConfig;\n const config = getDefaultConfig(projectRoot, {\n ...options,\n unstable_beforeAssetSerializationPlugins: [\n ...(options.unstable_beforeAssetSerializationPlugins || []),\n ...(options.injectReleaseForWeb ?? true ? [unstableReleaseConstantsPlugin(projectRoot)] : []),\n unstableBeforeAssetSerializationDebugIdPlugin,\n ],\n });\n\n let newConfig = withSentryFramesCollapsed(config);\n if (options.annotateReactComponents) {\n newConfig = withSentryBabelTransformer(newConfig, options.annotateReactComponents);\n }\n\n if (options.includeWebReplay === false) {\n newConfig = withSentryResolver(newConfig, options.includeWebReplay);\n }\n\n if (options.enableSourceContextInDevelopment ?? true) {\n newConfig = withSentryMiddleware(newConfig);\n }\n\n if (options.optionsFile ?? true) {\n newConfig = withSentryOptionsFromFile(newConfig, options.optionsFile ?? true);\n }\n\n return newConfig;\n}\n\nfunction loadExpoMetroConfigModule(): {\n getDefaultConfig: (\n projectRoot: string,\n options: {\n unstable_beforeAssetSerializationPlugins?: ((serializationInput: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n }) => Module[])[];\n },\n ) => MetroConfig;\n} {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n return require('expo/metro-config');\n } catch (e) {\n throw new Error('Unable to load `expo/metro-config`. Make sure you have Expo installed.');\n }\n}\n\n/**\n * Adds Sentry Babel transformer to the Metro config.\n */\nexport function withSentryBabelTransformer(\n config: MetroConfig,\n annotateReactComponents: true | { ignoredComponents?: string[] },\n): MetroConfig {\n const defaultBabelTransformerPath = config.transformer?.babelTransformerPath;\n debug.log('Default Babel transformer path from `config.transformer`:', defaultBabelTransformerPath);\n\n if (!defaultBabelTransformerPath) {\n // This has to be console.warn because the options is enabled but won't be used\n // eslint-disable-next-line no-console\n console.warn('`transformer.babelTransformerPath` is undefined.');\n // eslint-disable-next-line no-console\n console.warn('Sentry Babel transformer cannot be used. Not adding it...');\n return config;\n }\n\n if (defaultBabelTransformerPath) {\n setSentryDefaultBabelTransformerPathEnv(defaultBabelTransformerPath);\n }\n\n if (typeof annotateReactComponents === 'object') {\n setSentryBabelTransformerOptions({\n annotateReactComponents,\n });\n }\n\n return {\n ...config,\n transformer: {\n ...config.transformer,\n babelTransformerPath: require.resolve('./sentryBabelTransformer'),\n },\n };\n}\n\nfunction withSentryDebugId(config: MetroConfig): MetroConfig {\n const customSerializer = createSentryMetroSerializer(\n config.serializer?.customSerializer || undefined,\n ) as MetroCustomSerializer;\n // MetroConfig types customSerializers as async only, but sync returns are also supported\n // The default serializer is sync\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer,\n },\n };\n}\n\n// Based on: https://github.com/facebook/metro/blob/c21daba415ea26511e157f794689caab9abe8236/packages/metro-resolver/src/resolve.js#L86-L91\ntype CustomResolverBeforeMetro068 = (\n context: CustomResolutionContext,\n realModuleName: string,\n platform: string | null,\n moduleName?: string,\n) => Resolution;\n\n/**\n * Includes `@sentry/replay` packages based on the `includeWebReplay` flag and current bundle `platform`.\n */\nexport function withSentryResolver(config: MetroConfig, includeWebReplay: boolean | undefined): MetroConfig {\n const originalResolver = config.resolver?.resolveRequest as CustomResolver | CustomResolverBeforeMetro068 | undefined;\n\n const sentryResolverRequest: CustomResolver = (\n context: CustomResolutionContext,\n moduleName: string,\n platform: string | null,\n oldMetroModuleName?: string,\n ) => {\n if (\n (includeWebReplay === false ||\n (includeWebReplay === undefined && (platform === 'android' || platform === 'ios'))) &&\n !!(oldMetroModuleName ?? moduleName).match(/@sentry(?:-internal)?\\/replay/)\n ) {\n return { type: 'empty' } as Resolution;\n }\n if (originalResolver) {\n return oldMetroModuleName\n ? originalResolver(context, moduleName, platform, oldMetroModuleName)\n : originalResolver(context, moduleName, platform);\n }\n\n // Prior 0.68, resolve context.resolveRequest is sentryResolver itself, where on later version it is the default resolver.\n if (context.resolveRequest === sentryResolverRequest) {\n // eslint-disable-next-line no-console\n console.error(\n `Error: [@sentry/react-native/metro] Can not resolve the defaultResolver on Metro older than 0.68.\nPlease follow one of the following options:\n- Include your resolverRequest on your metroconfig.\n- Update your Metro version to 0.68 or higher.\n- Set includeWebReplay as true on your metro config.\n- If you are still facing issues, report the issue at http://www.github.com/getsentry/sentry-react-native/issues`,\n );\n // Return required for test.\n return process.exit(-1);\n }\n\n return context.resolveRequest(context, moduleName, platform);\n };\n\n return {\n ...config,\n resolver: {\n ...config.resolver,\n resolveRequest: sentryResolverRequest,\n },\n };\n}\n\ntype MetroFrame = Parameters<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>[0];\ntype MetroCustomizeFrame = { readonly collapse?: boolean };\ntype MetroCustomizeFrameReturnValue =\n | ReturnType<Required<Required<MetroConfig>['symbolicator']>['customizeFrame']>\n | undefined;\n\n/**\n * Collapses Sentry internal frames from the stack trace view in LogBox.\n */\nexport function withSentryFramesCollapsed(config: MetroConfig): MetroConfig {\n const originalCustomizeFrame = config.symbolicator?.customizeFrame;\n const collapseSentryInternalFrames = (frame: MetroFrame): boolean =>\n typeof frame.file === 'string' &&\n (frame.file.includes('node_modules/@sentry/core/cjs/instrument.js') ||\n frame.file.includes('node_modules/@sentry/core/cjs/debug.js'));\n\n const customizeFrame = (frame: MetroFrame): MetroCustomizeFrameReturnValue => {\n const originalOrSentryCustomizeFrame = (\n originalCustomization: MetroCustomizeFrame | undefined,\n ): MetroCustomizeFrame => ({\n ...originalCustomization,\n collapse: originalCustomization?.collapse || collapseSentryInternalFrames(frame),\n });\n\n const maybePromiseCustomization = originalCustomizeFrame?.(frame) || undefined;\n\n if (maybePromiseCustomization !== undefined && 'then' in maybePromiseCustomization) {\n return maybePromiseCustomization.then<MetroCustomizeFrame>(originalCustomization =>\n originalOrSentryCustomizeFrame(originalCustomization),\n );\n }\n\n return originalOrSentryCustomizeFrame(maybePromiseCustomization);\n };\n\n return {\n ...config,\n symbolicator: {\n ...config.symbolicator,\n customizeFrame,\n },\n };\n}\n\n/**\n * Sets the `___SENTRY_METRO_DEV_SERVER___` environment flag.\n * This is used to determine if the SDK is running in Node in Metro Dev Server.\n * For example during static routes generation in `expo-router`.\n */\nfunction setSentryMetroDevServerEnvFlag(): void {\n env.___SENTRY_METRO_DEV_SERVER___ = 'true';\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sentryMetroSerializer.d.ts","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAU,eAAe,EAA4D,MAAM,SAAS,CAAC;AAkBjH;;GAEG;AACH,wBAAgB,6CAA6C,CAAC,EAC5D,UAAU,EACV,OAAO,GACR,EAAE;IACD,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,EAAE,CAcX;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,sBAAuB,eAAe,KAAG,eA4DhF,CAAC"}
1
+ {"version":3,"file":"sentryMetroSerializer.d.ts","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,KAAK,EAAU,eAAe,EAA4D,MAAM,SAAS,CAAC;AAkBjH;;GAEG;AACH,wBAAgB,6CAA6C,CAAC,EAC5D,UAAU,EACV,OAAO,GACR,EAAE;IACD,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IAClC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,MAAM,EAAE,CAcX;AAGD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,sBAAuB,eAAe,KAAG,eA4DhF,CAAC"}
@@ -34,6 +34,7 @@ function unstableBeforeAssetSerializationDebugIdPlugin({ premodules, debugId, })
34
34
  return (0, utils_1.prependModule)(premodules, debugIdModule);
35
35
  }
36
36
  exports.unstableBeforeAssetSerializationDebugIdPlugin = unstableBeforeAssetSerializationDebugIdPlugin;
37
+ // TODO: deprecate this and afterwards rename to createSentryDebugIdSerializer
37
38
  /**
38
39
  * Creates a Metro serializer that adds Debug ID module to the plain bundle.
39
40
  * The Debug ID module is a virtual module that provides a debug ID in runtime.
@@ -1 +1 @@
1
- {"version":3,"file":"sentryMetroSerializer.js","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AAIjC,mCAMiB;AACjB,gDAAoE;AAIpE,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAC1D,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAE3C,MAAM,kBAAkB,GAAG,uBAAuB,CAAC;AACnD,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAExC;;GAEG;AACH,SAAgB,6CAA6C,CAAC,EAC5D,UAAU,EACV,OAAO,GAKR;IACC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,UAAU,CAAC;KACnB;IAED,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IACvG,IAAI,mBAAmB,EAAE;QACvB,sCAAsC;QACtC,OAAO,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;KACnB;IAED,MAAM,aAAa,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IACnD,OAAO,IAAA,qBAAa,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;AAClD,CAAC;AArBD,sGAqBC;AAED;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,CAAC,gBAAkC,EAAmB,EAAE;IACjG,MAAM,UAAU,GAAG,gBAAgB,IAAI,IAAA,oCAA4B,GAAE,CAAC;IACtE,OAAO,UAAgB,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO;;YAC3D,IAAI,KAAK,CAAC,gBAAgB,CAAC,GAAG,EAAE;gBAC9B,OAAO,UAAU,CAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,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C,CAAC;AACvE,CAAC","sourcesContent":["import * as crypto from 'crypto';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { Bundle, MetroSerializer, MetroSerializerOutput, SerializedBundle, VirtualJSOutput } from './utils';\nimport {\n createDebugIdSnippet,\n createVirtualJSModule,\n determineDebugIdFromBundleSource,\n prependModule,\n stringToUUID,\n} from './utils';\nimport { createDefaultMetroSerializer } from './vendor/metro/utils';\n\ntype SourceMap = Record<string, unknown>;\n\nconst DEBUG_ID_PLACE_HOLDER = '__debug_id_place_holder__';\nconst DEBUG_ID_MODULE_PATH = '__debugid__';\n\nconst SOURCE_MAP_COMMENT = '//# sourceMappingURL=';\nconst DEBUG_ID_COMMENT = '//# debugId=';\n\n/**\n * Adds Sentry Debug ID polyfill module to the bundle.\n */\nexport function unstableBeforeAssetSerializationDebugIdPlugin({\n premodules,\n debugId,\n}: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n}): Module[] {\n if (!debugId) {\n return premodules;\n }\n\n const debugIdModuleExists = premodules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('\\n\\nDebug ID module found. Skipping Sentry Debug ID module...\\n\\n');\n return premodules;\n }\n\n const debugIdModule = createDebugIdModule(debugId);\n return prependModule(premodules, debugIdModule);\n}\n\n/**\n * Creates a Metro serializer that adds Debug ID module to the plain bundle.\n * The Debug ID module is a virtual module that provides a debug ID in runtime.\n *\n * RAM Bundles do not support custom serializers.\n */\nexport const createSentryMetroSerializer = (customSerializer?: MetroSerializer): MetroSerializer => {\n const serializer = customSerializer || createDefaultMetroSerializer();\n return async function (entryPoint, preModules, graph, options) {\n if (graph.transformOptions.hot) {\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModuleExists = preModules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('Debug ID module found. Skipping Sentry Debug ID module...');\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModule = createDebugIdModule(DEBUG_ID_PLACE_HOLDER);\n options.sentryBundleCallback = createSentryBundleCallback(debugIdModule);\n const modifiedPreModules = prependModule(preModules, debugIdModule);\n\n // Run wrapped serializer\n const serializerResult = serializer(entryPoint, modifiedPreModules, graph, options);\n const { code: bundleCode, map: bundleMapString } = await extractSerializerResult(serializerResult);\n\n // Add debug id comment to the bundle\n let debugId = determineDebugIdFromBundleSource(bundleCode);\n if (!debugId) {\n // For lazy-loaded chunks or bundles without the debug ID module,\n // calculate the debug ID from the bundle content.\n // This ensures Metro 0.83.2+ code-split bundles get debug IDs.\n // That needs to be done because when Metro 0.83.2 stopped importing `BabelSourceMapSegment`\n // from `@babel/generator` and defined it locally, it subtly changed the source map output format.\n // https://github.com/facebook/metro/blob/main/packages/metro-source-map/src/source-map.js#L47\n debugId = calculateDebugId(bundleCode);\n // eslint-disable-next-line no-console\n console.log('info ' + `Bundle Debug ID (calculated): ${debugId}`);\n }\n // Only print debug id for command line builds => not hot reload from dev server\n // eslint-disable-next-line no-console\n console.log('info ' + `Bundle Debug ID: ${debugId}`);\n\n const debugIdComment = `${DEBUG_ID_COMMENT}${debugId}`;\n const indexOfSourceMapComment = bundleCode.lastIndexOf(SOURCE_MAP_COMMENT);\n const bundleCodeWithDebugId =\n indexOfSourceMapComment === -1\n ? // If source map comment is missing lets just add the debug id comment\n `${bundleCode}\\n${debugIdComment}`\n : // If source map comment is present lets add the debug id comment before it\n `${bundleCode.substring(0, indexOfSourceMapComment) + debugIdComment}\\n${bundleCode.substring(\n indexOfSourceMapComment,\n )}`;\n\n const bundleMap: SourceMap = JSON.parse(bundleMapString);\n // For now we write both fields until we know what will become the standard - if ever.\n bundleMap['debug_id'] = debugId;\n bundleMap['debugId'] = debugId;\n\n return {\n code: bundleCodeWithDebugId,\n map: JSON.stringify(bundleMap),\n };\n };\n};\n\n/**\n * This function is expected to be called after serializer creates the final bundle object\n * and before the source maps are generated.\n *\n * It injects a debug ID into the bundle and returns the modified bundle.\n *\n * Access it via `options.sentryBundleCallback` in your custom serializer.\n */\nfunction createSentryBundleCallback(debugIdModule: Module<VirtualJSOutput> & { setSource: (code: string) => void }) {\n return (bundle: Bundle) => {\n const debugId = calculateDebugId(bundle.pre, bundle.modules);\n debugIdModule.setSource(injectDebugId(debugIdModule.getSource().toString(), debugId));\n bundle.pre = injectDebugId(bundle.pre, debugId);\n return bundle;\n };\n}\n\nasync function extractSerializerResult(serializerResult: MetroSerializerOutput): Promise<SerializedBundle> {\n if (typeof serializerResult === 'string') {\n return { code: serializerResult, map: '{}' };\n }\n\n if ('map' in serializerResult) {\n return { code: serializerResult.code, map: serializerResult.map };\n }\n\n const awaitedResult = await serializerResult;\n if (typeof awaitedResult === 'string') {\n return { code: awaitedResult, map: '{}' };\n }\n\n return { code: awaitedResult.code, map: awaitedResult.map };\n}\n\nfunction createDebugIdModule(debugId: string): Module<VirtualJSOutput> & { setSource: (code: string) => void } {\n return createVirtualJSModule(DEBUG_ID_MODULE_PATH, createDebugIdSnippet(debugId));\n}\n\nfunction calculateDebugId(bundleCode: string, modules?: Array<[id: number, code: string]>): string {\n const hash = crypto.createHash('md5');\n hash.update(bundleCode);\n if (modules) {\n for (const [, code] of modules) {\n hash.update(code);\n }\n }\n return stringToUUID(hash.digest('hex'));\n}\n\nfunction injectDebugId(code: string, debugId: string): string {\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n return code.replace(new RegExp(DEBUG_ID_PLACE_HOLDER, 'g'), debugId);\n}\n"]}
1
+ {"version":3,"file":"sentryMetroSerializer.js","sourceRoot":"","sources":["../../../src/js/tools/sentryMetroSerializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAAiC;AAIjC,mCAMiB;AACjB,gDAAoE;AAIpE,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AAC1D,MAA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,CAAC;SACnE;QAED,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC;QAC7C,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE;YACrC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;SAC3C;QAED,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,GAAG,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC;IAC9D,CAAC;CAAA;AAED,SAAS,mBAAmB,CAAC,OAAe;IAC1C,OAAO,IAAA,6BAAqB,EAAC,oBAAoB,EAAE,IAAA,4BAAoB,EAAC,OAAO,CAAC,CAAC,CAAC;AACpF,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAkB,EAAE,OAA2C;IACvF,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACxB,IAAI,OAAO,EAAE;QACX,KAAK,MAAM,CAAC,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE;YAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACnB;KACF;IACD,OAAO,IAAA,oBAAY,EAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,aAAa,CAAC,IAAY,EAAE,OAAe;IAClD,sEAAsE;IACtE,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,qBAAqB,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import * as crypto from 'crypto';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MixedOutput, Module, ReadOnlyGraph } from 'metro';\nimport type { Bundle, MetroSerializer, MetroSerializerOutput, SerializedBundle, VirtualJSOutput } from './utils';\nimport {\n createDebugIdSnippet,\n createVirtualJSModule,\n determineDebugIdFromBundleSource,\n prependModule,\n stringToUUID,\n} from './utils';\nimport { createDefaultMetroSerializer } from './vendor/metro/utils';\n\ntype SourceMap = Record<string, unknown>;\n\nconst DEBUG_ID_PLACE_HOLDER = '__debug_id_place_holder__';\nconst DEBUG_ID_MODULE_PATH = '__debugid__';\n\nconst SOURCE_MAP_COMMENT = '//# sourceMappingURL=';\nconst DEBUG_ID_COMMENT = '//# debugId=';\n\n/**\n * Adds Sentry Debug ID polyfill module to the bundle.\n */\nexport function unstableBeforeAssetSerializationDebugIdPlugin({\n premodules,\n debugId,\n}: {\n graph: ReadOnlyGraph<MixedOutput>;\n premodules: Module[];\n debugId?: string;\n}): Module[] {\n if (!debugId) {\n return premodules;\n }\n\n const debugIdModuleExists = premodules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('\\n\\nDebug ID module found. Skipping Sentry Debug ID module...\\n\\n');\n return premodules;\n }\n\n const debugIdModule = createDebugIdModule(debugId);\n return prependModule(premodules, debugIdModule);\n}\n\n// TODO: deprecate this and afterwards rename to createSentryDebugIdSerializer\n/**\n * Creates a Metro serializer that adds Debug ID module to the plain bundle.\n * The Debug ID module is a virtual module that provides a debug ID in runtime.\n *\n * RAM Bundles do not support custom serializers.\n */\nexport const createSentryMetroSerializer = (customSerializer?: MetroSerializer): MetroSerializer => {\n const serializer = customSerializer || createDefaultMetroSerializer();\n return async function (entryPoint, preModules, graph, options) {\n if (graph.transformOptions.hot) {\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModuleExists = preModules.findIndex(module => module.path === DEBUG_ID_MODULE_PATH) != -1;\n if (debugIdModuleExists) {\n // eslint-disable-next-line no-console\n console.warn('Debug ID module found. Skipping Sentry Debug ID module...');\n return serializer(entryPoint, preModules, graph, options);\n }\n\n const debugIdModule = createDebugIdModule(DEBUG_ID_PLACE_HOLDER);\n options.sentryBundleCallback = createSentryBundleCallback(debugIdModule);\n const modifiedPreModules = prependModule(preModules, debugIdModule);\n\n // Run wrapped serializer\n const serializerResult = serializer(entryPoint, modifiedPreModules, graph, options);\n const { code: bundleCode, map: bundleMapString } = await extractSerializerResult(serializerResult);\n\n // Add debug id comment to the bundle\n let debugId = determineDebugIdFromBundleSource(bundleCode);\n if (!debugId) {\n // For lazy-loaded chunks or bundles without the debug ID module,\n // calculate the debug ID from the bundle content.\n // This ensures Metro 0.83.2+ code-split bundles get debug IDs.\n // That needs to be done because when Metro 0.83.2 stopped importing `BabelSourceMapSegment`\n // from `@babel/generator` and defined it locally, it subtly changed the source map output format.\n // https://github.com/facebook/metro/blob/main/packages/metro-source-map/src/source-map.js#L47\n debugId = calculateDebugId(bundleCode);\n // eslint-disable-next-line no-console\n console.log('info ' + `Bundle Debug ID (calculated): ${debugId}`);\n }\n // Only print debug id for command line builds => not hot reload from dev server\n // eslint-disable-next-line no-console\n console.log('info ' + `Bundle Debug ID: ${debugId}`);\n\n const debugIdComment = `${DEBUG_ID_COMMENT}${debugId}`;\n const indexOfSourceMapComment = bundleCode.lastIndexOf(SOURCE_MAP_COMMENT);\n const bundleCodeWithDebugId =\n indexOfSourceMapComment === -1\n ? // If source map comment is missing lets just add the debug id comment\n `${bundleCode}\\n${debugIdComment}`\n : // If source map comment is present lets add the debug id comment before it\n `${bundleCode.substring(0, indexOfSourceMapComment) + debugIdComment}\\n${bundleCode.substring(\n indexOfSourceMapComment,\n )}`;\n\n const bundleMap: SourceMap = JSON.parse(bundleMapString);\n // For now we write both fields until we know what will become the standard - if ever.\n bundleMap['debug_id'] = debugId;\n bundleMap['debugId'] = debugId;\n\n return {\n code: bundleCodeWithDebugId,\n map: JSON.stringify(bundleMap),\n };\n };\n};\n\n/**\n * This function is expected to be called after serializer creates the final bundle object\n * and before the source maps are generated.\n *\n * It injects a debug ID into the bundle and returns the modified bundle.\n *\n * Access it via `options.sentryBundleCallback` in your custom serializer.\n */\nfunction createSentryBundleCallback(debugIdModule: Module<VirtualJSOutput> & { setSource: (code: string) => void }) {\n return (bundle: Bundle) => {\n const debugId = calculateDebugId(bundle.pre, bundle.modules);\n debugIdModule.setSource(injectDebugId(debugIdModule.getSource().toString(), debugId));\n bundle.pre = injectDebugId(bundle.pre, debugId);\n return bundle;\n };\n}\n\nasync function extractSerializerResult(serializerResult: MetroSerializerOutput): Promise<SerializedBundle> {\n if (typeof serializerResult === 'string') {\n return { code: serializerResult, map: '{}' };\n }\n\n if ('map' in serializerResult) {\n return { code: serializerResult.code, map: serializerResult.map };\n }\n\n const awaitedResult = await serializerResult;\n if (typeof awaitedResult === 'string') {\n return { code: awaitedResult, map: '{}' };\n }\n\n return { code: awaitedResult.code, map: awaitedResult.map };\n}\n\nfunction createDebugIdModule(debugId: string): Module<VirtualJSOutput> & { setSource: (code: string) => void } {\n return createVirtualJSModule(DEBUG_ID_MODULE_PATH, createDebugIdSnippet(debugId));\n}\n\nfunction calculateDebugId(bundleCode: string, modules?: Array<[id: number, code: string]>): string {\n const hash = crypto.createHash('md5');\n hash.update(bundleCode);\n if (modules) {\n for (const [, code] of modules) {\n hash.update(code);\n }\n }\n return stringToUUID(hash.digest('hex'));\n}\n\nfunction injectDebugId(code: string, debugId: string): string {\n // eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\n return code.replace(new RegExp(DEBUG_ID_PLACE_HOLDER, 'g'), debugId);\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { MetroConfig } from 'metro';
2
+ /**
3
+ * Loads Sentry options from a file in
4
+ */
5
+ export declare function withSentryOptionsFromFile(config: MetroConfig, optionsFile: string | boolean): MetroConfig;
6
+ //# sourceMappingURL=sentryOptionsSerializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentryOptionsSerializer.d.ts","sourceRoot":"","sources":["../../../src/js/tools/sentryOptionsSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAA4C,MAAM,OAAO,CAAC;AASnF;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,WAAW,CAkDzG"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSentryOptionsFromFile = void 0;
4
+ const core_1 = require("@sentry/core");
5
+ const fs = require("fs");
6
+ const path = require("path");
7
+ const utils_1 = require("./utils");
8
+ // eslint-disable-next-line import/no-extraneous-dependencies
9
+ const countLines_1 = require("./vendor/metro/countLines");
10
+ const DEFAULT_OPTIONS_FILE_NAME = 'sentry.options.json';
11
+ /**
12
+ * Loads Sentry options from a file in
13
+ */
14
+ function withSentryOptionsFromFile(config, optionsFile) {
15
+ var _a;
16
+ if (optionsFile === false) {
17
+ return config;
18
+ }
19
+ const { projectRoot } = config;
20
+ if (!projectRoot) {
21
+ // eslint-disable-next-line no-console
22
+ console.error('[@sentry/react-native/metro] Project root is required to load Sentry options from a file');
23
+ return config;
24
+ }
25
+ let optionsPath = path.join(projectRoot, DEFAULT_OPTIONS_FILE_NAME);
26
+ if (typeof optionsFile === 'string' && path.isAbsolute(optionsFile)) {
27
+ optionsPath = optionsFile;
28
+ }
29
+ else if (typeof optionsFile === 'string') {
30
+ optionsPath = path.join(projectRoot, optionsFile);
31
+ }
32
+ const originalSerializer = (_a = config.serializer) === null || _a === void 0 ? void 0 : _a.customSerializer;
33
+ if (!originalSerializer) {
34
+ // It's okay to bail here because we don't expose this for direct usage, but as part of `withSentryConfig`
35
+ // If used directly in RN, the user is responsible for providing a custom serializer first, Expo provides serializer in default config
36
+ // eslint-disable-next-line no-console
37
+ console.error('[@sentry/react-native/metro] `config.serializer.customSerializer` is required to load Sentry options from a file');
38
+ return config;
39
+ }
40
+ const sentryOptionsSerializer = (entryPoint, preModules, graph, options) => {
41
+ const sentryOptionsModule = createSentryOptionsModule(optionsPath);
42
+ if (sentryOptionsModule) {
43
+ preModules.push(sentryOptionsModule);
44
+ }
45
+ return originalSerializer(entryPoint, preModules, graph, options);
46
+ };
47
+ return Object.assign(Object.assign({}, config), { serializer: Object.assign(Object.assign({}, config.serializer), { customSerializer: sentryOptionsSerializer }) });
48
+ }
49
+ exports.withSentryOptionsFromFile = withSentryOptionsFromFile;
50
+ function createSentryOptionsModule(filePath) {
51
+ let content;
52
+ try {
53
+ content = fs.readFileSync(filePath, 'utf8');
54
+ }
55
+ catch (error) {
56
+ if (error.code === 'ENOENT') {
57
+ core_1.logger.debug(`[@sentry/react-native/metro] Sentry options file does not exist at ${filePath}`);
58
+ }
59
+ else {
60
+ core_1.logger.error(`[@sentry/react-native/metro] Failed to read Sentry options file at ${filePath}`);
61
+ }
62
+ return null;
63
+ }
64
+ let parsedContent;
65
+ try {
66
+ parsedContent = JSON.parse(content);
67
+ }
68
+ catch (error) {
69
+ core_1.logger.error(`[@sentry/react-native/metro] Failed to parse Sentry options file at ${filePath}`);
70
+ return null;
71
+ }
72
+ const minifiedContent = JSON.stringify(parsedContent);
73
+ const optionsCode = `var __SENTRY_OPTIONS__=${minifiedContent};`;
74
+ core_1.logger.debug(`[@sentry/react-native/metro] Sentry options added to the bundle from file at ${filePath}`);
75
+ return {
76
+ dependencies: new Map(),
77
+ getSource: () => Buffer.from(optionsCode),
78
+ inverseDependencies: (0, utils_1.createSet)(),
79
+ path: '__sentry-options__',
80
+ output: [
81
+ {
82
+ type: 'js/script/virtual',
83
+ data: {
84
+ code: optionsCode,
85
+ lineCount: (0, countLines_1.default)(optionsCode),
86
+ map: [],
87
+ },
88
+ },
89
+ ],
90
+ };
91
+ }
92
+ //# sourceMappingURL=sentryOptionsSerializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sentryOptionsSerializer.js","sourceRoot":"","sources":["../../../src/js/tools/sentryOptionsSerializer.ts"],"names":[],"mappings":";;;AAAA,uCAAsC;AACtC,yBAAyB;AAEzB,6BAA6B;AAE7B,mCAAoC;AACpC,6DAA6D;AAC7D,0DAAmD;AAEnD,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AAExD;;GAEG;AACH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,CAAC","sourcesContent":["import { logger } from '@sentry/core';\nimport * as fs from 'fs';\nimport type { MetroConfig, Module, ReadOnlyGraph, SerializerOptions } from 'metro';\nimport * as path from 'path';\nimport type { MetroCustomSerializer, VirtualJSOutput } from './utils';\nimport { createSet } from './utils';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport countLines from './vendor/metro/countLines';\n\nconst DEFAULT_OPTIONS_FILE_NAME = 'sentry.options.json';\n\n/**\n * Loads Sentry options from a file in\n */\nexport function withSentryOptionsFromFile(config: MetroConfig, optionsFile: string | boolean): MetroConfig {\n if (optionsFile === false) {\n return config;\n }\n\n const { projectRoot } = config;\n if (!projectRoot) {\n // eslint-disable-next-line no-console\n console.error('[@sentry/react-native/metro] Project root is required to load Sentry options from a file');\n return config;\n }\n\n let optionsPath = path.join(projectRoot, DEFAULT_OPTIONS_FILE_NAME);\n if (typeof optionsFile === 'string' && path.isAbsolute(optionsFile)) {\n optionsPath = optionsFile;\n } else if (typeof optionsFile === 'string') {\n optionsPath = path.join(projectRoot, optionsFile);\n }\n\n const originalSerializer = config.serializer?.customSerializer;\n if (!originalSerializer) {\n // It's okay to bail here because we don't expose this for direct usage, but as part of `withSentryConfig`\n // If used directly in RN, the user is responsible for providing a custom serializer first, Expo provides serializer in default config\n // eslint-disable-next-line no-console\n console.error(\n '[@sentry/react-native/metro] `config.serializer.customSerializer` is required to load Sentry options from a file',\n );\n return config;\n }\n\n const sentryOptionsSerializer: MetroCustomSerializer = (\n entryPoint: string,\n preModules: readonly Module[],\n graph: ReadOnlyGraph,\n options: SerializerOptions,\n ) => {\n const sentryOptionsModule = createSentryOptionsModule(optionsPath);\n if (sentryOptionsModule) {\n (preModules as Module[]).push(sentryOptionsModule);\n }\n return originalSerializer(entryPoint, preModules, graph, options);\n };\n\n return {\n ...config,\n serializer: {\n ...config.serializer,\n customSerializer: sentryOptionsSerializer,\n },\n };\n}\n\nfunction createSentryOptionsModule(filePath: string): Module<VirtualJSOutput> | null {\n let content: string;\n try {\n content = fs.readFileSync(filePath, 'utf8');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n logger.debug(`[@sentry/react-native/metro] Sentry options file does not exist at ${filePath}`);\n } else {\n logger.error(`[@sentry/react-native/metro] Failed to read Sentry options file at ${filePath}`);\n }\n return null;\n }\n\n let parsedContent: Record<string, unknown>;\n try {\n parsedContent = JSON.parse(content);\n } catch (error) {\n logger.error(`[@sentry/react-native/metro] Failed to parse Sentry options file at ${filePath}`);\n return null;\n }\n\n const minifiedContent = JSON.stringify(parsedContent);\n const optionsCode = `var __SENTRY_OPTIONS__=${minifiedContent};`;\n\n logger.debug(`[@sentry/react-native/metro] Sentry options added to the bundle from file at ${filePath}`);\n return {\n dependencies: new Map(),\n getSource: () => Buffer.from(optionsCode),\n inverseDependencies: createSet(),\n path: '__sentry-options__',\n output: [\n {\n type: 'js/script/virtual',\n data: {\n code: optionsCode,\n lineCount: countLines(optionsCode),\n map: [],\n },\n },\n ],\n };\n}\n"]}
@@ -1,5 +1,6 @@
1
- import type { MixedOutput, Module, ReadOnlyGraph, SerializerOptions } from 'metro';
1
+ import type { MetroConfig, MixedOutput, Module, ReadOnlyGraph, SerializerOptions } from 'metro';
2
2
  import type CountingSet from 'metro/src/lib/CountingSet';
3
+ export type MetroCustomSerializer = Required<Required<MetroConfig>['serializer']>['customSerializer'] | undefined;
3
4
  export type VirtualJSOutput = {
4
5
  type: 'js/script/virtual';
5
6
  data: {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/tools/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACnF,OAAO,KAAK,WAAW,MAAM,2BAA2B,CAAC;AAKzD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,IAAI,EAAE;QACJ,IAAI,EAAE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AO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aAClF,CAAC;SACH;KACF;IAAC,WAAM;QACN,yCAAyC;KAC1C;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AArBD,sCAqBC","sourcesContent":["import * as crypto from 'crypto';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MixedOutput, Module, ReadOnlyGraph, SerializerOptions } from 'metro';\nimport type CountingSet from 'metro/src/lib/CountingSet'; // types are in src but exports are in private\nimport countLines from './vendor/metro/countLines';\n\n// Variant of MixedOutput\n// https://github.com/facebook/metro/blob/9b85f83c9cc837d8cd897aa7723be7da5b296067/packages/metro/src/DeltaBundler/types.flow.js#L21\nexport type VirtualJSOutput = {\n type: 'js/script/virtual';\n data: {\n code: string;\n lineCount: number;\n map: [];\n };\n};\n\nexport type Bundle = {\n modules: Array<[id: number, code: string]>;\n post: string;\n pre: string;\n};\n\nexport type SentryMetroSerializerOptionsExtras = {\n sentryBundleCallback?: (bundle: Bundle) => Bundle;\n};\n\nexport type SerializedBundle = { code: string; map: string };\n\nexport type MetroSerializerOutput = string | SerializedBundle | Promise<string | SerializedBundle>;\n\nexport type MetroSerializer = (\n entryPoint: string,\n preModules: ReadonlyArray<Module>,\n graph: ReadOnlyGraph,\n options: SerializerOptions & SentryMetroSerializerOptionsExtras,\n) => MetroSerializerOutput;\n\n/**\n * Returns minified Debug ID code snippet.\n */\nexport function createDebugIdSnippet(debugId: string): string {\n return `var _sentryDebugIds,_sentryDebugIdIdentifier;void 0===_sentryDebugIds&&(_sentryDebugIds={});try{var stack=(new Error).stack;stack&&(_sentryDebugIds[stack]=\"${debugId}\",_sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\")}catch(e){}`;\n}\n\n/**\n * Deterministically hashes a string and turns the hash into a uuid.\n *\n * https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/58271f1af2ade6b3e64d393d70376ae53bc5bd2f/packages/bundler-plugin-core/src/utils.ts#L174\n */\nexport function stringToUUID(str: string): string {\n const md5sum = crypto.createHash('md5');\n md5sum.update(str);\n const md5Hash = md5sum.digest('hex');\n\n // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)\n // RFC 4122 section 4.4\n const v4variant = ['8', '9', 'a', 'b'][md5Hash.substring(16, 17).charCodeAt(0) % 4] as string;\n\n return `${md5Hash.substring(0, 8)}-${md5Hash.substring(8, 12)}-4${md5Hash.substring(\n 13,\n 16,\n )}-${v4variant}${md5Hash.substring(17, 20)}-${md5Hash.substring(20)}`.toLowerCase();\n}\n\n/**\n * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle\n * source and extracts the bundle's debug ID from it.\n *\n * The string pattern is injected via the debug ID injection snipped.\n *\n * https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/40f918458ed449d8b3eabaf64d13c08218213f65/packages/bundler-plugin-core/src/debug-id-upload.ts#L293-L294\n */\nexport function determineDebugIdFromBundleSource(code: string): string | undefined {\n const match = code.match(\n /sentry-dbid-([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})/,\n );\n return match ? match[1] : undefined;\n}\n\n/**\n * CountingSet was added in Metro 0.72.0 before that NodeJS Set was used.\n *\n * https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/CountingSet.js\n */\nfunction resolveSetCreator(): () => CountingSet<string> {\n const CountingSetFromPrivate = safeRequireCountingSetFromPrivate();\n if (CountingSetFromPrivate) {\n return () => new CountingSetFromPrivate.default();\n }\n\n const CountingSetFromSrc = safeRequireCountingSetFromSrc();\n if (CountingSetFromSrc) {\n return () => new CountingSetFromSrc.default();\n }\n\n return () => new Set() as unknown as CountingSet<string>;\n}\n\n/**\n * CountingSet was added in Metro 0.72.0 before that NodeJS Set was used.\n *\n * https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/CountingSet.js\n */\nfunction safeRequireCountingSetFromSrc(): { default: new <T>() => CountingSet<T> } | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies\n return require('metro/src/lib/CountingSet');\n } catch (e) {\n return undefined;\n }\n}\n\n/**\n * CountingSet was moved to private in Metro 0.83.0. (all src exports were moved to private)\n *\n * https://github.com/facebook/metro/commit/ae6f42372ed361611b5672705f22081c2022cf28\n */\nfunction safeRequireCountingSetFromPrivate(): { default: new <T>() => CountingSet<T> } | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies\n return require('metro/private/lib/CountingSet');\n } catch (e) {\n return undefined;\n }\n}\n\nexport const createSet = resolveSetCreator();\n\nconst PRELUDE_MODULE_PATH = '__prelude__';\n\n/**\n * Prepends the module after default required prelude modules.\n */\nexport function prependModule(\n modules: readonly Module<MixedOutput>[],\n module: Module<VirtualJSOutput>,\n): Module<MixedOutput>[] {\n const modifiedPreModules = [...modules];\n if (\n modifiedPreModules.length > 0 &&\n modifiedPreModules[0] !== undefined &&\n modifiedPreModules[0].path === PRELUDE_MODULE_PATH\n ) {\n // prelude module must be first as it measures the bundle startup time\n modifiedPreModules.unshift(modules[0] as Module<VirtualJSOutput>);\n modifiedPreModules[1] = module;\n } else {\n modifiedPreModules.unshift(module);\n }\n return modifiedPreModules;\n}\n\n/**\n * Creates a virtual JS module with the given path and code.\n */\nexport function createVirtualJSModule(\n modulePath: string,\n moduleCode: string,\n): Module<VirtualJSOutput> & { setSource: (code: string) => void } {\n let sourceCode = moduleCode;\n\n return {\n setSource: (code: string) => {\n sourceCode = code;\n },\n dependencies: new Map(),\n getSource: () => Buffer.from(sourceCode),\n inverseDependencies: createSet(),\n path: modulePath,\n output: [\n {\n type: 'js/script/virtual',\n data: {\n code: sourceCode,\n lineCount: countLines(sourceCode),\n map: [],\n },\n },\n ],\n };\n}\n\n/**\n * Tries to load Expo config using `@expo/config` package.\n */\nexport function getExpoConfig(projectRoot: string): Partial<{\n name: string;\n version: string;\n}> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies\n const expoConfig = require('@expo/config') as {\n getConfig?: (projectRoot: string) => { exp: Record<string, unknown> };\n };\n if (expoConfig.getConfig) {\n const { exp } = expoConfig.getConfig(projectRoot);\n return {\n name: typeof exp.name === 'string' && exp.name ? exp.name : undefined,\n version: typeof exp.version === 'string' && exp.version ? exp.version : undefined,\n };\n }\n } catch {\n // @expo/config not available, do nothing\n }\n\n return {};\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/js/tools/utils.ts"],"names":[],"mappings":";;;AAAA,iCAAiC;AAIjC,0DAAmD;AAoCnD;;GAEG;AACH,SAAgB,oBAAoB,CAAC,OAAe;IAClD,OAAO,+JAA+J,OAAO,2CAA2C,OAAO,eAAe,CAAC;AACjP,CAAC;AAFD,oDAEC;AAED;;;;GAIG;AACH,SAAgB,YAAY,CAAC,GAAW;IACtC,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAErC,oFAAoF;IACpF,uBAAuB;IACvB,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAW,CAAC;IAE9F,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC,SAAS,CACjF,EAAE,EACF,EAAE,CACH,IAAI,SAAS,GAAG,OAAO,C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SAAS,EAAE;YACxB,MAAM,EAAE,GAAG,EAAE,GAAG,UAAU,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;YAClD,OAAO;gBACL,IAAI,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;gBACrE,OAAO,EAAE,OAAO,GAAG,CAAC,OAAO,KAAK,QAAQ,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aAClF,CAAC;SACH;KACF;IAAC,WAAM;QACN,yCAAyC;KAC1C;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AArBD,sCAqBC","sourcesContent":["import * as crypto from 'crypto';\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport type { MetroConfig, MixedOutput, Module, ReadOnlyGraph, SerializerOptions } from 'metro';\nimport type CountingSet from 'metro/src/lib/CountingSet'; // types are in src but exports are in private\nimport countLines from './vendor/metro/countLines';\n\nexport type MetroCustomSerializer = Required<Required<MetroConfig>['serializer']>['customSerializer'] | undefined;\n\n// Variant of MixedOutput\n// https://github.com/facebook/metro/blob/9b85f83c9cc837d8cd897aa7723be7da5b296067/packages/metro/src/DeltaBundler/types.flow.js#L21\nexport type VirtualJSOutput = {\n type: 'js/script/virtual';\n data: {\n code: string;\n lineCount: number;\n map: [];\n };\n};\n\nexport type Bundle = {\n modules: Array<[id: number, code: string]>;\n post: string;\n pre: string;\n};\n\nexport type SentryMetroSerializerOptionsExtras = {\n sentryBundleCallback?: (bundle: Bundle) => Bundle;\n};\n\nexport type SerializedBundle = { code: string; map: string };\n\nexport type MetroSerializerOutput = string | SerializedBundle | Promise<string | SerializedBundle>;\n\nexport type MetroSerializer = (\n entryPoint: string,\n preModules: ReadonlyArray<Module>,\n graph: ReadOnlyGraph,\n options: SerializerOptions & SentryMetroSerializerOptionsExtras,\n) => MetroSerializerOutput;\n\n/**\n * Returns minified Debug ID code snippet.\n */\nexport function createDebugIdSnippet(debugId: string): string {\n return `var _sentryDebugIds,_sentryDebugIdIdentifier;void 0===_sentryDebugIds&&(_sentryDebugIds={});try{var stack=(new Error).stack;stack&&(_sentryDebugIds[stack]=\"${debugId}\",_sentryDebugIdIdentifier=\"sentry-dbid-${debugId}\")}catch(e){}`;\n}\n\n/**\n * Deterministically hashes a string and turns the hash into a uuid.\n *\n * https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/58271f1af2ade6b3e64d393d70376ae53bc5bd2f/packages/bundler-plugin-core/src/utils.ts#L174\n */\nexport function stringToUUID(str: string): string {\n const md5sum = crypto.createHash('md5');\n md5sum.update(str);\n const md5Hash = md5sum.digest('hex');\n\n // Position 16 is fixed to either 8, 9, a, or b in the uuid v4 spec (10xx in binary)\n // RFC 4122 section 4.4\n const v4variant = ['8', '9', 'a', 'b'][md5Hash.substring(16, 17).charCodeAt(0) % 4] as string;\n\n return `${md5Hash.substring(0, 8)}-${md5Hash.substring(8, 12)}-4${md5Hash.substring(\n 13,\n 16,\n )}-${v4variant}${md5Hash.substring(17, 20)}-${md5Hash.substring(20)}`.toLowerCase();\n}\n\n/**\n * Looks for a particular string pattern (`sdbid-[debug ID]`) in the bundle\n * source and extracts the bundle's debug ID from it.\n *\n * The string pattern is injected via the debug ID injection snipped.\n *\n * https://github.com/getsentry/sentry-javascript-bundler-plugins/blob/40f918458ed449d8b3eabaf64d13c08218213f65/packages/bundler-plugin-core/src/debug-id-upload.ts#L293-L294\n */\nexport function determineDebugIdFromBundleSource(code: string): string | undefined {\n const match = code.match(\n /sentry-dbid-([0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})/,\n );\n return match ? match[1] : undefined;\n}\n\n/**\n * CountingSet was added in Metro 0.72.0 before that NodeJS Set was used.\n *\n * https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/CountingSet.js\n */\nfunction resolveSetCreator(): () => CountingSet<string> {\n const CountingSetFromPrivate = safeRequireCountingSetFromPrivate();\n if (CountingSetFromPrivate) {\n return () => new CountingSetFromPrivate.default();\n }\n\n const CountingSetFromSrc = safeRequireCountingSetFromSrc();\n if (CountingSetFromSrc) {\n return () => new CountingSetFromSrc.default();\n }\n\n return () => new Set() as unknown as CountingSet<string>;\n}\n\n/**\n * CountingSet was added in Metro 0.72.0 before that NodeJS Set was used.\n *\n * https://github.com/facebook/metro/blob/fc29a1177f883144674cf85a813b58567f69d545/packages/metro/src/lib/CountingSet.js\n */\nfunction safeRequireCountingSetFromSrc(): { default: new <T>() => CountingSet<T> } | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies\n return require('metro/src/lib/CountingSet');\n } catch (e) {\n return undefined;\n }\n}\n\n/**\n * CountingSet was moved to private in Metro 0.83.0. (all src exports were moved to private)\n *\n * https://github.com/facebook/metro/commit/ae6f42372ed361611b5672705f22081c2022cf28\n */\nfunction safeRequireCountingSetFromPrivate(): { default: new <T>() => CountingSet<T> } | undefined {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies\n return require('metro/private/lib/CountingSet');\n } catch (e) {\n return undefined;\n }\n}\n\nexport const createSet = resolveSetCreator();\n\nconst PRELUDE_MODULE_PATH = '__prelude__';\n\n/**\n * Prepends the module after default required prelude modules.\n */\nexport function prependModule(\n modules: readonly Module<MixedOutput>[],\n module: Module<VirtualJSOutput>,\n): Module<MixedOutput>[] {\n const modifiedPreModules = [...modules];\n if (\n modifiedPreModules.length > 0 &&\n modifiedPreModules[0] !== undefined &&\n modifiedPreModules[0].path === PRELUDE_MODULE_PATH\n ) {\n // prelude module must be first as it measures the bundle startup time\n modifiedPreModules.unshift(modules[0] as Module<VirtualJSOutput>);\n modifiedPreModules[1] = module;\n } else {\n modifiedPreModules.unshift(module);\n }\n return modifiedPreModules;\n}\n\n/**\n * Creates a virtual JS module with the given path and code.\n */\nexport function createVirtualJSModule(\n modulePath: string,\n moduleCode: string,\n): Module<VirtualJSOutput> & { setSource: (code: string) => void } {\n let sourceCode = moduleCode;\n\n return {\n setSource: (code: string) => {\n sourceCode = code;\n },\n dependencies: new Map(),\n getSource: () => Buffer.from(sourceCode),\n inverseDependencies: createSet(),\n path: modulePath,\n output: [\n {\n type: 'js/script/virtual',\n data: {\n code: sourceCode,\n lineCount: countLines(sourceCode),\n map: [],\n },\n },\n ],\n };\n}\n\n/**\n * Tries to load Expo config using `@expo/config` package.\n */\nexport function getExpoConfig(projectRoot: string): Partial<{\n name: string;\n version: string;\n}> {\n try {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, import/no-extraneous-dependencies\n const expoConfig = require('@expo/config') as {\n getConfig?: (projectRoot: string) => { exp: Record<string, unknown> };\n };\n if (expoConfig.getConfig) {\n const { exp } = expoConfig.getConfig(projectRoot);\n return {\n name: typeof exp.name === 'string' && exp.name ? exp.name : undefined,\n version: typeof exp.version === 'string' && exp.version ? exp.version : undefined,\n };\n }\n } catch {\n // @expo/config not available, do nothing\n }\n\n return {};\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react-native" />
2
2
  import type { InternalGlobal } from '@sentry/core';
3
3
  import type { ErrorUtils } from 'react-native/types';
4
+ import type { ReactNativeOptions } from '../options';
4
5
  import type { ExpoGlobalObject } from './expoglobalobject';
5
6
  export interface HermesPromiseRejectionTrackingOptions {
6
7
  allRejections: boolean;
@@ -32,6 +33,7 @@ export interface ReactNativeInternalGlobal extends InternalGlobal {
32
33
  nativePerformanceNow?: () => number;
33
34
  TextEncoder?: TextEncoder;
34
35
  alert?: (message: string) => void;
36
+ __SENTRY_OPTIONS__?: ReactNativeOptions;
35
37
  SENTRY_RELEASE?: {
36
38
  /** Used by Sentry Webpack Plugin, not used by RN, only to silence TS */
37
39
  id?: string;