@sentry/react-native 5.11.1 → 5.12.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 (35) hide show
  1. package/CHANGELOG.md +25 -4
  2. package/RNSentry.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/dist/js/profiling/convertHermesProfile.d.ts +6 -1
  5. package/dist/js/profiling/convertHermesProfile.d.ts.map +1 -1
  6. package/dist/js/profiling/convertHermesProfile.js +38 -13
  7. package/dist/js/profiling/convertHermesProfile.js.map +1 -1
  8. package/dist/js/profiling/hermes.d.ts +3 -6
  9. package/dist/js/profiling/hermes.d.ts.map +1 -1
  10. package/dist/js/profiling/hermes.js +3 -10
  11. package/dist/js/profiling/hermes.js.map +1 -1
  12. package/dist/js/profiling/types.d.ts +3 -1
  13. package/dist/js/profiling/types.d.ts.map +1 -1
  14. package/dist/js/profiling/types.js.map +1 -1
  15. package/dist/js/profiling/utils.d.ts +5 -1
  16. package/dist/js/profiling/utils.d.ts.map +1 -1
  17. package/dist/js/profiling/utils.js +35 -5
  18. package/dist/js/profiling/utils.js.map +1 -1
  19. package/dist/js/sdk.d.ts.map +1 -1
  20. package/dist/js/sdk.js +4 -0
  21. package/dist/js/sdk.js.map +1 -1
  22. package/dist/js/utils/environment.d.ts +2 -0
  23. package/dist/js/utils/environment.d.ts.map +1 -1
  24. package/dist/js/utils/environment.js +4 -0
  25. package/dist/js/utils/environment.js.map +1 -1
  26. package/dist/js/version.d.ts +1 -1
  27. package/dist/js/version.js +1 -1
  28. package/dist/js/version.js.map +1 -1
  29. package/package.json +11 -11
  30. package/ts3.8/dist/js/profiling/convertHermesProfile.d.ts +6 -1
  31. package/ts3.8/dist/js/profiling/hermes.d.ts +3 -6
  32. package/ts3.8/dist/js/profiling/types.d.ts +3 -1
  33. package/ts3.8/dist/js/profiling/utils.d.ts +5 -1
  34. package/ts3.8/dist/js/utils/environment.d.ts +2 -0
  35. package/ts3.8/dist/js/version.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.12.0
