@sentry/react-native 5.18.0 → 5.19.1

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 (80) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +115 -24
  5. package/dist/js/NativeRNSentry.d.ts +1 -0
  6. package/dist/js/NativeRNSentry.d.ts.map +1 -1
  7. package/dist/js/NativeRNSentry.js.map +1 -1
  8. package/dist/js/client.d.ts.map +1 -1
  9. package/dist/js/client.js +14 -19
  10. package/dist/js/client.js.map +1 -1
  11. package/dist/js/index.d.ts +1 -1
  12. package/dist/js/index.d.ts.map +1 -1
  13. package/dist/js/index.js +5 -1
  14. package/dist/js/index.js.map +1 -1
  15. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  16. package/dist/js/integrations/debugsymbolicator.js +1 -0
  17. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  18. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  19. package/dist/js/integrations/reactnativeerrorhandlers.js +2 -0
  20. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  21. package/dist/js/integrations/rewriteframes.d.ts +2 -2
  22. package/dist/js/integrations/rewriteframes.d.ts.map +1 -1
  23. package/dist/js/integrations/rewriteframes.js.map +1 -1
  24. package/dist/js/profiling/cache.d.ts +3 -3
  25. package/dist/js/profiling/cache.d.ts.map +1 -1
  26. package/dist/js/profiling/cache.js.map +1 -1
  27. package/dist/js/profiling/integration.d.ts +7 -3
  28. package/dist/js/profiling/integration.d.ts.map +1 -1
  29. package/dist/js/profiling/integration.js +16 -5
  30. package/dist/js/profiling/integration.js.map +1 -1
  31. package/dist/js/profiling/nativeTypes.d.ts +8 -0
  32. package/dist/js/profiling/nativeTypes.d.ts.map +1 -1
  33. package/dist/js/profiling/nativeTypes.js.map +1 -1
  34. package/dist/js/profiling/types.d.ts +59 -2
  35. package/dist/js/profiling/types.d.ts.map +1 -1
  36. package/dist/js/profiling/types.js.map +1 -1
  37. package/dist/js/profiling/utils.d.ts +9 -5
  38. package/dist/js/profiling/utils.d.ts.map +1 -1
  39. package/dist/js/profiling/utils.js +16 -1
  40. package/dist/js/profiling/utils.js.map +1 -1
  41. package/dist/js/sdk.d.ts +1 -1
  42. package/dist/js/sdk.d.ts.map +1 -1
  43. package/dist/js/sdk.js +3 -2
  44. package/dist/js/sdk.js.map +1 -1
  45. package/dist/js/tools/sentryMetroSerializer.js +1 -0
  46. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  47. package/dist/js/tracing/addTracingExtensions.d.ts.map +1 -1
  48. package/dist/js/tracing/addTracingExtensions.js.map +1 -1
  49. package/dist/js/tracing/nativeframes.d.ts.map +1 -1
  50. package/dist/js/tracing/nativeframes.js +3 -1
  51. package/dist/js/tracing/nativeframes.js.map +1 -1
  52. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  53. package/dist/js/tracing/reactnativetracing.js +3 -1
  54. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  55. package/dist/js/version.d.ts +1 -1
  56. package/dist/js/version.js +1 -1
  57. package/dist/js/version.js.map +1 -1
  58. package/dist/js/wrapper.d.ts +2 -1
  59. package/dist/js/wrapper.d.ts.map +1 -1
  60. package/dist/js/wrapper.js +5 -1
  61. package/dist/js/wrapper.js.map +1 -1
  62. package/package.json +11 -11
  63. package/plugin/build/utils.d.ts +12 -0
  64. package/plugin/build/utils.js +31 -2
  65. package/plugin/build/withSentry.js +15 -10
  66. package/plugin/build/withSentryAndroid.js +1 -1
  67. package/plugin/build/withSentryIOS.js +13 -4
  68. package/scripts/sentry-xcode-debug-files.sh +5 -2
  69. package/src/js/NativeRNSentry.ts +6 -1
  70. package/ts3.8/dist/js/NativeRNSentry.d.ts +1 -0
  71. package/ts3.8/dist/js/index.d.ts +1 -1
  72. package/ts3.8/dist/js/integrations/rewriteframes.d.ts +2 -2
  73. package/ts3.8/dist/js/profiling/cache.d.ts +3 -3
  74. package/ts3.8/dist/js/profiling/integration.d.ts +7 -3
  75. package/ts3.8/dist/js/profiling/nativeTypes.d.ts +8 -0
  76. package/ts3.8/dist/js/profiling/types.d.ts +59 -2
  77. package/ts3.8/dist/js/profiling/utils.d.ts +9 -5
  78. package/ts3.8/dist/js/sdk.d.ts +1 -1
  79. package/ts3.8/dist/js/version.d.ts +1 -1
  80. package/ts3.8/dist/js/wrapper.d.ts +2 -1
