@sentry/react-native 5.15.0 → 5.16.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/app.plugin.js +1 -0
  3. package/dist/js/profiling/constants.d.ts +2 -0
  4. package/dist/js/profiling/constants.d.ts.map +1 -0
  5. package/dist/js/profiling/constants.js +2 -0
  6. package/dist/js/profiling/constants.js.map +1 -0
  7. package/dist/js/profiling/convertHermesProfile.d.ts.map +1 -1
  8. package/dist/js/profiling/convertHermesProfile.js +1 -1
  9. package/dist/js/profiling/convertHermesProfile.js.map +1 -1
  10. package/dist/js/profiling/integration.d.ts +0 -1
  11. package/dist/js/profiling/integration.d.ts.map +1 -1
  12. package/dist/js/profiling/integration.js +1 -1
  13. package/dist/js/profiling/integration.js.map +1 -1
  14. package/dist/js/sdk.d.ts.map +1 -1
  15. package/dist/js/sdk.js +9 -8
  16. package/dist/js/sdk.js.map +1 -1
  17. package/dist/js/touchevents.js +5 -8
  18. package/dist/js/touchevents.js.map +1 -1
  19. package/dist/js/version.d.ts +1 -1
  20. package/dist/js/version.d.ts.map +1 -1
  21. package/dist/js/version.js +1 -1
  22. package/dist/js/version.js.map +1 -1
  23. package/expo.d.ts +1 -0
  24. package/expo.js +1 -0
  25. package/package.json +16 -6
  26. package/plugin/build/index.d.ts +3 -0
  27. package/plugin/build/index.js +6 -0
  28. package/plugin/build/utils.d.ts +7 -0
  29. package/plugin/build/utils.js +39 -0
  30. package/plugin/build/withSentry.d.ts +10 -0
  31. package/plugin/build/withSentry.js +50 -0
  32. package/plugin/build/withSentryAndroid.d.ts +7 -0
  33. package/plugin/build/withSentryAndroid.js +68 -0
  34. package/plugin/build/withSentryIOS.d.ts +8 -0
  35. package/plugin/build/withSentryIOS.js +71 -0
  36. package/scripts/sentry-xcode-debug-files.sh +5 -1
  37. package/scripts/sentry-xcode.sh +7 -2
  38. package/ts3.8/dist/js/profiling/constants.d.ts +2 -0
  39. package/ts3.8/dist/js/profiling/integration.d.ts +0 -1
  40. package/ts3.8/dist/js/version.d.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # Changelog
2
2
 
