@sentry/react-native 5.7.0 → 5.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/RNSentry.podspec +9 -4
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/MapConverter.java +134 -0
- package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +103 -15
- package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +14 -2
- package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +13 -2
- package/dist/js/NativeRNSentry.d.ts +13 -4
- package/dist/js/NativeRNSentry.d.ts.map +1 -1
- package/dist/js/NativeRNSentry.js.map +1 -1
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +1 -0
- package/dist/js/client.js.map +1 -1
- package/dist/js/integrations/devicecontext.js +5 -5
- package/dist/js/integrations/devicecontext.js.map +1 -1
- package/dist/js/integrations/index.d.ts +1 -0
- package/dist/js/integrations/index.d.ts.map +1 -1
- package/dist/js/integrations/index.js +1 -0
- package/dist/js/integrations/index.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts +5 -0
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +31 -6
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/integrations/rewriteframes.d.ts +2 -0
- package/dist/js/integrations/rewriteframes.d.ts.map +1 -1
- package/dist/js/integrations/rewriteframes.js +2 -2
- package/dist/js/integrations/rewriteframes.js.map +1 -1
- package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
- package/dist/js/integrations/sdkinfo.js +1 -2
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/profiling/cache.d.ts +9 -0
- package/dist/js/profiling/cache.d.ts.map +1 -0
- package/dist/js/profiling/cache.js +3 -0
- package/dist/js/profiling/cache.js.map +1 -0
- package/dist/js/profiling/convertHermesProfile.d.ts +27 -0
- package/dist/js/profiling/convertHermesProfile.d.ts.map +1 -0
- package/dist/js/profiling/convertHermesProfile.js +141 -0
- package/dist/js/profiling/convertHermesProfile.js.map +1 -0
- package/dist/js/profiling/hermes.d.ts +52 -0
- package/dist/js/profiling/hermes.d.ts.map +1 -0
- package/dist/js/profiling/hermes.js +35 -0
- package/dist/js/profiling/hermes.js.map +1 -0
- package/dist/js/profiling/integration.d.ts +36 -0
- package/dist/js/profiling/integration.d.ts.map +1 -0
- package/dist/js/profiling/integration.js +151 -0
- package/dist/js/profiling/integration.js.map +1 -0
- package/dist/js/profiling/types.d.ts +5 -0
- package/dist/js/profiling/types.d.ts.map +1 -0
- package/dist/js/profiling/types.js +2 -0
- package/dist/js/profiling/types.js.map +1 -0
- package/dist/js/profiling/utils.d.ts +26 -0
- package/dist/js/profiling/utils.d.ts.map +1 -0
- package/dist/js/profiling/utils.js +135 -0
- package/dist/js/profiling/utils.js.map +1 -0
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +6 -1
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/version.d.ts +1 -1
- package/dist/js/version.js +1 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts +4 -2
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +36 -27
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry.mm +75 -13
- package/package.json +14 -13
- package/src/js/NativeRNSentry.ts +7 -4
- package/ts3.8/dist/js/NativeRNSentry.d.ts +13 -4
- package/ts3.8/dist/js/integrations/index.d.ts +1 -0
- package/ts3.8/dist/js/integrations/reactnativeerrorhandlers.d.ts +5 -0
- package/ts3.8/dist/js/integrations/rewriteframes.d.ts +2 -0
- package/ts3.8/dist/js/profiling/cache.d.ts +9 -0
- package/ts3.8/dist/js/profiling/convertHermesProfile.d.ts +27 -0
- package/ts3.8/dist/js/profiling/hermes.d.ts +52 -0
- package/ts3.8/dist/js/profiling/integration.d.ts +36 -0
- package/ts3.8/dist/js/profiling/types.d.ts +5 -0
- package/ts3.8/dist/js/profiling/utils.d.ts +26 -0
- package/ts3.8/dist/js/version.d.ts +1 -1
- package/ts3.8/dist/js/wrapper.d.ts +4 -2
package/dist/js/wrapper.js
CHANGED
|
@@ -132,7 +132,6 @@ export const NATIVE = {
|
|
|
132
132
|
},
|
|
133
133
|
/**
|
|
134
134
|
* Fetches the Sdk info for the native sdk.
|
|
135
|
-
* NOTE: Only available on iOS.
|
|
136
135
|
*/
|
|
137
136
|
fetchNativeSdkInfo() {
|
|
138
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -142,9 +141,6 @@ export const NATIVE = {
|
|
|
142
141
|
if (!this._isModuleLoaded(RNSentry)) {
|
|
143
142
|
throw this._NativeClientError;
|
|
144
143
|
}
|
|
145
|
-
if (this.platform !== 'ios') {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
144
|
return RNSentry.fetchNativeSdkInfo();
|
|
149
145
|
});
|
|
150
146
|
},
|
|
@@ -159,10 +155,6 @@ export const NATIVE = {
|
|
|
159
155
|
if (!this._isModuleLoaded(RNSentry)) {
|
|
160
156
|
throw this._NativeClientError;
|
|
161
157
|
}
|
|
162
|
-
if (this.platform !== 'ios') {
|
|
163
|
-
// Only ios uses deviceContexts, return an empty object.
|
|
164
|
-
return {};
|
|
165
|
-
}
|
|
166
158
|
return RNSentry.fetchNativeDeviceContexts();
|
|
167
159
|
});
|
|
168
160
|
},
|
|
@@ -378,6 +370,42 @@ export const NATIVE = {
|
|
|
378
370
|
return raw ? new Uint8Array(raw) : null;
|
|
379
371
|
});
|
|
380
372
|
},
|
|
373
|
+
startProfiling() {
|
|
374
|
+
if (!this.enableNative) {
|
|
375
|
+
throw this._DisabledNativeError;
|
|
376
|
+
}
|
|
377
|
+
if (!this._isModuleLoaded(RNSentry)) {
|
|
378
|
+
throw this._NativeClientError;
|
|
379
|
+
}
|
|
380
|
+
const { started, error } = RNSentry.startProfiling();
|
|
381
|
+
if (started) {
|
|
382
|
+
logger.log('[NATIVE] Start Profiling');
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
logger.error('[NATIVE] Start Profiling Failed', error);
|
|
386
|
+
}
|
|
387
|
+
return !!started;
|
|
388
|
+
},
|
|
389
|
+
stopProfiling() {
|
|
390
|
+
if (!this.enableNative) {
|
|
391
|
+
throw this._DisabledNativeError;
|
|
392
|
+
}
|
|
393
|
+
if (!this._isModuleLoaded(RNSentry)) {
|
|
394
|
+
throw this._NativeClientError;
|
|
395
|
+
}
|
|
396
|
+
const { profile, error } = RNSentry.stopProfiling();
|
|
397
|
+
if (!profile || error) {
|
|
398
|
+
logger.error('[NATIVE] Stop Profiling Failed', error);
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
try {
|
|
402
|
+
return JSON.parse(profile);
|
|
403
|
+
}
|
|
404
|
+
catch (e) {
|
|
405
|
+
logger.error('[NATIVE] Failed to parse Hermes Profile JSON', e);
|
|
406
|
+
return null;
|
|
407
|
+
}
|
|
408
|
+
},
|
|
381
409
|
/**
|
|
382
410
|
* Gets the event from envelopeItem and applies the level filter to the selected event.
|
|
383
411
|
* @param data An envelope item containing the event.
|
|
@@ -392,7 +420,6 @@ export const NATIVE = {
|
|
|
392
420
|
// @ts-ignore Android still uses the old message object, without this the serialization of events will break.
|
|
393
421
|
event.message = { message: event.message };
|
|
394
422
|
}
|
|
395
|
-
event.breadcrumbs = this._getBreadcrumbs(event);
|
|
396
423
|
}
|
|
397
424
|
return [itemHeader, event];
|
|
398
425
|
}
|
|
@@ -440,24 +467,6 @@ export const NATIVE = {
|
|
|
440
467
|
},
|
|
441
468
|
_DisabledNativeError: new SentryError('Native is disabled'),
|
|
442
469
|
_NativeClientError: new SentryError("Native Client is not available, can't start on native."),
|
|
443
|
-
/**
|
|
444
|
-
* Get breadcrumbs (removes breadcrumbs from handled exceptions on Android)
|
|
445
|
-
*
|
|
446
|
-
* We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs
|
|
447
|
-
* from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs
|
|
448
|
-
* sent through the scope sync feature. This causes duplicate breadcrumbs.
|
|
449
|
-
* We then remove the breadcrumbs in all cases but if it is handled == false,
|
|
450
|
-
* this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
|
|
451
|
-
* the envelope.
|
|
452
|
-
*/
|
|
453
|
-
_getBreadcrumbs(event) {
|
|
454
|
-
let breadcrumbs = event.breadcrumbs;
|
|
455
|
-
const hardCrashed = isHardCrash(event);
|
|
456
|
-
if (NATIVE.platform === 'android' && event.breadcrumbs && !hardCrashed) {
|
|
457
|
-
breadcrumbs = [];
|
|
458
|
-
}
|
|
459
|
-
return breadcrumbs;
|
|
460
|
-
},
|
|
461
470
|
enableNative: true,
|
|
462
471
|
nativeIsReady: false,
|
|
463
472
|
platform: Platform.OS,
|
package/dist/js/wrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAWrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,QAAQ,GAAqB,oBAAoB,EAAE;IACvD,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAO,UAAU,CAAC;IAC3C,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC;AAqD3B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwB;IACnC,YAAY;;YAChB,IAAI,CAAC,IAAI,CAA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AAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAChE,WAAW,QAAE,KAAK,CAAC,WAAW,0CAAE,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,iCAC7C,UAAU,KACb,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IAC1E,IACH,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IAEH,aAAa,CAAC,KAAoB;QAChC,IAAI,KAAK,IAAK,KAAuB,EAAE;YACrC,OAAO,OAAwB,CAAC;SACjC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,MAAwB;QACtC,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CAAC,wDAAwD,CAAC;IAE7F;;;;;;;;;OASG;IACH,eAAe,CAAC,KAAY;QAC1B,IAAI,WAAW,GAA6B,KAAK,CAAC,WAAW,CAAC;QAE9D,MAAM,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,KAAK,CAAC,WAAW,IAAI,CAAC,WAAW,EAAE;YACtE,WAAW,GAAG,EAAE,CAAC;SAClB;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type {\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n Envelope,\n EnvelopeItem,\n Event,\n Package,\n SeverityLevel,\n User,\n} from '@sentry/types';\nimport { logger, normalize, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform, TurboModuleRegistry } from 'react-native';\n\nimport { isHardCrash } from './misc';\nimport type {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n NativeScreenshot,\n Spec,\n} from './NativeRNSentry';\nimport type { ReactNativeClientOptions } from './options';\nimport type { RequiredKeysUser } from './user';\nimport { isTurboModuleEnabled } from './utils/environment';\nimport { utf8ToBytes } from './vendor';\n\nconst RNSentry: Spec | undefined = isTurboModuleEnabled()\n ? TurboModuleRegistry.get<Spec>('RNSentry')\n : NativeModules.RNSentry;\n\nexport interface Screenshot {\n data: Uint8Array;\n contentType: string;\n filename: string;\n}\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processItem(envelopeItem: EnvelopeItem): EnvelopeItem;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(module: Spec | undefined): module is Spec;\n _getBreadcrumbs(event: Event): Breadcrumb[] | undefined;\n\n isNativeAvailable(): boolean;\n\n initNativeSdk(options: Partial<ReactNativeClientOptions>): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\n captureScreenshot(): Promise<Screenshot[] | null>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): void;\n enableNativeFramesTracking(): void;\n\n addBreadcrumb(breadcrumb: Breadcrumb): void;\n setContext(key: string, context: { [key: string]: unknown } | null): void;\n clearBreadcrumbs(): void;\n setExtra(key: string, extra: unknown): void;\n setUser(user: User | null): void;\n setTag(key: string, value: string): void;\n\n nativeCrash(): void;\n\n fetchModules(): Promise<Record<string, string> | null>;\n fetchViewHierarchy(): PromiseLike<Uint8Array | null>;\n}\n\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n async fetchModules(): Promise<Record<string, string> | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchModules();\n if (raw) {\n return JSON.parse(raw);\n }\n return null;\n },\n /**\n * Sending the envelope over the bridge to native\n * @param envelope Envelope\n */\n async sendEnvelope(envelope: Envelope): Promise<void> {\n if (!this.enableNative) {\n logger.warn('Event was skipped as native SDK is not enabled.');\n return;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const [EOL] = utf8ToBytes('\\n');\n\n const [envelopeHeader, envelopeItems] = envelope;\n\n const headerString = JSON.stringify(envelopeHeader);\n let envelopeBytes: number[] = utf8ToBytes(headerString);\n envelopeBytes.push(EOL);\n\n let hardCrashed: boolean = false;\n for (const rawItem of envelopeItems) {\n const [itemHeader, itemPayload] = this._processItem(rawItem);\n\n let bytesContentType: string;\n let bytesPayload: number[] = [];\n if (typeof itemPayload === 'string') {\n bytesContentType = 'text/plain';\n bytesPayload = utf8ToBytes(itemPayload);\n } else if (itemPayload instanceof Uint8Array) {\n bytesContentType =\n typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream';\n bytesPayload = [...itemPayload];\n } else {\n bytesContentType = 'application/json';\n bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));\n if (!hardCrashed) {\n hardCrashed = isHardCrash(itemPayload);\n }\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (itemHeader as BaseEnvelopeItemHeaders).content_type = bytesContentType;\n (itemHeader as BaseEnvelopeItemHeaders).length = bytesPayload.length;\n const serializedItemHeader = JSON.stringify(itemHeader);\n\n envelopeBytes.push(...utf8ToBytes(serializedItemHeader));\n envelopeBytes.push(EOL);\n envelopeBytes = envelopeBytes.concat(bytesPayload);\n envelopeBytes.push(EOL);\n }\n\n await RNSentry.captureEnvelope(envelopeBytes, { store: hardCrashed });\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeClientOptions\n */\n async initNativeSdk(originalOptions: Partial<ReactNativeClientOptions>): Promise<boolean> {\n const options: Partial<ReactNativeClientOptions> = {\n enableNative: true,\n autoInitializeNativeSdk: true,\n ...originalOptions,\n };\n\n if (!options.enableNative) {\n if (options.enableNativeNagger) {\n logger.warn('Note: Native Sentry SDK is disabled.');\n }\n this.enableNative = false;\n return false;\n }\n if (!options.autoInitializeNativeSdk) {\n if (options.enableNativeNagger) {\n logger.warn(\n 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false',\n );\n }\n this.enableNative = true;\n return false;\n }\n\n if (!options.dsn) {\n logger.warn(\n 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.',\n );\n this.enableNative = false;\n return false;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // filter out all the options that would crash native.\n /* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const { beforeSend, beforeBreadcrumb, beforeSendTransaction, integrations, ...filteredOptions } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\n this.enableNative = true;\n\n return nativeIsReady;\n },\n\n /**\n * Fetches the release from native\n */\n async fetchNativeRelease(): Promise<NativeReleaseResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeRelease();\n },\n\n /**\n * Fetches the Sdk info for the native sdk.\n * NOTE: Only available on iOS.\n */\n async fetchNativeSdkInfo(): Promise<Package | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== 'ios') {\n return null;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n if (this.platform !== 'ios') {\n // Only ios uses deviceContexts, return an empty object.\n return {};\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n return RNSentry.fetchNativeAppStart();\n },\n\n async fetchNativeFrames(): Promise<NativeFramesResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeFrames();\n },\n\n /**\n * Triggers a native crash.\n * Use this only for testing purposes.\n */\n nativeCrash(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.crash();\n },\n\n /**\n * Sets the user in the native scope.\n * Passing null clears the user.\n */\n setUser(user: User | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // separate and serialize all non-default user keys.\n let userKeys = null;\n let userDataKeys = null;\n if (user) {\n const { id, ip_address, email, username, segment, ...otherKeys } = user;\n const requiredUser: RequiredKeysUser = {\n id,\n ip_address,\n email,\n username,\n segment,\n };\n userKeys = this._serializeObject(requiredUser);\n userDataKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(userKeys, userDataKeys);\n },\n\n /**\n * Sets a tag in the native module.\n * @param key string\n * @param value string\n */\n setTag(key: string, value: string): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const stringifiedValue = typeof value === 'string' ? value : JSON.stringify(value);\n\n RNSentry.setTag(key, stringifiedValue);\n },\n\n /**\n * Sets an extra in the native scope, will stringify\n * extra value if it isn't already a string.\n * @param key string\n * @param extra any\n */\n setExtra(key: string, extra: unknown): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // we stringify the extra as native only takes in strings.\n const stringifiedExtra = typeof extra === 'string' ? extra : JSON.stringify(extra);\n\n RNSentry.setExtra(key, stringifiedExtra);\n },\n\n /**\n * Adds breadcrumb to the native scope.\n * @param breadcrumb Breadcrumb\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.addBreadcrumb({\n ...breadcrumb,\n // Process and convert deprecated levels\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n });\n },\n\n /**\n * Clears breadcrumbs on the native scope.\n */\n clearBreadcrumbs(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.clearBreadcrumbs();\n },\n\n /**\n * Sets context on the native scope. Not implemented in Android yet.\n * @param key string\n * @param context key-value map\n */\n setContext(key: string, context: { [key: string]: unknown } | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.setContext(key, context !== null ? normalize(context) : null);\n },\n\n /**\n * Closes the Native Layer SDK\n */\n async closeNativeSdk(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.closeNativeSdk().then(() => {\n this.enableNative = false;\n });\n },\n\n disableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.disableNativeFramesTracking();\n },\n\n enableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.enableNativeFramesTracking();\n },\n\n isNativeAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\n },\n\n async captureScreenshot(): Promise<Screenshot[] | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n let raw: NativeScreenshot[] | null | undefined;\n try {\n raw = await RNSentry.captureScreenshot();\n } catch (e) {\n logger.warn('Failed to capture screenshot', e);\n }\n\n if (raw) {\n return raw.map((item: NativeScreenshot) => ({\n ...item,\n data: new Uint8Array(item.data),\n }));\n } else {\n return null;\n }\n },\n\n async fetchViewHierarchy(): Promise<Uint8Array | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchViewHierarchy();\n return raw ? new Uint8Array(raw) : null;\n },\n\n /**\n * Gets the event from envelopeItem and applies the level filter to the selected event.\n * @param data An envelope item containing the event.\n * @returns The event from envelopeItem or undefined.\n */\n _processItem(item: EnvelopeItem): EnvelopeItem {\n const [itemHeader, itemPayload] = item;\n\n if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {\n const event = this._processLevels(itemPayload as Event);\n\n if (NATIVE.platform === 'android') {\n if ('message' in event) {\n // @ts-ignore Android still uses the old message object, without this the serialization of events will break.\n event.message = { message: event.message };\n }\n event.breadcrumbs = this._getBreadcrumbs(event);\n }\n\n return [itemHeader, event];\n }\n\n return item;\n },\n\n /**\n * Serializes all values of root-level keys into strings.\n * @param data key-value map.\n * @returns An object where all root-level values are strings.\n */\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach(dataKey => {\n const value = data[dataKey];\n serialized[dataKey] = typeof value === 'string' ? value : JSON.stringify(value);\n });\n\n return serialized;\n },\n\n /**\n * Convert js severity level in event.level and event.breadcrumbs to more widely supported levels.\n * @param event\n * @returns Event with more widely supported Severity level strings\n */\n\n _processLevels(event: Event): Event {\n const processed: Event = {\n ...event,\n level: event.level ? this._processLevel(event.level) : undefined,\n breadcrumbs: event.breadcrumbs?.map(breadcrumb => ({\n ...breadcrumb,\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n })),\n };\n\n return processed;\n },\n\n /**\n * Convert js severity level which has critical and log to more widely supported levels.\n * @param level\n * @returns More widely supported Severity level strings\n */\n\n _processLevel(level: SeverityLevel): SeverityLevel {\n if (level == ('log' as SeverityLevel)) {\n return 'debug' as SeverityLevel;\n }\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(module: Spec | undefined): module is Spec {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\"Native Client is not available, can't start on native.\"),\n\n /**\n * Get breadcrumbs (removes breadcrumbs from handled exceptions on Android)\n *\n * We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs\n * from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs\n * sent through the scope sync feature. This causes duplicate breadcrumbs.\n * We then remove the breadcrumbs in all cases but if it is handled == false,\n * this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read\n * the envelope.\n */\n _getBreadcrumbs(event: Event): Breadcrumb[] | undefined {\n let breadcrumbs: Breadcrumb[] | undefined = event.breadcrumbs;\n\n const hardCrashed = isHardCrash(event);\n if (NATIVE.platform === 'android' && event.breadcrumbs && !hardCrashed) {\n breadcrumbs = [];\n }\n\n return breadcrumbs;\n },\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":";AAWA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAYrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,QAAQ,GAAqB,oBAAoB,EAAE;IACvD,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAO,UAAU,CAAC;IAC3C,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC;AAuD3B;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwB;IACnC,YAAY;;YAChB,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,MAAM,IAAI,CAAC,oBAAoB,CAAC;aACjC;YACD,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;gBACnC,MAAM,IAAI,CAAC,kBAAkB,CAAC;aAC/B;YAED,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,YAAY,EAAE,CAAC;YAC1C,IAAI,GAAG,EAAE;gBACP,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;aACxB;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IACD;;;OAGG;IACG,YAAY,CAAC,QAAkB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AAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type {\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n Envelope,\n EnvelopeItem,\n Event,\n Package,\n SeverityLevel,\n User,\n} from '@sentry/types';\nimport { logger, normalize, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform, TurboModuleRegistry } from 'react-native';\n\nimport { isHardCrash } from './misc';\nimport type {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n NativeScreenshot,\n Spec,\n} from './NativeRNSentry';\nimport type { ReactNativeClientOptions } from './options';\nimport type * as Hermes from './profiling/hermes';\nimport type { RequiredKeysUser } from './user';\nimport { isTurboModuleEnabled } from './utils/environment';\nimport { utf8ToBytes } from './vendor';\n\nconst RNSentry: Spec | undefined = isTurboModuleEnabled()\n ? TurboModuleRegistry.get<Spec>('RNSentry')\n : NativeModules.RNSentry;\n\nexport interface Screenshot {\n data: Uint8Array;\n contentType: string;\n filename: string;\n}\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _processItem(envelopeItem: EnvelopeItem): EnvelopeItem;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(module: Spec | undefined): module is Spec;\n\n isNativeAvailable(): boolean;\n\n initNativeSdk(options: Partial<ReactNativeClientOptions>): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\n captureScreenshot(): Promise<Screenshot[] | null>;\n\n fetchNativeRelease(): PromiseLike<NativeReleaseResponse>;\n fetchNativeDeviceContexts(): PromiseLike<NativeDeviceContextsResponse | null>;\n fetchNativeAppStart(): PromiseLike<NativeAppStartResponse | null>;\n fetchNativeFrames(): PromiseLike<NativeFramesResponse | null>;\n fetchNativeSdkInfo(): PromiseLike<Package | null>;\n\n disableNativeFramesTracking(): void;\n enableNativeFramesTracking(): void;\n\n addBreadcrumb(breadcrumb: Breadcrumb): void;\n setContext(key: string, context: { [key: string]: unknown } | null): void;\n clearBreadcrumbs(): void;\n setExtra(key: string, extra: unknown): void;\n setUser(user: User | null): void;\n setTag(key: string, value: string): void;\n\n nativeCrash(): void;\n\n fetchModules(): Promise<Record<string, string> | null>;\n fetchViewHierarchy(): PromiseLike<Uint8Array | null>;\n\n startProfiling(): boolean;\n stopProfiling(): Hermes.Profile | null;\n}\n\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\n async fetchModules(): Promise<Record<string, string> | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchModules();\n if (raw) {\n return JSON.parse(raw);\n }\n return null;\n },\n /**\n * Sending the envelope over the bridge to native\n * @param envelope Envelope\n */\n async sendEnvelope(envelope: Envelope): Promise<void> {\n if (!this.enableNative) {\n logger.warn('Event was skipped as native SDK is not enabled.');\n return;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const [EOL] = utf8ToBytes('\\n');\n\n const [envelopeHeader, envelopeItems] = envelope;\n\n const headerString = JSON.stringify(envelopeHeader);\n let envelopeBytes: number[] = utf8ToBytes(headerString);\n envelopeBytes.push(EOL);\n\n let hardCrashed: boolean = false;\n for (const rawItem of envelopeItems) {\n const [itemHeader, itemPayload] = this._processItem(rawItem);\n\n let bytesContentType: string;\n let bytesPayload: number[] = [];\n if (typeof itemPayload === 'string') {\n bytesContentType = 'text/plain';\n bytesPayload = utf8ToBytes(itemPayload);\n } else if (itemPayload instanceof Uint8Array) {\n bytesContentType =\n typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream';\n bytesPayload = [...itemPayload];\n } else {\n bytesContentType = 'application/json';\n bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));\n if (!hardCrashed) {\n hardCrashed = isHardCrash(itemPayload);\n }\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (itemHeader as BaseEnvelopeItemHeaders).content_type = bytesContentType;\n (itemHeader as BaseEnvelopeItemHeaders).length = bytesPayload.length;\n const serializedItemHeader = JSON.stringify(itemHeader);\n\n envelopeBytes.push(...utf8ToBytes(serializedItemHeader));\n envelopeBytes.push(EOL);\n envelopeBytes = envelopeBytes.concat(bytesPayload);\n envelopeBytes.push(EOL);\n }\n\n await RNSentry.captureEnvelope(envelopeBytes, { store: hardCrashed });\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeClientOptions\n */\n async initNativeSdk(originalOptions: Partial<ReactNativeClientOptions>): Promise<boolean> {\n const options: Partial<ReactNativeClientOptions> = {\n enableNative: true,\n autoInitializeNativeSdk: true,\n ...originalOptions,\n };\n\n if (!options.enableNative) {\n if (options.enableNativeNagger) {\n logger.warn('Note: Native Sentry SDK is disabled.');\n }\n this.enableNative = false;\n return false;\n }\n if (!options.autoInitializeNativeSdk) {\n if (options.enableNativeNagger) {\n logger.warn(\n 'Note: Native Sentry SDK was not initialized automatically, you will need to initialize it manually. If you wish to disable the native SDK and get rid of this warning, pass enableNative: false',\n );\n }\n this.enableNative = true;\n return false;\n }\n\n if (!options.dsn) {\n logger.warn(\n 'Warning: No DSN was provided. The Sentry SDK will be disabled. Native SDK will also not be initalized.',\n );\n this.enableNative = false;\n return false;\n }\n\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // filter out all the options that would crash native.\n /* eslint-disable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const { beforeSend, beforeBreadcrumb, beforeSendTransaction, integrations, ...filteredOptions } = options;\n /* eslint-enable @typescript-eslint/unbound-method,@typescript-eslint/no-unused-vars */\n const nativeIsReady = await RNSentry.initNativeSdk(filteredOptions);\n\n this.nativeIsReady = nativeIsReady;\n this.enableNative = true;\n\n return nativeIsReady;\n },\n\n /**\n * Fetches the release from native\n */\n async fetchNativeRelease(): Promise<NativeReleaseResponse> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeRelease();\n },\n\n /**\n * Fetches the Sdk info for the native sdk.\n */\n async fetchNativeSdkInfo(): Promise<Package | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeSdkInfo();\n },\n\n /**\n * Fetches the device contexts. Not used on Android.\n */\n async fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeDeviceContexts();\n },\n\n async fetchNativeAppStart(): Promise<NativeAppStartResponse | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n return RNSentry.fetchNativeAppStart();\n },\n\n async fetchNativeFrames(): Promise<NativeFramesResponse | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n return RNSentry.fetchNativeFrames();\n },\n\n /**\n * Triggers a native crash.\n * Use this only for testing purposes.\n */\n nativeCrash(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.crash();\n },\n\n /**\n * Sets the user in the native scope.\n * Passing null clears the user.\n */\n setUser(user: User | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // separate and serialize all non-default user keys.\n let userKeys = null;\n let userDataKeys = null;\n if (user) {\n const { id, ip_address, email, username, segment, ...otherKeys } = user;\n const requiredUser: RequiredKeysUser = {\n id,\n ip_address,\n email,\n username,\n segment,\n };\n userKeys = this._serializeObject(requiredUser);\n userDataKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(userKeys, userDataKeys);\n },\n\n /**\n * Sets a tag in the native module.\n * @param key string\n * @param value string\n */\n setTag(key: string, value: string): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const stringifiedValue = typeof value === 'string' ? value : JSON.stringify(value);\n\n RNSentry.setTag(key, stringifiedValue);\n },\n\n /**\n * Sets an extra in the native scope, will stringify\n * extra value if it isn't already a string.\n * @param key string\n * @param extra any\n */\n setExtra(key: string, extra: unknown): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n // we stringify the extra as native only takes in strings.\n const stringifiedExtra = typeof extra === 'string' ? extra : JSON.stringify(extra);\n\n RNSentry.setExtra(key, stringifiedExtra);\n },\n\n /**\n * Adds breadcrumb to the native scope.\n * @param breadcrumb Breadcrumb\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.addBreadcrumb({\n ...breadcrumb,\n // Process and convert deprecated levels\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n });\n },\n\n /**\n * Clears breadcrumbs on the native scope.\n */\n clearBreadcrumbs(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.clearBreadcrumbs();\n },\n\n /**\n * Sets context on the native scope. Not implemented in Android yet.\n * @param key string\n * @param context key-value map\n */\n setContext(key: string, context: { [key: string]: unknown } | null): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n RNSentry.setContext(key, context !== null ? normalize(context) : null);\n },\n\n /**\n * Closes the Native Layer SDK\n */\n async closeNativeSdk(): Promise<void> {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n return RNSentry.closeNativeSdk().then(() => {\n this.enableNative = false;\n });\n },\n\n disableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.disableNativeFramesTracking();\n },\n\n enableNativeFramesTracking(): void {\n if (!this.enableNative) {\n return;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n return;\n }\n\n RNSentry.enableNativeFramesTracking();\n },\n\n isNativeAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\n },\n\n async captureScreenshot(): Promise<Screenshot[] | null> {\n if (!this.enableNative) {\n logger.warn(this._DisabledNativeError);\n return null;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n logger.error(this._NativeClientError);\n return null;\n }\n\n let raw: NativeScreenshot[] | null | undefined;\n try {\n raw = await RNSentry.captureScreenshot();\n } catch (e) {\n logger.warn('Failed to capture screenshot', e);\n }\n\n if (raw) {\n return raw.map((item: NativeScreenshot) => ({\n ...item,\n data: new Uint8Array(item.data),\n }));\n } else {\n return null;\n }\n },\n\n async fetchViewHierarchy(): Promise<Uint8Array | null> {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const raw = await RNSentry.fetchViewHierarchy();\n return raw ? new Uint8Array(raw) : null;\n },\n\n startProfiling(): boolean {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const { started, error } = RNSentry.startProfiling();\n if (started) {\n logger.log('[NATIVE] Start Profiling');\n } else {\n logger.error('[NATIVE] Start Profiling Failed', error);\n }\n\n return !!started;\n },\n\n stopProfiling(): Hermes.Profile | null {\n if (!this.enableNative) {\n throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\n }\n\n const { profile, error } = RNSentry.stopProfiling();\n if (!profile || error) {\n logger.error('[NATIVE] Stop Profiling Failed', error);\n return null;\n }\n\n try {\n return JSON.parse(profile) as Hermes.Profile;\n } catch (e) {\n logger.error('[NATIVE] Failed to parse Hermes Profile JSON', e);\n return null;\n }\n },\n\n /**\n * Gets the event from envelopeItem and applies the level filter to the selected event.\n * @param data An envelope item containing the event.\n * @returns The event from envelopeItem or undefined.\n */\n _processItem(item: EnvelopeItem): EnvelopeItem {\n const [itemHeader, itemPayload] = item;\n\n if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {\n const event = this._processLevels(itemPayload as Event);\n\n if (NATIVE.platform === 'android') {\n if ('message' in event) {\n // @ts-ignore Android still uses the old message object, without this the serialization of events will break.\n event.message = { message: event.message };\n }\n }\n\n return [itemHeader, event];\n }\n\n return item;\n },\n\n /**\n * Serializes all values of root-level keys into strings.\n * @param data key-value map.\n * @returns An object where all root-level values are strings.\n */\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach(dataKey => {\n const value = data[dataKey];\n serialized[dataKey] = typeof value === 'string' ? value : JSON.stringify(value);\n });\n\n return serialized;\n },\n\n /**\n * Convert js severity level in event.level and event.breadcrumbs to more widely supported levels.\n * @param event\n * @returns Event with more widely supported Severity level strings\n */\n\n _processLevels(event: Event): Event {\n const processed: Event = {\n ...event,\n level: event.level ? this._processLevel(event.level) : undefined,\n breadcrumbs: event.breadcrumbs?.map(breadcrumb => ({\n ...breadcrumb,\n level: breadcrumb.level ? this._processLevel(breadcrumb.level) : undefined,\n })),\n };\n\n return processed;\n },\n\n /**\n * Convert js severity level which has critical and log to more widely supported levels.\n * @param level\n * @returns More widely supported Severity level strings\n */\n\n _processLevel(level: SeverityLevel): SeverityLevel {\n if (level == ('log' as SeverityLevel)) {\n return 'debug' as SeverityLevel;\n }\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(module: Spec | undefined): module is Spec {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\"Native Client is not available, can't start on native.\"),\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
|
package/ios/RNSentry.mm
CHANGED
|
@@ -11,6 +11,17 @@
|
|
|
11
11
|
#import <Sentry/SentryScreenFrames.h>
|
|
12
12
|
#import <Sentry/SentryOptions+HybridSDKs.h>
|
|
13
13
|
|
|
14
|
+
#if __has_include(<hermes/hermes.h>)
|
|
15
|
+
#define SENTRY_PROFILING_ENABLED 1
|
|
16
|
+
#else
|
|
17
|
+
#define SENTRY_PROFILING_ENABLED 0
|
|
18
|
+
#endif
|
|
19
|
+
|
|
20
|
+
// This guard prevents importing Hermes in JSC apps
|
|
21
|
+
#if SENTRY_PROFILING_ENABLED
|
|
22
|
+
#import <hermes/hermes.h>
|
|
23
|
+
#endif
|
|
24
|
+
|
|
14
25
|
// Thanks to this guard, we won't import this header when we build for the old architecture.
|
|
15
26
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
16
27
|
#import "RNSentrySpec.h"
|
|
@@ -188,44 +199,44 @@ RCT_EXPORT_METHOD(fetchNativeDeviceContexts:(RCTPromiseResolveBlock)resolve
|
|
|
188
199
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
189
200
|
{
|
|
190
201
|
NSLog(@"Bridge call to: deviceContexts");
|
|
191
|
-
__block NSMutableDictionary<NSString *, id> *
|
|
202
|
+
__block NSMutableDictionary<NSString *, id> *serializedScope;
|
|
192
203
|
// Temp work around until sorted out this API in sentry-cocoa.
|
|
193
204
|
// TODO: If the callback isnt' executed the promise wouldn't be resolved.
|
|
194
205
|
[SentrySDK configureScope:^(SentryScope * _Nonnull scope) {
|
|
195
|
-
|
|
196
|
-
contexts = [serializedScope mutableCopy];
|
|
206
|
+
serializedScope = [[scope serialize] mutableCopy];
|
|
197
207
|
|
|
198
|
-
NSDictionary<NSString *, id> *user = [
|
|
208
|
+
NSDictionary<NSString *, id> *user = [serializedScope valueForKey:@"user"];
|
|
199
209
|
if (user == nil) {
|
|
200
|
-
[
|
|
210
|
+
[serializedScope
|
|
201
211
|
setValue:@{ @"id": PrivateSentrySDKOnly.installationID }
|
|
202
212
|
forKey:@"user"];
|
|
203
213
|
}
|
|
204
214
|
|
|
205
215
|
if (PrivateSentrySDKOnly.options.debug) {
|
|
206
|
-
NSData *data = [NSJSONSerialization dataWithJSONObject:
|
|
216
|
+
NSData *data = [NSJSONSerialization dataWithJSONObject:serializedScope options:0 error:nil];
|
|
207
217
|
NSString *debugContext = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
|
208
218
|
NSLog(@"Contexts: %@", debugContext);
|
|
209
219
|
}
|
|
210
220
|
}];
|
|
211
221
|
|
|
212
222
|
NSDictionary<NSString *, id> *extraContext = [PrivateSentrySDKOnly getExtraContext];
|
|
213
|
-
NSMutableDictionary<NSString *, NSDictionary<NSString *, id> *> *
|
|
223
|
+
NSMutableDictionary<NSString *, NSDictionary<NSString *, id> *> *contexts = [serializedScope[@"context"] mutableCopy];
|
|
214
224
|
|
|
215
225
|
if (extraContext && [extraContext[@"device"] isKindOfClass:[NSDictionary class]]) {
|
|
216
|
-
NSMutableDictionary<NSString *, NSDictionary<NSString *, id> *> *deviceContext = [contexts[@"
|
|
226
|
+
NSMutableDictionary<NSString *, NSDictionary<NSString *, id> *> *deviceContext = [contexts[@"device"] mutableCopy];
|
|
217
227
|
[deviceContext addEntriesFromDictionary:extraContext[@"device"]];
|
|
218
|
-
[
|
|
228
|
+
[contexts setValue:deviceContext forKey:@"device"];
|
|
219
229
|
}
|
|
220
230
|
|
|
221
231
|
if (extraContext && [extraContext[@"app"] isKindOfClass:[NSDictionary class]]) {
|
|
222
|
-
NSMutableDictionary<NSString *, NSDictionary<NSString *, id> *> *appContext = [contexts[@"
|
|
232
|
+
NSMutableDictionary<NSString *, NSDictionary<NSString *, id> *> *appContext = [contexts[@"app"] mutableCopy];
|
|
223
233
|
[appContext addEntriesFromDictionary:extraContext[@"app"]];
|
|
224
|
-
[
|
|
234
|
+
[contexts setValue:appContext forKey:@"app"];
|
|
225
235
|
}
|
|
226
236
|
|
|
227
|
-
[
|
|
228
|
-
|
|
237
|
+
[serializedScope setValue:contexts forKey:@"contexts"];
|
|
238
|
+
[serializedScope removeObjectForKey:@"context"];
|
|
239
|
+
resolve(serializedScope);
|
|
229
240
|
}
|
|
230
241
|
|
|
231
242
|
RCT_EXPORT_METHOD(fetchNativeAppStart:(RCTPromiseResolveBlock)resolve
|
|
@@ -498,6 +509,57 @@ RCT_EXPORT_METHOD(enableNativeFramesTracking)
|
|
|
498
509
|
// the 'tracesSampleRate' or 'tracesSampler' option.
|
|
499
510
|
}
|
|
500
511
|
|
|
512
|
+
static NSString* const enabledProfilingMessage = @"Enable Hermes to use Sentry Profiling.";
|
|
513
|
+
|
|
514
|
+
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, startProfiling)
|
|
515
|
+
{
|
|
516
|
+
#if SENTRY_PROFILING_ENABLED
|
|
517
|
+
try {
|
|
518
|
+
facebook::hermes::HermesRuntime::enableSamplingProfiler();
|
|
519
|
+
return @{ @"started": @YES };
|
|
520
|
+
} catch (const std::exception& ex) {
|
|
521
|
+
return @{ @"error": [NSString stringWithCString: ex.what() encoding:[NSString defaultCStringEncoding]] };
|
|
522
|
+
} catch (...) {
|
|
523
|
+
return @{ @"error": @"Failed to start profiling" };
|
|
524
|
+
}
|
|
525
|
+
#else
|
|
526
|
+
return @{ @"error": enabledProfilingMessage };
|
|
527
|
+
#endif
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSDictionary *, stopProfiling)
|
|
531
|
+
{
|
|
532
|
+
#if SENTRY_PROFILING_ENABLED
|
|
533
|
+
try {
|
|
534
|
+
facebook::hermes::HermesRuntime::disableSamplingProfiler();
|
|
535
|
+
std::stringstream ss;
|
|
536
|
+
facebook::hermes::HermesRuntime::dumpSampledTraceToStream(ss);
|
|
537
|
+
|
|
538
|
+
std::string s = ss.str();
|
|
539
|
+
NSString *data = [NSString stringWithCString:s.c_str() encoding:[NSString defaultCStringEncoding]];
|
|
540
|
+
|
|
541
|
+
#if SENTRY_PROFILING_DEBUG_ENABLED
|
|
542
|
+
NSString *rawProfileFileName = @"hermes.profile";
|
|
543
|
+
NSError *error = nil;
|
|
544
|
+
NSString *rawProfileFilePath = [NSTemporaryDirectory() stringByAppendingPathComponent:rawProfileFileName];
|
|
545
|
+
if (![data writeToFile:rawProfileFilePath atomically:YES encoding:NSUTF8StringEncoding error:&error]) {
|
|
546
|
+
NSLog(@"Error writing Raw Hermes Profile to %@: %@", rawProfileFilePath, error);
|
|
547
|
+
} else {
|
|
548
|
+
NSLog(@"Raw Hermes Profile saved to %@", rawProfileFilePath);
|
|
549
|
+
}
|
|
550
|
+
#endif
|
|
551
|
+
|
|
552
|
+
return @{ @"profile": data };
|
|
553
|
+
} catch (const std::exception& ex) {
|
|
554
|
+
return @{ @"error": [NSString stringWithCString: ex.what() encoding:[NSString defaultCStringEncoding]] };
|
|
555
|
+
} catch (...) {
|
|
556
|
+
return @{ @"error": @"Failed to stop profiling" };
|
|
557
|
+
}
|
|
558
|
+
#else
|
|
559
|
+
return @{ @"error": enabledProfilingMessage };
|
|
560
|
+
#endif
|
|
561
|
+
}
|
|
562
|
+
|
|
501
563
|
// Thanks to this guard, we won't compile this code when we build for the old architecture.
|
|
502
564
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
503
565
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
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.
|
|
5
|
+
"version": "5.8.0",
|
|
6
6
|
"description": "Official Sentry SDK for react-native",
|
|
7
7
|
"typings": "dist/js/index.d.ts",
|
|
8
8
|
"types": "dist/js/index.d.ts",
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
|
|
34
34
|
"test:watch": "jest --watch",
|
|
35
35
|
"run-ios": "cd sample-new-architecture && yarn react-native run-ios",
|
|
36
|
-
"run-android": "cd sample-new-architecture && yarn react-native run-android"
|
|
36
|
+
"run-android": "cd sample-new-architecture && yarn react-native run-android",
|
|
37
|
+
"yalc:add:sentry-javascript": "yalc add @sentry/browser @sentry/core @sentry/hub @sentry/integrations @sentry/react @sentry/types @sentry/utils"
|
|
37
38
|
},
|
|
38
39
|
"keywords": [
|
|
39
40
|
"react-native",
|
|
@@ -55,22 +56,22 @@
|
|
|
55
56
|
"react-native": ">=0.65.0"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"@sentry/browser": "7.
|
|
59
|
+
"@sentry/browser": "7.60.1",
|
|
59
60
|
"@sentry/cli": "2.19.4",
|
|
60
|
-
"@sentry/core": "7.
|
|
61
|
-
"@sentry/hub": "7.
|
|
62
|
-
"@sentry/integrations": "7.
|
|
63
|
-
"@sentry/react": "7.
|
|
64
|
-
"@sentry/types": "7.
|
|
65
|
-
"@sentry/utils": "7.
|
|
61
|
+
"@sentry/core": "7.60.1",
|
|
62
|
+
"@sentry/hub": "7.60.1",
|
|
63
|
+
"@sentry/integrations": "7.60.1",
|
|
64
|
+
"@sentry/react": "7.60.1",
|
|
65
|
+
"@sentry/types": "7.60.1",
|
|
66
|
+
"@sentry/utils": "7.60.1"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@sentry-internal/eslint-config-sdk": "7.
|
|
69
|
-
"@sentry-internal/eslint-plugin-sdk": "7.
|
|
69
|
+
"@sentry-internal/eslint-config-sdk": "7.60.1",
|
|
70
|
+
"@sentry-internal/eslint-plugin-sdk": "7.60.1",
|
|
70
71
|
"@sentry/typescript": "^5.20.1",
|
|
71
72
|
"@sentry/wizard": "3.2.3",
|
|
72
73
|
"@types/jest": "^29.2.5",
|
|
73
|
-
"@types/react": "^18.
|
|
74
|
+
"@types/react": "^18.2.14",
|
|
74
75
|
"babel-jest": "^29.3.1",
|
|
75
76
|
"downlevel-dts": "^0.11.0",
|
|
76
77
|
"eslint": "^7.6.0",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"prettier": "^2.0.5",
|
|
82
83
|
"react": "18.2.0",
|
|
83
84
|
"react-native": "0.72.0",
|
|
84
|
-
"replace-in-file": "^
|
|
85
|
+
"replace-in-file": "^7.0.1",
|
|
85
86
|
"rimraf": "^4.1.1",
|
|
86
87
|
"ts-jest": "^29.0.5",
|
|
87
88
|
"typescript": "4.1.3"
|
package/src/js/NativeRNSentry.ts
CHANGED
|
@@ -19,8 +19,8 @@ export interface Spec extends TurboModule {
|
|
|
19
19
|
closeNativeSdk(): Promise<void>;
|
|
20
20
|
disableNativeFramesTracking(): void;
|
|
21
21
|
fetchNativeRelease(): Promise<NativeReleaseResponse>;
|
|
22
|
-
fetchNativeSdkInfo(): Promise<Package>;
|
|
23
|
-
fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse>;
|
|
22
|
+
fetchNativeSdkInfo(): Promise<Package | null>;
|
|
23
|
+
fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null>;
|
|
24
24
|
fetchNativeAppStart(): Promise<NativeAppStartResponse | null>;
|
|
25
25
|
fetchNativeFrames(): Promise<NativeFramesResponse | null>;
|
|
26
26
|
initNativeSdk(options: UnsafeObject): Promise<boolean>;
|
|
@@ -31,6 +31,8 @@ export interface Spec extends TurboModule {
|
|
|
31
31
|
enableNativeFramesTracking(): void;
|
|
32
32
|
fetchModules(): Promise<string | undefined | null>;
|
|
33
33
|
fetchViewHierarchy(): Promise<number[] | undefined | null>;
|
|
34
|
+
startProfiling(): { started?: boolean; error?: string };
|
|
35
|
+
stopProfiling(): { profile?: string; error?: string };
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export type NativeAppStartResponse = {
|
|
@@ -52,14 +54,15 @@ export type NativeReleaseResponse = {
|
|
|
52
54
|
};
|
|
53
55
|
|
|
54
56
|
/**
|
|
55
|
-
* This type describes serialized scope from sentry-cocoa
|
|
57
|
+
* This type describes serialized scope from sentry-cocoa and sentry-android
|
|
56
58
|
* https://github.com/getsentry/sentry-cocoa/blob/master/Sources/Sentry/SentryScope.m
|
|
59
|
+
* https://github.com/getsentry/sentry-java/blob/a461f7e125b65240004e6162b341f383ce2e1394/sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java#L32
|
|
57
60
|
*/
|
|
58
61
|
export type NativeDeviceContextsResponse = {
|
|
59
62
|
[key: string]: unknown;
|
|
60
63
|
tags?: Record<string, string>;
|
|
61
64
|
extra?: Record<string, unknown>;
|
|
62
|
-
|
|
65
|
+
contexts?: Record<string, Record<string, unknown>>;
|
|
63
66
|
user?: {
|
|
64
67
|
userId?: string;
|
|
65
68
|
email?: string;
|
|
@@ -12,8 +12,8 @@ export interface Spec extends TurboModule {
|
|
|
12
12
|
closeNativeSdk(): Promise<void>;
|
|
13
13
|
disableNativeFramesTracking(): void;
|
|
14
14
|
fetchNativeRelease(): Promise<NativeReleaseResponse>;
|
|
15
|
-
fetchNativeSdkInfo(): Promise<Package>;
|
|
16
|
-
fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse>;
|
|
15
|
+
fetchNativeSdkInfo(): Promise<Package | null>;
|
|
16
|
+
fetchNativeDeviceContexts(): Promise<NativeDeviceContextsResponse | null>;
|
|
17
17
|
fetchNativeAppStart(): Promise<NativeAppStartResponse | null>;
|
|
18
18
|
fetchNativeFrames(): Promise<NativeFramesResponse | null>;
|
|
19
19
|
initNativeSdk(options: UnsafeObject): Promise<boolean>;
|
|
@@ -24,6 +24,14 @@ export interface Spec extends TurboModule {
|
|
|
24
24
|
enableNativeFramesTracking(): void;
|
|
25
25
|
fetchModules(): Promise<string | undefined | null>;
|
|
26
26
|
fetchViewHierarchy(): Promise<number[] | undefined | null>;
|
|
27
|
+
startProfiling(): {
|
|
28
|
+
started?: boolean;
|
|
29
|
+
error?: string;
|
|
30
|
+
};
|
|
31
|
+
stopProfiling(): {
|
|
32
|
+
profile?: string;
|
|
33
|
+
error?: string;
|
|
34
|
+
};
|
|
27
35
|
}
|
|
28
36
|
export declare type NativeAppStartResponse = {
|
|
29
37
|
isColdStart: boolean;
|
|
@@ -41,14 +49,15 @@ export declare type NativeReleaseResponse = {
|
|
|
41
49
|
version: string;
|
|
42
50
|
};
|
|
43
51
|
/**
|
|
44
|
-
* This type describes serialized scope from sentry-cocoa
|
|
52
|
+
* This type describes serialized scope from sentry-cocoa and sentry-android
|
|
45
53
|
* https://github.com/getsentry/sentry-cocoa/blob/master/Sources/Sentry/SentryScope.m
|
|
54
|
+
* https://github.com/getsentry/sentry-java/blob/a461f7e125b65240004e6162b341f383ce2e1394/sentry-android-core/src/main/java/io/sentry/android/core/InternalSentrySdk.java#L32
|
|
46
55
|
*/
|
|
47
56
|
export declare type NativeDeviceContextsResponse = {
|
|
48
57
|
[key: string]: unknown;
|
|
49
58
|
tags?: Record<string, string>;
|
|
50
59
|
extra?: Record<string, unknown>;
|
|
51
|
-
|
|
60
|
+
contexts?: Record<string, Record<string, unknown>>;
|
|
52
61
|
user?: {
|
|
53
62
|
userId?: string;
|
|
54
63
|
email?: string;
|
|
@@ -6,4 +6,5 @@ export { EventOrigin } from './eventorigin';
|
|
|
6
6
|
export { SdkInfo } from './sdkinfo';
|
|
7
7
|
export { ReactNativeInfo } from './reactnativeinfo';
|
|
8
8
|
export { ModulesLoader } from './modulesloader';
|
|
9
|
+
export { HermesProfiling } from '../profiling/integration';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -37,6 +37,11 @@ export declare class ReactNativeErrorHandlers implements Integration {
|
|
|
37
37
|
* - The package resolution fix no longer works with 0.67 on iOS Hermes.
|
|
38
38
|
*/
|
|
39
39
|
private _polyfillPromise;
|
|
40
|
+
/**
|
|
41
|
+
* Single source of truth for the Promise implementation we want to use.
|
|
42
|
+
* This is important for verifying that the rejected promise tracing will work as expected.
|
|
43
|
+
*/
|
|
44
|
+
private _getPromisePolyfill;
|
|
40
45
|
/**
|
|
41
46
|
* Attach the unhandled rejection handler
|
|
42
47
|
*/
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { RewriteFrames } from '@sentry/integrations';
|
|
2
|
+
export declare const ANDROID_DEFAULT_BUNDLE_NAME = "app:///index.android.bundle";
|
|
3
|
+
export declare const IOS_DEFAULT_BUNDLE_NAME = "app:///main.jsbundle";
|
|
2
4
|
/**
|
|
3
5
|
* Creates React Native default rewrite frames integration
|
|
4
6
|
* which appends app:// to the beginning of the filename
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RawThreadCpuProfile } from './types';
|
|
2
|
+
export declare const PROFILE_QUEUE: {
|
|
3
|
+
get: (key: string) => RawThreadCpuProfile | undefined;
|
|
4
|
+
add: (key: string, value: RawThreadCpuProfile) => void;
|
|
5
|
+
delete: (key: string) => boolean;
|
|
6
|
+
clear: () => void;
|
|
7
|
+
size: () => number;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=cache.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ThreadCpuSample, ThreadId } from '@sentry/types';
|
|
2
|
+
import type * as Hermes from './hermes';
|
|
3
|
+
import type { RawThreadCpuProfile } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Converts a Hermes profile to a Sentry profile.
|
|
6
|
+
*
|
|
7
|
+
* Maps Hermes samples to Sentry samples.
|
|
8
|
+
* Maps Hermes stack frames to Sentry frames.
|
|
9
|
+
* Hermes stack frame is an object representing a function call in the stack
|
|
10
|
+
* with a link to its parent stack frame. Root of the represented stack tree
|
|
11
|
+
* is main function call in Hermes that is [root] stack frame.
|
|
12
|
+
*
|
|
13
|
+
* @returns Sentry profile or null if no samples are found.
|
|
14
|
+
*/
|
|
15
|
+
export declare function convertToSentryProfile(hermesProfile: Hermes.Profile): RawThreadCpuProfile | null;
|
|
16
|
+
/**
|
|
17
|
+
* Maps Hermes samples to Sentry samples.
|
|
18
|
+
* Calculates the elapsed time since the first sample based on the absolute timestamps of the Hermes samples.
|
|
19
|
+
* Hermes stack frame IDs represent the last (leaf, furthest from the main func) frame of the call stack.
|
|
20
|
+
* @returns the mapped Sentry samples, the set of Hermes stack frame IDs, and the set of JS thread IDs
|
|
21
|
+
*/
|
|
22
|
+
export declare function mapSamples(hermesSamples: Hermes.Sample[], maxElapsedSinceStartNs?: number): {
|
|
23
|
+
samples: ThreadCpuSample[];
|
|
24
|
+
hermesStacks: Set<Hermes.StackFrameId>;
|
|
25
|
+
jsThreads: Set<ThreadId>;
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=convertHermesProfile.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { RawThreadCpuProfile } from './types';
|
|
2
|
+
export declare type StackFrameId = number;
|
|
3
|
+
export declare type MicrosecondsSinceBoot = string;
|
|
4
|
+
export interface TraceEvent {
|
|
5
|
+
name: string;
|
|
6
|
+
ph: string;
|
|
7
|
+
cat: string;
|
|
8
|
+
pid: number;
|
|
9
|
+
ts: MicrosecondsSinceBoot;
|
|
10
|
+
tid: string;
|
|
11
|
+
args: {
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface Sample {
|
|
16
|
+
cpu: string;
|
|
17
|
+
name: string;
|
|
18
|
+
ts: MicrosecondsSinceBoot;
|
|
19
|
+
pid: number;
|
|
20
|
+
tid: string;
|
|
21
|
+
weight: string;
|
|
22
|
+
sf: StackFrameId;
|
|
23
|
+
}
|
|
24
|
+
export interface StackFrame {
|
|
25
|
+
line?: string;
|
|
26
|
+
column?: string;
|
|
27
|
+
funcLine?: string;
|
|
28
|
+
funcColumn?: string;
|
|
29
|
+
name: string;
|
|
30
|
+
category: string;
|
|
31
|
+
parent?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface Profile {
|
|
34
|
+
traceEvents: TraceEvent[];
|
|
35
|
+
samples: Sample[];
|
|
36
|
+
stackFrames: Record<string, StackFrame>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Hermes Profile Stack Frame Name contains function name and file path.
|
|
40
|
+
*
|
|
41
|
+
* `foo(/path/to/file.js:1:2)` -> `foo`
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseHermesStackFrameFunctionName(hermesName: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Starts Hermes Sampling Profiler and returns the timestamp when profiling started in nanoseconds.
|
|
46
|
+
*/
|
|
47
|
+
export declare function startProfiling(): number | null;
|
|
48
|
+
/**
|
|
49
|
+
* Stops Hermes Sampling Profiler and returns the profile.
|
|
50
|
+
*/
|
|
51
|
+
export declare function stopProfiling(): RawThreadCpuProfile | null;
|
|
52
|
+
//# sourceMappingURL=hermes.d.ts.map
|