@sentry/react-native 5.17.0 → 5.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +1 -1
  3. package/RNSentry.podspec +1 -1
  4. package/android/build.gradle +1 -1
  5. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +117 -26
  6. package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +4 -3
  7. package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +6 -5
  8. package/dist/js/NativeRNSentry.d.ts +3 -2
  9. package/dist/js/NativeRNSentry.d.ts.map +1 -1
  10. package/dist/js/NativeRNSentry.js.map +1 -1
  11. package/dist/js/client.d.ts.map +1 -1
  12. package/dist/js/client.js +14 -19
  13. package/dist/js/client.js.map +1 -1
  14. package/dist/js/index.d.ts +1 -1
  15. package/dist/js/index.d.ts.map +1 -1
  16. package/dist/js/index.js +5 -1
  17. package/dist/js/index.js.map +1 -1
  18. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  19. package/dist/js/integrations/debugsymbolicator.js +22 -6
  20. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  21. package/dist/js/integrations/default.d.ts.map +1 -1
  22. package/dist/js/integrations/default.js +6 -0
  23. package/dist/js/integrations/default.js.map +1 -1
  24. package/dist/js/integrations/index.d.ts +1 -0
  25. package/dist/js/integrations/index.d.ts.map +1 -1
  26. package/dist/js/integrations/index.js +1 -0
  27. package/dist/js/integrations/index.js.map +1 -1
  28. package/dist/js/integrations/nativelinkederrors.d.ts +6 -2
  29. package/dist/js/integrations/nativelinkederrors.d.ts.map +1 -1
  30. package/dist/js/integrations/nativelinkederrors.js +63 -72
  31. package/dist/js/integrations/nativelinkederrors.js.map +1 -1
  32. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  33. package/dist/js/integrations/reactnativeerrorhandlers.js +2 -0
  34. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  35. package/dist/js/integrations/rewriteframes.d.ts +2 -2
  36. package/dist/js/integrations/rewriteframes.d.ts.map +1 -1
  37. package/dist/js/integrations/rewriteframes.js.map +1 -1
  38. package/dist/js/integrations/spotlight.d.ts +18 -0
  39. package/dist/js/integrations/spotlight.d.ts.map +1 -0
  40. package/dist/js/integrations/spotlight.js +84 -0
  41. package/dist/js/integrations/spotlight.js.map +1 -0
  42. package/dist/js/options.d.ts +19 -0
  43. package/dist/js/options.d.ts.map +1 -1
  44. package/dist/js/options.js.map +1 -1
  45. package/dist/js/profiling/cache.d.ts +3 -3
  46. package/dist/js/profiling/cache.d.ts.map +1 -1
  47. package/dist/js/profiling/cache.js.map +1 -1
  48. package/dist/js/profiling/integration.d.ts +7 -3
  49. package/dist/js/profiling/integration.d.ts.map +1 -1
  50. package/dist/js/profiling/integration.js +16 -5
  51. package/dist/js/profiling/integration.js.map +1 -1
  52. package/dist/js/profiling/nativeTypes.d.ts +8 -0
  53. package/dist/js/profiling/nativeTypes.d.ts.map +1 -1
  54. package/dist/js/profiling/nativeTypes.js.map +1 -1
  55. package/dist/js/profiling/types.d.ts +59 -2
  56. package/dist/js/profiling/types.d.ts.map +1 -1
  57. package/dist/js/profiling/types.js.map +1 -1
  58. package/dist/js/profiling/utils.d.ts +9 -5
  59. package/dist/js/profiling/utils.d.ts.map +1 -1
  60. package/dist/js/profiling/utils.js +16 -1
  61. package/dist/js/profiling/utils.js.map +1 -1
  62. package/dist/js/sdk.d.ts +1 -1
  63. package/dist/js/sdk.d.ts.map +1 -1
  64. package/dist/js/sdk.js +3 -2
  65. package/dist/js/sdk.js.map +1 -1
  66. package/dist/js/tools/sentryMetroSerializer.js +1 -0
  67. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  68. package/dist/js/tracing/addTracingExtensions.d.ts.map +1 -1
  69. package/dist/js/tracing/addTracingExtensions.js.map +1 -1
  70. package/dist/js/tracing/nativeframes.d.ts.map +1 -1
  71. package/dist/js/tracing/nativeframes.js +3 -1
  72. package/dist/js/tracing/nativeframes.js.map +1 -1
  73. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  74. package/dist/js/tracing/reactnativetracing.js +3 -1
  75. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  76. package/dist/js/utils/worldwide.d.ts +2 -0
  77. package/dist/js/utils/worldwide.d.ts.map +1 -1
  78. package/dist/js/utils/worldwide.js.map +1 -1
  79. package/dist/js/utils/xhr.d.ts +20 -0
  80. package/dist/js/utils/xhr.d.ts.map +1 -0
  81. package/dist/js/utils/xhr.js +31 -0
  82. package/dist/js/utils/xhr.js.map +1 -0
  83. package/dist/js/version.d.ts +1 -1
  84. package/dist/js/version.js +1 -1
  85. package/dist/js/version.js.map +1 -1
  86. package/dist/js/wrapper.d.ts +4 -3
  87. package/dist/js/wrapper.d.ts.map +1 -1
  88. package/dist/js/wrapper.js +19 -19
  89. package/dist/js/wrapper.js.map +1 -1
  90. package/ios/RNSentry.mm +5 -8
  91. package/package.json +16 -12
  92. package/scripts/expo-upload-sourcemaps.js +54 -12
  93. package/scripts/sentry-xcode-debug-files.sh +5 -2
  94. package/src/js/NativeRNSentry.ts +8 -3
  95. package/ts3.8/dist/js/NativeRNSentry.d.ts +3 -2
  96. package/ts3.8/dist/js/index.d.ts +1 -1
  97. package/ts3.8/dist/js/integrations/index.d.ts +1 -0
  98. package/ts3.8/dist/js/integrations/nativelinkederrors.d.ts +6 -2
  99. package/ts3.8/dist/js/integrations/rewriteframes.d.ts +2 -2
  100. package/ts3.8/dist/js/integrations/spotlight.d.ts +18 -0
  101. package/ts3.8/dist/js/options.d.ts +19 -0
  102. package/ts3.8/dist/js/profiling/cache.d.ts +3 -3
  103. package/ts3.8/dist/js/profiling/integration.d.ts +7 -3
  104. package/ts3.8/dist/js/profiling/nativeTypes.d.ts +8 -0
  105. package/ts3.8/dist/js/profiling/types.d.ts +59 -2
  106. package/ts3.8/dist/js/profiling/utils.d.ts +9 -5
  107. package/ts3.8/dist/js/sdk.d.ts +1 -1
  108. package/ts3.8/dist/js/utils/worldwide.d.ts +2 -0
  109. package/ts3.8/dist/js/utils/xhr.d.ts +20 -0
  110. package/ts3.8/dist/js/version.d.ts +1 -1
  111. package/ts3.8/dist/js/wrapper.d.ts +4 -3