4
+
5
+ ### Features
6
+
7
+ - Automatically detect environment if not set ([#3362](https://github.com/getsentry/sentry-react-native/pull/3362))
8
+ - Send Source Maps Debug ID for symbolicated Profiles ([#3343](https://github.com/getsentry/sentry-react-native/pull/3343))
9
+
10
+ ### Fixes
11
+
12
+ - Add actual `activeThreadId` to Profiles ([#3338](https://github.com/getsentry/sentry-react-native/pull/3338))
13
+ - Parse Hermes Profiling Bytecode Frames ([#3342](https://github.com/getsentry/sentry-react-native/pull/3342))
14
+
15
+ ### Dependencies
16
+
17
+ - Bump JavaScript SDK from v7.73.0 to v7.76.0 ([#3344](https://github.com/getsentry/sentry-react-native/pull/3344), [#3365](https://github.com/getsentry/sentry-react-native/pull/3365))
18
+ - [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#7760)
19
+ - [diff](https://github.com/getsentry/sentry-javascript/compare/7.73.0...7.76.0)
20
+ - Bump Cocoa SDK from v8.13.0 to v8.14.2 ([#3340](https://github.com/getsentry/sentry-react-native/pull/3340))
21
+ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8142)
22
+ - [diff](https://github.com/getsentry/sentry-cocoa/compare/8.13.0...8.14.2)
23
+ - Bump Android SDK from v6.30.0 to v6.32.0 ([#3341](https://github.com/getsentry/sentry-react-native/pull/3341))
24
+ - [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#6320)
25
+ - [diff](https://github.com/getsentry/sentry-java/compare/6.30.0...6.32.0)
26
+
3
27
  ## 5.11.1
4
28
 
5
29
  ### Fixes
@@ -65,6 +89,7 @@
65
89
  - Ignore defaults when warning about duplicate definition of trace propagation targets ([#3327](https://github.com/getsentry/sentry-react-native/pull/3327))
66
90
  - Screenshots are not taken when the SDK is disabled ([#3333](https://github.com/getsentry/sentry-react-native/pull/3333))
67
91
  - Use deprecated `ReactNativeTracingOptions.tracingOrigins` if set in the options ([#3331](https://github.com/getsentry/sentry-react-native/pull/3331))
92
+ - Cancel auto instrumentation transaction when app goes to background ([#3307](https://github.com/getsentry/sentry-react-native/pull/3307))
68
93
 
69
94
  ### Dependencies
70
95
 
@@ -89,10 +114,6 @@
89
114
  - This flag equals `true` when Hermes Bundle contains Debug Info (Hermes Source Map was not emitted)
90
115
  - Add `enableNdk` property to ReactNativeOptions for Android. ([#3304](https://github.com/getsentry/sentry-react-native/pull/3304))
91
116
 
92
- ### Fixes
93
-
94
- - Cancel auto instrumentation transaction when app goes to background ([#3307])(https://github.com/getsentry/sentry-react-native/pull/3307)
95
-
96
117
  ## 5.9.2
97
118
 
98
119
  ### Fixes
package/RNSentry.podspec CHANGED
@@ -24,7 +24,7 @@ Pod::Spec.new do |s|
24
24
  s.preserve_paths = '*.js'
25
25
 
26
26
  s.dependency 'React-Core'
27
- s.dependency 'Sentry/HybridSDK', '8.13.0'
27
+ s.dependency 'Sentry/HybridSDK', '8.14.2'
28
28
 
29
29
  s.source_files = 'ios/**/*.{h,mm}'
30
30
  s.public_header_files = 'ios/RNSentry.h'
@@ -54,5 +54,5 @@ android {
54
54
 
55
55
  dependencies {
56
56
  implementation 'com.facebook.react:react-native:+'
57
- api 'io.sentry:sentry-android:6.30.0'
57
+ api 'io.sentry:sentry-android:6.32.0'
58
58
  }
@@ -1,4 +1,4 @@
1
- import type { ThreadCpuSample, ThreadId } from '@sentry/types';
1
+ import type { ThreadCpuFrame, ThreadCpuSample, ThreadId } from '@sentry/types';
2
2
  import type * as Hermes from './hermes';
3
3
  import type { RawThreadCpuProfile } from './types';
4
4
  /**
@@ -24,4 +24,9 @@ export declare function mapSamples(hermesSamples: Hermes.Sample[], maxElapsedSin
24
24
  hermesStacks: Set<Hermes.StackFrameId>;
25
25
  jsThreads: Set<ThreadId>;
26
26
  };
27
+ /**
28
+ * Parses Hermes StackFrame to Sentry StackFrame.
29
+ * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.
30
+ */
31
+ export declare function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame;
27
32
  //# sourceMappingURL=convertHermesProfile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertHermesProfile.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoC,eAAe,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAKjH,OAAO,KAAK,KAAK,MAAM,MAAM,UAAU,CAAC;AAGxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAWnD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAwChG;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,EAC9B,sBAAsB,GAAE,MAAgC,GACvD;IACD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;CAC1B,CA+BA"}
1
+ {"version":3,"file":"convertHermesProfile.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,cAAc,EAAE,eAAe,EAAkB,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGjH,OAAO,KAAK,KAAK,MAAM,MAAM,UAAU,CAAC;AAGxC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AASnD;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,mBAAmB,GAAG,IAAI,CA0ChG;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,EAC9B,sBAAsB,GAAE,MAAgC,GACvD;IACD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IACvC,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC;CAC1B,CA+BA;AA8DD;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,cAAc,CA8BhF"}
@@ -1,15 +1,12 @@
1
1
  import { logger } from '@sentry/utils';
2
- import { Platform } from 'react-native';
3
- import { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';
4
- import { parseHermesStackFrameFunctionName } from './hermes';
2
+ import { DEFAULT_BUNDLE_NAME } from './hermes';
5
3
  import { MAX_PROFILE_DURATION_MS } from './integration';
4
+ const PLACEHOLDER_THREAD_ID_STRING = '0';
6
5
  const MS_TO_NS = 1e6;
7
6
  const MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;
8
- const ANONYMOUS_FUNCTION_NAME = 'anonymous';
9
7
  const UNKNOWN_STACK_ID = -1;
10
8
  const JS_THREAD_NAME = 'JavaScriptThread';
11
9
  const JS_THREAD_PRIORITY = 1;
12
- const DEFAULT_BUNDLE_NAME = Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;
13
10
  /**
14
11
  * Converts a Hermes profile to a Sentry profile.
15
12
  *
@@ -46,11 +43,13 @@ export function convertToSentryProfile(hermesProfile) {
46
43
  priority: JS_THREAD_PRIORITY,
47
44
  };
48
45
  }
46
+ const active_thread_id = Object.keys(thread_metadata)[0] || PLACEHOLDER_THREAD_ID_STRING;
49
47
  return {
50
48
  samples,
51
49
  frames,
52
50
  stacks,
53
51
  thread_metadata,
52
+ active_thread_id,
54
53
  };
55
54
  }
56
55
  /**
@@ -99,14 +98,7 @@ function mapFrames(hermesStackFrames) {
99
98
  continue;
100
99
  }
101
100
  hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);
102
- const hermesFrame = hermesStackFrames[key];
103
- const functionName = parseHermesStackFrameFunctionName(hermesFrame.name);
104
- frames.push({
105
- function: functionName || ANONYMOUS_FUNCTION_NAME,
106
- file: hermesFrame.category == 'JavaScript' ? DEFAULT_BUNDLE_NAME : undefined,
107
- lineno: hermesFrame.line !== undefined ? Number(hermesFrame.line) : undefined,
108
- colno: hermesFrame.column !== undefined ? Number(hermesFrame.column) : undefined,
109
- });
101
+ frames.push(parseHermesJSStackFrame(hermesStackFrames[key]));
110
102
  }
111
103
  return {
112
104
  frames,
@@ -138,4 +130,37 @@ function mapStacks(hermesStacks, hermesStackFrames, hermesStackFrameIdToSentryFr
138
130
  hermesStackToSentryStackMap,
139
131
  };
140
132
  }
133
+ /**
134
+ * Parses Hermes StackFrame to Sentry StackFrame.
135
+ * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.
136
+ */
137
+ export function parseHermesJSStackFrame(frame) {
138
+ if (frame.category !== 'JavaScript') {
139
+ // Native
140
+ if (frame.name === '[root]') {
141
+ return { function: frame.name, in_app: false };
142
+ }
143
+ return { function: frame.name };
144
+ }
145
+ if (frame.funcVirtAddr !== undefined && frame.offset !== undefined) {
146
+ // Hermes Bytecode
147
+ return {
148
+ function: frame.name,
149
+ abs_path: DEFAULT_BUNDLE_NAME,
150
+ // https://github.com/krystofwoldrich/metro/blob/417e6f276ff9422af6039fc4d1bce41fcf7d9f46/packages/metro-symbolicate/src/Symbolication.js#L298-L301
151
+ // Hermes lineno is hardcoded 1, currently only one bundle symbolication is supported by metro-symbolicate and thus by us.
152
+ lineno: 1,
153
+ // Hermes colno is 0-based, while Sentry is 1-based
154
+ colno: Number(frame.funcVirtAddr) + Number(frame.offset) + 1,
155
+ };
156
+ }
157
+ // JavaScript
158
+ const indexOfLeftParenthesis = frame.name.indexOf('(');
159
+ return {
160
+ function: indexOfLeftParenthesis !== -1 ? frame.name.substring(0, indexOfLeftParenthesis) || undefined : frame.name,
161
+ abs_path: DEFAULT_BUNDLE_NAME,
162
+ lineno: frame.line !== undefined ? Number(frame.line) : undefined,
163
+ colno: frame.column !== undefined ? Number(frame.column) : undefined,
164
+ };
165
+ }
141
166
  //# sourceMappingURL=convertHermesProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAErG,OAAO,EAAE,iCAAiC,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AACnE,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAC5C,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAC7B,MAAM,mBAAmB,GACvB,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;AAExH;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA6B;IAClE,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,0CAA0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,CAAC,KAAK,CAAC,CAAC;KACpB;IAED,OAAO;QACL,MAAM;QACN,2BAA2B;KAC5B,CAAC;AACJ,CAAC","sourcesContent":["import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport { Platform } from 'react-native';\n\nimport { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';\nimport type * as Hermes from './hermes';\nimport { parseHermesStackFrameFunctionName } from './hermes';\nimport { MAX_PROFILE_DURATION_MS } from './integration';\nimport type { RawThreadCpuProfile } from './types';\n\nconst MS_TO_NS = 1e6;\nconst MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;\nconst ANONYMOUS_FUNCTION_NAME = 'anonymous';\nconst UNKNOWN_STACK_ID = -1;\nconst JS_THREAD_NAME = 'JavaScriptThread';\nconst JS_THREAD_PRIORITY = 1;\nconst DEFAULT_BUNDLE_NAME =\n Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;\n\n/**\n * Converts a Hermes profile to a Sentry profile.\n *\n * Maps Hermes samples to Sentry samples.\n * Maps Hermes stack frames to Sentry frames.\n * Hermes stack frame is an object representing a function call in the stack\n * with a link to its parent stack frame. Root of the represented stack tree\n * is main function call in Hermes that is [root] stack frame.\n *\n * @returns Sentry profile or null if no samples are found.\n */\nexport function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null {\n if (hermesProfile.samples.length === 0) {\n logger.warn('[Profiling] No samples found in profile.');\n return null;\n }\n\n const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);\n\n const { frames, hermesStackFrameIdToSentryFrameIdMap } = mapFrames(hermesProfile.stackFrames);\n\n const { stacks, hermesStackToSentryStackMap } = mapStacks(\n hermesStacks,\n hermesProfile.stackFrames,\n hermesStackFrameIdToSentryFrameIdMap,\n );\n\n for (const sample of samples) {\n const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);\n if (sentryStackId === undefined) {\n logger.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);\n sample.stack_id = UNKNOWN_STACK_ID;\n } else {\n sample.stack_id = sentryStackId;\n }\n }\n\n const thread_metadata: Record<ThreadId, { name?: string; priority?: number }> = {};\n for (const jsThreadId of jsThreads) {\n thread_metadata[jsThreadId] = {\n name: JS_THREAD_NAME,\n priority: JS_THREAD_PRIORITY,\n };\n }\n\n return {\n samples,\n frames,\n stacks,\n thread_metadata,\n };\n}\n\n/**\n * Maps Hermes samples to Sentry samples.\n * Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs\n */\nexport function mapSamples(\n hermesSamples: Hermes.Sample[],\n maxElapsedSinceStartNs: number = MAX_PROFILE_DURATION_NS,\n): {\n samples: ThreadCpuSample[];\n hermesStacks: Set<Hermes.StackFrameId>;\n jsThreads: Set<ThreadId>;\n} {\n const jsThreads = new Set<ThreadId>();\n const hermesStacks = new Set<Hermes.StackFrameId>();\n\n const start = Number(hermesSamples[0].ts);\n const samples: ThreadCpuSample[] = [];\n for (const hermesSample of hermesSamples) {\n jsThreads.add(hermesSample.tid);\n hermesStacks.add(hermesSample.sf);\n\n const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;\n if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {\n logger.warn(\n `[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +\n `greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`,\n );\n break;\n }\n\n samples.push({\n stack_id: hermesSample.sf,\n thread_id: hermesSample.tid,\n elapsed_since_start_ns: elapsed_since_start_ns.toFixed(0),\n });\n }\n\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n}\n\n/**\n * Maps Hermes StackFrames tree represented as an JS object to a Sentry frames array.\n * Converts line and columns strings to numbers.\n * @returns the mapped Sentry frames\n */\nfunction mapFrames(hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>): {\n frames: ThreadCpuFrame[];\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>;\n} {\n const frames: ThreadCpuFrame[] = [];\n const hermesStackFrameIdToSentryFrameIdMap = new Map<Hermes.StackFrameId, FrameId>();\n for (const key in hermesStackFrames) {\n // asc order based on the key is not guaranteed\n if (!Object.prototype.hasOwnProperty.call(hermesStackFrames, key)) {\n continue;\n }\n hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);\n const hermesFrame = hermesStackFrames[key];\n\n const functionName = parseHermesStackFrameFunctionName(hermesFrame.name);\n frames.push({\n function: functionName || ANONYMOUS_FUNCTION_NAME,\n file: hermesFrame.category == 'JavaScript' ? DEFAULT_BUNDLE_NAME : undefined,\n lineno: hermesFrame.line !== undefined ? Number(hermesFrame.line) : undefined,\n colno: hermesFrame.column !== undefined ? Number(hermesFrame.column) : undefined,\n });\n }\n\n return {\n frames,\n hermesStackFrameIdToSentryFrameIdMap,\n };\n}\n\n/**\n * Maps Hermes stack frame IDs to Sentry stack arrays.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry stacks and a map from Hermes stack IDs to Sentry stack IDs (indices in the stacks array)\n */\nfunction mapStacks(\n hermesStacks: Set<Hermes.StackFrameId>,\n hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>,\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>,\n): {\n stacks: ThreadCpuStack[];\n hermesStackToSentryStackMap: Map<Hermes.StackFrameId, StackId>;\n} {\n const hermesStackToSentryStackMap = new Map<Hermes.StackFrameId, StackId>();\n const stacks: ThreadCpuStack[] = [];\n for (const hermesStackFunctionFrameId of hermesStacks) {\n const stackId = stacks.length;\n hermesStackToSentryStackMap.set(hermesStackFunctionFrameId, stackId);\n const stack: ThreadCpuStack = [];\n let currentHermesFrameId: Hermes.StackFrameId | undefined = hermesStackFunctionFrameId;\n while (currentHermesFrameId !== undefined) {\n const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId);\n sentryFrameId !== undefined && stack.push(sentryFrameId);\n currentHermesFrameId = hermesStackFrames[currentHermesFrameId] && hermesStackFrames[currentHermesFrameId].parent;\n }\n stacks.push(stack);\n }\n\n return {\n stacks,\n hermesStackToSentryStackMap,\n };\n}\n"]}
1
+ {"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,GAAG,uBAAuB,GAAG,QAAQ,CAAC;AACnE,MAAM,gBAAgB,GAAG,CAAC,CAAC,CAAC;AAC5B,MAAM,cAAc,GAAG,kBAAkB,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAE7B;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA6B;IAClE,IAAI,aAAa,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACtC,MAAM,CAAC,IAAI,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC;KACb;IAED,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAE/E,MAAM,EAAE,MAAM,EAAE,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E,KAAK,CAAC,IAAI;YACpB,QAAQ,EAAE,mBAAmB;YAC7B,mJAAmJ;YACnJ,0HAA0H;YAC1H,MAAM,EAAE,CAAC;YACT,mDAAmD;YACnD,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC;SAC7D,CAAC;KACH;IAED,aAAa;IACb,MAAM,sBAAsB,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,OAAO;QACL,QAAQ,EAAE,sBAAsB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI;QACnH,QAAQ,EAAE,mBAAmB;QAC7B,MAAM,EAAE,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS;QACjE,KAAK,EAAE,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;KACrE,CAAC;AACJ,CAAC","sourcesContent":["import type { FrameId, StackId, ThreadCpuFrame, ThreadCpuSample, ThreadCpuStack, ThreadId } from '@sentry/types';\nimport { logger } from '@sentry/utils';\n\nimport type * as Hermes from './hermes';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\nimport { MAX_PROFILE_DURATION_MS } from './integration';\nimport type { RawThreadCpuProfile } from './types';\n\nconst PLACEHOLDER_THREAD_ID_STRING = '0';\nconst MS_TO_NS = 1e6;\nconst MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;\nconst UNKNOWN_STACK_ID = -1;\nconst JS_THREAD_NAME = 'JavaScriptThread';\nconst JS_THREAD_PRIORITY = 1;\n\n/**\n * Converts a Hermes profile to a Sentry profile.\n *\n * Maps Hermes samples to Sentry samples.\n * Maps Hermes stack frames to Sentry frames.\n * Hermes stack frame is an object representing a function call in the stack\n * with a link to its parent stack frame. Root of the represented stack tree\n * is main function call in Hermes that is [root] stack frame.\n *\n * @returns Sentry profile or null if no samples are found.\n */\nexport function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null {\n if (hermesProfile.samples.length === 0) {\n logger.warn('[Profiling] No samples found in profile.');\n return null;\n }\n\n const { samples, hermesStacks, jsThreads } = mapSamples(hermesProfile.samples);\n\n const { frames, hermesStackFrameIdToSentryFrameIdMap } = mapFrames(hermesProfile.stackFrames);\n\n const { stacks, hermesStackToSentryStackMap } = mapStacks(\n hermesStacks,\n hermesProfile.stackFrames,\n hermesStackFrameIdToSentryFrameIdMap,\n );\n\n for (const sample of samples) {\n const sentryStackId = hermesStackToSentryStackMap.get(sample.stack_id);\n if (sentryStackId === undefined) {\n logger.error(`[Profiling] Hermes Stack ID ${sample.stack_id} not found when mapping to Sentry Stack ID.`);\n sample.stack_id = UNKNOWN_STACK_ID;\n } else {\n sample.stack_id = sentryStackId;\n }\n }\n\n const thread_metadata: Record<ThreadId, { name?: string; priority?: number }> = {};\n for (const jsThreadId of jsThreads) {\n thread_metadata[jsThreadId] = {\n name: JS_THREAD_NAME,\n priority: JS_THREAD_PRIORITY,\n };\n }\n const active_thread_id = Object.keys(thread_metadata)[0] || PLACEHOLDER_THREAD_ID_STRING;\n\n return {\n samples,\n frames,\n stacks,\n thread_metadata,\n active_thread_id,\n };\n}\n\n/**\n * Maps Hermes samples to Sentry samples.\n * Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs\n */\nexport function mapSamples(\n hermesSamples: Hermes.Sample[],\n maxElapsedSinceStartNs: number = MAX_PROFILE_DURATION_NS,\n): {\n samples: ThreadCpuSample[];\n hermesStacks: Set<Hermes.StackFrameId>;\n jsThreads: Set<ThreadId>;\n} {\n const jsThreads = new Set<ThreadId>();\n const hermesStacks = new Set<Hermes.StackFrameId>();\n\n const start = Number(hermesSamples[0].ts);\n const samples: ThreadCpuSample[] = [];\n for (const hermesSample of hermesSamples) {\n jsThreads.add(hermesSample.tid);\n hermesStacks.add(hermesSample.sf);\n\n const elapsed_since_start_ns = (Number(hermesSample.ts) - start) * 1e3;\n if (elapsed_since_start_ns >= maxElapsedSinceStartNs) {\n logger.warn(\n `[Profiling] Sample has elapsed time since start ${elapsed_since_start_ns}ns ` +\n `greater than the max elapsed time ${maxElapsedSinceStartNs}ns.`,\n );\n break;\n }\n\n samples.push({\n stack_id: hermesSample.sf,\n thread_id: hermesSample.tid,\n elapsed_since_start_ns: elapsed_since_start_ns.toFixed(0),\n });\n }\n\n return {\n samples,\n hermesStacks,\n jsThreads,\n };\n}\n\n/**\n * Maps Hermes StackFrames tree represented as an JS object to a Sentry frames array.\n * Converts line and columns strings to numbers.\n * @returns the mapped Sentry frames\n */\nfunction mapFrames(hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>): {\n frames: ThreadCpuFrame[];\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>;\n} {\n const frames: ThreadCpuFrame[] = [];\n const hermesStackFrameIdToSentryFrameIdMap = new Map<Hermes.StackFrameId, FrameId>();\n for (const key in hermesStackFrames) {\n // asc order based on the key is not guaranteed\n if (!Object.prototype.hasOwnProperty.call(hermesStackFrames, key)) {\n continue;\n }\n hermesStackFrameIdToSentryFrameIdMap.set(Number(key), frames.length);\n frames.push(parseHermesJSStackFrame(hermesStackFrames[key]));\n }\n\n return {\n frames,\n hermesStackFrameIdToSentryFrameIdMap,\n };\n}\n\n/**\n * Maps Hermes stack frame IDs to Sentry stack arrays.\n * Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.\n * @returns the mapped Sentry stacks and a map from Hermes stack IDs to Sentry stack IDs (indices in the stacks array)\n */\nfunction mapStacks(\n hermesStacks: Set<Hermes.StackFrameId>,\n hermesStackFrames: Record<Hermes.StackFrameId, Hermes.StackFrame>,\n hermesStackFrameIdToSentryFrameIdMap: Map<Hermes.StackFrameId, FrameId>,\n): {\n stacks: ThreadCpuStack[];\n hermesStackToSentryStackMap: Map<Hermes.StackFrameId, StackId>;\n} {\n const hermesStackToSentryStackMap = new Map<Hermes.StackFrameId, StackId>();\n const stacks: ThreadCpuStack[] = [];\n for (const hermesStackFunctionFrameId of hermesStacks) {\n const stackId = stacks.length;\n hermesStackToSentryStackMap.set(hermesStackFunctionFrameId, stackId);\n const stack: ThreadCpuStack = [];\n let currentHermesFrameId: Hermes.StackFrameId | undefined = hermesStackFunctionFrameId;\n while (currentHermesFrameId !== undefined) {\n const sentryFrameId = hermesStackFrameIdToSentryFrameIdMap.get(currentHermesFrameId);\n sentryFrameId !== undefined && stack.push(sentryFrameId);\n currentHermesFrameId = hermesStackFrames[currentHermesFrameId] && hermesStackFrames[currentHermesFrameId].parent;\n }\n stacks.push(stack);\n }\n\n return {\n stacks,\n hermesStackToSentryStackMap,\n };\n}\n\n/**\n * Parses Hermes StackFrame to Sentry StackFrame.\n * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.\n */\nexport function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame {\n if (frame.category !== 'JavaScript') {\n // Native\n if (frame.name === '[root]') {\n return { function: frame.name, in_app: false };\n }\n return { function: frame.name };\n }\n\n if (frame.funcVirtAddr !== undefined && frame.offset !== undefined) {\n // Hermes Bytecode\n return {\n function: frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n // https://github.com/krystofwoldrich/metro/blob/417e6f276ff9422af6039fc4d1bce41fcf7d9f46/packages/metro-symbolicate/src/Symbolication.js#L298-L301\n // Hermes lineno is hardcoded 1, currently only one bundle symbolication is supported by metro-symbolicate and thus by us.\n lineno: 1,\n // Hermes colno is 0-based, while Sentry is 1-based\n colno: Number(frame.funcVirtAddr) + Number(frame.offset) + 1,\n };\n }\n\n // JavaScript\n const indexOfLeftParenthesis = frame.name.indexOf('(');\n return {\n function: indexOfLeftParenthesis !== -1 ? frame.name.substring(0, indexOfLeftParenthesis) || undefined : frame.name,\n abs_path: DEFAULT_BUNDLE_NAME,\n lineno: frame.line !== undefined ? Number(frame.line) : undefined,\n colno: frame.column !== undefined ? Number(frame.column) : undefined,\n };\n}\n"]}
@@ -22,6 +22,8 @@ export interface Sample {
22
22
  sf: StackFrameId;
23
23
  }
24
24
  export interface StackFrame {
25
+ funcVirtAddr?: string;
26
+ offset?: string;
25
27
  line?: string;
26
28
  column?: string;
27
29
  funcLine?: string;
@@ -35,12 +37,7 @@ export interface Profile {
35
37
  samples: Sample[];
36
38
  stackFrames: Record<string, StackFrame>;
37
39
  }
38
- /**
39
- * Hermes Profile Stack Frame Name contains function name and file path.
40
- *
41
- * `foo(/path/to/file.js:1:2)` -> `foo`
42
- */
43
- export declare function parseHermesStackFrameFunctionName(hermesName: string): string;
40
+ export declare const DEFAULT_BUNDLE_NAME: string | undefined;
44
41
  /**
45
42
  * Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
46
43
  */
@@ -1 +1 @@
1
- {"version":3,"file":"hermes.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,qBAAqB,CAAC;IAC1B,GAAG,EA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ME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';
1
3
  import { NATIVE } from '../wrapper';
2
4
  import { convertToSentryProfile } from './convertHermesProfile';
3
- /**
4
- * Hermes Profile Stack Frame Name contains function name and file path.
5
- *
6
- * `foo(/path/to/file.js:1:2)` -> `foo`
7
- */
8
- export function parseHermesStackFrameFunctionName(hermesName) {
9
- const indexOfLeftParenthesis = hermesName.indexOf('(');
10
- const name = indexOfLeftParenthesis !== -1 ? hermesName.substring(0, indexOfLeftParenthesis) : hermesName;
11
- return name;
12
- }
5
+ export const DEFAULT_BUNDLE_NAME = Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;
13
6
  const MS_TO_NS = 1e6;
14
7
  /**
15
8
  * Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
@@ -1 +1 @@
1
- {"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AA4ChE;;;;GAIG;AACH,MAAM,UAAU,iCAAiC,CAAC,UAAkB;IAClE,MAAM,sBAAsB,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,sBAAsB,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAC1G,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,QAAQ,GAAW,GAAG,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IACtD,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAC7C,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { NATIVE } from '../wrapper';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { RawThreadCpuProfile } from './types';\n\nexport type StackFrameId = number;\nexport type MicrosecondsSinceBoot = string;\n\nexport interface TraceEvent {\n name: string;\n ph: string;\n cat: string;\n pid: number;\n ts: MicrosecondsSinceBoot;\n tid: string;\n args: {\n name?: string;\n };\n}\n\nexport interface Sample {\n cpu: string;\n name: string;\n ts: MicrosecondsSinceBoot;\n pid: number;\n tid: string;\n weight: string;\n sf: StackFrameId;\n}\n\nexport interface StackFrame {\n line?: string;\n column?: string;\n funcLine?: string;\n funcColumn?: string;\n name: string;\n category: string;\n parent?: number;\n}\n\nexport interface Profile {\n traceEvents: TraceEvent[];\n samples: Sample[];\n stackFrames: Record<string, StackFrame>;\n}\n\n/**\n * Hermes Profile Stack Frame Name contains function name and file path.\n *\n * `foo(/path/to/file.js:1:2)` -> `foo`\n */\nexport function parseHermesStackFrameFunctionName(hermesName: string): string {\n const indexOfLeftParenthesis = hermesName.indexOf('(');\n const name = indexOfLeftParenthesis !== -1 ? hermesName.substring(0, indexOfLeftParenthesis) : hermesName;\n return name;\n}\n\nconst MS_TO_NS: number = 1e6;\n\n/**\n * Starts Hermes Sampling Profiler 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 const profileStartTimestampNs = Date.now() * MS_TO_NS;\n return profileStartTimestampNs;\n}\n\n/**\n * Stops Hermes Sampling Profiler and returns the profile.\n */\nexport function stopProfiling(): RawThreadCpuProfile | null {\n const hermesProfile = NATIVE.stopProfiling();\n if (!hermesProfile) {\n return null;\n }\n return convertToSentryProfile(hermesProfile);\n}\n"]}
1
+ {"version":3,"file":"hermes.js","sourceRoot":"","sources":["../../../src/js/profiling/hermes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACrG,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAmDhE,MAAM,CAAC,MAAM,mBAAmB,GAC9B,QAAQ,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;AAExH,MAAM,QAAQ,GAAW,GAAG,CAAC;AAE7B;;GAEG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,IAAI,CAAC;KACb;IAED,MAAM,uBAAuB,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IACtD,OAAO,uBAAuB,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;IAC7C,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO,IAAI,CAAC;KACb;IACD,OAAO,sBAAsB,CAAC,aAAa,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import { Platform } from 'react-native';\n\nimport { ANDROID_DEFAULT_BUNDLE_NAME, IOS_DEFAULT_BUNDLE_NAME } from '../integrations/rewriteframes';\nimport { NATIVE } from '../wrapper';\nimport { convertToSentryProfile } from './convertHermesProfile';\nimport type { RawThreadCpuProfile } from './types';\n\nexport type StackFrameId = number;\nexport type MicrosecondsSinceBoot = string;\n\nexport interface TraceEvent {\n name: string;\n ph: string;\n cat: string;\n pid: number;\n ts: MicrosecondsSinceBoot;\n tid: string;\n args: {\n name?: string;\n };\n}\n\nexport interface Sample {\n cpu: string;\n name: string;\n ts: MicrosecondsSinceBoot;\n pid: number;\n tid: string;\n weight: string;\n sf: StackFrameId;\n}\n\nexport interface StackFrame {\n // Hermes Bytecode\n funcVirtAddr?: string;\n offset?: string;\n\n // JavaScript\n line?: string;\n column?: string;\n funcLine?: string;\n funcColumn?: string;\n\n // Common\n name: string;\n category: string;\n parent?: number;\n}\n\nexport interface Profile {\n traceEvents: TraceEvent[];\n samples: Sample[];\n stackFrames: Record<string, StackFrame>;\n}\n\nexport const DEFAULT_BUNDLE_NAME =\n Platform.OS === 'android' ? ANDROID_DEFAULT_BUNDLE_NAME : Platform.OS === 'ios' ? IOS_DEFAULT_BUNDLE_NAME : undefined;\n\nconst MS_TO_NS: number = 1e6;\n\n/**\n * Starts Hermes Sampling Profiler 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 const profileStartTimestampNs = Date.now() * MS_TO_NS;\n return profileStartTimestampNs;\n}\n\n/**\n * Stops Hermes Sampling Profiler and returns the profile.\n */\nexport function stopProfiling(): RawThreadCpuProfile | null {\n const hermesProfile = NATIVE.stopProfiling();\n if (!hermesProfile) {\n return null;\n }\n return convertToSentryProfile(hermesProfile);\n}\n"]}
@@ -1,5 +1,7 @@
1
- import type { ThreadCpuProfile } from '@sentry/types';
1
+ import type { ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
2
2
  export interface RawThreadCpuProfile extends ThreadCpuProfile {
3
+ frames: ThreadCpuFrame[];
3
4
  profile_id?: string;
5
+ active_thread_id: string;
4
6
  }
5
7
  //# 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,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtE,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,MAAM,EAAE,cAAc,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC1B"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThreadCpuProfile } from '@sentry/types';\n\nexport interface RawThreadCpuProfile extends ThreadCpuProfile {\n profile_id?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/js/profiling/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';\n\nexport interface RawThreadCpuProfile extends ThreadCpuProfile {\n frames: ThreadCpuFrame[];\n profile_id?: string;\n active_thread_id: string;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { Envelope, Event, Profile } from '@sentry/types';
1
+ import type { DebugImage, Envelope, Event, Profile } from '@sentry/types';
2
2
  import type { RawThreadCpuProfile } from './types';
3
3
  /**
4
4
  *
@@ -18,6 +18,10 @@ export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope)
18
18
  * @returns {Profile | null}
19
19
  */
20
20
  export declare function createProfilingEvent(profile: RawThreadCpuProfile, event: Event): Profile | null;
21
+ /**
22
+ * Returns debug meta images of the loaded bundle.
23
+ */
24
+ export declare function getDebugMetadata(): DebugImage[];
21
25
  /**
22
26
  * Adds items to envelope if they are not already present - mutates the envelope.
23
27
  * @param envelope
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAInD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,IAAI,mBAAmB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAgBpH;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAqBhF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI,CAuB/F;AAwFD;;;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":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAK1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,IAAI,mBAAmB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAgBpH;AAED;;;;GAIG;AACH,wBAAgB,oCAAoC,CAAC,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,CAqBhF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,GAAG,IAAI,CAuB/F;AA2FD;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,EAAE,CA4B/C;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,QAAQ,CAUvF"}
@@ -1,5 +1,6 @@
1
- import { forEachEnvelopeItem, logger } from '@sentry/utils';
2
- const ACTIVE_THREAD_ID_STRING = '0';
1
+ import { forEachEnvelopeItem, GLOBAL_OBJ, logger } from '@sentry/utils';
2
+ import { getDefaultEnvironment } from '../utils/environment';
3
+ import { DEFAULT_BUNDLE_NAME } from './hermes';
3
4
  /**
4
5
  *
5
6
  */
@@ -53,7 +54,7 @@ export function createProfilingEvent(profile, event) {
53
54
  }
54
55
  return createProfilePayload(profile, {
55
56
  release: event.release || '',
56
- environment: event.environment || '',
57
+ environment: event.environment || getDefaultEnvironment(),
57
58
  event_id: event.event_id || '',
58
59
  transaction: event.transaction || '',
59
60
  start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),
@@ -88,7 +89,7 @@ function createProfilePayload(cpuProfile, { release, environment, event_id, tran
88
89
  const profile = {
89
90
  event_id: profile_id,
90
91
  timestamp: new Date(start_timestamp).toISOString(),
91
- platform: 'node',
92
+ platform: 'javascript',
92
93
  version: '1',
93
94
  release: release,
94
95
  environment: environment,
@@ -113,11 +114,40 @@ function createProfilePayload(cpuProfile, { release, environment, event_id, tran
113
114
  name: transaction,
114
115
  id: event_id,
115
116
  trace_id: trace_id || '',
116
- active_thread_id: ACTIVE_THREAD_ID_STRING,
117
+ active_thread_id: cpuProfile.active_thread_id,
118
+ },
119
+ debug_meta: {
120
+ images: getDebugMetadata(),
117
121
  },
118
122
  };
119
123
  return profile;
120
124
  }
125
+ /**
126
+ * Returns debug meta images of the loaded bundle.
127
+ */
128
+ export function getDebugMetadata() {
129
+ if (!DEFAULT_BUNDLE_NAME) {
130
+ return [];
131
+ }
132
+ const debugIdMap = GLOBAL_OBJ._sentryDebugIds;
133
+ if (!debugIdMap) {
134
+ return [];
135
+ }
136
+ const debugIdsKeys = Object.keys(debugIdMap);
137
+ if (!debugIdsKeys.length) {
138
+ return [];
139
+ }
140
+ if (debugIdsKeys.length > 1) {
141
+ logger.warn('[Profiling] Multiple debug images found, but only one one bundle is supported. Using the first one...');
142
+ }
143
+ return [
144
+ {
145
+ code_file: DEFAULT_BUNDLE_NAME,
146
+ debug_id: debugIdMap[debugIdsKeys[0]],
147
+ type: 'sourcemap',
148
+ },
149
+ ];
150
+ }
121
151
  /**
122
152
  * Adds items to envelope if they are not already present - mutates the envelope.
123
153
  * @param envelope
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAA4B;IACzD,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;QAC/B,IAAI,OAAO,EAAE;YACX,6EAA6E;YAC7E,8EAA8E;YAC9E,gEAAgE;YAChE,MAAM,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;SACtF;QACD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAAC,QAA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":["import type { Envelope, Event, Profile } from '@sentry/types';\nimport { forEachEnvelopeItem, logger } from '@sentry/utils';\n\nimport type { RawThreadCpuProfile } from './types';\n\nconst ACTIVE_THREAD_ID_STRING = '0';\n\n/**\n *\n */\nexport function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n if (__DEV__) {\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n }\n return false;\n }\n\n if (!profile.profile_id) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param envelope\n * @returns\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: Event[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type\n for (let j = 1; j < item.length; j++) {\n const event = item[j];\n\n // @ts-expect-error accessing private property\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (event && event.contexts && event.contexts['profile'] && event.contexts['profile']['profile_id']) {\n events.push(item[j] as Event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param event\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(profile: RawThreadCpuProfile, event: Event): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(profile, {\n release: event.release || '',\n environment: event.environment || '',\n event_id: event.event_id || '',\n transaction: event.transaction || '',\n start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),\n trace_id: (event?.contexts?.trace?.trace_id as string) ?? '',\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n profile_id: profile.profile_id,\n os_platform: event.contexts?.os?.name || '',\n os_version: event.contexts?.os?.version || '',\n os_build: event.contexts?.os?.build || '',\n device_locale: (event.contexts?.device?.locale as string) || '',\n device_model: event.contexts?.device?.model || '',\n device_manufacturer: event.contexts?.device?.manufacturer || '',\n device_architecture: event.contexts?.device?.arch || '',\n device_is_emulator: event.contexts?.device?.simulator || false,\n });\n}\n\n/**\n * Create a profile\n * @param profile\n * @param options\n * @returns\n */\nfunction createProfilePayload(\n cpuProfile: RawThreadCpuProfile,\n {\n release,\n environment,\n event_id,\n transaction,\n start_timestamp,\n trace_id,\n profile_id,\n os_platform,\n os_version,\n os_build,\n device_locale,\n device_model,\n device_manufacturer,\n device_architecture,\n device_is_emulator,\n }: {\n release: string;\n environment: string;\n event_id: string;\n transaction: string;\n start_timestamp: number;\n trace_id: string | undefined;\n profile_id: string;\n os_platform: string;\n os_version: string;\n os_build?: string;\n device_locale: string;\n device_model: string;\n device_manufacturer: string;\n device_architecture: string;\n device_is_emulator: boolean;\n },\n): Profile {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id && trace_id.length !== 32) {\n if (__DEV__) {\n logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n }\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(start_timestamp).toISOString(),\n platform: 'node',\n version: '1',\n release: release,\n environment: environment,\n runtime: {\n name: 'hermes',\n version: '', // TODO: get hermes version\n },\n os: {\n name: os_platform,\n version: os_version,\n build_number: os_build,\n },\n device: {\n locale: device_locale,\n model: device_model,\n manufacturer: device_manufacturer,\n architecture: device_architecture,\n is_emulator: device_is_emulator,\n },\n profile: cpuProfile,\n transaction: {\n name: transaction,\n id: event_id,\n trace_id: trace_id || '',\n active_thread_id: ACTIVE_THREAD_ID_STRING,\n },\n };\n\n return profile;\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param envelope\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/js/profiling/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAExE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAA4B;IACzD,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE;QAC/B,IAAI,OAAO,EAAE;YACX,6EAA6E;YAC7E,8EAA8E;YAC9E,gEAAgE;YAChE,MAAM,CAAC,GAAG,CAAC,wEAAwE,CAAC,CAAC;SACtF;QACD,OAAO,KAAK,CAAC;KACd;IAED,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;QACvB,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAAC,QAAkB;IACrE,MAAM,MAAM,GAAY,EAAE,CAAC;IAE3B,mBAAmB,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QAC3C,IAAI,IAAI,KAAK,aAAa,EAAE;YAC1B,OAAO;SACR;QAED,yBAAyB;QACzB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACpC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAEtB,8CAA8C;YAC9C,sEAAsE;YACtE,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,KAAK,CAAC,QAAQ,CA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O,IAAI,QAAQ,EAAE;QAC9B,oCAAoC;QACpC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;KAClD;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import type { DebugImage, Envelope, Event, Profile } from '@sentry/types';\nimport { forEachEnvelopeItem, GLOBAL_OBJ, logger } from '@sentry/utils';\n\nimport { getDefaultEnvironment } from '../utils/environment';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\nimport type { RawThreadCpuProfile } from './types';\n\n/**\n *\n */\nexport function isValidProfile(profile: RawThreadCpuProfile): profile is RawThreadCpuProfile & { profile_id: string } {\n if (profile.samples.length <= 1) {\n if (__DEV__) {\n // Log a warning if the profile has less than 2 samples so users can know why\n // they are not seeing any profiling data and we cant avoid the back and forth\n // of asking them to provide us with a dump of the profile data.\n logger.log('[Profiling] Discarding profile because it contains less than 2 samples');\n }\n return false;\n }\n\n if (!profile.profile_id) {\n return false;\n }\n\n return true;\n}\n\n/**\n * Finds transactions with profile_id context in the envelope\n * @param envelope\n * @returns\n */\nexport function findProfiledTransactionsFromEnvelope(envelope: Envelope): Event[] {\n const events: Event[] = [];\n\n forEachEnvelopeItem(envelope, (item, type) => {\n if (type !== 'transaction') {\n return;\n }\n\n // First item is the type\n for (let j = 1; j < item.length; j++) {\n const event = item[j];\n\n // @ts-expect-error accessing private property\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (event && event.contexts && event.contexts['profile'] && event.contexts['profile']['profile_id']) {\n events.push(item[j] as Event);\n }\n }\n });\n\n return events;\n}\n\n/**\n * Creates a profiling envelope item, if the profile does not pass validation, returns null.\n * @param event\n * @returns {Profile | null}\n */\nexport function createProfilingEvent(profile: RawThreadCpuProfile, event: Event): Profile | null {\n if (!isValidProfile(profile)) {\n return null;\n }\n\n return createProfilePayload(profile, {\n release: event.release || '',\n environment: event.environment || getDefaultEnvironment(),\n event_id: event.event_id || '',\n transaction: event.transaction || '',\n start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),\n trace_id: (event?.contexts?.trace?.trace_id as string) ?? '',\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n profile_id: profile.profile_id,\n os_platform: event.contexts?.os?.name || '',\n os_version: event.contexts?.os?.version || '',\n os_build: event.contexts?.os?.build || '',\n device_locale: (event.contexts?.device?.locale as string) || '',\n device_model: event.contexts?.device?.model || '',\n device_manufacturer: event.contexts?.device?.manufacturer || '',\n device_architecture: event.contexts?.device?.arch || '',\n device_is_emulator: event.contexts?.device?.simulator || false,\n });\n}\n\n/**\n * Create a profile\n * @param profile\n * @param options\n * @returns\n */\nfunction createProfilePayload(\n cpuProfile: RawThreadCpuProfile,\n {\n release,\n environment,\n event_id,\n transaction,\n start_timestamp,\n trace_id,\n profile_id,\n os_platform,\n os_version,\n os_build,\n device_locale,\n device_model,\n device_manufacturer,\n device_architecture,\n device_is_emulator,\n }: {\n release: string;\n environment: string;\n event_id: string;\n transaction: string;\n start_timestamp: number;\n trace_id: string | undefined;\n profile_id: string;\n os_platform: string;\n os_version: string;\n os_build?: string;\n device_locale: string;\n device_model: string;\n device_manufacturer: string;\n device_architecture: string;\n device_is_emulator: boolean;\n },\n): Profile {\n // Log a warning if the profile has an invalid traceId (should be uuidv4).\n // All profiles and transactions are rejected if this is the case and we want to\n // warn users that this is happening if they enable debug flag\n if (trace_id && trace_id.length !== 32) {\n if (__DEV__) {\n logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);\n }\n }\n\n const profile: Profile = {\n event_id: profile_id,\n timestamp: new Date(start_timestamp).toISOString(),\n platform: 'javascript',\n version: '1',\n release: release,\n environment: environment,\n runtime: {\n name: 'hermes',\n version: '', // TODO: get hermes version\n },\n os: {\n name: os_platform,\n version: os_version,\n build_number: os_build,\n },\n device: {\n locale: device_locale,\n model: device_model,\n manufacturer: device_manufacturer,\n architecture: device_architecture,\n is_emulator: device_is_emulator,\n },\n profile: cpuProfile,\n transaction: {\n name: transaction,\n id: event_id,\n trace_id: trace_id || '',\n active_thread_id: cpuProfile.active_thread_id,\n },\n debug_meta: {\n images: getDebugMetadata(),\n },\n };\n\n return profile;\n}\n\n/**\n * Returns debug meta images of the loaded bundle.\n */\nexport function getDebugMetadata(): DebugImage[] {\n if (!DEFAULT_BUNDLE_NAME) {\n return [];\n }\n\n const debugIdMap = GLOBAL_OBJ._sentryDebugIds;\n if (!debugIdMap) {\n return [];\n }\n\n const debugIdsKeys = Object.keys(debugIdMap);\n if (!debugIdsKeys.length) {\n return [];\n }\n\n if (debugIdsKeys.length > 1) {\n logger.warn(\n '[Profiling] Multiple debug images found, but only one one bundle is supported. Using the first one...',\n );\n }\n\n return [\n {\n code_file: DEFAULT_BUNDLE_NAME,\n debug_id: debugIdMap[debugIdsKeys[0]],\n type: 'sourcemap',\n },\n ];\n}\n\n/**\n * Adds items to envelope if they are not already present - mutates the envelope.\n * @param envelope\n */\nexport function addProfilesToEnvelope(envelope: Envelope, profiles: Profile[]): Envelope {\n if (!profiles.length) {\n return envelope;\n }\n\n for (const profile of profiles) {\n // @ts-expect-error untyped envelope\n envelope[1].push([{ type: 'profile' }, profile]);\n }\n return envelope;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAA6C,GAAG,EAAmC,MAAM,cAAc,CAAC;AAQ/G,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,OAAO,KAAK,EAA4B,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA+BzG;;GAEG;AACH,wBAAgB,IAAI,CAAC,aAAa,EAAE,kBAAkB,GAAG,IA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AC;AAkB/B,OAAO,KAAK,EAA4B,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAgCzG;;GAEG;AACH,wBAAgB,IAAI,CAAC,aAAa,EAAE,kBAAkB,GAAG,IAAI,CAsF5D;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,aAAa,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACrC,OAAO,CAAC,EAAE,yBAAyB,GAClC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAsBxB;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAKlC;AAED;;;GAGG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,CAe9C;AAED;;GAEG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAU3C;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CASxF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CASlG"}
package/dist/js/sdk.js CHANGED
@@ -15,6 +15,7 @@ import { TouchEventBoundary } from './touchevents';
15
15
  import { ReactNativeProfiler, ReactNativeTracing } from './tracing';
16
16
  import { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';
17
17
  import { makeUtf8TextEncoder } from './transports/TextEncoder';
18
+ import { getDefaultEnvironment } from './utils/environment';
18
19
  import { safeFactory, safeTracesSampler } from './utils/safe';
19
20
  import { NATIVE } from './wrapper';
20
21
  const IGNORED_DEFAULT_INTEGRATIONS = [
@@ -56,6 +57,9 @@ export function init(passedOptions) {
56
57
  enableNative,
57
58
  })
58
59
  || makeFetchTransport, transportOptions: Object.assign(Object.assign(Object.assign({}, DEFAULT_OPTIONS.transportOptions), ((_d = passedOptions.transportOptions) !== null && _d !== void 0 ? _d : {})), { bufferSize: maxQueueSize }), maxQueueSize, integrations: [], stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser), beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }), initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }), tracesSampler: safeTracesSampler(passedOptions.tracesSampler) });
60
+ if (!('environment' in options)) {
61
+ options.environment = getDefaultEnvironment();
62
+ }
59
63
  const defaultIntegrations = passedOptions.defaultIntegrations || [];
60
64
  if (passedOptions.defaultIntegrations === undefined) {
61
65
  defaultIntegrations.push(new ModulesLoader());
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,mBAAmB,IAAI,wBAAwB,EAC/C,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,KAAK,MAAM,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,CAAC;SACzC;IACH,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAsB;;IACxD,MAAA,aAAa,EAAE,CAAC,SAAS,EAAqB,0CAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgC;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgC;IAC7D,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;SAChE;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["import type { Scope } from '@sentry/core';\nimport { getIntegrationsToSetup, hasTracingEnabled, Hub, initAndBind, makeMain, setExtra } from '@sentry/core';\nimport { HttpClient } from '@sentry/integrations';\nimport {\n defaultIntegrations as reactDefaultIntegrations,\n defaultStackParser,\n getCurrentHub,\n makeFetchTransport,\n} from '@sentry/react';\nimport type { Integration, UserFeedback } from '@sentry/types';\nimport { logger, stackParserFromStackParserOptions } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport {\n DebugSymbolicator,\n DeviceContext,\n EventOrigin,\n HermesProfiling,\n ModulesLoader,\n ReactNativeErrorHandlers,\n ReactNativeInfo,\n Release,\n SdkInfo,\n} from './integrations';\nimport { NativeLinkedErrors } from './integrations/nativelinkederrors';\nimport { createReactNativeRewriteFrames } from './integrations/rewriteframes';\nimport { Screenshot } from './integrations/screenshot';\nimport { ViewHierarchy } from './integrations/viewhierarchy';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { ReactNativeScope } from './scope';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler, ReactNativeTracing } from './tracing';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { makeUtf8TextEncoder } from './transports/TextEncoder';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\nimport { NATIVE } from './wrapper';\n\nconst IGNORED_DEFAULT_INTEGRATIONS = [\n 'GlobalHandlers', // We will use the react-native internal handlers\n 'TryCatch', // We don't need this\n 'LinkedErrors', // We replace this with `NativeLinkedError`\n];\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n transportOptions: {\n textEncoder: makeUtf8TextEncoder(),\n },\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n enableCaptureFailedRequests: false,\n enableNdk: true,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n const reactNativeHub = new Hub(undefined, new ReactNativeScope());\n makeMain(reactNativeHub);\n\n const maxQueueSize = passedOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? passedOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n\n const enableNative = passedOptions.enableNative === undefined || passedOptions.enableNative\n ? NATIVE.isNativeAvailable()\n : false;\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n enableNative,\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport\n || makeNativeTransportFactory({\n enableNative,\n })\n || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }),\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n tracesSampler: safeTracesSampler(passedOptions.tracesSampler),\n };\n\n const defaultIntegrations: Integration[] = passedOptions.defaultIntegrations || [];\n if (passedOptions.defaultIntegrations === undefined) {\n defaultIntegrations.push(new ModulesLoader());\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\n defaultIntegrations.push(new Release());\n defaultIntegrations.push(...[\n ...reactDefaultIntegrations.filter(\n (i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)\n ),\n ]);\n\n defaultIntegrations.push(new NativeLinkedErrors());\n defaultIntegrations.push(new EventOrigin());\n defaultIntegrations.push(new SdkInfo());\n defaultIntegrations.push(new ReactNativeInfo());\n\n if (__DEV__) {\n defaultIntegrations.push(new DebugSymbolicator());\n }\n\n defaultIntegrations.push(createReactNativeRewriteFrames());\n if (options.enableNative) {\n defaultIntegrations.push(new DeviceContext());\n }\n if (options._experiments && typeof options._experiments.profilesSampleRate === 'number') {\n defaultIntegrations.push(new HermesProfiling());\n }\n if (hasTracingEnabled(options) && options.enableAutoPerformanceTracing) {\n defaultIntegrations.push(new ReactNativeTracing());\n }\n if (options.attachScreenshot) {\n defaultIntegrations.push(new Screenshot());\n }\n if (options.attachViewHierarchy) {\n defaultIntegrations.push(new ViewHierarchy());\n }\n if (options.enableCaptureFailedRequests) {\n defaultIntegrations.push(new HttpClient());\n }\n }\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P extends Record<string, unknown>>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);\n if (tracingIntegration) {\n tracingIntegration.useAppStartWithProfiler = true;\n }\n\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * Deprecated. Sets the release on the event.\n * NOTE: Does not set the release on sessions.\n * @deprecated\n */\nexport function setRelease(release: string): void {\n setExtra('__sentry_release', release);\n}\n\n/**\n * Deprecated. Sets the dist on the event.\n * NOTE: Does not set the dist on sessions.\n * @deprecated\n */\nexport function setDist(dist: string): void {\n setExtra('__sentry_dist', dist);\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n if (client) {\n client.nativeCrash();\n }\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n */\nexport function captureUserFeedback(feedback: UserFeedback): void {\n getCurrentHub().getClient<ReactNativeClient>()?.captureUserFeedback(feedback);\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n }\n };\n getCurrentHub().withScope(safeCallback);\n}\n\n/**\n * Callback to set context information onto the scope.\n * @param callback Callback function that receives Scope.\n */\nexport function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running configureScope callback', e);\n }\n };\n getCurrentHub().configureScope(safeCallback);\n}\n"]}
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/js/sdk.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,GAAG,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,mBAAmB,IAAI,wBAAwB,EAC/C,kBAAkB,EAClB,aAAa,EACb,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,iCAAiC,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,i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,MAAM,EAAE;gBACV,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;aACtB;SACF;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC;SACzC;IACH,CAAC;CAAA;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,QAAsB;;IACxD,MAAA,aAAa,EAAE,CAAC,SAAS,EAAqB,0CAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AAChF,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgC;IACxD,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,CAAC,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,QAAgC;IAC7D,MAAM,YAAY,GAAG,CAAC,KAAY,EAAQ,EAAE;QAC1C,IAAI;YACF,QAAQ,CAAC,KAAK,CAAC,CAAC;SACjB;QAAC,OAAO,CAAC,EAAE;YACV,MAAM,CAAC,KAAK,CAAC,6CAA6C,EAAE,CAAC,CAAC,CAAC;SAChE;IACH,CAAC,CAAC;IACF,aAAa,EAAE,CAAC,cAAc,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC","sourcesContent":["/* eslint-disable complexity */\nimport type { Scope } from '@sentry/core';\nimport { getIntegrationsToSetup, hasTracingEnabled, Hub, initAndBind, makeMain, setExtra } from '@sentry/core';\nimport { HttpClient } from '@sentry/integrations';\nimport {\n defaultIntegrations as reactDefaultIntegrations,\n defaultStackParser,\n getCurrentHub,\n makeFetchTransport,\n} from '@sentry/react';\nimport type { Integration, UserFeedback } from '@sentry/types';\nimport { logger, stackParserFromStackParserOptions } from '@sentry/utils';\nimport * as React from 'react';\n\nimport { ReactNativeClient } from './client';\nimport {\n DebugSymbolicator,\n DeviceContext,\n EventOrigin,\n HermesProfiling,\n ModulesLoader,\n ReactNativeErrorHandlers,\n ReactNativeInfo,\n Release,\n SdkInfo,\n} from './integrations';\nimport { NativeLinkedErrors } from './integrations/nativelinkederrors';\nimport { createReactNativeRewriteFrames } from './integrations/rewriteframes';\nimport { Screenshot } from './integrations/screenshot';\nimport { ViewHierarchy } from './integrations/viewhierarchy';\nimport type { ReactNativeClientOptions, ReactNativeOptions, ReactNativeWrapperOptions } from './options';\nimport { ReactNativeScope } from './scope';\nimport { TouchEventBoundary } from './touchevents';\nimport { ReactNativeProfiler, ReactNativeTracing } from './tracing';\nimport { DEFAULT_BUFFER_SIZE, makeNativeTransportFactory } from './transports/native';\nimport { makeUtf8TextEncoder } from './transports/TextEncoder';\nimport { getDefaultEnvironment } from './utils/environment';\nimport { safeFactory, safeTracesSampler } from './utils/safe';\nimport { NATIVE } from './wrapper';\n\nconst IGNORED_DEFAULT_INTEGRATIONS = [\n 'GlobalHandlers', // We will use the react-native internal handlers\n 'TryCatch', // We don't need this\n 'LinkedErrors', // We replace this with `NativeLinkedError`\n];\nconst DEFAULT_OPTIONS: ReactNativeOptions = {\n enableNativeCrashHandling: true,\n enableNativeNagger: true,\n autoInitializeNativeSdk: true,\n enableAutoPerformanceTracing: true,\n enableWatchdogTerminationTracking: true,\n patchGlobalPromise: true,\n transportOptions: {\n textEncoder: makeUtf8TextEncoder(),\n },\n sendClientReports: true,\n maxQueueSize: DEFAULT_BUFFER_SIZE,\n attachStacktrace: true,\n enableCaptureFailedRequests: false,\n enableNdk: true,\n};\n\n/**\n * Inits the SDK and returns the final options.\n */\nexport function init(passedOptions: ReactNativeOptions): void {\n const reactNativeHub = new Hub(undefined, new ReactNativeScope());\n makeMain(reactNativeHub);\n\n const maxQueueSize = passedOptions.maxQueueSize\n // eslint-disable-next-line deprecation/deprecation\n ?? passedOptions.transportOptions?.bufferSize\n ?? DEFAULT_OPTIONS.maxQueueSize;\n\n const enableNative = passedOptions.enableNative === undefined || passedOptions.enableNative\n ? NATIVE.isNativeAvailable()\n : false;\n const options: ReactNativeClientOptions = {\n ...DEFAULT_OPTIONS,\n ...passedOptions,\n enableNative,\n // If custom transport factory fails the SDK won't initialize\n transport: passedOptions.transport\n || makeNativeTransportFactory({\n enableNative,\n })\n || makeFetchTransport,\n transportOptions: {\n ...DEFAULT_OPTIONS.transportOptions,\n ...(passedOptions.transportOptions ?? {}),\n bufferSize: maxQueueSize,\n },\n maxQueueSize,\n integrations: [],\n stackParser: stackParserFromStackParserOptions(passedOptions.stackParser || defaultStackParser),\n beforeBreadcrumb: safeFactory(passedOptions.beforeBreadcrumb, { loggerMessage: 'The beforeBreadcrumb threw an error' }),\n initialScope: safeFactory(passedOptions.initialScope, { loggerMessage: 'The initialScope threw an error' }),\n tracesSampler: safeTracesSampler(passedOptions.tracesSampler),\n };\n if (!('environment' in options)) {\n options.environment = getDefaultEnvironment();\n }\n\n const defaultIntegrations: Integration[] = passedOptions.defaultIntegrations || [];\n if (passedOptions.defaultIntegrations === undefined) {\n defaultIntegrations.push(new ModulesLoader());\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\n defaultIntegrations.push(new Release());\n defaultIntegrations.push(...[\n ...reactDefaultIntegrations.filter(\n (i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)\n ),\n ]);\n\n defaultIntegrations.push(new NativeLinkedErrors());\n defaultIntegrations.push(new EventOrigin());\n defaultIntegrations.push(new SdkInfo());\n defaultIntegrations.push(new ReactNativeInfo());\n\n if (__DEV__) {\n defaultIntegrations.push(new DebugSymbolicator());\n }\n\n defaultIntegrations.push(createReactNativeRewriteFrames());\n if (options.enableNative) {\n defaultIntegrations.push(new DeviceContext());\n }\n if (options._experiments && typeof options._experiments.profilesSampleRate === 'number') {\n defaultIntegrations.push(new HermesProfiling());\n }\n if (hasTracingEnabled(options) && options.enableAutoPerformanceTracing) {\n defaultIntegrations.push(new ReactNativeTracing());\n }\n if (options.attachScreenshot) {\n defaultIntegrations.push(new Screenshot());\n }\n if (options.attachViewHierarchy) {\n defaultIntegrations.push(new ViewHierarchy());\n }\n if (options.enableCaptureFailedRequests) {\n defaultIntegrations.push(new HttpClient());\n }\n }\n\n options.integrations = getIntegrationsToSetup({\n integrations: safeFactory(passedOptions.integrations, { loggerMessage: 'The integrations threw an error' }),\n defaultIntegrations,\n });\n initAndBind(ReactNativeClient, options);\n}\n\n/**\n * Inits the Sentry React Native SDK with automatic instrumentation and wrapped features.\n */\nexport function wrap<P extends Record<string, unknown>>(\n RootComponent: React.ComponentType<P>,\n options?: ReactNativeWrapperOptions\n): React.ComponentType<P> {\n const tracingIntegration = getCurrentHub().getIntegration(ReactNativeTracing);\n if (tracingIntegration) {\n tracingIntegration.useAppStartWithProfiler = true;\n }\n\n const profilerProps = {\n ...(options?.profilerProps ?? {}),\n name: RootComponent.displayName ?? 'Root',\n };\n\n const RootApp: React.FC<P> = (appProps) => {\n return (\n <TouchEventBoundary {...(options?.touchEventBoundaryProps ?? {})}>\n <ReactNativeProfiler {...profilerProps}>\n <RootComponent {...appProps} />\n </ReactNativeProfiler>\n </TouchEventBoundary>\n );\n };\n\n return RootApp;\n}\n\n/**\n * Deprecated. Sets the release on the event.\n * NOTE: Does not set the release on sessions.\n * @deprecated\n */\nexport function setRelease(release: string): void {\n setExtra('__sentry_release', release);\n}\n\n/**\n * Deprecated. Sets the dist on the event.\n * NOTE: Does not set the dist on sessions.\n * @deprecated\n */\nexport function setDist(dist: string): void {\n setExtra('__sentry_dist', dist);\n}\n\n/**\n * If native client is available it will trigger a native crash.\n * Use this only for testing purposes.\n */\nexport function nativeCrash(): void {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n if (client) {\n client.nativeCrash();\n }\n}\n\n/**\n * Flushes all pending events in the queue to disk.\n * Use this before applying any realtime updates such as code-push or expo updates.\n */\nexport async function flush(): Promise<boolean> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n const result = await client.flush();\n\n return result;\n }\n // eslint-disable-next-line no-empty\n } catch (_) { }\n\n logger.error('Failed to flush the event queue.');\n\n return false;\n}\n\n/**\n * Closes the SDK, stops sending events.\n */\nexport async function close(): Promise<void> {\n try {\n const client = getCurrentHub().getClient<ReactNativeClient>();\n\n if (client) {\n await client.close();\n }\n } catch (e) {\n logger.error('Failed to close the SDK');\n }\n}\n\n/**\n * Captures user feedback and sends it to Sentry.\n */\nexport function captureUserFeedback(feedback: UserFeedback): void {\n getCurrentHub().getClient<ReactNativeClient>()?.captureUserFeedback(feedback);\n}\n\n/**\n * Creates a new scope with and executes the given operation within.\n * The scope is automatically removed once the operation\n * finishes or throws.\n *\n * This is essentially a convenience function for:\n *\n * pushScope();\n * callback();\n * popScope();\n *\n * @param callback that will be enclosed into push/popScope.\n */\nexport function withScope(callback: (scope: Scope) => void): ReturnType<Hub['withScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running withScope callback', e);\n }\n };\n getCurrentHub().withScope(safeCallback);\n}\n\n/**\n * Callback to set context information onto the scope.\n * @param callback Callback function that receives Scope.\n */\nexport function configureScope(callback: (scope: Scope) => void): ReturnType<Hub['configureScope']> {\n const safeCallback = (scope: Scope): void => {\n try {\n callback(scope);\n } catch (e) {\n logger.error('Error while running configureScope callback', e);\n }\n };\n getCurrentHub().configureScope(safeCallback);\n}\n"]}
@@ -10,4 +10,6 @@ export declare function getReactNativeVersion(): string;
10
10
  export declare function isExpo(): boolean;
11
11
  /** Returns Hermes Version if hermes is present in the runtime */
12
12
  export declare function getHermesVersion(): string | undefined;
13
+ /** Returns default environment based on __DEV__ */
14
+ export declare function getDefaultEnvironment(): 'development' | 'production';
13
15
  //# sourceMappingURL=environment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/js/utils/environment.ts"],"names":[],"mappings":"AAIA,0DAA0D;AAC1D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,oDAAoD;AACpD,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAMrD"}
1
+ {"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../../../src/js/utils/environment.ts"],"names":[],"mappings":"AAIA,0DAA0D;AAC1D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,IAAI,OAAO,CAEzC;AAED,oDAAoD;AACpD,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,+CAA+C;AAC/C,wBAAgB,MAAM,IAAI,OAAO,CAEhC;AAED,iEAAiE;AACjE,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,SAAS,CAMrD;AAED,mDAAmD;AACnD,wBAAgB,qBAAqB,IAAI,aAAa,GAAG,YAAY,CAEpE"}
@@ -26,4 +26,8 @@ export function getHermesVersion() {
26
26
  RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties &&
27
27
  RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties()['OSS Release Version']);
28
28
  }
29
+ /** Returns default environment based on __DEV__ */
30
+ export function getDefaultEnvironment() {
31
+ return typeof __DEV__ !== 'undefined' && __DEV__ ? 'development' : 'production';
32
+ }
29
33
  //# sourceMappingURL=environment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/js/utils/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,gDAAgD,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,0DAA0D;AAC1D,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC;AACxC,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,oBAAoB;IAClC,OAAO,aAAa,CAAC,kBAAkB,IAAI,IAAI,CAAC;AAClD,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,eAAe;IAC7B,OAAO,aAAa,CAAC,qBAAqB,IAAI,IAAI,CAAC;AACrD,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,qBAAqB;IACnC,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACvG,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,MAAM;IACpB,OAAO,aAAa,CAAC,IAAI,IAAI,IAAI,CAAC;AACpC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CACL,aAAa,CAAC,cAAc;QAC5B,aAAa,CAAC,cAAc,CAAC,oBAAoB;QACjD,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC,qBAAqB,CAAC,CAC3E,CAAC;AACJ,CAAC","sourcesContent":["import { version as RNV } from 'react-native/Libraries/Core/ReactNativeVersion';\n\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\n\n/** Checks if the React Native Hermes engine is running */\nexport function isHermesEnabled(): boolean {\n return !!RN_GLOBAL_OBJ.HermesInternal;\n}\n\n/** Checks if the React Native TurboModules are enabled */\nexport function isTurboModuleEnabled(): boolean {\n return RN_GLOBAL_OBJ.__turboModuleProxy != null;\n}\n\n/** Checks if the React Native Fabric renderer is running */\nexport function isFabricEnabled(): boolean {\n return RN_GLOBAL_OBJ.nativeFabricUIManager != null;\n}\n\n/** Returns React Native Version as semver string */\nexport function getReactNativeVersion(): string {\n return `${RNV.major}.${RNV.minor}.${RNV.patch}${RNV.prerelease != null ? `-${RNV.prerelease}` : ''}`;\n}\n\n/** Checks if Expo is present in the runtime */\nexport function isExpo(): boolean {\n return RN_GLOBAL_OBJ.expo != null;\n}\n\n/** Returns Hermes Version if hermes is present in the runtime */\nexport function getHermesVersion(): string | undefined {\n return (\n RN_GLOBAL_OBJ.HermesInternal &&\n RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties &&\n RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties()['OSS Release Version']\n );\n}\n"]}
1
+ {"version":3,"file":"environment.js","sourceRoot":"","sources":["../../../src/js/utils/environment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,gDAAgD,CAAC;AAEhF,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,0DAA0D;AAC1D,MAAM,UAAU,eAAe;IAC7B,OAAO,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC;AACxC,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,oBAAoB;IAClC,OAAO,aAAa,CAAC,kBAAkB,IAAI,IAAI,CAAC;AAClD,CAAC;AAED,4DAA4D;AAC5D,MAAM,UAAU,eAAe;IAC7B,OAAO,aAAa,CAAC,qBAAqB,IAAI,IAAI,CAAC;AACrD,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,qBAAqB;IACnC,OAAO,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,UAAU,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACvG,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,MAAM;IACpB,OAAO,aAAa,CAAC,IAAI,IAAI,IAAI,CAAC;AACpC,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CACL,aAAa,CAAC,cAAc;QAC5B,aAAa,CAAC,cAAc,CAAC,oBAAoB;QACjD,aAAa,CAAC,cAAc,CAAC,oBAAoB,EAAE,CAAC,qBAAqB,CAAC,CAC3E,CAAC;AACJ,CAAC;AAED,mDAAmD;AACnD,MAAM,UAAU,qBAAqB;IACnC,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;AAClF,CAAC","sourcesContent":["import { version as RNV } from 'react-native/Libraries/Core/ReactNativeVersion';\n\nimport { RN_GLOBAL_OBJ } from '../utils/worldwide';\n\n/** Checks if the React Native Hermes engine is running */\nexport function isHermesEnabled(): boolean {\n return !!RN_GLOBAL_OBJ.HermesInternal;\n}\n\n/** Checks if the React Native TurboModules are enabled */\nexport function isTurboModuleEnabled(): boolean {\n return RN_GLOBAL_OBJ.__turboModuleProxy != null;\n}\n\n/** Checks if the React Native Fabric renderer is running */\nexport function isFabricEnabled(): boolean {\n return RN_GLOBAL_OBJ.nativeFabricUIManager != null;\n}\n\n/** Returns React Native Version as semver string */\nexport function getReactNativeVersion(): string {\n return `${RNV.major}.${RNV.minor}.${RNV.patch}${RNV.prerelease != null ? `-${RNV.prerelease}` : ''}`;\n}\n\n/** Checks if Expo is present in the runtime */\nexport function isExpo(): boolean {\n return RN_GLOBAL_OBJ.expo != null;\n}\n\n/** Returns Hermes Version if hermes is present in the runtime */\nexport function getHermesVersion(): string | undefined {\n return (\n RN_GLOBAL_OBJ.HermesInternal &&\n RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties &&\n RN_GLOBAL_OBJ.HermesInternal.getRuntimeProperties()['OSS Release Version']\n );\n}\n\n/** Returns default environment based on __DEV__ */\nexport function getDefaultEnvironment(): 'development' | 'production' {\n return typeof __DEV__ !== 'undefined' && __DEV__ ? 'development' : 'production';\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
2
2
  export declare const SDK_NAME = "sentry.javascript.react-native";
3
- export declare const SDK_VERSION = "5.11.1";
3
+ export declare const SDK_VERSION = "5.12.0";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';
2
2
  export const SDK_NAME = 'sentry.javascript.react-native';
3
- export const SDK_VERSION = '5.11.1';
3
+ export const SDK_VERSION = '5.12.0';
4
4
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.11.1';\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAC3D,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,QAAQ,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.12.0';\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@sentry/react-native",
3
3
  "homepage": "https://github.com/getsentry/sentry-react-native",
4
4
  "repository": "https://github.com/getsentry/sentry-react-native",
5
- "version": "5.11.1",
5
+ "version": "5.12.0",
6
6
  "description": "Official Sentry SDK for react-native",
7
7
  "typings": "dist/js/index.d.ts",
8
8
  "types": "dist/js/index.d.ts",
@@ -58,20 +58,20 @@
58
58
  "react-native": ">=0.65.0"
59
59
  },
60
60
  "dependencies": {
61
- "@sentry/browser": "7.73.0",
61
+ "@sentry/browser": "7.76.0",
62
62
  "@sentry/cli": "2.21.2",
63
- "@sentry/core": "7.73.0",
64
- "@sentry/hub": "7.73.0",
65
- "@sentry/integrations": "7.73.0",
66
- "@sentry/react": "7.73.0",
67
- "@sentry/types": "7.73.0",
68
- "@sentry/utils": "7.73.0"
63
+ "@sentry/core": "7.76.0",
64
+ "@sentry/hub": "7.76.0",
65
+ "@sentry/integrations": "7.76.0",
66
+ "@sentry/react": "7.76.0",
67
+ "@sentry/types": "7.76.0",
68
+ "@sentry/utils": "7.76.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@sentry-internal/eslint-config-sdk": "7.73.0",
72
- "@sentry-internal/eslint-plugin-sdk": "7.73.0",
71
+ "@sentry-internal/eslint-config-sdk": "7.76.0",
72
+ "@sentry-internal/eslint-plugin-sdk": "7.76.0",
73
73
  "@sentry/typescript": "^5.20.1",
74
- "@sentry/wizard": "3.13.0",
74
+ "@sentry/wizard": "3.16.1",
75
75
  "@types/jest": "^29.5.3",
76
76
  "@types/react": "^18.2.14",
77
77
  "@types/uglify-js": "^3.17.2",
@@ -1,4 +1,4 @@
1
- import type { ThreadCpuSample, ThreadId } from '@sentry/types';
1
+ import type { ThreadCpuFrame, ThreadCpuSample, ThreadId } from '@sentry/types';
2
2
  import type * as Hermes from './hermes';
3
3
  import type { RawThreadCpuProfile } from './types';
4
4
  /**
@@ -24,4 +24,9 @@ export declare function mapSamples(hermesSamples: Hermes.Sample[], maxElapsedSin
24
24
  hermesStacks: Set<Hermes.StackFrameId>;
25
25
  jsThreads: Set<ThreadId>;
26
26
  };
27
+ /**
28
+ * Parses Hermes StackFrame to Sentry StackFrame.
29
+ * For native frames only function name is returned, for Hermes bytecode the line and column are calculated.
30
+ */
31
+ export declare function parseHermesJSStackFrame(frame: Hermes.StackFrame): ThreadCpuFrame;
27
32
  //# sourceMappingURL=convertHermesProfile.d.ts.map
@@ -22,6 +22,8 @@ export interface Sample {
22
22
  sf: StackFrameId;
23
23
  }
24
24
  export interface StackFrame {
25
+ funcVirtAddr?: string;
26
+ offset?: string;
25
27
  line?: string;
26
28
  column?: string;
27
29
  funcLine?: string;
@@ -35,12 +37,7 @@ export interface Profile {
35
37
  samples: Sample[];
36
38
  stackFrames: Record<string, StackFrame>;
37
39
  }
38
- /**
39
- * Hermes Profile Stack Frame Name contains function name and file path.
40
- *
41
- * `foo(/path/to/file.js:1:2)` -> `foo`
42
- */
43
- export declare function parseHermesStackFrameFunctionName(hermesName: string): string;
40
+ export declare const DEFAULT_BUNDLE_NAME: string | undefined;
44
41
  /**
45
42
  * Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
46
43
  */
@@ -1,5 +1,7 @@
1
- import type { ThreadCpuProfile } from '@sentry/types';
1
+ import type { ThreadCpuFrame, ThreadCpuProfile } from '@sentry/types';
2
2
  export interface RawThreadCpuProfile extends ThreadCpuProfile {
3
+ frames: ThreadCpuFrame[];
3
4
  profile_id?: string;
5
+ active_thread_id: string;
4
6
  }
5
7
  //# sourceMappingURL=types.d.ts.map
@@ -1,4 +1,4 @@
1
- import type { Envelope, Event, Profile } from '@sentry/types';
1
+ import type { DebugImage, Envelope, Event, Profile } from '@sentry/types';
2
2
  import type { RawThreadCpuProfile } from './types';
3
3
  /**
4
4
  *
@@ -18,6 +18,10 @@ export declare function findProfiledTransactionsFromEnvelope(envelope: Envelope)
18
18
  * @returns {Profile | null}
19
19
  */
20
20
  export declare function createProfilingEvent(profile: RawThreadCpuProfile, event: Event): Profile | null;
21
+ /**
22
+ * Returns debug meta images of the loaded bundle.
23
+ */
24
+ export declare function getDebugMetadata(): DebugImage[];
21
25
  /**
22
26
  * Adds items to envelope if they are not already present - mutates the envelope.
23
27
  * @param envelope
@@ -10,4 +10,6 @@ export declare function getReactNativeVersion(): string;
10
10
  export declare function isExpo(): boolean;
11
11
  /** Returns Hermes Version if hermes is present in the runtime */
12
12
  export declare function getHermesVersion(): string | undefined;
13
+ /** Returns default environment based on __DEV__ */
14
+ export declare function getDefaultEnvironment(): 'development' | 'production';
13
15
  //# sourceMappingURL=environment.d.ts.map
@@ -1,4 +1,4 @@
1
1
  export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
2
2
  export declare const SDK_NAME = "sentry.javascript.react-native";
3
- export declare const SDK_VERSION = "5.11.1";
3
+ export declare const SDK_VERSION = "5.12.0";
4
4
  //# sourceMappingURL=version.d.ts.map