3
+ ## 5.16.0-alpha.1
4
+
5
+ ### Features
6
+
7
+ - Add `@sentry/react-native/expo` Expo config plugin ([#3429](https://github.com/getsentry/sentry-react-native/pull/3429))
8
+
9
+ This Release introduces the first alpha version of our new SDK for Expo.
10
+ At this time, the SDK is considered experimental and things might break and change in future versions.
11
+
12
+ The core of the SDK is Expo plugin which you can easily add to your App config:
13
+
14
+ ```js
15
+ const { withSentry } = require('@sentry/react-native/expo');
16
+
17
+ const config = {...};
18
+
19
+ module.exports = withSentry(config, {
20
+ url: 'https://www.sentry.io/',
21
+ authToken: 'example-token', // Or use SENTRY_AUTH_TOKEN env
22
+ project: 'project-slug', // Or use SENTRY_PROJECT env
23
+ organization: 'org-slug', // Or use SENTRY_ORG env
24
+ });
25
+ ```
26
+
27
+ - And `Sentry.init` in `App.js`
28
+
29
+ ```js
30
+ import * as Sentry from '@sentry/react-native';
31
+
32
+ Sentry.init({
33
+ dsn: '__DSN__',
34
+ });
35
+ ```
36
+
37
+ - Update `sentry-xcode.sh` scripts with Node modules resolution ([#3450](https://github.com/getsentry/sentry-react-native/pull/3450))
38
+ - RN SDK and Sentry CLI are dynamically resolved if override is not supplied
39
+
40
+ ### Fixes
41
+
42
+ - Transform shipped JSX for both react-native and web ([#3428](https://github.com/getsentry/sentry-react-native/pull/3428))
43
+ - Removes builds errors when using react-native-web with Webpack
44
+
3
45
  ## 5.15.0
4
46
 
5
47
  ### Features
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./expo');
@@ -0,0 +1,2 @@
1
+ export declare const MAX_PROFILE_DURATION_MS: number;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/js/profiling/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,QAAW,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const MAX_PROFILE_DURATION_MS = 30 * 1e3;
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/js/profiling/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,GAAG,CAAC","sourcesContent":["export const MAX_PROFILE_DURATION_MS = 30 * 1e3;\n"]}
@@ -1 +1 @@
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
+ {"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;AAIjH,OAAO,KAAK,KAAK,MAAM,MAAM,UAAU,CAAC;AAExC,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,6 +1,6 @@
1
1
  import { logger } from '@sentry/utils';
2
+ import { MAX_PROFILE_DURATION_MS } from './constants';
2
3
  import { DEFAULT_BUNDLE_NAME } from './hermes';
3
- import { MAX_PROFILE_DURATION_MS } from './integration';
4
4
  const PLACEHOLDER_THREAD_ID_STRING = '0';
5
5
  const MS_TO_NS = 1e6;
6
6
  const MAX_PROFILE_DURATION_NS = MAX_PROFILE_DURATION_MS * MS_TO_NS;
@@ -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;AAGvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGxD,MAAM,4BAA4B,GAAG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,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"]}
1
+ {"version":3,"file":"convertHermesProfile.js","sourceRoot":"","sources":["../../../src/js/profiling/convertHermesProfile.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,MAAM,4BAA4B,GAAG,GAAG,CAAC;AACzC,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,MAAM,uBAAuB,G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,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 { MAX_PROFILE_DURATION_MS } from './constants';\nimport type * as Hermes from './hermes';\nimport { DEFAULT_BUNDLE_NAME } from './hermes';\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"]}
@@ -2,7 +2,6 @@ import type { Hub } from '@sentry/core';
2
2
  import type { EventProcessor, Integration, ThreadCpuProfile } from '@sentry/types';
3
3
  import type { NativeProfileEvent } from './nativeTypes';
4
4
  import type { CombinedProfileEvent, HermesProfileEvent } from './types';
5
- export declare const MAX_PROFILE_DURATION_MS: number;
6
5
  /**
7
6
  * Profiling integration creates a profile for each transaction and adds it to the event envelope.
8
7
  *
@@ -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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AkB,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"}
@@ -4,9 +4,9 @@ import { Platform } from 'react-native';
4
4
  import { isHermesEnabled } from '../utils/environment';
5
5
  import { NATIVE } from '../wrapper';
6
6
  import { PROFILE_QUEUE } from './cache';
7
+ import { MAX_PROFILE_DURATION_MS } from './constants';
7
8
  import { convertToSentryProfile } from './convertHermesProfile';
8
9
  import { addProfilesToEnvelope, createHermesProfilingEvent, enrichCombinedProfileWithEventContext, findProfiledTransactionsFromEnvelope, } from './utils';
9
- export const MAX_PROFILE_DURATION_MS = 30 * 1e3;
10
10
  const MS_TO_NS = 1e6;
11
11
  /**
12
12
  * Profiling integration creates a profile for each transaction and adds it to the event envelope.
@@ -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,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,qCAAqC,EACrC,oCAAoC,GACrC,MAAM,SAAS,CAAC;AAEjB,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,GAAG,GAAG,CAAC;AAEhD,MAAM,QAAQ,GAAW,GAA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C,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 { 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\nexport const MAX_PROFILE_DURATION_MS = 30 * 1e3;\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,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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veTransaction } 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 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/js/s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,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
@@ -4,6 +4,7 @@ import { HttpClient } from '@sentry/integrations';
4
4
  import { defaultIntegrations as reactDefaultIntegrations, defaultStackParser, getCurrentHub, makeFetchTransport, } from '@sentry/react';
5
5
  import { logger, stackParserFromStackParserOptions } from '@sentry/utils';
6
6
  import * as React from 'react';
7
+ import { Platform } from 'react-native';
7
8
  import { ReactNativeClient } from './client';
8
9
  import { DebugSymbolicator, DeviceContext, EventOrigin, HermesProfiling, ModulesLoader, ReactNativeErrorHandlers, ReactNativeInfo, Release, SdkInfo, } from './integrations';
9
10
  import { NativeLinkedErrors } from './integrations/nativelinkederrors';
@@ -63,9 +64,11 @@ export function init(passedOptions) {
63
64
  const defaultIntegrations = passedOptions.defaultIntegrations || [];
64
65
  if (passedOptions.defaultIntegrations === undefined) {
65
66
  defaultIntegrations.push(new ModulesLoader());
66
- defaultIntegrations.push(new ReactNativeErrorHandlers({
67
- patchGlobalPromise: options.patchGlobalPromise,
68
- }));
67
+ if (Platform.OS !== 'web') {
68
+ defaultIntegrations.push(new ReactNativeErrorHandlers({
69
+ patchGlobalPromise: options.patchGlobalPromise,
70
+ }));
71
+ }
69
72
  defaultIntegrations.push(new Release());
70
73
  defaultIntegrations.push(...[
71
74
  ...reactDefaultIntegrations.filter((i) => !IGNORED_DEFAULT_INTEGRATIONS.includes(i.name)),
@@ -115,11 +118,9 @@ export function wrap(RootComponent, options) {
115
118
  const profilerProps = Object.assign(Object.assign({}, ((_a = options === null || options === void 0 ? void 0 : options.profilerProps) !== null && _a !== void 0 ? _a : {})), { name: (_b = RootComponent.displayName) !== null && _b !== void 0 ? _b : 'Root' });
116
119
  const RootApp = (appProps) => {
117
120
  var _a;
118
- return (<TouchEventBoundary {...((_a = options === null || options === void 0 ? void 0 : options.touchEventBoundaryProps) !== null && _a !== void 0 ? _a : {})}>
119
- <ReactNativeProfiler {...profilerProps}>
120
- <RootComponent {...appProps}/>
121
- </ReactNativeProfiler>
122
- </TouchEventBoundary>);
121
+ return (React.createElement(TouchEventBoundary, Object.assign({}, ((_a = options === null || options === void 0 ? void 0 : options.touchEventBoundaryProps) !== null && _a !== void 0 ? _a : {})),
122
+ React.createElement(ReactNativeProfiler, Object.assign({}, profilerProps),
123
+ React.createElement(RootComponent, Object.assign({}, appProps)))));
123
124
  };
124
125
  return RootApp;
125
126
  }
@@ -1 +1 @@
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,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,eAAe,EACf,aAAa,EACb,wBAAwB,EACxB,eAAe,EACf,OAAO,EACP,OAAO,GACR,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OA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C,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"]}
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;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,iBAAiB,EAAE,MAAM,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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';\nimport { Platform } from 'react-native';\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 if (Platform.OS !== 'web') {\n defaultIntegrations.push(new ReactNativeErrorHandlers({\n patchGlobalPromise: options.patchGlobalPromise,\n }));\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"]}
@@ -38,11 +38,9 @@ class TouchEventBoundary extends React.Component {
38
38
  *
39
39
  */
40
40
  render() {
41
- return (<View style={touchEventStyles.wrapperView}
42
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
- onTouchStart={this._onTouchStart.bind(this)}>
44
- {this.props.children}
45
- </View>);
41
+ return (React.createElement(View, { style: touchEventStyles.wrapperView,
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
+ onTouchStart: this._onTouchStart.bind(this) }, this.props.children));
46
44
  }
47
45
  /**
48
46
  * Logs the touch event given the component tree names and a label.
@@ -163,9 +161,8 @@ TouchEventBoundary.defaultProps = {
163
161
  const withTouchEventBoundary = (
164
162
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
165
163
  InnerComponent, boundaryProps) => {
166
- const WrappedComponent = (props) => (<TouchEventBoundary {...(boundaryProps !== null && boundaryProps !== void 0 ? boundaryProps : {})}>
167
- <InnerComponent {...props}/>
168
- </TouchEventBoundary>);
164
+ const WrappedComponent = (props) => (React.createElement(TouchEventBoundary, Object.assign({}, (boundaryProps !== null && boundaryProps !== void 0 ? boundaryProps : {})),
165
+ React.createElement(InnerComponent, Object.assign({}, props))));
169
166
  WrappedComponent.displayName = 'WithTouchEventBoundary';
170
167
  return WrappedComponent;
171
168
  };
@@ -1 +1 @@
1
- {"version":3,"file":"touchevents.js","sourceRoot":"","sources":["../../src/js/touchevents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmChD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC;IACzC,WAAW,EAAE;QACX,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAC5C,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE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BAClD;aACF;YAED,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC;SAClC;QAED,MAAM,UAAU,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,iBAAiB,CAAC;QAEpD,IAAI,kBAAkB,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,EAAE;YAC/C,IAAI,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,CAAC,CAAC;SACrD;QAED,MAAA,IAAI,CAAC,mBAAmB,0CAAE,+BAA+B,CAAC;YACxD,SAAS,EAAE,WAAW;YACtB,EAAE,EAAE,eAAe;SACpB,CAAC,CAAC;IACL,CAAC;;AAvKa,8BAAW,GAAW,6BAA6B,CAAC;AACpD,+BAAY,GAAqC;IAC7D,kBAAkB,EAAE,2BAA2B;IAC/C,cAAc,EAAE,uBAAuB;IACvC,WAAW,EAAE,EAAE;IACf,oBAAoB,EAAE,+BAA+B;CACtD,CAAC;AAoKJ;;;;GAIG;AACH,MAAM,sBAAsB,GAAG;AAC7B,8DAA8D;AAC9D,cAAwC,EACxC,aAAuC,EACd,EAAE;IAC3B,MAAM,gBAAgB,GAA4B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3D,CAAC,kBAAkB,CAAC,IAAI,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,CAAC,CAAC,CAC5C;MAAA,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC,EAC5B;IAAA,EAAE,kBAAkB,CAAC,CACtB,CAAC;IAEF,gBAAgB,CAAC,WAAW,GAAG,wBAAwB,CAAC;IAExD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { addBreadcrumb, getCurrentHub } from '@sentry/core';\nimport type { SeverityLevel } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport * as React from 'react';\nimport type { GestureResponderEvent} from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\nimport { createIntegration } from './integrations/factory';\nimport { ReactNativeTracing } from './tracing';\nimport { UI_ACTION_TOUCH } from './tracing/ops';\n\nexport type TouchEventBoundaryProps = {\n /**\n * The category assigned to the breadcrumb that is logged by the touch event.\n */\n breadcrumbCategory?: string;\n /**\n * The type assigned to the breadcrumb that is logged by the touch event.\n */\n breadcrumbType?: string;\n /**\n * The max number of components to display when logging a touch's component tree.\n */\n maxComponentTreeSize?: number;\n /**\n * Component name(s) to ignore when logging the touch event. This prevents unhelpful logs such as\n * \"Touch event within element: View\" where you still can't tell which View it occurred in.\n */\n ignoreNames?: Array<string | RegExp>;\n /**\n * Deprecated, use ignoreNames instead\n * @deprecated\n */\n ignoredDisplayNames?: Array<string | RegExp>;\n /**\n * React Node wrapped by TouchEventBoundary.\n */\n children?: React.ReactNode;\n /**\n * Label Name used to identify the touched element.\n */\n labelName?: string;\n};\n\nconst touchEventStyles = StyleSheet.create({\n wrapperView: {\n flex: 1,\n },\n});\n\nconst DEFAULT_BREADCRUMB_CATEGORY = 'touch';\nconst DEFAULT_BREADCRUMB_TYPE = 'user';\nconst DEFAULT_MAX_COMPONENT_TREE_SIZE = 20;\n\nconst SENTRY_LABEL_PROP_KEY = 'sentry-label';\n\ninterface ElementInstance {\n elementType?: {\n displayName?: string;\n name?: string;\n };\n memoizedProps?: Record<string, unknown>;\n return?: ElementInstance;\n}\n\ninterface PrivateGestureResponderEvent extends GestureResponderEvent {\n _targetInst?: ElementInstance;\n}\n\n/**\n * Boundary to log breadcrumbs for interaction events.\n */\nclass TouchEventBoundary extends React.Component<TouchEventBoundaryProps> {\n\n public static displayName: string = '__Sentry.TouchEventBoundary';\n public static defaultProps: Partial<TouchEventBoundaryProps> = {\n breadcrumbCategory: DEFAULT_BREADCRUMB_CATEGORY,\n breadcrumbType: DEFAULT_BREADCRUMB_TYPE,\n ignoreNames: [],\n maxComponentTreeSize: DEFAULT_MAX_COMPONENT_TREE_SIZE,\n };\n\n public readonly name: string = 'TouchEventBoundary';\n\n private _tracingIntegration: ReactNativeTracing | null = null;\n\n /**\n * Registers the TouchEventBoundary as a Sentry Integration.\n */\n public componentDidMount(): void {\n const client = getCurrentHub().getClient();\n client?.addIntegration?.(createIntegration(this.name));\n if (!this._tracingIntegration && client) {\n this._tracingIntegration = client.getIntegration(ReactNativeTracing);\n }\n }\n\n /**\n *\n */\n public render(): React.ReactNode {\n return (\n <View\n style={touchEventStyles.wrapperView}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onTouchStart={this._onTouchStart.bind(this) as any}\n >\n {this.props.children}\n </View>\n );\n }\n\n /**\n * Logs the touch event given the component tree names and a label.\n */\n private _logTouchEvent(\n componentTreeNames: string[],\n activeLabel?: string\n ): void {\n const level = 'info' as SeverityLevel;\n const crumb = {\n category: this.props.breadcrumbCategory,\n data: { componentTree: componentTreeNames },\n level: level,\n message: activeLabel\n ? `Touch event within element: ${activeLabel}`\n : 'Touch event within component tree',\n type: this.props.breadcrumbType,\n };\n addBreadcrumb(crumb);\n\n logger.log(`[TouchEvents] ${crumb.message}`);\n }\n\n /**\n * Checks if the name is supposed to be ignored.\n */\n private _isNameIgnored(name: string): boolean {\n let ignoreNames = this.props.ignoreNames || [];\n // eslint-disable-next-line deprecation/deprecation\n if (this.props.ignoredDisplayNames) {\n // This is to make it compatible with prior version.\n // eslint-disable-next-line deprecation/deprecation\n ignoreNames = [...ignoreNames, ...this.props.ignoredDisplayNames];\n }\n\n return ignoreNames.some(\n (ignoreName: string | RegExp) =>\n (typeof ignoreName === 'string' && name === ignoreName) ||\n (ignoreName instanceof RegExp && name.match(ignoreName))\n );\n }\n\n // Originally was going to clean the names of any HOCs as well but decided that it might hinder debugging effectively. Will leave here in case\n // private readonly _cleanName = (name: string): string =>\n // name.replace(/.*\\(/g, \"\").replace(/\\)/g, \"\");\n\n /**\n * Traverses through the component tree when a touch happens and logs it.\n * @param e\n */\n // eslint-disable-next-line complexity\n private _onTouchStart(e: PrivateGestureResponderEvent): void {\n if (!e._targetInst) {\n return;\n }\n\n let currentInst: ElementInstance | undefined = e._targetInst;\n\n let activeLabel: string | undefined;\n let activeDisplayName: string | undefined;\n const componentTreeNames: string[] = [];\n\n while (\n currentInst &&\n // maxComponentTreeSize will always be defined as we have a defaultProps. But ts needs a check so this is here.\n this.props.maxComponentTreeSize &&\n componentTreeNames.length < this.props.maxComponentTreeSize\n ) {\n if (\n // If the loop gets to the boundary itself, break.\n currentInst.elementType?.displayName ===\n TouchEventBoundary.displayName\n ) {\n break;\n }\n\n const props = currentInst.memoizedProps;\n const sentryLabel =\n typeof props?.[SENTRY_LABEL_PROP_KEY] !== 'undefined'\n ? `${props[SENTRY_LABEL_PROP_KEY]}`\n : undefined;\n\n // For some reason type narrowing doesn't work as expected with indexing when checking it all in one go in\n // the \"check-label\" if sentence, so we have to assign it to a variable here first\n let labelValue;\n if (typeof this.props.labelName === 'string')\n labelValue = props?.[this.props.labelName];\n\n // Check the label first\n if (sentryLabel && !this._isNameIgnored(sentryLabel)) {\n if (!activeLabel) {\n activeLabel = sentryLabel;\n }\n componentTreeNames.push(sentryLabel);\n } else if (\n typeof labelValue === 'string' &&\n !this._isNameIgnored(labelValue)\n ) {\n if (!activeLabel) {\n activeLabel = labelValue;\n }\n componentTreeNames.push(labelValue);\n } else if (currentInst.elementType) {\n const { elementType } = currentInst;\n\n if (\n elementType.displayName &&\n !this._isNameIgnored(elementType.displayName)\n ) {\n // Check display name\n if (!activeDisplayName) {\n activeDisplayName = elementType.displayName;\n }\n componentTreeNames.push(elementType.displayName);\n }\n }\n\n currentInst = currentInst.return;\n }\n\n const finalLabel = activeLabel ?? activeDisplayName;\n\n if (componentTreeNames.length > 0 || finalLabel) {\n this._logTouchEvent(componentTreeNames, finalLabel);\n }\n\n this._tracingIntegration?.startUserInteractionTransaction({\n elementId: activeLabel,\n op: UI_ACTION_TOUCH,\n });\n }\n}\n\n/**\n * Convenience Higher-Order-Component for TouchEventBoundary\n * @param WrappedComponent any React Component\n * @param boundaryProps TouchEventBoundaryProps\n */\nconst withTouchEventBoundary = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n InnerComponent: React.ComponentType<any>,\n boundaryProps?: TouchEventBoundaryProps\n): React.FunctionComponent => {\n const WrappedComponent: React.FunctionComponent = (props) => (\n <TouchEventBoundary {...(boundaryProps ?? {})}>\n <InnerComponent {...props} />\n </TouchEventBoundary>\n );\n\n WrappedComponent.displayName = 'WithTouchEventBoundary';\n\n return WrappedComponent;\n};\n\nexport { TouchEventBoundary, withTouchEventBoundary };\n"]}
1
+ {"version":3,"file":"touchevents.js","sourceRoot":"","sources":["../../src/js/touchevents.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAmChD,MAAM,gBAAgB,GAAG,UAAU,CAAC,MAAM,CAAC;IACzC,WAAW,EAAE;QACX,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,MAAM,2BAA2B,GAAG,OAAO,CAAC;AAC5C,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC,MAAM,+BAA+B,GAAG,EAAE,CAAC;AAE3C,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAe7C;;GAEG;AACH,MAAM,kBAAmB,SAAQ,KAAK,CAAC,SAAkC;IAAzE;;QAUkB,SAAI,GAAW,oBAAoB,CAAC;QAE5C,wBAAmB,GAA8B,IAAI,CAAC;IA8JhE,CAAC;IA5JC;;OAEG;IACI,iBAAiB;;QACtB,MAAM,MAAM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B,0CAAE,+BAA+B,CAAC;YACxD,SAAS,EAAE,WAAW;YACtB,EAAE,EAAE,eAAe;SACpB,CAAC,CAAC;IACL,CAAC;;AAvKa,8BAAW,GAAW,6BAA6B,CAAC;AACpD,+BAAY,GAAqC;IAC7D,kBAAkB,EAAE,2BAA2B;IAC/C,cAAc,EAAE,uBAAuB;IACvC,WAAW,EAAE,EAAE;IACf,oBAAoB,EAAE,+BAA+B;CACtD,CAAC;AAoKJ;;;;GAIG;AACH,MAAM,sBAAsB,GAAG;AAC7B,8DAA8D;AAC9D,cAAwC,EACxC,aAAuC,EACd,EAAE;IAC3B,MAAM,gBAAgB,GAA4B,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3D,oBAAC,kBAAkB,oBAAK,CAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,CAAC;QAC3C,oBAAC,cAAc,oBAAK,KAAK,EAAI,CACV,CACtB,CAAC;IAEF,gBAAgB,CAAC,WAAW,GAAG,wBAAwB,CAAC;IAExD,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["import { addBreadcrumb, getCurrentHub } from '@sentry/core';\nimport type { SeverityLevel } from '@sentry/types';\nimport { logger } from '@sentry/utils';\nimport * as React from 'react';\nimport type { GestureResponderEvent} from 'react-native';\nimport { StyleSheet, View } from 'react-native';\n\nimport { createIntegration } from './integrations/factory';\nimport { ReactNativeTracing } from './tracing';\nimport { UI_ACTION_TOUCH } from './tracing/ops';\n\nexport type TouchEventBoundaryProps = {\n /**\n * The category assigned to the breadcrumb that is logged by the touch event.\n */\n breadcrumbCategory?: string;\n /**\n * The type assigned to the breadcrumb that is logged by the touch event.\n */\n breadcrumbType?: string;\n /**\n * The max number of components to display when logging a touch's component tree.\n */\n maxComponentTreeSize?: number;\n /**\n * Component name(s) to ignore when logging the touch event. This prevents unhelpful logs such as\n * \"Touch event within element: View\" where you still can't tell which View it occurred in.\n */\n ignoreNames?: Array<string | RegExp>;\n /**\n * Deprecated, use ignoreNames instead\n * @deprecated\n */\n ignoredDisplayNames?: Array<string | RegExp>;\n /**\n * React Node wrapped by TouchEventBoundary.\n */\n children?: React.ReactNode;\n /**\n * Label Name used to identify the touched element.\n */\n labelName?: string;\n};\n\nconst touchEventStyles = StyleSheet.create({\n wrapperView: {\n flex: 1,\n },\n});\n\nconst DEFAULT_BREADCRUMB_CATEGORY = 'touch';\nconst DEFAULT_BREADCRUMB_TYPE = 'user';\nconst DEFAULT_MAX_COMPONENT_TREE_SIZE = 20;\n\nconst SENTRY_LABEL_PROP_KEY = 'sentry-label';\n\ninterface ElementInstance {\n elementType?: {\n displayName?: string;\n name?: string;\n };\n memoizedProps?: Record<string, unknown>;\n return?: ElementInstance;\n}\n\ninterface PrivateGestureResponderEvent extends GestureResponderEvent {\n _targetInst?: ElementInstance;\n}\n\n/**\n * Boundary to log breadcrumbs for interaction events.\n */\nclass TouchEventBoundary extends React.Component<TouchEventBoundaryProps> {\n\n public static displayName: string = '__Sentry.TouchEventBoundary';\n public static defaultProps: Partial<TouchEventBoundaryProps> = {\n breadcrumbCategory: DEFAULT_BREADCRUMB_CATEGORY,\n breadcrumbType: DEFAULT_BREADCRUMB_TYPE,\n ignoreNames: [],\n maxComponentTreeSize: DEFAULT_MAX_COMPONENT_TREE_SIZE,\n };\n\n public readonly name: string = 'TouchEventBoundary';\n\n private _tracingIntegration: ReactNativeTracing | null = null;\n\n /**\n * Registers the TouchEventBoundary as a Sentry Integration.\n */\n public componentDidMount(): void {\n const client = getCurrentHub().getClient();\n client?.addIntegration?.(createIntegration(this.name));\n if (!this._tracingIntegration && client) {\n this._tracingIntegration = client.getIntegration(ReactNativeTracing);\n }\n }\n\n /**\n *\n */\n public render(): React.ReactNode {\n return (\n <View\n style={touchEventStyles.wrapperView}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n onTouchStart={this._onTouchStart.bind(this) as any}\n >\n {this.props.children}\n </View>\n );\n }\n\n /**\n * Logs the touch event given the component tree names and a label.\n */\n private _logTouchEvent(\n componentTreeNames: string[],\n activeLabel?: string\n ): void {\n const level = 'info' as SeverityLevel;\n const crumb = {\n category: this.props.breadcrumbCategory,\n data: { componentTree: componentTreeNames },\n level: level,\n message: activeLabel\n ? `Touch event within element: ${activeLabel}`\n : 'Touch event within component tree',\n type: this.props.breadcrumbType,\n };\n addBreadcrumb(crumb);\n\n logger.log(`[TouchEvents] ${crumb.message}`);\n }\n\n /**\n * Checks if the name is supposed to be ignored.\n */\n private _isNameIgnored(name: string): boolean {\n let ignoreNames = this.props.ignoreNames || [];\n // eslint-disable-next-line deprecation/deprecation\n if (this.props.ignoredDisplayNames) {\n // This is to make it compatible with prior version.\n // eslint-disable-next-line deprecation/deprecation\n ignoreNames = [...ignoreNames, ...this.props.ignoredDisplayNames];\n }\n\n return ignoreNames.some(\n (ignoreName: string | RegExp) =>\n (typeof ignoreName === 'string' && name === ignoreName) ||\n (ignoreName instanceof RegExp && name.match(ignoreName))\n );\n }\n\n // Originally was going to clean the names of any HOCs as well but decided that it might hinder debugging effectively. Will leave here in case\n // private readonly _cleanName = (name: string): string =>\n // name.replace(/.*\\(/g, \"\").replace(/\\)/g, \"\");\n\n /**\n * Traverses through the component tree when a touch happens and logs it.\n * @param e\n */\n // eslint-disable-next-line complexity\n private _onTouchStart(e: PrivateGestureResponderEvent): void {\n if (!e._targetInst) {\n return;\n }\n\n let currentInst: ElementInstance | undefined = e._targetInst;\n\n let activeLabel: string | undefined;\n let activeDisplayName: string | undefined;\n const componentTreeNames: string[] = [];\n\n while (\n currentInst &&\n // maxComponentTreeSize will always be defined as we have a defaultProps. But ts needs a check so this is here.\n this.props.maxComponentTreeSize &&\n componentTreeNames.length < this.props.maxComponentTreeSize\n ) {\n if (\n // If the loop gets to the boundary itself, break.\n currentInst.elementType?.displayName ===\n TouchEventBoundary.displayName\n ) {\n break;\n }\n\n const props = currentInst.memoizedProps;\n const sentryLabel =\n typeof props?.[SENTRY_LABEL_PROP_KEY] !== 'undefined'\n ? `${props[SENTRY_LABEL_PROP_KEY]}`\n : undefined;\n\n // For some reason type narrowing doesn't work as expected with indexing when checking it all in one go in\n // the \"check-label\" if sentence, so we have to assign it to a variable here first\n let labelValue;\n if (typeof this.props.labelName === 'string')\n labelValue = props?.[this.props.labelName];\n\n // Check the label first\n if (sentryLabel && !this._isNameIgnored(sentryLabel)) {\n if (!activeLabel) {\n activeLabel = sentryLabel;\n }\n componentTreeNames.push(sentryLabel);\n } else if (\n typeof labelValue === 'string' &&\n !this._isNameIgnored(labelValue)\n ) {\n if (!activeLabel) {\n activeLabel = labelValue;\n }\n componentTreeNames.push(labelValue);\n } else if (currentInst.elementType) {\n const { elementType } = currentInst;\n\n if (\n elementType.displayName &&\n !this._isNameIgnored(elementType.displayName)\n ) {\n // Check display name\n if (!activeDisplayName) {\n activeDisplayName = elementType.displayName;\n }\n componentTreeNames.push(elementType.displayName);\n }\n }\n\n currentInst = currentInst.return;\n }\n\n const finalLabel = activeLabel ?? activeDisplayName;\n\n if (componentTreeNames.length > 0 || finalLabel) {\n this._logTouchEvent(componentTreeNames, finalLabel);\n }\n\n this._tracingIntegration?.startUserInteractionTransaction({\n elementId: activeLabel,\n op: UI_ACTION_TOUCH,\n });\n }\n}\n\n/**\n * Convenience Higher-Order-Component for TouchEventBoundary\n * @param WrappedComponent any React Component\n * @param boundaryProps TouchEventBoundaryProps\n */\nconst withTouchEventBoundary = (\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n InnerComponent: React.ComponentType<any>,\n boundaryProps?: TouchEventBoundaryProps\n): React.FunctionComponent => {\n const WrappedComponent: React.FunctionComponent = (props) => (\n <TouchEventBoundary {...(boundaryProps ?? {})}>\n <InnerComponent {...props} />\n </TouchEventBoundary>\n );\n\n WrappedComponent.displayName = 'WithTouchEventBoundary';\n\n return WrappedComponent;\n};\n\nexport { TouchEventBoundary, withTouchEventBoundary };\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.15.0";
3
+ export declare const SDK_VERSION = "5.16.0-alpha.1";
4
4
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAC3D,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AACzD,eAAO,MAAM,WAAW,WAAW,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,6BAA6B,CAAC;AAC3D,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AACzD,eAAO,MAAM,WAAW,mBAAmB,CAAC"}
@@ -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.15.0';
3
+ export const SDK_VERSION = '5.16.0-alpha.1';
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.15.0';\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,gBAAgB,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.16.0-alpha.1';\n"]}
package/expo.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './plugin/build';
package/expo.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build');
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.15.0",
5
+ "version": "5.16.0-alpha.1",
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",
@@ -18,21 +18,23 @@
18
18
  },
19
19
  "main": "dist/js/index.js",
20
20
  "scripts": {
21
- "build": "yarn build:sdk && yarn downlevel && yarn build:tools",
21
+ "build": "yarn build:sdk && yarn downlevel && yarn build:tools && yarn build:plugin",
22
22
  "build:sdk": "tsc -p tsconfig.build.json",
23
23
  "build:sdk:watch": "tsc -p tsconfig.build.json -w --preserveWatchOutput",
24
24
  "build:tools": "tsc -p tsconfig.build.tools.json",
25
+ "build:plugin": "EXPO_NONINTERACTIVE=true expo-module build plugin",
25
26
  "downlevel": "downlevel-dts dist ts3.8/dist --to=3.8",
26
- "clean": "rimraf dist coverage",
27
+ "clean": "rimraf dist coverage && yarn clean:plugin",
28
+ "clean:plugin": "expo-module clean plugin",
27
29
  "test": "yarn test:sdk && yarn test:tools",
28
30
  "test:sdk": "jest",
29
31
  "test:tools": "jest --config jest.config.tools.js",
30
32
  "fix": "yarn fix:eslint && yarn fix:prettier",
31
33
  "fix:eslint": "eslint --config .eslintrc.js --fix .",
32
- "fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
34
+ "fix:prettier": "prettier --write \"{src,test,scripts,plugin/src}/**/**.ts\"",
33
35
  "lint": "yarn lint:eslint && yarn lint:prettier",
34
36
  "lint:eslint": "eslint --config .eslintrc.js .",
35
- "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
37
+ "lint:prettier": "prettier --check \"{src,test,scripts,plugin/src}/**/**.ts\"",
36
38
  "test:watch": "jest --watch",
37
39
  "run-ios": "cd samples/react-native && yarn react-native run-ios",
38
40
  "run-android": "cd samples/react-native && yarn react-native run-android",
@@ -55,7 +57,8 @@
55
57
  ],
56
58
  "peerDependencies": {
57
59
  "react": ">=17.0.0",
58
- "react-native": ">=0.65.0"
60
+ "react-native": ">=0.65.0",
61
+ "expo": ">=47.0.0"
59
62
  },
60
63
  "dependencies": {
61
64
  "@sentry/browser": "7.81.1",
@@ -82,6 +85,8 @@
82
85
  "eslint": "^7.6.0",
83
86
  "eslint-plugin-react": "^7.20.6",
84
87
  "eslint-plugin-react-native": "^3.8.1",
88
+ "expo": "^47.0.0",
89
+ "expo-module-scripts": "^3.1.0",
85
90
  "jest": "^29.6.2",
86
91
  "jest-environment-jsdom": "^29.6.2",
87
92
  "metro": "0.76",
@@ -110,5 +115,10 @@
110
115
  "android": {
111
116
  "javaPackageName": "io.sentry.react"
112
117
  }
118
+ },
119
+ "peerDependenciesMeta": {
120
+ "expo": {
121
+ "optional": true
122
+ }
113
123
  }
114
124
  }
@@ -0,0 +1,3 @@
1
+ import { withSentry } from './withSentry';
2
+ export { withSentry };
3
+ export default withSentry;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSentry = void 0;
4
+ const withSentry_1 = require("./withSentry");
5
+ Object.defineProperty(exports, "withSentry", { enumerable: true, get: function () { return withSentry_1.withSentry; } });
6
+ exports.default = withSentry_1.withSentry;
@@ -0,0 +1,7 @@
1
+ export declare function writeSentryPropertiesTo(filepath: string, sentryProperties: string): void;
2
+ declare const sdkPackage: {
3
+ name: string;
4
+ version: string;
5
+ };
6
+ declare const SDK_PACKAGE_NAME: string;
7
+ export { sdkPackage, SDK_PACKAGE_NAME };
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.SDK_PACKAGE_NAME = exports.sdkPackage = exports.writeSentryPropertiesTo = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const path = __importStar(require("path"));
29
+ function writeSentryPropertiesTo(filepath, sentryProperties) {
30
+ if (!fs.existsSync(filepath)) {
31
+ throw new Error(`Directory '${filepath}' does not exist.`);
32
+ }
33
+ fs.writeFileSync(path.resolve(filepath, 'sentry.properties'), sentryProperties);
34
+ }
35
+ exports.writeSentryPropertiesTo = writeSentryPropertiesTo;
36
+ const sdkPackage = require('../../package.json');
37
+ exports.sdkPackage = sdkPackage;
38
+ const SDK_PACKAGE_NAME = sdkPackage.name;
39
+ exports.SDK_PACKAGE_NAME = SDK_PACKAGE_NAME;
@@ -0,0 +1,10 @@
1
+ import type { ConfigPlugin } from 'expo/config-plugins';
2
+ interface PluginProps {
3
+ organization?: string;
4
+ project?: string;
5
+ authToken?: string;
6
+ url?: string;
7
+ }
8
+ export declare function getSentryProperties(props: PluginProps | void): string | null;
9
+ declare const withSentry: ConfigPlugin<void | PluginProps>;
10
+ export { withSentry };
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.withSentry = exports.getSentryProperties = void 0;
4
+ const config_plugins_1 = require("expo/config-plugins");
5
+ const utils_1 = require("./utils");
6
+ const withSentryAndroid_1 = require("./withSentryAndroid");
7
+ const withSentryIOS_1 = require("./withSentryIOS");
8
+ const withSentryPlugin = (config, props) => {
9
+ const sentryProperties = getSentryProperties(props);
10
+ let cfg = config;
11
+ if (sentryProperties !== null) {
12
+ try {
13
+ cfg = (0, withSentryAndroid_1.withSentryAndroid)(cfg, sentryProperties);
14
+ }
15
+ catch (e) {
16
+ config_plugins_1.WarningAggregator.addWarningAndroid(utils_1.SDK_PACKAGE_NAME, `There was a problem configuring sentry-expo in your native Android project: ${e}`);
17
+ }
18
+ try {
19
+ cfg = (0, withSentryIOS_1.withSentryIOS)(cfg, sentryProperties);
20
+ }
21
+ catch (e) {
22
+ config_plugins_1.WarningAggregator.addWarningIOS(utils_1.SDK_PACKAGE_NAME, `There was a problem configuring sentry-expo in your native iOS project: ${e}`);
23
+ }
24
+ }
25
+ return cfg;
26
+ };
27
+ const missingAuthTokenMessage = '# auth.token is configured through SENTRY_AUTH_TOKEN environment variable';
28
+ const missingProjectMessage = '# no project found, falling back to SENTRY_PROJECT environment variable';
29
+ const missingOrgMessage = '# no org found, falling back to SENTRY_ORG environment variable';
30
+ function getSentryProperties(props) {
31
+ const { organization, project, authToken, url = 'https://sentry.io/' } = props ?? {};
32
+ // eslint-disable-next-line no-prototype-builtins
33
+ const missingProperties = ['organization', 'project'].filter(each => !props?.hasOwnProperty(each));
34
+ if (missingProperties.length) {
35
+ const warningMessage = `Missing Sentry configuration properties: ${missingProperties.join(', ')} in config plugin. Builds will fall back to environment variables. See: https://docs.sentry.io/platforms/react-native/manual-setup/.`;
36
+ config_plugins_1.WarningAggregator.addWarningAndroid(utils_1.SDK_PACKAGE_NAME, warningMessage);
37
+ config_plugins_1.WarningAggregator.addWarningIOS(utils_1.SDK_PACKAGE_NAME, warningMessage);
38
+ }
39
+ return `defaults.url=${url}
40
+ ${organization ? `defaults.org=${organization}` : missingOrgMessage}
41
+ ${project ? `defaults.project=${project}` : missingProjectMessage}
42
+ ${authToken
43
+ ? `# Configure this value through \`SENTRY_AUTH_TOKEN\` environment variable instead. See: https://docs.sentry.io/platforms/react-native/manual-setup/\nauth.token=${authToken}`
44
+ : missingAuthTokenMessage}
45
+ `;
46
+ }
47
+ exports.getSentryProperties = getSentryProperties;
48
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
49
+ const withSentry = (0, config_plugins_1.createRunOncePlugin)(withSentryPlugin, utils_1.sdkPackage.name, utils_1.sdkPackage.version);
50
+ exports.withSentry = withSentry;
@@ -0,0 +1,7 @@
1
+ import type { ConfigPlugin } from 'expo/config-plugins';
2
+ export declare const withSentryAndroid: ConfigPlugin<string>;
3
+ /**
4
+ * Writes to projectDirectory/android/app/build.gradle,
5
+ * adding the relevant @sentry/react-native script.
6
+ */
7
+ export declare function modifyAppBuildGradle(buildGradle: string): string;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.modifyAppBuildGradle = exports.withSentryAndroid = void 0;
27
+ const config_plugins_1 = require("expo/config-plugins");
28
+ const path = __importStar(require("path"));
29
+ const utils_1 = require("./utils");
30
+ const withSentryAndroid = (config, sentryProperties) => {
31
+ const cfg = (0, config_plugins_1.withAppBuildGradle)(config, config => {
32
+ if (config.modResults.language === 'groovy') {
33
+ config.modResults.contents = modifyAppBuildGradle(config.modResults.contents);
34
+ }
35
+ else {
36
+ throw new Error('Cannot configure Sentry in the app gradle because the build.gradle is not groovy');
37
+ }
38
+ return config;
39
+ });
40
+ return (0, config_plugins_1.withDangerousMod)(cfg, [
41
+ 'android',
42
+ config => {
43
+ (0, utils_1.writeSentryPropertiesTo)(path.resolve(config.modRequest.projectRoot, 'android'), sentryProperties);
44
+ return config;
45
+ },
46
+ ]);
47
+ };
48
+ exports.withSentryAndroid = withSentryAndroid;
49
+ const resolveSentryReactNativePackageJsonPath = '["node", "--print", "require(\'path\').dirname(require.resolve(\'@sentry/react-native/package.json\'))"].execute().text.trim()';
50
+ /**
51
+ * Writes to projectDirectory/android/app/build.gradle,
52
+ * adding the relevant @sentry/react-native script.
53
+ */
54
+ function modifyAppBuildGradle(buildGradle) {
55
+ if (buildGradle.includes('sentry.gradle')) {
56
+ return buildGradle;
57
+ }
58
+ // Use the same location that sentry-wizard uses
59
+ // See: https://github.com/getsentry/sentry-wizard/blob/e9b4522f27a852069c862bd458bdf9b07cab6e33/lib/Steps/Integrations/ReactNative.ts#L232
60
+ const pattern = /^android {/m;
61
+ if (!buildGradle.match(pattern)) {
62
+ config_plugins_1.WarningAggregator.addWarningAndroid(utils_1.SDK_PACKAGE_NAME, 'Could not find `^android {` in `android/app/build.gradle`. Please open a bug report at https://github.com/getsentry/sentry-react-native.');
63
+ return buildGradle;
64
+ }
65
+ const applyFrom = `apply from: new File(${resolveSentryReactNativePackageJsonPath}, "sentry.gradle")`;
66
+ return buildGradle.replace(pattern, match => `${applyFrom}\n\n${match}`);
67
+ }
68
+ exports.modifyAppBuildGradle = modifyAppBuildGradle;
@@ -0,0 +1,8 @@
1
+ import type { ConfigPlugin } from 'expo/config-plugins';
2
+ type BuildPhase = {
3
+ shellScript: string;
4
+ };
5
+ export declare const withSentryIOS: ConfigPlugin<string>;
6
+ export declare function modifyExistingXcodeBuildScript(script: BuildPhase): void;
7
+ export declare function addSentryWithBundledScriptsToBundleShellScript(script: string): string;
8
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.addSentryWithBundledScriptsToBundleShellScript = exports.modifyExistingXcodeBuildScript = exports.withSentryIOS = void 0;
27
+ const config_plugins_1 = require("expo/config-plugins");
28
+ const path = __importStar(require("path"));
29
+ const utils_1 = require("./utils");
30
+ const SENTRY_REACT_NATIVE_XCODE_PATH = "`\"$NODE_BINARY\" --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode.sh'\"`";
31
+ const SENTRY_REACT_NATIVE_XCODE_DEBUG_FILES_PATH = "`${NODE_BINARY:-node} --print \"require('path').dirname(require.resolve('@sentry/react-native/package.json')) + '/scripts/sentry-xcode-debug-files.sh'\"`";
32
+ const withSentryIOS = (config, sentryProperties) => {
33
+ const cfg = (0, config_plugins_1.withXcodeProject)(config, config => {
34
+ const xcodeProject = config.modResults;
35
+ const sentryBuildPhase = xcodeProject.pbxItemByComment('Upload Debug Symbols to Sentry', 'PBXShellScriptBuildPhase');
36
+ if (!sentryBuildPhase) {
37
+ xcodeProject.addBuildPhase([], 'PBXShellScriptBuildPhase', 'Upload Debug Symbols to Sentry', null, {
38
+ shellPath: '/bin/sh',
39
+ shellScript: `/bin/sh ${SENTRY_REACT_NATIVE_XCODE_DEBUG_FILES_PATH}`,
40
+ });
41
+ }
42
+ const bundleReactNativePhase = xcodeProject.pbxItemByComment('Bundle React Native code and images', 'PBXShellScriptBuildPhase');
43
+ modifyExistingXcodeBuildScript(bundleReactNativePhase);
44
+ return config;
45
+ });
46
+ return (0, config_plugins_1.withDangerousMod)(cfg, [
47
+ 'ios',
48
+ config => {
49
+ (0, utils_1.writeSentryPropertiesTo)(path.resolve(config.modRequest.projectRoot, 'ios'), sentryProperties);
50
+ return config;
51
+ },
52
+ ]);
53
+ };
54
+ exports.withSentryIOS = withSentryIOS;
55
+ function modifyExistingXcodeBuildScript(script) {
56
+ if (!script.shellScript.match(/(packager|scripts)\/react-native-xcode\.sh\b/) ||
57
+ script.shellScript.includes('sentry-xcode.sh') ||
58
+ script.shellScript.includes('@sentry')) {
59
+ config_plugins_1.WarningAggregator.addWarningIOS(utils_1.SDK_PACKAGE_NAME, "Unable to modify build script 'Bundle React Native code and images'. Please open a bug report at https://github.com/expo/sentry-expo.");
60
+ return;
61
+ }
62
+ const code = JSON.parse(script.shellScript);
63
+ script.shellScript = JSON.stringify(addSentryWithBundledScriptsToBundleShellScript(code));
64
+ }
65
+ exports.modifyExistingXcodeBuildScript = modifyExistingXcodeBuildScript;
66
+ function addSentryWithBundledScriptsToBundleShellScript(script) {
67
+ return script.replace(/^.*?(packager|scripts)\/react-native-xcode\.sh\s*(\\'\\\\")?/m,
68
+ // eslint-disable-next-line no-useless-escape
69
+ (match) => `/bin/sh ${SENTRY_REACT_NATIVE_XCODE_PATH} ${match}`);
70
+ }
71
+ exports.addSentryWithBundledScriptsToBundleShellScript = addSentryWithBundledScriptsToBundleShellScript;
@@ -5,6 +5,8 @@
5
5
  # print commands before executing them and stop on first error
6
6
  set -x -e
7
7
 
8
+ LOCAL_NODE_BINARY=${NODE_BINARY:-node}
9
+
8
10
  # load envs if loader file exists (since rn 0.68)
9
11
  WITH_ENVIRONMENT="../node_modules/react-native/scripts/xcode/with-environment.sh"
10
12
  if [ -f "$WITH_ENVIRONMENT" ]; then
@@ -12,7 +14,9 @@ if [ -f "$WITH_ENVIRONMENT" ]; then
12
14
  fi
13
15
 
14
16
  [ -z "$SENTRY_PROPERTIES" ] && export SENTRY_PROPERTIES=sentry.properties
15
- [ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="../node_modules/@sentry/cli/bin/sentry-cli"
17
+
18
+ [ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/cli/package.json'))")
19
+ [ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="${SENTRY_CLI_PACKAGE_PATH}/bin/sentry-cli"
16
20
 
17
21
  [[ $SENTRY_INCLUDE_NATIVE_SOURCES == "true" ]] && INCLUDE_SOURCES_FLAG="--include-sources" || INCLUDE_SOURCES_FLAG=""
18
22
 
@@ -7,9 +7,13 @@ set -x -e
7
7
 
8
8
  # WITH_ENVIRONMENT is executed by React Native
9
9
 
10
+ LOCAL_NODE_BINARY=${NODE_BINARY:-node}
11
+
10
12
  [ -z "$SENTRY_PROPERTIES" ] && export SENTRY_PROPERTIES=sentry.properties
11
13
  [ -z "$SOURCEMAP_FILE" ] && export SOURCEMAP_FILE="$DERIVED_FILE_DIR/main.jsbundle.map"
12
- [ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="../node_modules/@sentry/cli/bin/sentry-cli"
14
+
15
+ [ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/cli/package.json'))")
16
+ [ -z "$SENTRY_CLI_EXECUTABLE" ] && SENTRY_CLI_EXECUTABLE="${SENTRY_CLI_PACKAGE_PATH}/bin/sentry-cli"
13
17
 
14
18
  REACT_NATIVE_XCODE=$1
15
19
 
@@ -25,7 +29,8 @@ else
25
29
  /bin/sh -c "$REACT_NATIVE_XCODE"
26
30
  fi
27
31
 
28
- [ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_COLLECT_MODULES="../node_modules/@sentry/react-native/scripts/collect-modules.sh"
32
+ [ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_RN_PACKAGE_PATH=$("$LOCAL_NODE_BINARY" --print "require('path').dirname(require.resolve('@sentry/react-native/package.json'))")
33
+ [ -z "$SENTRY_COLLECT_MODULES" ] && SENTRY_COLLECT_MODULES="${SENTRY_RN_PACKAGE_PATH}/scripts/collect-modules.sh"
29
34
 
30
35
  if [ -f "$SENTRY_COLLECT_MODULES" ]; then
31
36
  /bin/sh "$SENTRY_COLLECT_MODULES"
@@ -0,0 +1,2 @@
1
+ export declare const MAX_PROFILE_DURATION_MS: number;
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -2,7 +2,6 @@ import type { Hub } from '@sentry/core';
2
2
  import type { EventProcessor, Integration, ThreadCpuProfile } from '@sentry/types';
3
3
  import type { NativeProfileEvent } from './nativeTypes';
4
4
  import type { CombinedProfileEvent, HermesProfileEvent } from './types';
5
- export declare const MAX_PROFILE_DURATION_MS: number;
6
5
  /**
7
6
  * Profiling integration creates a profile for each transaction and adds it to the event envelope.
8
7
  *
@@ -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.15.0";
3
+ export declare const SDK_VERSION = "5.16.0-alpha.1";
4
4
  //# sourceMappingURL=version.d.ts.map