@@ -1 +1 @@
1
- {"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGrE,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAY/G,6DAA6D;AAC7D,MAAM,OAAO,iBAAiB;IAA9B;QAKE;;WAEG;QACI,SAAI,GAAW,iBAAiB,CAAC,EAAE,CAAC;IA0O7C,CAAC;IAxOC;;OAEG;IACI,SAAS,CAAC,uBAA2D,EAAE,aAAwB;QACpG,uBAAuB,CAAC,CAAO,KAAY,EAAE,IAAe,EAAE,EAAE;YAC9D,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAE/D,IAAI,CAAC,IAAI,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;YAED,IAAI,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,E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,KAAK,GAAG,EAAE;4BACtB,OAAO,CAAC,IAAI,CAAC,CAAC;yBACf;wBACD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;qBAC3B;gBACH,CAAC,CAAC;gBACF,GAAG,CAAC,OAAO,GAAG,GAAS,EAAE;oBACvB,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;OAEG;IACK,gBAAgB,CAAC,UAAkB;QACzC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACK,sBAAsB,CAC5B,KAAoC,EACpC,SAAmC;QAEnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACK,aAAa;;QACnB,IAAI;YACF,OAAO,MAAA,oBAAoB,CAAC,QAAQ,0CAAE,YAAY,EAAE,CAAC;SACtD;QAAC,OAAO,GAAG,EAAE;YACZ,8BAA8B;SAC/B;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;;AAhPD;;GAEG;AACW,oBAAE,GAAW,mBAAmB,CAAC","sourcesContent":["import type { Event, EventHint, EventProcessor, Hub, Integration, StackFrame as SentryStackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\n\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor(async (event: Event, hint: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self) {\n return event;\n }\n\n if (event.exception && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const symbolicatedFrames = await this._symbolicate(\n hint.originalException.stack,\n getFramesToPop(hint.originalException as Error),\n );\n symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await this._symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n // syntheticException is used for Sentry.captureMessage() threads\n symbolicatedFrames && this._replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = this._parseErrorStack(rawStack);\n\n const prettyStack = await this._symbolicateStackTrace(parsedStack);\n if (!prettyStack) {\n logger.error('React Native DevServer could not symbolicate the stack trace.');\n return null;\n }\n\n // This has been changed in an react-native version so stack is contained in here\n const newStack = prettyStack.stack || prettyStack;\n\n // https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23\n // Match SentryParser which counts lines of stack (-1 for first line with the Error message)\n const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);\n const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser\n ? newStack.slice(skipFirstAdjustedToSentryStackParser)\n : newStack;\n\n const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(\n (frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n return await this._convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n return null;\n }\n }\n\n /**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\n private async _convertReactNativeFramesToSentryFrames(frames: ReactNative.StackFrame[]): Promise<SentryStackFrame[]> {\n return Promise.all(\n frames.map(async (frame: ReactNative.StackFrame): Promise<SentryStackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: SentryStackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n if (inApp) {\n await this._addSourceContext(newFrame);\n }\n\n return newFrame;\n }),\n );\n }\n\n /**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceExceptionFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * Replaces the frames in the thread of a message.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {\n event.threads.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\n private async _addSourceContext(frame: SentryStackFrame): Promise<void> {\n let sourceContext: string | null = null;\n\n const segments = frame.filename?.split('/') ?? [];\n\n const serverUrl = this._getDevServer()?.url;\n if (!serverUrl) {\n return;\n }\n\n for (const idx in segments) {\n if (!Object.prototype.hasOwnProperty.call(segments, idx)) {\n continue;\n }\n\n sourceContext = await this._fetchSourceContext(serverUrl, segments, -idx);\n if (sourceContext) {\n break;\n }\n }\n\n if (!sourceContext) {\n return;\n }\n\n const lines = sourceContext.split('\\n');\n addContextToFrame(lines, frame);\n }\n\n /**\n * Get source context for segment\n */\n private async _fetchSourceContext(url: string, segments: Array<string>, start: number): Promise<string | null> {\n return new Promise(resolve => {\n const fullUrl = `${url}${segments.slice(start).join('/')}`;\n\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(null);\n return;\n }\n\n xhr.open('GET', fullUrl, true);\n xhr.send();\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(null);\n }\n resolve(xhr.responseText);\n }\n };\n xhr.onerror = (): void => {\n resolve(null);\n };\n });\n }\n\n /**\n * Loads and calls RN Core Devtools parseErrorStack function.\n */\n private _parseErrorStack(errorStack: string): Array<ReactNative.StackFrame> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.parseErrorStack(errorStack);\n }\n\n /**\n * Loads and calls RN Core Devtools symbolicateStackTrace function.\n */\n private _symbolicateStackTrace(\n stack: Array<ReactNative.StackFrame>,\n extraData?: Record<string, unknown>,\n ): Promise<ReactNative.SymbolicatedStackTrace> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.symbolicateStackTrace(stack, extraData);\n }\n\n /**\n * Loads and returns the RN DevServer URL.\n */\n private _getDevServer(): ReactNative.DevServerInfo | undefined {\n try {\n return ReactNativeLibraries.Devtools?.getDevServer();\n } catch (_oO) {\n // We can't load devserver URL\n }\n return undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"debugsymbolicator.js","sourceRoot":"","sources":["../../../src/js/integrations/debugsymbolicator.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGrE,sEAAsE;AACtE,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,CAAC,+BAA+B,EAAE,oBAAoB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAY/G,6DAA6D;AAC7D,MAAM,OAAO,iBAAiB;IAA9B;QAKE;;WAEG;QACI,SAAI,GAAW,iBAAiB,CAAC,EAAE,CAAC;IA0O7C,CAAC;IAxOC;;OAEG;IACI,SAAS,CAAC,uBAA2D,EAAE,aAAwB;QACpG,uBAAuB,CAAC,CAAO,KAAY,EAAE,IAAe,EAAE,EAAE;YAC9D,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;YAE/D,IAAI,CAAC,IAAI,EAAE;gBACT,OAAO,KAAK,CAAC;aACd;YAED,IAAI,KAAK,CAAC,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE;gBAC1D,wCA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E;4BACtB,OAAO,CAAC,IAAI,CAAC,CAAC;yBACf;wBACD,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;qBAC3B;gBACH,CAAC,CAAC;gBACF,GAAG,CAAC,OAAO,GAAG,GAAS,EAAE;oBACvB,OAAO,CAAC,IAAI,CAAC,CAAC;gBAChB,CAAC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC;KAAA;IAED;;OAEG;IACK,gBAAgB,CAAC,UAAkB;QACzC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IACnE,CAAC;IAED;;OAEG;IACK,sBAAsB,CAC5B,KAAoC,EACpC,SAAmC;QAEnC,IAAI,CAAC,oBAAoB,CAAC,QAAQ,EAAE;YAClC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACzD;QACD,OAAO,oBAAoB,CAAC,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC/E,CAAC;IAED;;OAEG;IACK,aAAa;;QACnB,IAAI;YACF,OAAO,MAAA,oBAAoB,CAAC,QAAQ,0CAAE,YAAY,EAAE,CAAC;SACtD;QAAC,OAAO,GAAG,EAAE;YACZ,8BAA8B;SAC/B;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;;AAhPD;;GAEG;AACW,oBAAE,GAAW,mBAAmB,CAAC","sourcesContent":["import type { Event, EventHint, EventProcessor, Hub, Integration, StackFrame as SentryStackFrame } from '@sentry/types';\nimport { addContextToFrame, logger } from '@sentry/utils';\n\nimport { getFramesToPop, isErrorLike } from '../utils/error';\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\nimport type * as ReactNative from '../vendor/react-native';\n\n// eslint-disable-next-line @sentry-internal/sdk/no-regexp-constructor\nconst INTERNAL_CALLSITES_REGEX = new RegExp(['ReactNativeRenderer-dev\\\\.js$', 'MessageQueue\\\\.js$'].join('|'));\n\n/**\n * React Native Error\n */\nexport type ReactNativeError = Error & {\n framesToPop?: number;\n jsEngine?: string;\n preventSymbolication?: boolean;\n componentStack?: string;\n};\n\n/** Tries to symbolicate the JS stack trace on the device. */\nexport class DebugSymbolicator implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'DebugSymbolicator';\n /**\n * @inheritDoc\n */\n public name: string = DebugSymbolicator.id;\n\n /**\n * @inheritDoc\n */\n public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, getCurrentHub: () => Hub): void {\n addGlobalEventProcessor(async (event: Event, hint: EventHint) => {\n const self = getCurrentHub().getIntegration(DebugSymbolicator);\n\n if (!self) {\n return event;\n }\n\n if (event.exception && isErrorLike(hint.originalException)) {\n // originalException is ErrorLike object\n const symbolicatedFrames = await this._symbolicate(\n hint.originalException.stack,\n getFramesToPop(hint.originalException as Error),\n );\n symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);\n } else if (hint.syntheticException && isErrorLike(hint.syntheticException)) {\n // syntheticException is Error object\n const symbolicatedFrames = await this._symbolicate(\n hint.syntheticException.stack,\n getFramesToPop(hint.syntheticException),\n );\n\n if (event.exception) {\n symbolicatedFrames && this._replaceExceptionFramesInEvent(event, symbolicatedFrames);\n } else if (event.threads) {\n // RN JS doesn't have threads\n // syntheticException is used for Sentry.captureMessage() threads\n symbolicatedFrames && this._replaceThreadFramesInEvent(event, symbolicatedFrames);\n }\n }\n\n return event;\n });\n }\n\n /**\n * Symbolicates the stack on the device talking to local dev server.\n * Mutates the passed event.\n */\n private async _symbolicate(rawStack: string, skipFirstFrames: number = 0): Promise<SentryStackFrame[] | null> {\n try {\n const parsedStack = this._parseErrorStack(rawStack);\n\n const prettyStack = await this._symbolicateStackTrace(parsedStack);\n if (!prettyStack) {\n logger.error('React Native DevServer could not symbolicate the stack trace.');\n return null;\n }\n\n // This has been changed in an react-native version so stack is contained in here\n const newStack = prettyStack.stack || prettyStack;\n\n // https://github.com/getsentry/sentry-javascript/blob/739d904342aaf9327312f409952f14ceff4ae1ab/packages/utils/src/stacktrace.ts#L23\n // Match SentryParser which counts lines of stack (-1 for first line with the Error message)\n const skipFirstAdjustedToSentryStackParser = Math.max(skipFirstFrames - 1, 0);\n const stackWithoutPoppedFrames = skipFirstAdjustedToSentryStackParser\n ? newStack.slice(skipFirstAdjustedToSentryStackParser)\n : newStack;\n\n const stackWithoutInternalCallsites = stackWithoutPoppedFrames.filter(\n (frame: { file?: string }) => frame.file && frame.file.match(INTERNAL_CALLSITES_REGEX) === null,\n );\n\n return await this._convertReactNativeFramesToSentryFrames(stackWithoutInternalCallsites);\n } catch (error) {\n if (error instanceof Error) {\n logger.warn(`Unable to symbolicate stack trace: ${error.message}`);\n }\n return null;\n }\n }\n\n /**\n * Converts ReactNativeFrames to frames in the Sentry format\n * @param frames ReactNativeFrame[]\n */\n private async _convertReactNativeFramesToSentryFrames(frames: ReactNative.StackFrame[]): Promise<SentryStackFrame[]> {\n return Promise.all(\n frames.map(async (frame: ReactNative.StackFrame): Promise<SentryStackFrame> => {\n let inApp = !!frame.column && !!frame.lineNumber;\n inApp =\n inApp &&\n frame.file !== undefined &&\n !frame.file.includes('node_modules') &&\n !frame.file.includes('native code');\n\n const newFrame: SentryStackFrame = {\n lineno: frame.lineNumber,\n colno: frame.column,\n filename: frame.file,\n function: frame.methodName,\n in_app: inApp,\n };\n\n if (inApp) {\n await this._addSourceContext(newFrame);\n }\n\n return newFrame;\n }),\n );\n }\n\n /**\n * Replaces the frames in the exception of a error.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceExceptionFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (\n event.exception &&\n event.exception.values &&\n event.exception.values[0] &&\n event.exception.values[0].stacktrace\n ) {\n event.exception.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * Replaces the frames in the thread of a message.\n * @param event Event\n * @param frames StackFrame[]\n */\n private _replaceThreadFramesInEvent(event: Event, frames: SentryStackFrame[]): void {\n if (event.threads && event.threads.values && event.threads.values[0] && event.threads.values[0].stacktrace) {\n event.threads.values[0].stacktrace.frames = frames.reverse();\n }\n }\n\n /**\n * This tries to add source context for in_app Frames\n *\n * @param frame StackFrame\n * @param getDevServer function from RN to get DevServer URL\n */\n private async _addSourceContext(frame: SentryStackFrame): Promise<void> {\n let sourceContext: string | null = null;\n\n const segments = frame.filename?.split('/') ?? [];\n\n const serverUrl = this._getDevServer()?.url;\n if (!serverUrl) {\n return;\n }\n\n for (const idx in segments) {\n if (!Object.prototype.hasOwnProperty.call(segments, idx)) {\n continue;\n }\n\n sourceContext = await this._fetchSourceContext(serverUrl, segments, -idx);\n if (sourceContext) {\n break;\n }\n }\n\n if (!sourceContext) {\n return;\n }\n\n const lines = sourceContext.split('\\n');\n addContextToFrame(lines, frame);\n }\n\n /**\n * Get source context for segment\n */\n private async _fetchSourceContext(url: string, segments: Array<string>, start: number): Promise<string | null> {\n return new Promise(resolve => {\n const fullUrl = `${url}${segments.slice(start).join('/')}`;\n\n const xhr = createStealthXhr();\n if (!xhr) {\n resolve(null);\n return;\n }\n\n xhr.open('GET', fullUrl, true);\n xhr.send();\n\n xhr.onreadystatechange = (): void => {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n if (xhr.status !== 200) {\n resolve(null);\n }\n resolve(xhr.responseText);\n }\n };\n xhr.onerror = (): void => {\n resolve(null);\n };\n });\n }\n\n /**\n * Loads and calls RN Core Devtools parseErrorStack function.\n */\n private _parseErrorStack(errorStack: string): Array<ReactNative.StackFrame> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.parseErrorStack(errorStack);\n }\n\n /**\n * Loads and calls RN Core Devtools symbolicateStackTrace function.\n */\n private _symbolicateStackTrace(\n stack: Array<ReactNative.StackFrame>,\n extraData?: Record<string, unknown>,\n ): Promise<ReactNative.SymbolicatedStackTrace> {\n if (!ReactNativeLibraries.Devtools) {\n throw new Error('React Native Devtools not available.');\n }\n return ReactNativeLibraries.Devtools.symbolicateStackTrace(stack, extraData);\n }\n\n /**\n * Loads and returns the RN DevServer URL.\n */\n private _getDevServer(): ReactNative.DevServerInfo | undefined {\n try {\n return ReactNativeLibraries.Devtools?.getDevServer();\n } catch (_oO) {\n // We can't load devserver URL\n }\n return undefined;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativeerrorhandlers.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,WAAW,EAAiB,MAAM,eAAe,CAAC;AAQ3E,uCAAuC;AACvC,UAAU,+BAA+B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAOD,2CAA2C;AAC3C,qBAAa,wBAAyB,YAAW,WAAW;IAC1D;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAA8B;IAEtD;;OAEG;IACI,IAAI,EAAE,MAAM,CAA+B;IAElD,yBAAyB;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAE3D,kBAAkB;gBACC,OAAO,CAAC,EAAE,OAAO,CAAC,+BAA+B,CAAC;IASrE;;OAEG;IACI,SAAS,IAAI,IAAI;IAKxB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAM3B;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAoCxC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAsC5B;;OAEG;IACH,OAAO,CAAC,cAAc;IAqEtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAO/B"}
1
+ {"version":3,"file":"reactnativeerrorhandlers.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,WAAW,EAAiB,MAAM,eAAe,CAAC;AAQ3E,uCAAuC;AACvC,UAAU,+BAA+B;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAOD,2CAA2C;AAC3C,qBAAa,wBAAyB,YAAW,WAAW;IAC1D;;OAEG;IACH,OAAc,EAAE,EAAE,MAAM,CAA8B;IAEtD;;OAEG;IACI,IAAI,EAAE,MAAM,CAA+B;IAElD,yBAAyB;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAE3D,kBAAkB;gBACC,OAAO,CAAC,EAAE,OAAO,CAAC,+BAA+B,CAAC;IASrE;;OAEG;IACI,SAAS,IAAI,IAAI;IAKxB;;OAEG;IACH,OAAO,CAAC,0BAA0B;IAUlC;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB;IAiBxB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAM3B;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAoCxC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAsC5B;;OAEG;IACH,OAAO,CAAC,cAAc;IA6EtB;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAO/B"}
@@ -182,6 +182,8 @@ export class ReactNativeErrorHandlers {
182
182
  if (!__DEV__) {
183
183
  void client.flush(options.shutdownTimeout || 2000).then(() => {
184
184
  defaultHandler(error, isFatal);
185
+ }, (reason) => {
186
+ logger.error('[ReactNativeErrorHandlers] Error while flushing the event cache after uncaught error.', reason);
185
187
  });
186
188
  }
187
189
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[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CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;wBAC3D,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBACjC,CAAC,CAAC,CAAC;iBACJ;qBAAM;oBACL,gFAAgF;oBAChF,mCAAmC;oBACnC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBAChC;YACH,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,sBAAsB;QAI5B,gGAAgG;QAChG,OAAO,OAAO,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;;AAjPD;;GAEG;AACW,2BAAE,GAAW,0BAA0B,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport type { EventHint, Integration, SeverityLevel } from '@sentry/types';\nimport { addExceptionMechanism, logger } from '@sentry/utils';\n\nimport type { ReactNativeClient } from '../client';\nimport { createSyntheticError, isErrorLike } from '../utils/error';\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\n\n/** ReactNativeErrorHandlers Options */\ninterface ReactNativeErrorHandlersOptions {\n onerror: boolean;\n onunhandledrejection: boolean;\n patchGlobalPromise: boolean;\n}\n\ninterface PromiseRejectionTrackingOptions {\n onUnhandled: (id: string, error: unknown) => void;\n onHandled: (id: string) => void;\n}\n\n/** ReactNativeErrorHandlers Integration */\nexport class ReactNativeErrorHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'ReactNativeErrorHandlers';\n\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeErrorHandlers.id;\n\n /** ReactNativeOptions */\n private readonly _options: ReactNativeErrorHandlersOptions;\n\n /** Constructor */\n public constructor(options?: Partial<ReactNativeErrorHandlersOptions>) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n patchGlobalPromise: true,\n ...options,\n };\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n this._handleUnhandledRejections();\n this._handleOnError();\n }\n\n /**\n * Handle Promises\n */\n private _handleUnhandledRejections(): void {\n if (this._options.onunhandledrejection) {\n if (this._options.patchGlobalPromise) {\n this._polyfillPromise();\n }\n\n this._attachUnhandledRejectionHandler();\n this._checkPromiseAndWarn();\n }\n }\n /**\n * Polyfill the global promise instance with one we can be sure that we can attach the tracking to.\n *\n * In newer RN versions >=0.63, the global promise is not the same reference as the one imported from the promise library.\n * This is due to a version mismatch between promise versions.\n * Originally we tried a solution where we would have you put a package resolution to ensure the promise instances match. However,\n * - Using a package resolution requires the you to manually troubleshoot.\n * - The package resolution fix no longer works with 0.67 on iOS Hermes.\n */\n private _polyfillPromise(): void {\n if (!ReactNativeLibraries.Utilities) {\n logger.warn('Could not polyfill Promise. React Native Libraries Utilities not found.');\n return;\n }\n\n const Promise = this._getPromisePolyfill();\n\n // As of RN 0.67 only done and finally are used\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('promise/setimmediate/done');\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('promise/setimmediate/finally');\n\n ReactNativeLibraries.Utilities.polyfillGlobal('Promise', () => Promise);\n }\n\n /**\n * Single source of truth for the Promise implementation we want to use.\n * This is important for verifying that the rejected promise tracing will work as expected.\n */\n private _getPromisePolyfill(): unknown {\n /* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */\n // Below, we follow the exact way React Native initializes its promise library, and we globally replace it.\n return require('promise/setimmediate/es6-extensions');\n }\n\n /**\n * Attach the unhandled rejection handler\n */\n private _attachUnhandledRejectionHandler(): void {\n const tracking = this._loadRejectionTracking();\n\n const promiseRejectionTrackingOptions: PromiseRejectionTrackingOptions = {\n onUnhandled: (id, rejection = {}) => {\n // eslint-disable-next-line no-console\n console.warn(`Possible Unhandled Promise Rejection (id: ${id}):\\n${rejection}`);\n },\n onHandled: id => {\n // eslint-disable-next-line no-console\n console.warn(\n `Promise Rejection Handled (id: ${id})\\n` +\n 'This means you can ignore any previous messages of the form ' +\n `\"Possible Unhandled Promise Rejection (id: ${id}):\"`,\n );\n },\n };\n\n tracking.enable({\n allRejections: true,\n onUnhandled: (id: string, error: unknown) => {\n if (__DEV__) {\n promiseRejectionTrackingOptions.onUnhandled(id, error);\n }\n\n getCurrentHub().captureException(error, {\n data: { id },\n originalException: error,\n syntheticException: isErrorLike(error) ? undefined : createSyntheticError(),\n });\n },\n onHandled: (id: string) => {\n promiseRejectionTrackingOptions.onHandled(id);\n },\n });\n }\n /**\n * Checks if the promise is the same one or not, if not it will warn the user\n */\n private _checkPromiseAndWarn(): void {\n try {\n // `promise` package is a dependency of react-native, therefore it is always available.\n // but it is possible that the user has installed a different version of promise\n // or dependency that uses a different version.\n // We have to check if the React Native Promise and the `promise` package Promise are using the same reference.\n // If they are not, likely there are multiple versions of the `promise` package installed.\n const ReactNativePromise = ReactNativeLibraries.Promise;\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n const PromisePackagePromise = require('promise/setimmediate/es6-extensions');\n const UsedPromisePolyfill = this._getPromisePolyfill();\n\n if (ReactNativePromise !== PromisePackagePromise) {\n logger.warn(\n 'You appear to have multiple versions of the \"promise\" package installed. ' +\n 'This may cause unexpected behavior like undefined `Promise.allSettled`. ' +\n 'Please install the `promise` package manually using the exact version as the React Native package. ' +\n 'See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.',\n );\n }\n\n // This only make sense if the user disabled the integration Polyfill\n if (UsedPromisePolyfill !== RN_GLOBAL_OBJ.Promise) {\n logger.warn(\n 'Unhandled promise rejections will not be caught by Sentry. ' +\n 'See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.',\n );\n } else {\n logger.log('Unhandled promise rejections will be caught by Sentry.');\n }\n } catch (e) {\n // Do Nothing\n logger.warn(\n 'Unhandled promise rejections will not be caught by Sentry. ' +\n 'See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.',\n );\n }\n }\n /**\n * Handle errors\n */\n private _handleOnError(): void {\n if (this._options.onerror) {\n let handlingFatal = false;\n\n const errorUtils = RN_GLOBAL_OBJ.ErrorUtils;\n if (!errorUtils) {\n logger.warn('ErrorUtils not found. Can be caused by different environment for example react-native-web.');\n return;\n }\n\n const defaultHandler = errorUtils.getGlobalHandler && errorUtils.getGlobalHandler();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errorUtils.setGlobalHandler(async (error: any, isFatal?: boolean) => {\n // We want to handle fatals, but only in production mode.\n const shouldHandleFatal = isFatal && !__DEV__;\n if (shouldHandleFatal) {\n if (handlingFatal) {\n logger.log('Encountered multiple fatals in a row. The latest:', error);\n return;\n }\n handlingFatal = true;\n }\n\n const currentHub = getCurrentHub();\n const client = currentHub.getClient<ReactNativeClient>();\n const scope = currentHub.getScope();\n\n if (!client) {\n logger.error('Sentry client is missing, the error event might be lost.', error);\n\n // If there is no client something is fishy, anyway we call the default handler\n defaultHandler(error, isFatal);\n\n return;\n }\n\n const options = client.getOptions();\n\n const hint: EventHint = {\n originalException: error,\n attachments: scope?.getAttachments(),\n };\n const event = await client.eventFromException(error, hint);\n\n if (isFatal) {\n event.level = 'fatal' as SeverityLevel;\n\n addExceptionMechanism(event, {\n handled: false,\n type: 'onerror',\n });\n }\n\n currentHub.captureEvent(event, hint);\n\n if (!__DEV__) {\n void client.flush(options.shutdownTimeout || 2000).then(() => {\n defaultHandler(error, isFatal);\n });\n } else {\n // If in dev, we call the default handler anyway and hope the error will be sent\n // Just for a better dev experience\n defaultHandler(error, isFatal);\n }\n });\n }\n }\n\n /**\n * Loads and returns rejection tracking module\n */\n private _loadRejectionTracking(): {\n disable: () => void;\n enable: (arg: unknown) => void;\n } {\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n return require('promise/setimmediate/rejection-tracking');\n }\n}\n"]}
1
+ {"version":3,"file":"reactnativeerrorhandlers.js","sourceRoot":"","sources":["../../../src/js/integrations/reactnativeerrorhandlers.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,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O,CAAC,CAAC;oBACjC,CAAC,EACD,CAAC,MAAe,EAAE,EAAE;wBAClB,MAAM,CAAC,KAAK,CACV,uFAAuF,EACvF,MAAM,CACP,CAAC;oBACJ,CAAC,CACF,CAAC;iBACH;qBAAM;oBACL,gFAAgF;oBAChF,mCAAmC;oBACnC,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;iBAChC;YACH,CAAC,CAAA,CAAC,CAAC;SACJ;IACH,CAAC;IAED;;OAEG;IACK,sBAAsB;QAI5B,gGAAgG;QAChG,OAAO,OAAO,CAAC,yCAAyC,CAAC,CAAC;IAC5D,CAAC;;AAzPD;;GAEG;AACW,2BAAE,GAAW,0BAA0B,CAAC","sourcesContent":["import { getCurrentHub } from '@sentry/core';\nimport type { EventHint, Integration, SeverityLevel } from '@sentry/types';\nimport { addExceptionMechanism, logger } from '@sentry/utils';\n\nimport type { ReactNativeClient } from '../client';\nimport { createSyntheticError, isErrorLike } from '../utils/error';\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\n\n/** ReactNativeErrorHandlers Options */\ninterface ReactNativeErrorHandlersOptions {\n onerror: boolean;\n onunhandledrejection: boolean;\n patchGlobalPromise: boolean;\n}\n\ninterface PromiseRejectionTrackingOptions {\n onUnhandled: (id: string, error: unknown) => void;\n onHandled: (id: string) => void;\n}\n\n/** ReactNativeErrorHandlers Integration */\nexport class ReactNativeErrorHandlers implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'ReactNativeErrorHandlers';\n\n /**\n * @inheritDoc\n */\n public name: string = ReactNativeErrorHandlers.id;\n\n /** ReactNativeOptions */\n private readonly _options: ReactNativeErrorHandlersOptions;\n\n /** Constructor */\n public constructor(options?: Partial<ReactNativeErrorHandlersOptions>) {\n this._options = {\n onerror: true,\n onunhandledrejection: true,\n patchGlobalPromise: true,\n ...options,\n };\n }\n\n /**\n * @inheritDoc\n */\n public setupOnce(): void {\n this._handleUnhandledRejections();\n this._handleOnError();\n }\n\n /**\n * Handle Promises\n */\n private _handleUnhandledRejections(): void {\n if (this._options.onunhandledrejection) {\n if (this._options.patchGlobalPromise) {\n this._polyfillPromise();\n }\n\n this._attachUnhandledRejectionHandler();\n this._checkPromiseAndWarn();\n }\n }\n /**\n * Polyfill the global promise instance with one we can be sure that we can attach the tracking to.\n *\n * In newer RN versions >=0.63, the global promise is not the same reference as the one imported from the promise library.\n * This is due to a version mismatch between promise versions.\n * Originally we tried a solution where we would have you put a package resolution to ensure the promise instances match. However,\n * - Using a package resolution requires the you to manually troubleshoot.\n * - The package resolution fix no longer works with 0.67 on iOS Hermes.\n */\n private _polyfillPromise(): void {\n if (!ReactNativeLibraries.Utilities) {\n logger.warn('Could not polyfill Promise. React Native Libraries Utilities not found.');\n return;\n }\n\n const Promise = this._getPromisePolyfill();\n\n // As of RN 0.67 only done and finally are used\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('promise/setimmediate/done');\n // eslint-disable-next-line import/no-extraneous-dependencies\n require('promise/setimmediate/finally');\n\n ReactNativeLibraries.Utilities.polyfillGlobal('Promise', () => Promise);\n }\n\n /**\n * Single source of truth for the Promise implementation we want to use.\n * This is important for verifying that the rejected promise tracing will work as expected.\n */\n private _getPromisePolyfill(): unknown {\n /* eslint-disable import/no-extraneous-dependencies,@typescript-eslint/no-var-requires */\n // Below, we follow the exact way React Native initializes its promise library, and we globally replace it.\n return require('promise/setimmediate/es6-extensions');\n }\n\n /**\n * Attach the unhandled rejection handler\n */\n private _attachUnhandledRejectionHandler(): void {\n const tracking = this._loadRejectionTracking();\n\n const promiseRejectionTrackingOptions: PromiseRejectionTrackingOptions = {\n onUnhandled: (id, rejection = {}) => {\n // eslint-disable-next-line no-console\n console.warn(`Possible Unhandled Promise Rejection (id: ${id}):\\n${rejection}`);\n },\n onHandled: id => {\n // eslint-disable-next-line no-console\n console.warn(\n `Promise Rejection Handled (id: ${id})\\n` +\n 'This means you can ignore any previous messages of the form ' +\n `\"Possible Unhandled Promise Rejection (id: ${id}):\"`,\n );\n },\n };\n\n tracking.enable({\n allRejections: true,\n onUnhandled: (id: string, error: unknown) => {\n if (__DEV__) {\n promiseRejectionTrackingOptions.onUnhandled(id, error);\n }\n\n getCurrentHub().captureException(error, {\n data: { id },\n originalException: error,\n syntheticException: isErrorLike(error) ? undefined : createSyntheticError(),\n });\n },\n onHandled: (id: string) => {\n promiseRejectionTrackingOptions.onHandled(id);\n },\n });\n }\n /**\n * Checks if the promise is the same one or not, if not it will warn the user\n */\n private _checkPromiseAndWarn(): void {\n try {\n // `promise` package is a dependency of react-native, therefore it is always available.\n // but it is possible that the user has installed a different version of promise\n // or dependency that uses a different version.\n // We have to check if the React Native Promise and the `promise` package Promise are using the same reference.\n // If they are not, likely there are multiple versions of the `promise` package installed.\n const ReactNativePromise = ReactNativeLibraries.Promise;\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n const PromisePackagePromise = require('promise/setimmediate/es6-extensions');\n const UsedPromisePolyfill = this._getPromisePolyfill();\n\n if (ReactNativePromise !== PromisePackagePromise) {\n logger.warn(\n 'You appear to have multiple versions of the \"promise\" package installed. ' +\n 'This may cause unexpected behavior like undefined `Promise.allSettled`. ' +\n 'Please install the `promise` package manually using the exact version as the React Native package. ' +\n 'See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.',\n );\n }\n\n // This only make sense if the user disabled the integration Polyfill\n if (UsedPromisePolyfill !== RN_GLOBAL_OBJ.Promise) {\n logger.warn(\n 'Unhandled promise rejections will not be caught by Sentry. ' +\n 'See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.',\n );\n } else {\n logger.log('Unhandled promise rejections will be caught by Sentry.');\n }\n } catch (e) {\n // Do Nothing\n logger.warn(\n 'Unhandled promise rejections will not be caught by Sentry. ' +\n 'See https://docs.sentry.io/platforms/react-native/troubleshooting/ for more details.',\n );\n }\n }\n /**\n * Handle errors\n */\n private _handleOnError(): void {\n if (this._options.onerror) {\n let handlingFatal = false;\n\n const errorUtils = RN_GLOBAL_OBJ.ErrorUtils;\n if (!errorUtils) {\n logger.warn('ErrorUtils not found. Can be caused by different environment for example react-native-web.');\n return;\n }\n\n const defaultHandler = errorUtils.getGlobalHandler && errorUtils.getGlobalHandler();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n errorUtils.setGlobalHandler(async (error: any, isFatal?: boolean) => {\n // We want to handle fatals, but only in production mode.\n const shouldHandleFatal = isFatal && !__DEV__;\n if (shouldHandleFatal) {\n if (handlingFatal) {\n logger.log('Encountered multiple fatals in a row. The latest:', error);\n return;\n }\n handlingFatal = true;\n }\n\n const currentHub = getCurrentHub();\n const client = currentHub.getClient<ReactNativeClient>();\n const scope = currentHub.getScope();\n\n if (!client) {\n logger.error('Sentry client is missing, the error event might be lost.', error);\n\n // If there is no client something is fishy, anyway we call the default handler\n defaultHandler(error, isFatal);\n\n return;\n }\n\n const options = client.getOptions();\n\n const hint: EventHint = {\n originalException: error,\n attachments: scope?.getAttachments(),\n };\n const event = await client.eventFromException(error, hint);\n\n if (isFatal) {\n event.level = 'fatal' as SeverityLevel;\n\n addExceptionMechanism(event, {\n handled: false,\n type: 'onerror',\n });\n }\n\n currentHub.captureEvent(event, hint);\n\n if (!__DEV__) {\n void client.flush(options.shutdownTimeout || 2000).then(\n () => {\n defaultHandler(error, isFatal);\n },\n (reason: unknown) => {\n logger.error(\n '[ReactNativeErrorHandlers] Error while flushing the event cache after uncaught error.',\n reason,\n );\n },\n );\n } else {\n // If in dev, we call the default handler anyway and hope the error will be sent\n // Just for a better dev experience\n defaultHandler(error, isFatal);\n }\n });\n }\n }\n\n /**\n * Loads and returns rejection tracking module\n */\n private _loadRejectionTracking(): {\n disable: () => void;\n enable: (arg: unknown) => void;\n } {\n // eslint-disable-next-line @typescript-eslint/no-var-requires,import/no-extraneous-dependencies\n return require('promise/setimmediate/rejection-tracking');\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { RewriteFrames } from '@sentry/integrations';
1
+ import type { Integration } from '@sentry/types';
2
2
  export declare const ANDROID_DEFAULT_BUNDLE_NAME = "app:///index.android.bundle";
3
3
  export declare const IOS_DEFAULT_BUNDLE_NAME = "app:///main.jsbundle";
4
4
  /**
@@ -7,5 +7,5 @@ export declare const IOS_DEFAULT_BUNDLE_NAME = "app:///main.jsbundle";
7
7
  * and removes file://, 'address at' prefixes, CodePush postfix,
8
8
  * and Expo bundle postfix.
9
9
  */
10
- export declare function createReactNativeRewriteFrames(): RewriteFrames;
10
+ export declare function createReactNativeRewriteFrames(): Integration;
11
11
  //# sourceMappingURL=rewriteframes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rewriteframes.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/rewriteframes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAMrD,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,aAAa,CAsD9D"}
1
+ {"version":3,"file":"rewriteframes.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/rewriteframes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,eAAe,CAAC;AAK7D,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AACzE,eAAO,MAAM,uBAAuB,yBAAyB,CAAC;AAE9D;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,WAAW,CAsD5D"}
@@ -1 +1 @@
1
- {"version":3,"file":"rewriteframes.js","sourceRoot":"","sources":["../../../src/js/integrations/rewriteframes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE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AK,KAAK,EAAE;gBACrC,KAAK,CAAC,QAAQ,GAAG,uBAAuB,CAAC;gBACzC,OAAO,KAAK,CAAC;aACd;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC;YAC3B,+DAA+D;YAC/D,IAAI,KAAK,CAAC,QAAQ,KAAK,sBAAsB,EAAE;gBAC7C,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC;aACtB;YACD,wCAAwC;YACxC,KAAK,CAAC,QAAQ;gBACZ,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACzG,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { RewriteFrames } from '@sentry/integrations';\nimport type { StackFrame } from '@sentry/types';\nimport { Platform } from 'react-native';\n\nimport { isExpo, isHermesEnabled } from '../utils/environment';\n\nexport const ANDROID_DEFAULT_BUNDLE_NAME = 'app:///index.android.bundle';\nexport const IOS_DEFAULT_BUNDLE_NAME = 'app:///main.jsbundle';\n\n/**\n * Creates React Native default rewrite frames integration\n * which appends app:// to the beginning of the filename\n * and removes file://, 'address at' prefixes, CodePush postfix,\n * and Expo bundle postfix.\n */\nexport function createReactNativeRewriteFrames(): RewriteFrames {\n return new RewriteFrames({\n iteratee: (frame: StackFrame) => {\n if (frame.platform === 'java' || frame.platform === 'cocoa') {\n // Because platform is not required in StackFrame type\n // we assume that if not set it's javascript\n return frame;\n }\n\n if (!frame.filename) {\n return frame;\n }\n delete frame.abs_path;\n\n frame.filename = frame.filename\n .replace(/^file:\\/\\//, '')\n .replace(/^address at /, '')\n .replace(/^.*\\/[^.]+(\\.app|CodePush|.*(?=\\/))/, '');\n\n if (frame.filename === '[native code]' || frame.filename === 'native') {\n return frame;\n }\n // Is React Native frame\n\n // Check Hermes Bytecode Frame and convert to 1-based column\n if (isHermesEnabled() && frame.lineno === 1 && frame.colno !== undefined) {\n // hermes bytecode columns are 0-based, while v8 and jsc are 1-based\n // Hermes frames without debug info have always line = 1 and col points to a bytecode pos\n // https://github.com/facebook/react/issues/21792#issuecomment-873171991\n frame.colno += 1;\n }\n\n // Expo adds hash to the end of bundle names\n if (isExpo() && Platform.OS === 'android') {\n frame.filename = ANDROID_DEFAULT_BUNDLE_NAME;\n return frame;\n }\n\n if (isExpo() && Platform.OS === 'ios') {\n frame.filename = IOS_DEFAULT_BUNDLE_NAME;\n return frame;\n }\n\n const appPrefix = 'app://';\n // https://github.com/getsentry/sentry-react-native/issues/3348\n if (frame.filename === '/InternalBytecode.js') {\n frame.in_app = false;\n }\n // We always want to have a triple slash\n frame.filename =\n frame.filename.indexOf('/') === 0 ? `${appPrefix}${frame.filename}` : `${appPrefix}/${frame.filename}`;\n return frame;\n },\n });\n}\n"]}
1
+ {"version":3,"file":"rewriteframes.js","sourceRoot":"","sources":["../../../src/js/integrations/rewriteframes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE/D,MAAM,CAAC,MAAM,2BAA2B,GAAG,6BAA6B,CAAC;AACzE,MAAM,CAAC,MAAM,uBAAuB,GAAG,sBAAsB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO,IAAI,aAAa,CAAC;QACvB,QAAQ,EAAE,CAAC,KAAiB,EAAE,EAAE;YAC9B,IAAI,KAAK,CAAC,QAAQ,KAAK,MAAM,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;gBAC3D,sDAAsD;gBACtD,4CAA4C;gBAC5C,OAAO,KAAK,CAAC;aACd;YAED,IAAI,CA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AG,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACzG,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { RewriteFrames } from '@sentry/integrations';\nimport type { Integration, StackFrame } from '@sentry/types';\nimport { Platform } from 'react-native';\n\nimport { isExpo, isHermesEnabled } from '../utils/environment';\n\nexport const ANDROID_DEFAULT_BUNDLE_NAME = 'app:///index.android.bundle';\nexport const IOS_DEFAULT_BUNDLE_NAME = 'app:///main.jsbundle';\n\n/**\n * Creates React Native default rewrite frames integration\n * which appends app:// to the beginning of the filename\n * and removes file://, 'address at' prefixes, CodePush postfix,\n * and Expo bundle postfix.\n */\nexport function createReactNativeRewriteFrames(): Integration {\n return new RewriteFrames({\n iteratee: (frame: StackFrame) => {\n if (frame.platform === 'java' || frame.platform === 'cocoa') {\n // Because platform is not required in StackFrame type\n // we assume that if not set it's javascript\n return frame;\n }\n\n if (!frame.filename) {\n return frame;\n }\n delete frame.abs_path;\n\n frame.filename = frame.filename\n .replace(/^file:\\/\\//, '')\n .replace(/^address at /, '')\n .replace(/^.*\\/[^.]+(\\.app|CodePush|.*(?=\\/))/, '');\n\n if (frame.filename === '[native code]' || frame.filename === 'native') {\n return frame;\n }\n // Is React Native frame\n\n // Check Hermes Bytecode Frame and convert to 1-based column\n if (isHermesEnabled() && frame.lineno === 1 && frame.colno !== undefined) {\n // hermes bytecode columns are 0-based, while v8 and jsc are 1-based\n // Hermes frames without debug info have always line = 1 and col points to a bytecode pos\n // https://github.com/facebook/react/issues/21792#issuecomment-873171991\n frame.colno += 1;\n }\n\n // Expo adds hash to the end of bundle names\n if (isExpo() && Platform.OS === 'android') {\n frame.filename = ANDROID_DEFAULT_BUNDLE_NAME;\n return frame;\n }\n\n if (isExpo() && Platform.OS === 'ios') {\n frame.filename = IOS_DEFAULT_BUNDLE_NAME;\n return frame;\n }\n\n const appPrefix = 'app://';\n // https://github.com/getsentry/sentry-react-native/issues/3348\n if (frame.filename === '/InternalBytecode.js') {\n frame.in_app = false;\n }\n // We always want to have a triple slash\n frame.filename =\n frame.filename.indexOf('/') === 0 ? `${appPrefix}${frame.filename}` : `${appPrefix}/${frame.filename}`;\n return frame;\n },\n });\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { CombinedProfileEvent } from './types';
1
+ import type { AndroidCombinedProfileEvent, CombinedProfileEvent } from './types';
2
2
  export declare const PROFILE_QUEUE: {
3
- get: (key: string) => CombinedProfileEvent | undefined;
4
- add: (key: string, value: CombinedProfileEvent) => void;
3
+ get: (key: string) => AndroidCombinedProfileEvent | CombinedProfileEvent | undefined;
4
+ add: (key: string, value: AndroidCombinedProfileEvent | CombinedProfileEvent) => void;
5
5
  delete: (key: string) => boolean;
6
6
  clear: () => void;
7
7
  size: () => number;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/cache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,aAAa;;;;;;CAAkD,CAAC"}
1
+ {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/cache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEjF,eAAO,MAAM,aAAa;;;;;;CAAgF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/js/profiling/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA+B,EAAE,CAAC,CAAC","sourcesContent":["import { makeFifoCache } from '@sentry/utils';\n\nimport type { CombinedProfileEvent } from './types';\n\nexport const PROFILE_QUEUE = makeFifoCache<string, CombinedProfileEvent>(20);\n"]}
1
+ {"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/js/profiling/cache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAA6D,EAAE,CAAC,CAAC","sourcesContent":["import { makeFifoCache } from '@sentry/utils';\n\nimport type { AndroidCombinedProfileEvent, CombinedProfileEvent } from './types';\n\nexport const PROFILE_QUEUE = makeFifoCache<string, CombinedProfileEvent | AndroidCombinedProfileEvent>(20);\n"]}
@@ -1,7 +1,7 @@
1
1
  import type { Hub } from '@sentry/core';
2
2
  import type { EventProcessor, Integration, ThreadCpuProfile } from '@sentry/types';
3
- import type { NativeProfileEvent } from './nativeTypes';
4
- import type { CombinedProfileEvent, HermesProfileEvent } from './types';
3
+ import type { NativeAndroidProfileEvent, NativeProfileEvent } from './nativeTypes';
4
+ import type { AndroidCombinedProfileEvent, CombinedProfileEvent, HermesProfileEvent } from './types';
5
5
  /**
6
6
  * Profiling integration creates a profile for each transaction and adds it to the event envelope.
7
7
  *
@@ -44,7 +44,11 @@ export declare function startProfiling(): number | null;
44
44
  /**
45
45
  * Stops Profilers and returns collected combined profile.
46
46
  */
47
- export declare function stopProfiling(): CombinedProfileEvent | null;
47
+ export declare function stopProfiling(profileStartTimestampNs: number): CombinedProfileEvent | AndroidCombinedProfileEvent | null;
48
+ /**
49
+ * Creates Android profile event with attached javascript profile.
50
+ */
51
+ export declare function createAndroidWithHermesProfile(hermes: HermesProfileEvent, nativeAndroid: NativeAndroidProfileEvent, durationNs: number): AndroidCombinedProfileEvent;
48
52
  /**
49
53
  * Merges Hermes and Native profile events into one.
50
54
  */
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/integration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,OA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AAE,kBAAkB,EAC1B,aAAa,EAAE,yBAAyB,EACxC,UAAU,EAAE,MAAM,GACjB,2BAA2B,CAQ7B;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,kBAAkB,GACzB,oBAAoB,CAStB;AAED;;GAEG;AACH,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,gBAAgB,EACxB,uBAAuB,EAAE,MAAM,GAAG,SAAS,GAC1C,oBAAoB,CAAC,SAAS,CAAC,CAkCjC"}
@@ -81,7 +81,7 @@ export class HermesProfiling {
81
81
  if (this._currentProfile === undefined) {
82
82
  return;
83
83
  }
84
- const profile = stopProfiling();
84
+ const profile = stopProfiling(this._currentProfile.startTimestampNs);
85
85
  if (!profile) {
86
86
  logger.warn('[Profiling] Stop failed. Cleaning up...');
87
87
  this._currentProfile = undefined;
@@ -170,11 +170,12 @@ export function startProfiling() {
170
170
  /**
171
171
  * Stops Profilers and returns collected combined profile.
172
172
  */
173
- export function stopProfiling() {
173
+ export function stopProfiling(profileStartTimestampNs) {
174
174
  const collectedProfiles = NATIVE.stopProfiling();
175
175
  if (!collectedProfiles) {
176
176
  return null;
177
177
  }
178
+ const profileEndTimestampNs = Date.now() * MS_TO_NS;
178
179
  const hermesProfile = convertToSentryProfile(collectedProfiles.hermesProfile);
179
180
  if (!hermesProfile) {
180
181
  return null;
@@ -183,10 +184,20 @@ export function stopProfiling() {
183
184
  if (!hermesProfileEvent) {
184
185
  return null;
185
186
  }
186
- if (!collectedProfiles.nativeProfile) {
187
- return hermesProfileEvent;
187
+ if (collectedProfiles.androidProfile) {
188
+ const durationNs = profileEndTimestampNs - profileStartTimestampNs;
189
+ return createAndroidWithHermesProfile(hermesProfileEvent, collectedProfiles.androidProfile, durationNs);
188
190
  }
189
- return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);
191
+ else if (collectedProfiles.nativeProfile) {
192
+ return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);
193
+ }
194
+ return hermesProfileEvent;
195
+ }
196
+ /**
197
+ * Creates Android profile event with attached javascript profile.
198
+ */
199
+ export function createAndroidWithHermesProfile(hermes, nativeAndroid, durationNs) {
200
+ return Object.assign(Object.assign({}, nativeAndroid), { platform: 'android', js_profile: hermes.profile, duration_ns: durationNs.toString(10), active_thread_id: hermes.transaction.active_thread_id });
190
201
  }
191
202
  /**
192
203
  * Merges Hermes and Native profile events into one.
@@ -1 +1 @@
1
- {"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/js/profiling/integration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAUpD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,SAAS,CAAC;AAEjB,MAAM,QAAQ,GAAW,GAAG,CAAC;AAE7B;;;;GAIG;AACH,MAAM,OAAO,eAAe;IAA5B;QAME;;WAEG;QACI,SAAI,GAAW,eAAe,CAAC,EAAE,CAAC;QAwDjC,6CAAwC,GAAG,GAAS,EAAE;YAC5D,IAAI,IAAI,CAAC,eAAe,EAAE;gBACxB,OAAO;aACR;YACD,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,IAAI,oBAAoB,CAAC,IAAI,CAAC,cAAc,E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AC","sourcesContent":["/* eslint-disable complexity */\nimport type { Hub } from '@sentry/core';\nimport { getActiveTransaction } from '@sentry/core';\nimport type {\n Envelope,\n Event,\n EventProcessor,\n Integration,\n Profile,\n ThreadCpuProfile,\n Transaction,\n} from '@sentry/types';\nimport { logger, uuid4 } from '@sentry/utils';\nimport { Platform } from 'react-native';\n\nimport { isHermesEnabled } from '../utils/environment';\nimport { NATIVE } from '../wrapper';\nimport { PROFILE_QUEUE } from './cache';\nimport { MAX_PROFILE_DURATION_MS } from './constants';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { NativeProfileEvent } from './nativeTypes';\nimport type { CombinedProfileEvent, HermesProfileEvent } from './types';\nimport {\n addProfilesToEnvelope,\n createHermesProfilingEvent,\n enrichCombinedProfileWithEventContext,\n findProfiledTransactionsFromEnvelope,\n} from './utils';\n\nconst MS_TO_NS: number = 1e6;\n\n/**\n * Profiling integration creates a profile for each transaction and adds it to the event envelope.\n *\n * @experimental\n */\nexport class HermesProfiling implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'HermesProfiling';\n\n /**\n * @inheritDoc\n */\n public name: string = HermesProfiling.id;\n\n private _getCurrentHub?: () => Hub;\n\n private _currentProfile:\n | {\n profile_id: string;\n startTimestampNs: number;\n }\n | undefined;\n\n private _currentProfileTimeout: number | undefined;\n\n /**\n * @inheritDoc\n */\n public setupOnce(_: (e: EventProcessor) => void, getCurrentHub: () => Hub): void {\n if (!isHermesEnabled()) {\n logger.log('[Profiling] Hermes is not enabled, not adding profiling integration.');\n return;\n }\n\n this._getCurrentHub = getCurrentHub;\n const client = getCurrentHub().getClient();\n\n if (!client || typeof client.on !== 'function') {\n return;\n }\n\n this._startCurrentProfileForActiveTransaction();\n client.on('startTransaction', this._startCurrentProfile);\n\n client.on('finishTransaction', this._finishCurrentProfile);\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (!PROFILE_QUEUE.size()) {\n return;\n }\n\n const profiledTransactions = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactions.length) {\n logger.log('[Profiling] no profiled transactions found in envelope');\n return;\n }\n\n const profilesToAddToEnvelope: Profile[] = [];\n for (const profiledTransaction of profiledTransactions) {\n const profile = this._createProfileEventFor(profiledTransaction);\n if (profile) {\n profilesToAddToEnvelope.push(profile);\n }\n }\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n }\n\n private _startCurrentProfileForActiveTransaction = (): void => {\n if (this._currentProfile) {\n return;\n }\n const transaction = this._getCurrentHub && getActiveTransaction(this._getCurrentHub());\n transaction && this._startCurrentProfile(transaction);\n };\n\n private _startCurrentProfile = (transaction: Transaction): void => {\n this._finishCurrentProfile();\n\n const shouldStartProfiling = this._shouldStartProfiling(transaction);\n if (!shouldStartProfiling) {\n return;\n }\n\n this._currentProfileTimeout = setTimeout(this._finishCurrentProfile, MAX_PROFILE_DURATION_MS);\n this._startNewProfile(transaction);\n };\n\n private _shouldStartProfiling = (transaction: Transaction): boolean => {\n if (!transaction.sampled) {\n logger.log('[Profiling] Transaction is not sampled, skipping profiling');\n return false;\n }\n\n const client = this._getCurrentHub && this._getCurrentHub().getClient();\n const options = client && client.getOptions();\n\n const profilesSampleRate =\n options && options._experiments && typeof options._experiments.profilesSampleRate === 'number'\n ? options._experiments.profilesSampleRate\n : undefined;\n if (profilesSampleRate === undefined) {\n logger.log('[Profiling] Profiling disabled, enable it by setting `profilesSampleRate` option to SDK init call.');\n return false;\n }\n\n // Check if we should sample this profile\n if (Math.random() > profilesSampleRate) {\n logger.log('[Profiling] Skip profiling transaction due to sampling.');\n return false;\n }\n\n return true;\n };\n\n /**\n * Starts a new profile and links it to the transaction.\n */\n private _startNewProfile = (transaction: Transaction): void => {\n const profileStartTimestampNs = startProfiling();\n if (!profileStartTimestampNs) {\n return;\n }\n\n this._currentProfile = {\n profile_id: uuid4(),\n startTimestampNs: profileStartTimestampNs,\n };\n transaction.setContext('profile', { profile_id: this._currentProfile.profile_id });\n // @ts-expect-error profile_id is not part of the metadata type\n transaction.setMetadata({ profile_id: this._currentProfile.profile_id });\n logger.log('[Profiling] started profiling: ', this._currentProfile.profile_id);\n };\n\n /**\n * Stops profiling and adds the profile to the queue to be processed on beforeEnvelope.\n */\n private _finishCurrentProfile = (): void => {\n this._clearCurrentProfileTimeout();\n if (this._currentProfile === undefined) {\n return;\n }\n\n const profile = stopProfiling();\n if (!profile) {\n logger.warn('[Profiling] Stop failed. Cleaning up...');\n this._currentProfile = undefined;\n return;\n }\n\n PROFILE_QUEUE.add(this._currentProfile.profile_id, profile);\n\n logger.log('[Profiling] finished profiling: ', this._currentProfile.profile_id);\n this._currentProfile = undefined;\n };\n\n private _createProfileEventFor = (profiledTransaction: Event): Profile | null => {\n const profile_id = profiledTransaction?.contexts?.['profile']?.['profile_id'];\n\n if (typeof profile_id !== 'string') {\n logger.log('[Profiling] cannot find profile for a transaction without a profile context');\n return null;\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profiledTransaction?.contexts?.['.profile']) {\n delete profiledTransaction.contexts.profile;\n }\n\n const profile = PROFILE_QUEUE.get(profile_id);\n PROFILE_QUEUE.delete(profile_id);\n\n if (!profile) {\n logger.log(`[Profiling] cannot find profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n return null;\n }\n\n const profileWithEvent = enrichCombinedProfileWithEventContext(profile_id, profile, profiledTransaction);\n logger.log(`[Profiling] Created profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n\n return profileWithEvent;\n };\n\n private _clearCurrentProfileTimeout = (): void => {\n this._currentProfileTimeout !== undefined && clearTimeout(this._currentProfileTimeout);\n this._currentProfileTimeout = undefined;\n };\n}\n\n/**\n * Starts Profilers and returns the timestamp when profiling started in nanoseconds.\n */\nexport function startProfiling(): number | null {\n const started = NATIVE.startProfiling();\n if (!started) {\n return null;\n }\n\n return Date.now() * MS_TO_NS;\n}\n\n/**\n * Stops Profilers and returns collected combined profile.\n */\nexport function stopProfiling(): CombinedProfileEvent | null {\n const collectedProfiles = NATIVE.stopProfiling();\n if (!collectedProfiles) {\n return null;\n }\n\n const hermesProfile = convertToSentryProfile(collectedProfiles.hermesProfile);\n if (!hermesProfile) {\n return null;\n }\n\n const hermesProfileEvent = createHermesProfilingEvent(hermesProfile);\n if (!hermesProfileEvent) {\n return null;\n }\n\n if (!collectedProfiles.nativeProfile) {\n return hermesProfileEvent;\n }\n\n return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);\n}\n\n/**\n * Merges Hermes and Native profile events into one.\n */\nexport function addNativeProfileToHermesProfile(\n hermes: HermesProfileEvent,\n native: NativeProfileEvent,\n): CombinedProfileEvent {\n return {\n ...hermes,\n profile: addNativeThreadCpuProfileToHermes(hermes.profile, native.profile, hermes.transaction.active_thread_id),\n debug_meta: {\n images: native.debug_meta.images,\n },\n measurements: native.measurements,\n };\n}\n\n/**\n * Merges Hermes And Native profiles into one.\n */\nexport function addNativeThreadCpuProfileToHermes(\n hermes: ThreadCpuProfile,\n native: ThreadCpuProfile,\n hermes_active_thread_id: string | undefined,\n): CombinedProfileEvent['profile'] {\n // assumes thread ids are unique\n hermes.thread_metadata = { ...native.thread_metadata, ...hermes.thread_metadata };\n // assumes queue ids are unique\n hermes.queue_metadata = { ...native.queue_metadata, ...hermes.queue_metadata };\n\n // recalculate frames and stacks using offset\n const framesOffset = hermes.frames.length;\n const stacksOffset = hermes.stacks.length;\n\n if (native.frames) {\n for (const frame of native.frames) {\n hermes.frames.push({\n function: frame.function,\n instruction_addr: frame.instruction_addr,\n platform: Platform.OS === 'ios' ? 'cocoa' : undefined,\n });\n }\n }\n hermes.stacks = [\n ...(hermes.stacks || []),\n ...(native.stacks || []).map(stack => stack.map(frameId => frameId + framesOffset)),\n ];\n hermes.samples = [\n ...(hermes.samples || []),\n ...(native.samples || [])\n .filter(sample => sample.thread_id !== hermes_active_thread_id)\n .map(sample => ({\n ...sample,\n stack_id: stacksOffset + sample.stack_id,\n })),\n ];\n\n return hermes;\n}\n"]}
1
+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;aACtB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,SAAS,KAAK,uBAAuB,CAAC;aAC9D,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,iCACV,MAAM,KACT,QAAQ,EAAE,YAAY,GAAG,MAAM,CAAC,QAAQ,IACxC,CAAC;KACN,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Hub } from '@sentry/core';\nimport { getActiveTransaction } from '@sentry/core';\nimport type { Envelope, Event, EventProcessor, Integration, ThreadCpuProfile, Transaction } from '@sentry/types';\nimport { logger, uuid4 } from '@sentry/utils';\nimport { Platform } from 'react-native';\n\nimport { isHermesEnabled } from '../utils/environment';\nimport { NATIVE } from '../wrapper';\nimport { PROFILE_QUEUE } from './cache';\nimport { MAX_PROFILE_DURATION_MS } from './constants';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { NativeAndroidProfileEvent, NativeProfileEvent } from './nativeTypes';\nimport type { AndroidCombinedProfileEvent, CombinedProfileEvent, HermesProfileEvent, ProfileEvent } from './types';\nimport {\n addProfilesToEnvelope,\n createHermesProfilingEvent,\n enrichCombinedProfileWithEventContext,\n findProfiledTransactionsFromEnvelope,\n} from './utils';\n\nconst MS_TO_NS: number = 1e6;\n\n/**\n * Profiling integration creates a profile for each transaction and adds it to the event envelope.\n *\n * @experimental\n */\nexport class HermesProfiling implements Integration {\n /**\n * @inheritDoc\n */\n public static id: string = 'HermesProfiling';\n\n /**\n * @inheritDoc\n */\n public name: string = HermesProfiling.id;\n\n private _getCurrentHub?: () => Hub;\n\n private _currentProfile:\n | {\n profile_id: string;\n startTimestampNs: number;\n }\n | undefined;\n\n private _currentProfileTimeout: number | undefined;\n\n /**\n * @inheritDoc\n */\n public setupOnce(_: (e: EventProcessor) => void, getCurrentHub: () => Hub): void {\n if (!isHermesEnabled()) {\n logger.log('[Profiling] Hermes is not enabled, not adding profiling integration.');\n return;\n }\n\n this._getCurrentHub = getCurrentHub;\n const client = getCurrentHub().getClient();\n\n if (!client || typeof client.on !== 'function') {\n return;\n }\n\n this._startCurrentProfileForActiveTransaction();\n client.on('startTransaction', this._startCurrentProfile);\n\n client.on('finishTransaction', this._finishCurrentProfile);\n\n client.on('beforeEnvelope', (envelope: Envelope) => {\n if (!PROFILE_QUEUE.size()) {\n return;\n }\n\n const profiledTransactions = findProfiledTransactionsFromEnvelope(envelope);\n if (!profiledTransactions.length) {\n logger.log('[Profiling] no profiled transactions found in envelope');\n return;\n }\n\n const profilesToAddToEnvelope: ProfileEvent[] = [];\n for (const profiledTransaction of profiledTransactions) {\n const profile = this._createProfileEventFor(profiledTransaction);\n if (profile) {\n profilesToAddToEnvelope.push(profile);\n }\n }\n addProfilesToEnvelope(envelope, profilesToAddToEnvelope);\n });\n }\n\n private _startCurrentProfileForActiveTransaction = (): void => {\n if (this._currentProfile) {\n return;\n }\n const transaction = this._getCurrentHub && getActiveTransaction(this._getCurrentHub());\n transaction && this._startCurrentProfile(transaction);\n };\n\n private _startCurrentProfile = (transaction: Transaction): void => {\n this._finishCurrentProfile();\n\n const shouldStartProfiling = this._shouldStartProfiling(transaction);\n if (!shouldStartProfiling) {\n return;\n }\n\n this._currentProfileTimeout = setTimeout(this._finishCurrentProfile, MAX_PROFILE_DURATION_MS);\n this._startNewProfile(transaction);\n };\n\n private _shouldStartProfiling = (transaction: Transaction): boolean => {\n if (!transaction.sampled) {\n logger.log('[Profiling] Transaction is not sampled, skipping profiling');\n return false;\n }\n\n const client = this._getCurrentHub && this._getCurrentHub().getClient();\n const options = client && client.getOptions();\n\n const profilesSampleRate =\n options && options._experiments && typeof options._experiments.profilesSampleRate === 'number'\n ? options._experiments.profilesSampleRate\n : undefined;\n if (profilesSampleRate === undefined) {\n logger.log('[Profiling] Profiling disabled, enable it by setting `profilesSampleRate` option to SDK init call.');\n return false;\n }\n\n // Check if we should sample this profile\n if (Math.random() > profilesSampleRate) {\n logger.log('[Profiling] Skip profiling transaction due to sampling.');\n return false;\n }\n\n return true;\n };\n\n /**\n * Starts a new profile and links it to the transaction.\n */\n private _startNewProfile = (transaction: Transaction): void => {\n const profileStartTimestampNs = startProfiling();\n if (!profileStartTimestampNs) {\n return;\n }\n\n this._currentProfile = {\n profile_id: uuid4(),\n startTimestampNs: profileStartTimestampNs,\n };\n transaction.setContext('profile', { profile_id: this._currentProfile.profile_id });\n // @ts-expect-error profile_id is not part of the metadata type\n transaction.setMetadata({ profile_id: this._currentProfile.profile_id });\n logger.log('[Profiling] started profiling: ', this._currentProfile.profile_id);\n };\n\n /**\n * Stops profiling and adds the profile to the queue to be processed on beforeEnvelope.\n */\n private _finishCurrentProfile = (): void => {\n this._clearCurrentProfileTimeout();\n if (this._currentProfile === undefined) {\n return;\n }\n\n const profile = stopProfiling(this._currentProfile.startTimestampNs);\n if (!profile) {\n logger.warn('[Profiling] Stop failed. Cleaning up...');\n this._currentProfile = undefined;\n return;\n }\n\n PROFILE_QUEUE.add(this._currentProfile.profile_id, profile);\n\n logger.log('[Profiling] finished profiling: ', this._currentProfile.profile_id);\n this._currentProfile = undefined;\n };\n\n private _createProfileEventFor = (profiledTransaction: Event): ProfileEvent | null => {\n const profile_id = profiledTransaction?.contexts?.['profile']?.['profile_id'];\n\n if (typeof profile_id !== 'string') {\n logger.log('[Profiling] cannot find profile for a transaction without a profile context');\n return null;\n }\n\n // Remove the profile from the transaction context before sending, relay will take care of the rest.\n if (profiledTransaction?.contexts?.['.profile']) {\n delete profiledTransaction.contexts.profile;\n }\n\n const profile = PROFILE_QUEUE.get(profile_id);\n PROFILE_QUEUE.delete(profile_id);\n\n if (!profile) {\n logger.log(`[Profiling] cannot find profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n return null;\n }\n\n const profileWithEvent = enrichCombinedProfileWithEventContext(profile_id, profile, profiledTransaction);\n logger.log(`[Profiling] Created profile ${profile_id} for transaction ${profiledTransaction.event_id}`);\n\n return profileWithEvent;\n };\n\n private _clearCurrentProfileTimeout = (): void => {\n this._currentProfileTimeout !== undefined && clearTimeout(this._currentProfileTimeout);\n this._currentProfileTimeout = undefined;\n };\n}\n\n/**\n * Starts Profilers and returns the timestamp when profiling started in nanoseconds.\n */\nexport function startProfiling(): number | null {\n const started = NATIVE.startProfiling();\n if (!started) {\n return null;\n }\n\n return Date.now() * MS_TO_NS;\n}\n\n/**\n * Stops Profilers and returns collected combined profile.\n */\nexport function stopProfiling(\n profileStartTimestampNs: number,\n): CombinedProfileEvent | AndroidCombinedProfileEvent | null {\n const collectedProfiles = NATIVE.stopProfiling();\n if (!collectedProfiles) {\n return null;\n }\n const profileEndTimestampNs = Date.now() * MS_TO_NS;\n\n const hermesProfile = convertToSentryProfile(collectedProfiles.hermesProfile);\n if (!hermesProfile) {\n return null;\n }\n\n const hermesProfileEvent = createHermesProfilingEvent(hermesProfile);\n if (!hermesProfileEvent) {\n return null;\n }\n\n if (collectedProfiles.androidProfile) {\n const durationNs = profileEndTimestampNs - profileStartTimestampNs;\n return createAndroidWithHermesProfile(hermesProfileEvent, collectedProfiles.androidProfile, durationNs);\n } else if (collectedProfiles.nativeProfile) {\n return addNativeProfileToHermesProfile(hermesProfileEvent, collectedProfiles.nativeProfile);\n }\n\n return hermesProfileEvent;\n}\n\n/**\n * Creates Android profile event with attached javascript profile.\n */\nexport function createAndroidWithHermesProfile(\n hermes: HermesProfileEvent,\n nativeAndroid: NativeAndroidProfileEvent,\n durationNs: number,\n): AndroidCombinedProfileEvent {\n return {\n ...nativeAndroid,\n platform: 'android',\n js_profile: hermes.profile,\n duration_ns: durationNs.toString(10),\n active_thread_id: hermes.transaction.active_thread_id,\n };\n}\n\n/**\n * Merges Hermes and Native profile events into one.\n */\nexport function addNativeProfileToHermesProfile(\n hermes: HermesProfileEvent,\n native: NativeProfileEvent,\n): CombinedProfileEvent {\n return {\n ...hermes,\n profile: addNativeThreadCpuProfileToHermes(hermes.profile, native.profile, hermes.transaction.active_thread_id),\n debug_meta: {\n images: native.debug_meta.images,\n },\n measurements: native.measurements,\n };\n}\n\n/**\n * Merges Hermes And Native profiles into one.\n */\nexport function addNativeThreadCpuProfileToHermes(\n hermes: ThreadCpuProfile,\n native: ThreadCpuProfile,\n hermes_active_thread_id: string | undefined,\n): CombinedProfileEvent['profile'] {\n // assumes thread ids are unique\n hermes.thread_metadata = { ...native.thread_metadata, ...hermes.thread_metadata };\n // assumes queue ids are unique\n hermes.queue_metadata = { ...native.queue_metadata, ...hermes.queue_metadata };\n\n // recalculate frames and stacks using offset\n const framesOffset = hermes.frames.length;\n const stacksOffset = hermes.stacks.length;\n\n if (native.frames) {\n for (const frame of native.frames) {\n hermes.frames.push({\n function: frame.function,\n instruction_addr: frame.instruction_addr,\n platform: Platform.OS === 'ios' ? 'cocoa' : undefined,\n });\n }\n }\n hermes.stacks = [\n ...(hermes.stacks || []),\n ...(native.stacks || []).map(stack => stack.map(frameId => frameId + framesOffset)),\n ];\n hermes.samples = [\n ...(hermes.samples || []),\n ...(native.samples || [])\n .filter(sample => sample.thread_id !== hermes_active_thread_id)\n .map(sample => ({\n ...sample,\n stack_id: stacksOffset + sample.stack_id,\n })),\n ];\n\n return hermes;\n}\n"]}
@@ -40,4 +40,12 @@ export interface NativeProfileEvent {
40
40
  }[];
41
41
  };
42
42
  }
43
+ export interface NativeAndroidProfileEvent {
44
+ sampled_profile: string;
45
+ android_api_level: number;
46
+ /**
47
+ * Proguard mapping file hash
48
+ */
49
+ build_id?: string;
50
+ }
43
51
  //# sourceMappingURL=nativeTypes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nativeTypes.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/nativeTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,OAAO,EAAE;YACP,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,sBAAsB,EAAE,MAAM,CAAC;SAChC,EAAE,CAAC;QACJ,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QACnB,MAAM,EAAE;YACN,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;SAC3B,EAAE,CAAC;QACJ,eAAe,EAAE,MAAM,CACrB,MAAM,EACN;YACE,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CACF,CAAC;QACF,cAAc,CAAC,EAAE,MAAM,CACrB,MAAM,EACN;YACE,KAAK,EAAE,MAAM,CAAC;SACf,CACF,CAAC;KACH,CAAC;IACF,WAAW,EAAE;QACX,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,YAAY,EAAE,MAAM,CAClB,MAAM,EACN;QACE,MAAM,EAAE;YACN,sBAAsB,EAAE,MAAM,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC;SACf,EAAE,CAAC;QACJ,IAAI,EAAE,MAAM,CAAC;KACd,CACF,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,OAAO,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,UAAU,EAAE,MAAM,CAAC;YACnB,SAAS,EAAE,MAAM,CAAC;SACnB,EAAE,CAAC;KACL,CAAC;CACH"}
1
+ {"version":3,"file":"nativeTypes.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/nativeTypes.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE;QACP,OAAO,EAAE;YACP,QAAQ,EAAE,MAAM,CAAC;YACjB,SAAS,EAAE,MAAM,CAAC;YAClB,aAAa,CAAC,EAAE,MAAM,CAAC;YACvB,sBAAsB,EAAE,MAAM,CAAC;SAChC,EAAE,CAAC;QACJ,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;QACnB,MAAM,EAAE;YACN,QAAQ,CAAC,EAAE,MAAM,CAAC;YAClB,gBAAgB,CAAC,EAAE,MAAM,CAAC;SAC3B,EAAE,CAAC;QACJ,eAAe,EAAE,MAAM,CACrB,MAAM,EACN;YACE,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,QAAQ,CAAC,EAAE,MAAM,CAAC;SACnB,CACF,CAAC;QACF,cAAc,CAAC,EAAE,MAAM,CACrB,MAAM,EACN;YACE,KAAK,EAAE,MAAM,CAAC;SACf,CACF,CAAC;KACH,CAAC;IACF,WAAW,EAAE;QACX,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,YAAY,EAAE,MAAM,CAClB,MAAM,EACN;QACE,MAAM,EAAE;YACN,sBAAsB,EAAE,MAAM,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC;SACf,EAAE,CAAC;QACJ,IAAI,EAAE,MAAM,CAAC;KACd,CACF,CAAC;IACF,UAAU,EAAE;QACV,MAAM,EAAE;YACN,IAAI,EAAE,OAAO,CAAC;YACd,QAAQ,EAAE,MAAM,CAAC;YACjB,UAAU,EAAE,MAAM,CAAC;YACnB,UAAU,EAAE,MAAM,CAAC;YACnB,SAAS,EAAE,MAAM,CAAC;SACnB,EAAE,CAAC;KACL,CAAC;CACH;AAED,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"nativeTypes.js","sourceRoot":"","sources":["../../../src/js/profiling/nativeTypes.ts"],"names":[],"mappings":"","sourcesContent":["export interface NativeProfileEvent {\n profile_id: string;\n profile: {\n samples: {\n stack_id: number;\n thread_id: string;\n queue_address?: string;\n elapsed_since_start_ns: string;\n }[];\n stacks: number[][];\n frames: {\n function?: string;\n instruction_addr?: string;\n }[];\n thread_metadata: Record<\n string,\n {\n name?: string;\n priority?: number;\n }\n >;\n queue_metadata?: Record<\n string,\n {\n label: string;\n }\n >;\n };\n transaction: {\n active_thread_id: string;\n };\n measurements: Record<\n string,\n {\n values: {\n elapsed_since_start_ns: number;\n value: number;\n }[];\n unit: string;\n }\n >;\n debug_meta: {\n images: {\n type: 'macho';\n debug_id: string;\n image_addr: string;\n image_size: number;\n code_file: string;\n }[];\n };\n}\n"]}
1
+ {"version":3,"file":"nativeTypes.js","sourceRoot":"","sources":["../../../src/js/profiling/nativeTypes.ts"],"names":[],"mappings":"","sourcesContent":["export interface NativeProfileEvent {\n profile_id: string;\n profile: {\n samples: {\n stack_id: number;\n thread_id: string;\n queue_address?: string;\n elapsed_since_start_ns: string;\n }[];\n stacks: number[][];\n frames: {\n function?: string;\n instruction_addr?: string;\n }[];\n thread_metadata: Record<\n string,\n {\n name?: string;\n priority?: number;\n }\n >;\n queue_metadata?: Record<\n string,\n {\n label: string;\n }\n >;\n };\n transaction: {\n active_thread_id: string;\n };\n measurements: Record<\n string,\n {\n values: {\n elapsed_since_start_ns: number;\n value: number;\n }[];\n unit: string;\n }\n >;\n debug_meta: {\n images: {\n type: 'macho';\n debug_id: string;\n image_addr: string;\n image_size: number;\n code_file: string;\n }[];\n };\n}\n\nexport interface NativeAndroidProfileEvent {\n sampled_profile: string;\n android_api_level: number;\n /**\n * Proguard mapping file hash\n */\n build_id?: string;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Profile, ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
1
+ import type { DebugImage, MeasurementUnit, Profile, ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
2
2
  import type { NativeProfileEvent } from './nativeTypes';
3
3
  export interface RawThreadCpuProfile extends ThreadCpuProfile {
4
4
  frames: ThreadCpuFrame[];
@@ -13,6 +13,63 @@ export type HermesProfileEvent = {
13
13
  active_thread_id: string;
14
14
  };
15
15
  };
16
- export type ProfileEvent = Profile;
16
+ export type AndroidCombinedProfileEvent = {
17
+ platform: 'android';
18
+ /**
19
+ * Proguard debug meta image uuid
20
+ */
21
+ build_id?: string | undefined;
22
+ sampled_profile: string;
23
+ js_profile: ThreadCpuProfile;
24
+ android_api_level: number;
25
+ duration_ns: string;
26
+ active_thread_id: string;
27
+ };
28
+ export type AndroidProfileEvent = {
29
+ sampled_profile: string;
30
+ /**
31
+ * Currently used only for JS
32
+ */
33
+ debug_meta?: {
34
+ images: DebugImage[];
35
+ };
36
+ js_profile: ThreadCpuProfile;
37
+ android_api_level: number;
38
+ /**
39
+ * Proguard debug meta image uuid
40
+ */
41
+ build_id: string;
42
+ device_cpu_frequencies: number[];
43
+ device_is_emulator: boolean;
44
+ device_locale: string;
45
+ device_manufacturer: string;
46
+ device_model: string;
47
+ device_os_name: string;
48
+ device_os_version: string;
49
+ device_physical_memory_bytes: string;
50
+ environment: string;
51
+ platform: 'android';
52
+ profile_id: string;
53
+ timestamp: string;
54
+ release: string;
55
+ dist: string;
56
+ version_code: string;
57
+ version_name: string;
58
+ transaction_id: string;
59
+ transaction_name: string;
60
+ trace_id: string;
61
+ duration_ns: string;
62
+ active_thread_id: string;
63
+ measurements?: Record<string, {
64
+ unit: MeasurementUnit;
65
+ values: {
66
+ elapsed_since_start_ns: number;
67
+ value: number;
68
+ }[];
69
+ }>;
70
+ transaction_metadata?: Record<string, string>;
71
+ transaction_tags?: Record<string, string>;
72
+ };
73
+ export type ProfileEvent = Profile | AndroidProfileEvent;
17
74
  export type CombinedProfileEvent = HermesProfileEvent & Partial<NativeProfileEvent>;
18
75
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAExD,MAAM,WAA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;IAEF,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,mBAAmB,CAAC;AAEzD,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Profile, ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';\n\nimport type { NativeProfileEvent } from './nativeTypes';\n\nexport interface RawThreadCpuProfile extends ThreadCpuProfile {\n frames: ThreadCpuFrame[];\n profile_id?: string;\n active_thread_id: string;\n}\n\nexport type HermesProfileEvent = {\n platform: 'javascript';\n version: '1';\n profile: ThreadCpuProfile;\n transaction: {\n active_thread_id: string;\n };\n};\n\nexport type ProfileEvent = Profile;\n\nexport type CombinedProfileEvent = HermesProfileEvent & Partial<NativeProfileEvent>;\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DebugImage, MeasurementUnit, Profile, ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';\n\nimport type { NativeProfileEvent } from './nativeTypes';\n\nexport interface RawThreadCpuProfile extends ThreadCpuProfile {\n frames: ThreadCpuFrame[];\n profile_id?: string;\n active_thread_id: string;\n}\n\nexport type HermesProfileEvent = {\n platform: 'javascript';\n version: '1';\n profile: ThreadCpuProfile;\n transaction: {\n active_thread_id: string;\n };\n};\n\n/*\n * Android profile with javascript without transaction metadata\n */\nexport type AndroidCombinedProfileEvent = {\n platform: 'android';\n /**\n * Proguard debug meta image uuid\n */\n build_id?: string | undefined;\n sampled_profile: string;\n js_profile: ThreadCpuProfile;\n android_api_level: number;\n duration_ns: string;\n active_thread_id: string;\n};\n\n/*\n * Complete Android profile with javascript and transaction metadata\n */\nexport type AndroidProfileEvent = {\n sampled_profile: string;\n /**\n * Currently used only for JS\n */\n debug_meta?: {\n images: DebugImage[];\n };\n js_profile: ThreadCpuProfile;\n\n android_api_level: number;\n /**\n * Proguard debug meta image uuid\n */\n build_id: string;\n\n device_cpu_frequencies: number[];\n device_is_emulator: boolean;\n device_locale: string;\n device_manufacturer: string;\n device_model: string;\n device_os_name: string;\n device_os_version: string;\n\n device_physical_memory_bytes: string;\n\n environment: string;\n\n platform: 'android';\n profile_id: string;\n\n timestamp: string;\n\n release: string;\n dist: string;\n\n version_code: string;\n version_name: string;\n\n transaction_id: string;\n transaction_name: string;\n trace_id: string;\n duration_ns: string;\n active_thread_id: string;\n\n measurements?: Record<\n string,\n {\n unit: MeasurementUnit;\n values: {\n elapsed_since_start_ns: number;\n value: number;\n }[];\n }\n >;\n\n transaction_metadata?: Record<string, string>;\n transaction_tags?: Record<string, string>;\n};\n\nexport type ProfileEvent = Profile | AndroidProfileEvent;\n\nexport type CombinedProfileEvent = HermesProfileEvent & Partial<NativeProfileEvent>;\n"]}
@@ -1,5 +1,5 @@
1
- import type { Envelope, Event, Profile, ThreadCpuProfile } from '@sentry/types';
2
- import type { CombinedProfileEvent, HermesProfileEvent, RawThreadCpuProfile } from './types';
1
+ import type { Envelope, Event, ThreadCpuProfile } from '@sentry/types';
2
+ import type { AndroidCombinedProfileEvent, AndroidProfileEvent, CombinedProfileEvent, HermesProfileEvent, ProfileEvent, RawThreadCpuProfile } from './types';
3
3
  /**
4
4
  *
5
5
  */
@@ -15,9 +15,13 @@ export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope)
15
15
  /**
16
16
  * Creates a profiling envelope item, if the profile does not pass validation, returns null.
17
17
  * @param event
18
- * @returns {Profile | null}
18
+ * @returns {ProfileEvent | null}
19
19
  */
20
- export declare function enrichCombinedProfileWithEventContext(profile_id: string, profile: CombinedProfileEvent, event: Event): Profile | null;
20
+ export declare function enrichCombinedProfileWithEventContext(profile_id: string, profile: CombinedProfileEvent | AndroidCombinedProfileEvent, event: Event): ProfileEvent | null;
21
+ /**
22
+ * Creates Android profiling envelope item.
23
+ */
24
+ export declare function enrichAndroidProfileWithEventContext(profile_id: string, profile: AndroidCombinedProfileEvent, event: Event): AndroidProfileEvent | null;
21
25
  /**
22
26
  * Creates profiling event compatible carrier Object from raw Hermes profile.
23
27
  */
@@ -26,5 +30,5 @@ export declare function createHermesProfilingEvent(profile: RawThreadCpuProfile)
26
30
  * Adds items to envelope if they are not already present - mutates the envelope.
27
31
  * @param envelope
28
32
  */
29
- export declare function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope;
33
+ export declare function addProfilesToEnvelope(envelope: Envelope, profiles: ProfileEvent[]): Envelope;
30
34
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE7F;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,IAAI,mBAAmB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAWjH;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAqBhF;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,EAC7B,KAAK,EAAE,KAAK,GACX,OAAO,GAAG,IAAI,CAgDhB;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAS3F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,QAAQ,CAUvF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKvE,OAAO,KAAK,EACV,2BAA2B,EAC3B,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,YAAY,EACZ,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,IAAI,mBAAmB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAWjH;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAqBhF;AAED;;;;GAIG;AACH,wBAAgB,qCAAqC,CACnD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,oBAAoB,GAAG,2BAA2B,EAC3D,KAAK,EAAE,KAAK,GACX,YAAY,GAAG,IAAI,CAoDrB;AAED;;GAEG;AACH,wBAAgB,oCAAoC,CAClD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,2BAA2B,EACpC,KAAK,EAAE,KAAK,GACX,mBAAmB,GAAG,IAAI,CAuC5B;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAS3F;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,QAAQ,CAU5F"}
@@ -42,9 +42,12 @@ export function findProfiledTransactionsFromEnvelope(envelope) {
42
42
  /**
43
43
  * Creates a profiling envelope item, if the profile does not pass validation, returns null.
44
44
  * @param event
45
- * @returns {Profile | null}
45
+ * @returns {ProfileEvent | null}
46
46
  */
47
47
  export function enrichCombinedProfileWithEventContext(profile_id, profile, event) {
48
+ if ('js_profile' in profile) {
49
+ return enrichAndroidProfileWithEventContext(profile_id, profile, event);
50
+ }
48
51
  if (!profile.profile || !isValidProfile(profile.profile)) {
49
52
  return null;
50
53
  }
@@ -79,6 +82,18 @@ export function enrichCombinedProfileWithEventContext(profile_id, profile, event
79
82
  images: [...getDebugMetadata(), ...((profile.debug_meta && profile.debug_meta.images) || [])],
80
83
  } });
81
84
  }
85
+ /**
86
+ * Creates Android profiling envelope item.
87
+ */
88
+ export function enrichAndroidProfileWithEventContext(profile_id, profile, event) {
89
+ return Object.assign(Object.assign({}, profile), { debug_meta: {
90
+ images: getDebugMetadata(),
91
+ }, build_id: profile.build_id || '', device_cpu_frequencies: [], device_is_emulator: (event.contexts && event.contexts.device && event.contexts.device.simulator) || false, device_locale: (event.contexts && event.contexts.device && event.contexts.device.locale) || '', device_manufacturer: (event.contexts && event.contexts.device && event.contexts.device.manufacturer) || '', device_model: (event.contexts && event.contexts.device && event.contexts.device.model) || '', device_os_name: (event.contexts && event.contexts.os && event.contexts.os.name) || '', device_os_version: (event.contexts && event.contexts.os && event.contexts.os.version) || '', device_physical_memory_bytes: (event.contexts &&
92
+ event.contexts.device &&
93
+ event.contexts.device.memory_size &&
94
+ Number(event.contexts.device.memory_size).toString(10)) ||
95
+ '', environment: event.environment || getDefaultEnvironment(), profile_id, timestamp: event.start_timestamp ? new Date(event.start_timestamp * 1000).toISOString() : new Date().toISOString(), release: event.release || '', dist: event.dist || '', transaction_id: event.event_id || '', transaction_name: event.transaction || '', trace_id: (event.contexts && event.contexts.trace && event.contexts.trace.trace_id) || '', version_name: event.release || '', version_code: event.dist || '' });
96
+ }
82
97
  /**
83
98
  * Creates profiling event compatible carrier Object from raw Hermes profile.
84
99
  */