@@ -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/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,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACnB,OAAO,KAAK,CAAC;aACd;YACD,OAAO,KAAK,CAAC,QAAQ,CAAC;YAEtB,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ;iBAC5B,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;iBACzB,OAAO,CAAC,cAAc,EAAE,EAAE,CAAC;iBAC3B,OAAO,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC;YAEtD,IAAI,KAAK,CAAC,QAAQ,KAAK,eAAe,IAAI,KAAK,CAAC,QAAQ,KAAK,QAAQ,EAAE;gBACrE,OAAO,KAAK,CAAC;aACd;YACD,wBAAwB;YAExB,4DAA4D;YAC5D,IAAI,eAAe,EAAE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE;gBACxE,oEAAoE;gBACpE,yFAAyF;gBACzF,wEAAwE;gBACxE,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;aAClB;YAED,4CAA4C;YAC5C,IAAI,MAAM,EAAE,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;gBACzC,KAAK,CAAC,QAAQ,GAAG,2BAA2B,CAAC;gBAC7C,OAAO,KAAK,CAAC;aACd;YAED,IAAI,MAAM,EAAE,IAAI,QAAQ,CAAC,EAAE,KAAK,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,OAA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;aACd;YAED,IAAI,MAAM,EAAE,IAAI,QAAQ,CAAC,EAAE,KAAK,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 { 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"]}
@@ -0,0 +1,18 @@
1
+ import type { Integration } from '@sentry/types';
2
+ type SpotlightReactNativeIntegrationOptions = {
3
+ /**
4
+ * The URL of the Sidecar instance to connect and forward events to.
5
+ * If not set, Spotlight will try to connect to the Sidecar running on localhost:8969.
6
+ *
7
+ * @default "http://localhost:8969/stream"
8
+ */
9
+ sidecarUrl?: string;
10
+ };
11
+ /**
12
+ * Use this integration to send errors and transactions to Spotlight.
13
+ *
14
+ * Learn more about spotlight at https://spotlightjs.com
15
+ */
16
+ export declare function Spotlight({ sidecarUrl, }?: SpotlightReactNativeIntegrationOptions): Integration;
17
+ export {};
18
+ //# sourceMappingURL=spotlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotlight.d.ts","sourceRoot":"","sources":["../../../src/js/integrations/spotlight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoC,WAAW,EAAE,MAAM,eAAe,CAAC;AAOnF,KAAK,sCAAsC,GAAG;IAC5C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EACxB,UAAmC,GACpC,GAAE,sCAA2C,GAAG,WAAW,CAe3D"}
@@ -0,0 +1,84 @@
1
+ import { logger, serializeEnvelope } from '@sentry/utils';
2
+ import { makeUtf8TextEncoder } from '../transports/TextEncoder';
3
+ import { ReactNativeLibraries } from '../utils/rnlibraries';
4
+ import { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';
5
+ /**
6
+ * Use this integration to send errors and transactions to Spotlight.
7
+ *
8
+ * Learn more about spotlight at https://spotlightjs.com
9
+ */
10
+ export function Spotlight({ sidecarUrl = getDefaultSidecarUrl(), } = {}) {
11
+ logger.info('[Spotlight] Using Sidecar URL', sidecarUrl);
12
+ return {
13
+ name: 'Spotlight',
14
+ setupOnce(_, getCurrentHub) {
15
+ const client = getCurrentHub().getClient();
16
+ if (client) {
17
+ setup(client, sidecarUrl);
18
+ }
19
+ else {
20
+ logger.warn('[Spotlight] Could not initialize Sidecar integration due to missing Client');
21
+ }
22
+ },
23
+ };
24
+ }
25
+ function setup(client, sidecarUrl) {
26
+ sendEnvelopesToSidecar(client, sidecarUrl);
27
+ }
28
+ function sendEnvelopesToSidecar(client, sidecarUrl) {
29
+ if (!client.on) {
30
+ return;
31
+ }
32
+ client.on('beforeEnvelope', (originalEnvelope) => {
33
+ // TODO: This is a workaround for spotlight/sidecar not supporting images
34
+ const spotlightEnvelope = [...originalEnvelope];
35
+ const envelopeItems = [...originalEnvelope[1]].filter(item => typeof item[0].content_type !== 'string' || !item[0].content_type.startsWith('image'));
36
+ spotlightEnvelope[1] = envelopeItems;
37
+ const xhr = createStealthXhr();
38
+ if (!xhr) {
39
+ logger.error('[Spotlight] Sentry SDK can not create XHR object');
40
+ return;
41
+ }
42
+ xhr.open('POST', sidecarUrl, true);
43
+ xhr.setRequestHeader('Content-Type', 'application/x-sentry-envelope');
44
+ xhr.onreadystatechange = function () {
45
+ if (xhr.readyState === XHR_READYSTATE_DONE) {
46
+ const status = xhr.status;
47
+ if (status === 0 || (status >= 200 && status < 400)) {
48
+ // The request has been completed successfully
49
+ }
50
+ else {
51
+ // Handle the error
52
+ logger.error("[Spotlight] Sentry SDK can't connect to Spotlight is it running? See https://spotlightjs.com to download it.", new Error(xhr.statusText));
53
+ }
54
+ }
55
+ };
56
+ xhr.send(serializeEnvelope(spotlightEnvelope, makeUtf8TextEncoder()));
57
+ });
58
+ }
59
+ function getDefaultSidecarUrl() {
60
+ var _a;
61
+ try {
62
+ const { url } = (_a = ReactNativeLibraries.Devtools) === null || _a === void 0 ? void 0 : _a.getDevServer();
63
+ return `http://${getHostnameFromString(url)}:8969/stream`;
64
+ }
65
+ catch (_oO) {
66
+ // We can't load devserver URL
67
+ }
68
+ return 'http://localhost:8969/stream';
69
+ }
70
+ /**
71
+ * React Native implementation of the URL class is missing the `hostname` property.
72
+ */
73
+ function getHostnameFromString(urlString) {
74
+ const regex = /^(?:\w+:)?\/\/([^/:]+)(:\d+)?(.*)$/;
75
+ const matches = urlString.match(regex);
76
+ if (matches && matches[1]) {
77
+ return matches[1];
78
+ }
79
+ else {
80
+ // Invalid URL format
81
+ return null;
82
+ }
83
+ }
84
+ //# sourceMappingURL=spotlight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotlight.js","sourceRoot":"","sources":["../../../src/js/integrations/spotlight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAYrE;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,UAAU,GAAG,oBA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Content":["import type { Client, Envelope, EventProcessor, Integration } from '@sentry/types';\nimport { logger, serializeEnvelope } from '@sentry/utils';\n\nimport { makeUtf8TextEncoder } from '../transports/TextEncoder';\nimport { ReactNativeLibraries } from '../utils/rnlibraries';\nimport { createStealthXhr, XHR_READYSTATE_DONE } from '../utils/xhr';\n\ntype SpotlightReactNativeIntegrationOptions = {\n /**\n * The URL of the Sidecar instance to connect and forward events to.\n * If not set, Spotlight will try to connect to the Sidecar running on localhost:8969.\n *\n * @default \"http://localhost:8969/stream\"\n */\n sidecarUrl?: string;\n};\n\n/**\n * Use this integration to send errors and transactions to Spotlight.\n *\n * Learn more about spotlight at https://spotlightjs.com\n */\nexport function Spotlight({\n sidecarUrl = getDefaultSidecarUrl(),\n}: SpotlightReactNativeIntegrationOptions = {}): Integration {\n logger.info('[Spotlight] Using Sidecar URL', sidecarUrl);\n\n return {\n name: 'Spotlight',\n\n setupOnce(_: (callback: EventProcessor) => void, getCurrentHub) {\n const client = getCurrentHub().getClient();\n if (client) {\n setup(client, sidecarUrl);\n } else {\n logger.warn('[Spotlight] Could not initialize Sidecar integration due to missing Client');\n }\n },\n };\n}\n\nfunction setup(client: Client, sidecarUrl: string): void {\n sendEnvelopesToSidecar(client, sidecarUrl);\n}\n\nfunction sendEnvelopesToSidecar(client: Client, sidecarUrl: string): void {\n if (!client.on) {\n return;\n }\n\n client.on('beforeEnvelope', (originalEnvelope: Envelope) => {\n // TODO: This is a workaround for spotlight/sidecar not supporting images\n const spotlightEnvelope: Envelope = [...originalEnvelope];\n const envelopeItems = [...originalEnvelope[1]].filter(\n item => typeof item[0].content_type !== 'string' || !item[0].content_type.startsWith('image'),\n );\n\n spotlightEnvelope[1] = envelopeItems as Envelope[1];\n\n const xhr = createStealthXhr();\n if (!xhr) {\n logger.error('[Spotlight] Sentry SDK can not create XHR object');\n return;\n }\n\n xhr.open('POST', sidecarUrl, true);\n xhr.setRequestHeader('Content-Type', 'application/x-sentry-envelope');\n\n xhr.onreadystatechange = function () {\n if (xhr.readyState === XHR_READYSTATE_DONE) {\n const status = xhr.status;\n if (status === 0 || (status >= 200 && status < 400)) {\n // The request has been completed successfully\n } else {\n // Handle the error\n logger.error(\n \"[Spotlight] Sentry SDK can't connect to Spotlight is it running? See https://spotlightjs.com to download it.\",\n new Error(xhr.statusText),\n );\n }\n }\n };\n\n xhr.send(serializeEnvelope(spotlightEnvelope, makeUtf8TextEncoder()));\n });\n}\n\nfunction getDefaultSidecarUrl(): string {\n try {\n const { url } = ReactNativeLibraries.Devtools?.getDevServer();\n return `http://${getHostnameFromString(url)}:8969/stream`;\n } catch (_oO) {\n // We can't load devserver URL\n }\n return 'http://localhost:8969/stream';\n}\n\n/**\n * React Native implementation of the URL class is missing the `hostname` property.\n */\nfunction getHostnameFromString(urlString: string): string | null {\n const regex = /^(?:\\w+:)?\\/\\/([^/:]+)(:\\d+)?(.*)$/;\n const matches = urlString.match(regex);\n\n if (matches && matches[1]) {\n return matches[1];\n } else {\n // Invalid URL format\n return null;\n }\n}\n"]}
@@ -134,6 +134,25 @@ export interface BaseReactNativeOptions {
134
134
  * @default false
135
135
  */
136
136
  enableCaptureFailedRequests?: boolean;
137
+ /**
138
+ * This option will enable forwarding captured Sentry events to Spotlight.
139
+ *
140
+ * More details: https://spotlightjs.com/
141
+ *
142
+ * IMPORTANT: Only set this option to `true` while developing, not in production!
143
+ */
144
+ enableSpotlight?: boolean;
145
+ /**
146
+ * This option changes the default Spotlight Sidecar URL.
147
+ *
148
+ * By default, the SDK expects the Sidecar to be running
149
+ * on the same host as React Native Metro Dev Server.
150
+ *
151
+ * More details: https://spotlightjs.com/
152
+ *
153
+ * @default "http://localhost:8969/stream"
154
+ */
155
+ spotlightSidecarUrl?: string;
137
156
  }
138
157
  export interface ReactNativeTransportOptions extends BrowserTransportOptions {
139
158
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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AE1B;;;;;;;;;OASG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,2BAA4B,SAAQ,uBAAuB;IAC1E;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AAEH,MAAM,WAAW,kBAAmB,SAAQ,OAAO,CAAC,2BAA2B,CAAC,EAAE,sBAAsB;CAAG;AAE3G,MAAM,WAAW,wBAAyB,SAAQ,aAAa,CAAC,2BAA2B,CAAC,EAAE,sBAAsB;CAAG;AAEvH,MAAM,WAAW,yBAAyB;IACxC,wCAAwC;IACxC,aAAa,CAAC,EAAE,aAAa,CAAC;IAE9B,8CAA8C;IAC9C,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAkBtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAqLvD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,WAAoB;IAC3D,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE;QACpC,yCAAyC;QACzC,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QACtD,oEAAoE;QACpE,OAAO,KAAK,CAAC;KACd;IAED,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,IAAI,aAAa,IAAI,aAAa,CAAC,YAAY,KAAK,MAAM,EAAE;QAC1D,yDAAyD;QACzD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { BrowserTransportOptions } from '@sentry/browser/types/transports/types';\nimport type { ProfilerProps } from '@sentry/react/types/profiler';\nimport type { CaptureContext, ClientOptions, Options } from '@sentry/types';\nimport { Platform } from 'react-native';\n\nimport type { TouchEventBoundaryProps } from './touchevents';\nimport { getExpoConstants } from './utils/expomodules';\n\nexport interface BaseReactNativeOptions {\n /**\n * Enables native transport + device info + offline caching.\n * Be careful, disabling this also breaks automatic release setting.\n * This means you have to manage setting the release yourself.\n * Defaults to `true`.\n */\n enableNative?: boolean;\n\n /**\n * Enables native crashHandling. This only works if `enableNative` is `true`.\n * Defaults to `true`.\n */\n enableNativeCrashHandling?: boolean;\n\n /**\n * Initializes the native SDK on init.\n * Set this to `false` if you have an existing native SDK and don't want to re-initialize.\n *\n * NOTE: Be careful and only use this if you know what you are doing.\n * If you use this flag, make sure a native SDK is running before the JS Engine initializes or events might not be captured.\n * Also, make sure the DSN on both the React Native side and the native side are the same one.\n * We strongly recommend checking the documentation if you need to use this.\n *\n * @default true\n */\n autoInitializeNativeSdk?: boolean;\n\n /** Should the native nagger alert be shown or not. */\n enableNativeNagger?: boolean;\n\n /** Should sessions be tracked to Sentry Health or not. */\n enableAutoSessionTracking?: boolean;\n\n /** The interval to end a session if the App goes to the background. */\n sessionTrackingIntervalMillis?: number;\n\n /** Enable NDK on Android\n *\n * @default true\n */\n enableNdk?: boolean;\n\n /** Enable scope sync from Java to NDK on Android\n * Only has an effect if `enableNdk` is `true`.\n */\n enableNdkScopeSync?: boolean;\n\n /** When enabled, all the threads are automatically attached to all logged events on Android */\n attachThreads?: boolean;\n\n /**\n * When enabled, certain personally identifiable information (PII) is added by active integrations.\n *\n * @default false\n */\n sendDefaultPii?: boolean;\n\n /**\n * Callback that is called after the RN SDK on the JS Layer has made contact with the Native Layer.\n */\n onReady?: (response: {\n /** `true` if the native SDK has been initialized, `false` otherwise. */\n didCallNativeInit: boolean;\n }) => void;\n\n /** Enable auto performance tracking by default. Renamed from `enableAutoPerformanceTracking` in v5. */\n enableAutoPerformanceTracing?: boolean;\n\n /**\n * Enables Out of Memory Tracking for iOS and macCatalyst.\n * See the following link for more information and possible restrictions:\n * https://docs.sentry.io/platforms/apple/guides/ios/configuration/out-of-memory/\n *\n * Renamed from `enableOutOfMemoryTracking` in v5.\n *\n * @default true\n */\n enableWatchdogTerminationTracking?: boolean;\n\n /**\n * Set data to the inital scope\n * @deprecated Use `Sentry.configureScope(...)`\n */\n initialScope?: CaptureContext;\n\n /**\n * When enabled, Sentry will overwrite the global Promise instance to ensure that unhandled rejections are correctly tracked.\n * If you run into issues with Promise polyfills such as `core-js`, make sure you polyfill after Sentry is initialized.\n * Read more at https://docs.sentry.io/platforms/react-native/troubleshooting/#unhandled-promise-rejections\n *\n * When disabled, this option will not disable unhandled rejection tracking. Set `onunhandledrejection: false` on the `ReactNativeErrorHandlers` integration instead.\n *\n * @default true\n */\n patchGlobalPromise?: boolean;\n\n /**\n * The max cache items for capping the number of envelopes.\n *\n * @default 30\n */\n maxCacheItems?: number;\n\n /**\n * When enabled, the SDK tracks when the application stops responding for a specific amount of\n * time defined by the `appHangTimeoutInterval` option.\n *\n * iOS only\n *\n * @default true\n */\n enableAppHangTracking?: boolean;\n\n /**\n * The minimum amount of time an app should be unresponsive to be classified as an App Hanging.\n * The actual amount may be a little longer.\n * Avoid using values lower than 100ms, which may cause a lot of app hangs events being transmitted.\n * Value should be in seconds.\n *\n * iOS only\n *\n * @default 2\n */\n appHangTimeoutInterval?: number;\n\n /**\n * The max queue size for capping the number of envelopes waiting to be sent by Transport.\n */\n maxQueueSize?: number;\n\n /**\n * When enabled and a user experiences an error, Sentry provides the ability to take a screenshot and include it as an attachment.\n *\n * @default false\n */\n attachScreenshot?: boolean;\n\n /**\n * When enabled Sentry includes the current view hierarchy in the error attachments.\n *\n * @default false\n */\n attachViewHierarchy?: boolean;\n\n /**\n * When enabled, Sentry will capture failed XHR/Fetch requests. This option also enabled HTTP Errors on iOS.\n * [Sentry Android Gradle Plugin](https://docs.sentry.io/platforms/android/configuration/integrations/okhttp/)\n * is needed to capture HTTP Errors on Android.\n *\n * @default false\n */\n enableCaptureFailedRequests?: boolean;\n}\n\nexport interface ReactNativeTransportOptions extends BrowserTransportOptions {\n /**\n * @deprecated use `maxQueueSize` in the root of the SDK options.\n */\n bufferSize?: number;\n}\n\n/**\n * Configuration options for the Sentry ReactNative SDK.\n * @see ReactNativeFrontend for more information.\n */\n\nexport interface ReactNativeOptions extends Options<ReactNativeTransportOptions>, BaseReactNativeOptions {}\n\nexport interface ReactNativeClientOptions extends ClientOptions<ReactNativeTransportOptions>, BaseReactNativeOptions {}\n\nexport interface ReactNativeWrapperOptions {\n /** Props for the root React profiler */\n profilerProps?: ProfilerProps;\n\n /** Props for the root touch event boundary */\n touchEventBoundaryProps?: TouchEventBoundaryProps;\n}\n\n/**\n * If the user has not explicitly set `enableNativeNagger`\n * the function enables native nagging based on the current\n * environment.\n */\nexport function shouldEnableNativeNagger(userOptions: unknown): boolean {\n if (typeof userOptions === 'boolean') {\n // User can override the default behavior\n return userOptions;\n }\n\n if (Platform.OS === 'web' || Platform.OS === 'windows') {\n // We don't want to nag on known platforms that don't support native\n return false;\n }\n\n const expoConstants = getExpoConstants();\n if (expoConstants && expoConstants.appOwnership === 'expo') {\n // If the app is running in Expo Go, we don't want to nag\n return false;\n }\n\n return true;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/js/options.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AA0MvD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,WAAoB;IAC3D,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE;QACpC,yCAAyC;QACzC,OAAO,WAAW,CAAC;KACpB;IAED,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,EAAE;QACtD,oEAAoE;QACpE,OAAO,KAAK,CAAC;KACd;IAED,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,IAAI,aAAa,IAAI,aAAa,CAAC,YAAY,KAAK,MAAM,EAAE;QAC1D,yDAAyD;QACzD,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { BrowserTransportOptions } from '@sentry/browser/types/transports/types';\nimport type { ProfilerProps } from '@sentry/react/types/profiler';\nimport type { CaptureContext, ClientOptions, Options } from '@sentry/types';\nimport { Platform } from 'react-native';\n\nimport type { TouchEventBoundaryProps } from './touchevents';\nimport { getExpoConstants } from './utils/expomodules';\n\nexport interface BaseReactNativeOptions {\n /**\n * Enables native transport + device info + offline caching.\n * Be careful, disabling this also breaks automatic release setting.\n * This means you have to manage setting the release yourself.\n * Defaults to `true`.\n */\n enableNative?: boolean;\n\n /**\n * Enables native crashHandling. This only works if `enableNative` is `true`.\n * Defaults to `true`.\n */\n enableNativeCrashHandling?: boolean;\n\n /**\n * Initializes the native SDK on init.\n * Set this to `false` if you have an existing native SDK and don't want to re-initialize.\n *\n * NOTE: Be careful and only use this if you know what you are doing.\n * If you use this flag, make sure a native SDK is running before the JS Engine initializes or events might not be captured.\n * Also, make sure the DSN on both the React Native side and the native side are the same one.\n * We strongly recommend checking the documentation if you need to use this.\n *\n * @default true\n */\n autoInitializeNativeSdk?: boolean;\n\n /** Should the native nagger alert be shown or not. */\n enableNativeNagger?: boolean;\n\n /** Should sessions be tracked to Sentry Health or not. */\n enableAutoSessionTracking?: boolean;\n\n /** The interval to end a session if the App goes to the background. */\n sessionTrackingIntervalMillis?: number;\n\n /** Enable NDK on Android\n *\n * @default true\n */\n enableNdk?: boolean;\n\n /** Enable scope sync from Java to NDK on Android\n * Only has an effect if `enableNdk` is `true`.\n */\n enableNdkScopeSync?: boolean;\n\n /** When enabled, all the threads are automatically attached to all logged events on Android */\n attachThreads?: boolean;\n\n /**\n * When enabled, certain personally identifiable information (PII) is added by active integrations.\n *\n * @default false\n */\n sendDefaultPii?: boolean;\n\n /**\n * Callback that is called after the RN SDK on the JS Layer has made contact with the Native Layer.\n */\n onReady?: (response: {\n /** `true` if the native SDK has been initialized, `false` otherwise. */\n didCallNativeInit: boolean;\n }) => void;\n\n /** Enable auto performance tracking by default. Renamed from `enableAutoPerformanceTracking` in v5. */\n enableAutoPerformanceTracing?: boolean;\n\n /**\n * Enables Out of Memory Tracking for iOS and macCatalyst.\n * See the following link for more information and possible restrictions:\n * https://docs.sentry.io/platforms/apple/guides/ios/configuration/out-of-memory/\n *\n * Renamed from `enableOutOfMemoryTracking` in v5.\n *\n * @default true\n */\n enableWatchdogTerminationTracking?: boolean;\n\n /**\n * Set data to the inital scope\n * @deprecated Use `Sentry.configureScope(...)`\n */\n initialScope?: CaptureContext;\n\n /**\n * When enabled, Sentry will overwrite the global Promise instance to ensure that unhandled rejections are correctly tracked.\n * If you run into issues with Promise polyfills such as `core-js`, make sure you polyfill after Sentry is initialized.\n * Read more at https://docs.sentry.io/platforms/react-native/troubleshooting/#unhandled-promise-rejections\n *\n * When disabled, this option will not disable unhandled rejection tracking. Set `onunhandledrejection: false` on the `ReactNativeErrorHandlers` integration instead.\n *\n * @default true\n */\n patchGlobalPromise?: boolean;\n\n /**\n * The max cache items for capping the number of envelopes.\n *\n * @default 30\n */\n maxCacheItems?: number;\n\n /**\n * When enabled, the SDK tracks when the application stops responding for a specific amount of\n * time defined by the `appHangTimeoutInterval` option.\n *\n * iOS only\n *\n * @default true\n */\n enableAppHangTracking?: boolean;\n\n /**\n * The minimum amount of time an app should be unresponsive to be classified as an App Hanging.\n * The actual amount may be a little longer.\n * Avoid using values lower than 100ms, which may cause a lot of app hangs events being transmitted.\n * Value should be in seconds.\n *\n * iOS only\n *\n * @default 2\n */\n appHangTimeoutInterval?: number;\n\n /**\n * The max queue size for capping the number of envelopes waiting to be sent by Transport.\n */\n maxQueueSize?: number;\n\n /**\n * When enabled and a user experiences an error, Sentry provides the ability to take a screenshot and include it as an attachment.\n *\n * @default false\n */\n attachScreenshot?: boolean;\n\n /**\n * When enabled Sentry includes the current view hierarchy in the error attachments.\n *\n * @default false\n */\n attachViewHierarchy?: boolean;\n\n /**\n * When enabled, Sentry will capture failed XHR/Fetch requests. This option also enabled HTTP Errors on iOS.\n * [Sentry Android Gradle Plugin](https://docs.sentry.io/platforms/android/configuration/integrations/okhttp/)\n * is needed to capture HTTP Errors on Android.\n *\n * @default false\n */\n enableCaptureFailedRequests?: boolean;\n\n /**\n * This option will enable forwarding captured Sentry events to Spotlight.\n *\n * More details: https://spotlightjs.com/\n *\n * IMPORTANT: Only set this option to `true` while developing, not in production!\n */\n enableSpotlight?: boolean;\n\n /**\n * This option changes the default Spotlight Sidecar URL.\n *\n * By default, the SDK expects the Sidecar to be running\n * on the same host as React Native Metro Dev Server.\n *\n * More details: https://spotlightjs.com/\n *\n * @default \"http://localhost:8969/stream\"\n */\n spotlightSidecarUrl?: string;\n}\n\nexport interface ReactNativeTransportOptions extends BrowserTransportOptions {\n /**\n * @deprecated use `maxQueueSize` in the root of the SDK options.\n */\n bufferSize?: number;\n}\n\n/**\n * Configuration options for the Sentry ReactNative SDK.\n * @see ReactNativeFrontend for more information.\n */\n\nexport interface ReactNativeOptions extends Options<ReactNativeTransportOptions>, BaseReactNativeOptions {}\n\nexport interface ReactNativeClientOptions extends ClientOptions<ReactNativeTransportOptions>, BaseReactNativeOptions {}\n\nexport interface ReactNativeWrapperOptions {\n /** Props for the root React profiler */\n profilerProps?: ProfilerProps;\n\n /** Props for the root touch event boundary */\n touchEventBoundaryProps?: TouchEventBoundaryProps;\n}\n\n/**\n * If the user has not explicitly set `enableNativeNagger`\n * the function enables native nagging based on the current\n * environment.\n */\nexport function shouldEnableNativeNagger(userOptions: unknown): boolean {\n if (typeof userOptions === 'boolean') {\n // User can override the default behavior\n return userOptions;\n }\n\n if (Platform.OS === 'web' || Platform.OS === 'windows') {\n // We don't want to nag on known platforms that don't support native\n return false;\n }\n\n const expoConstants = getExpoConstants();\n if (expoConstants && expoConstants.appOwnership === 'expo') {\n // If the app is running in Expo Go, we don't want to nag\n return false;\n }\n\n return true;\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,OAAO,KAAK,EAGV,cAAc,EACd,WAAW,EAEX,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AASvB,OAAO,KAAK,EAAE,kBAAkB,EA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AAgB,+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,EAAE,CAAC,CAAC;YACvF,WAAW,IAAI,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC;QACxD,CAAC,CAAC;QAEM,yBA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E/E,6CAA6C;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAC1C,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;IAE1C,IAAI,MAAM,CAAC,MAAM,EAAE;QACjB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE;YACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;gBACjB,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;gBACxC,QAAQ,EAAE,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS;aACtD,CAAC,CAAC;SACJ;KACF;IACD,MAAM,CAAC,MAAM,GAAG;QACd,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;QACxB,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;KACpF,CAAC;IACF,MAAM,CAAC,OAAO,GAAG;QACf,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACzB,GAAG,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;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 {\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
+ {"version":3,"file":"integration.js","sourceRoot":"","sources":["../../../src/js/profiling/integration.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,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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,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,g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C,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,EAA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