@sentry/react-native 5.0.0-alpha.3 → 5.0.0-alpha.4
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 +54 -6
- package/RNSentry.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/io/sentry/react/RNSentryModule.java +9 -12
- package/dist/js/client.d.ts +5 -1
- package/dist/js/client.d.ts.map +1 -1
- package/dist/js/client.js +17 -0
- package/dist/js/client.js.map +1 -1
- package/dist/js/definitions.d.ts +2 -4
- package/dist/js/definitions.d.ts.map +1 -1
- package/dist/js/definitions.js.map +1 -1
- package/dist/js/index.d.ts +2 -2
- package/dist/js/index.d.ts.map +1 -1
- package/dist/js/index.js +1 -1
- package/dist/js/index.js.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js +3 -1
- package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
- package/dist/js/integrations/sdkinfo.d.ts +4 -1
- package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
- package/dist/js/integrations/sdkinfo.js +14 -7
- package/dist/js/integrations/sdkinfo.js.map +1 -1
- package/dist/js/misc.d.ts +9 -0
- package/dist/js/misc.d.ts.map +1 -0
- package/dist/js/misc.js +17 -0
- package/dist/js/misc.js.map +1 -0
- package/dist/js/options.d.ts +27 -6
- package/dist/js/options.d.ts.map +1 -1
- package/dist/js/options.js.map +1 -1
- package/dist/js/scope.d.ts +9 -1
- package/dist/js/scope.d.ts.map +1 -1
- package/dist/js/scope.js +12 -0
- package/dist/js/scope.js.map +1 -1
- package/dist/js/sdk.d.ts +5 -0
- package/dist/js/sdk.d.ts.map +1 -1
- package/dist/js/sdk.js +30 -18
- package/dist/js/sdk.js.map +1 -1
- package/dist/js/tracing/reactnativetracing.d.ts +14 -5
- package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
- package/dist/js/tracing/reactnativetracing.js +10 -6
- package/dist/js/tracing/reactnativetracing.js.map +1 -1
- package/dist/js/tracing/utils.d.ts +1 -2
- package/dist/js/tracing/utils.d.ts.map +1 -1
- package/dist/js/tracing/utils.js +2 -10
- package/dist/js/tracing/utils.js.map +1 -1
- package/dist/js/transports/TextEncoder.d.ts +3 -0
- package/dist/js/transports/TextEncoder.d.ts.map +1 -0
- package/dist/js/transports/TextEncoder.js +12 -0
- package/dist/js/transports/TextEncoder.js.map +1 -0
- package/dist/js/utils/envelope.d.ts +10 -0
- package/dist/js/utils/envelope.d.ts.map +1 -0
- package/dist/js/utils/envelope.js +20 -0
- package/dist/js/utils/envelope.js.map +1 -0
- package/dist/js/vendor/buffer/index.d.ts +2 -0
- package/dist/js/vendor/buffer/index.d.ts.map +1 -0
- package/dist/js/vendor/buffer/index.js +2 -0
- package/dist/js/vendor/buffer/index.js.map +1 -0
- package/dist/js/vendor/buffer/utf8ToBytes.d.ts +10 -0
- package/dist/js/vendor/buffer/utf8ToBytes.d.ts.map +1 -0
- package/dist/js/vendor/buffer/utf8ToBytes.js +82 -0
- package/dist/js/vendor/buffer/utf8ToBytes.js.map +1 -0
- package/dist/js/vendor/index.d.ts +2 -0
- package/dist/js/vendor/index.d.ts.map +1 -0
- package/dist/js/vendor/index.js +2 -0
- package/dist/js/vendor/index.js.map +1 -0
- package/dist/js/version.d.ts +2 -1
- package/dist/js/version.d.ts.map +1 -1
- package/dist/js/version.js +2 -1
- package/dist/js/version.js.map +1 -1
- package/dist/js/wrapper.d.ts +3 -2
- package/dist/js/wrapper.d.ts.map +1 -1
- package/dist/js/wrapper.js +62 -57
- package/dist/js/wrapper.js.map +1 -1
- package/ios/RNSentry.m +22 -35
- package/package.json +11 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.d.ts","sourceRoot":"","sources":["../../../src/js/utils/envelope.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,aAAa,EACb,aAAa,EAEb,WAAW,EACX,YAAY,EAEb,MAAM,eAAe,CAAC;AAGvB;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,YAAY,EACtB,EACE,QAAQ,EACR,MAAM,EACN,GAAG,GACJ,EAAE;IACD,QAAQ,EAAE,WAAW,GAAG,SAAS,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,GAAG,EAAE,aAAa,GAAG,SAAS,CAAC;CAChC,GACA,aAAa,CAcf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createEnvelope, dsnToString } from '@sentry/utils';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an envelope from a user feedback.
|
|
4
|
+
*/
|
|
5
|
+
export function createUserFeedbackEnvelope(feedback, { metadata, tunnel, dsn, }) {
|
|
6
|
+
// TODO: Use EventEnvelope[0] when JS sdk fix is released
|
|
7
|
+
const headers = Object.assign(Object.assign({ event_id: feedback.event_id, sent_at: new Date().toISOString() }, (metadata && metadata.sdk && { sdk: {
|
|
8
|
+
name: metadata.sdk.name,
|
|
9
|
+
version: metadata.sdk.version,
|
|
10
|
+
} })), (!!tunnel && !!dsn && { dsn: dsnToString(dsn) }));
|
|
11
|
+
const item = createUserFeedbackEnvelopeItem(feedback);
|
|
12
|
+
return createEnvelope(headers, [item]);
|
|
13
|
+
}
|
|
14
|
+
function createUserFeedbackEnvelopeItem(feedback) {
|
|
15
|
+
const feedbackHeaders = {
|
|
16
|
+
type: 'user_report',
|
|
17
|
+
};
|
|
18
|
+
return [feedbackHeaders, feedback];
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=envelope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelope.js","sourceRoot":"","sources":["../../../src/js/utils/envelope.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5D;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAsB,EACtB,EACE,QAAQ,EACR,MAAM,EACN,GAAG,GAKJ;IAED,yDAAyD;IACzD,MAAM,OAAO,iCACX,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAC3B,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAC9B,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE;YACrC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI;YACvB,OAAO,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO;SAC9B,EAAC,CAAC,GACA,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CACpD,CAAC;IACF,MAAM,IAAI,GAAG,8BAA8B,CAAC,QAAQ,CAAC,CAAC;IAEtD,OAAO,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,8BAA8B,CACrC,QAAsB;IAEtB,MAAM,eAAe,GAAwB;QAC3C,IAAI,EAAE,aAAa;KACpB,CAAC;IACF,OAAO,CAAC,eAAe,EAAE,QAAQ,CAAC,CAAC;AACrC,CAAC","sourcesContent":["import {\n BaseEnvelopeHeaders,\n DsnComponents,\n EventEnvelope,\n EventEnvelopeHeaders,\n SdkMetadata,\n UserFeedback,\n UserFeedbackItem,\n} from '@sentry/types';\nimport { createEnvelope, dsnToString } from '@sentry/utils';\n\n/**\n * Creates an envelope from a user feedback.\n */\nexport function createUserFeedbackEnvelope(\n feedback: UserFeedback,\n {\n metadata,\n tunnel,\n dsn,\n }: {\n metadata: SdkMetadata | undefined,\n tunnel: string | undefined,\n dsn: DsnComponents | undefined,\n },\n): EventEnvelope {\n // TODO: Use EventEnvelope[0] when JS sdk fix is released\n const headers: EventEnvelopeHeaders & BaseEnvelopeHeaders = {\n event_id: feedback.event_id,\n sent_at: new Date().toISOString(),\n ...(metadata && metadata.sdk && { sdk: {\n name: metadata.sdk.name,\n version: metadata.sdk.version,\n }}),\n ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }),\n };\n const item = createUserFeedbackEnvelopeItem(feedback);\n\n return createEnvelope(headers, [item]);\n}\n\nfunction createUserFeedbackEnvelopeItem(\n feedback: UserFeedback\n): UserFeedbackItem {\n const feedbackHeaders: UserFeedbackItem[0] = {\n type: 'user_report',\n };\n return [feedbackHeaders, feedback];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/js/vendor/buffer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/js/vendor/buffer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,GACZ,MAAM,eAAe,CAAC","sourcesContent":["export {\n utf8ToBytes,\n} from './utf8ToBytes';\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert a string to a byte array
|
|
3
|
+
*
|
|
4
|
+
* This is a utf8ToBytes function from the buffer module (with added types)
|
|
5
|
+
* https://github.com/feross/buffer/blob/795bbb5bda1b39f1370ebd784bea6107b087e3a7/index.js#L1956
|
|
6
|
+
*
|
|
7
|
+
* License: MIT (https://github.com/feross/buffer)
|
|
8
|
+
*/
|
|
9
|
+
export declare function utf8ToBytes(string: string, units?: number): number[];
|
|
10
|
+
//# sourceMappingURL=utf8ToBytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8ToBytes.d.ts","sourceRoot":"","sources":["../../../../src/js/vendor/buffer/utf8ToBytes.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CA8EpE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* Convert a string to a byte array
|
|
4
|
+
*
|
|
5
|
+
* This is a utf8ToBytes function from the buffer module (with added types)
|
|
6
|
+
* https://github.com/feross/buffer/blob/795bbb5bda1b39f1370ebd784bea6107b087e3a7/index.js#L1956
|
|
7
|
+
*
|
|
8
|
+
* License: MIT (https://github.com/feross/buffer)
|
|
9
|
+
*/
|
|
10
|
+
export function utf8ToBytes(string, units) {
|
|
11
|
+
units = units || Infinity;
|
|
12
|
+
let codePoint;
|
|
13
|
+
const length = string.length;
|
|
14
|
+
let leadSurrogate = null;
|
|
15
|
+
const bytes = [];
|
|
16
|
+
for (let i = 0; i < length; ++i) {
|
|
17
|
+
codePoint = string.charCodeAt(i);
|
|
18
|
+
// is surrogate component
|
|
19
|
+
if (codePoint > 0xD7FF && codePoint < 0xE000) {
|
|
20
|
+
// last char was a lead
|
|
21
|
+
if (!leadSurrogate) {
|
|
22
|
+
// no lead yet
|
|
23
|
+
if (codePoint > 0xDBFF) {
|
|
24
|
+
// unexpected trail
|
|
25
|
+
if ((units -= 3) > -1)
|
|
26
|
+
bytes.push(0xEF, 0xBF, 0xBD);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
else if (i + 1 === length) {
|
|
30
|
+
// unpaired lead
|
|
31
|
+
if ((units -= 3) > -1)
|
|
32
|
+
bytes.push(0xEF, 0xBF, 0xBD);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
// valid lead
|
|
36
|
+
leadSurrogate = codePoint;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
// 2 leads in a row
|
|
40
|
+
if (codePoint < 0xDC00) {
|
|
41
|
+
if ((units -= 3) > -1)
|
|
42
|
+
bytes.push(0xEF, 0xBF, 0xBD);
|
|
43
|
+
leadSurrogate = codePoint;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
// valid surrogate pair
|
|
47
|
+
codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000;
|
|
48
|
+
}
|
|
49
|
+
else if (leadSurrogate) {
|
|
50
|
+
// valid bmp char, but last char was a lead
|
|
51
|
+
if ((units -= 3) > -1)
|
|
52
|
+
bytes.push(0xEF, 0xBF, 0xBD);
|
|
53
|
+
}
|
|
54
|
+
leadSurrogate = null;
|
|
55
|
+
// encode utf8
|
|
56
|
+
if (codePoint < 0x80) {
|
|
57
|
+
if ((units -= 1) < 0)
|
|
58
|
+
break;
|
|
59
|
+
bytes.push(codePoint);
|
|
60
|
+
}
|
|
61
|
+
else if (codePoint < 0x800) {
|
|
62
|
+
if ((units -= 2) < 0)
|
|
63
|
+
break;
|
|
64
|
+
bytes.push(codePoint >> 0x6 | 0xC0, codePoint & 0x3F | 0x80);
|
|
65
|
+
}
|
|
66
|
+
else if (codePoint < 0x10000) {
|
|
67
|
+
if ((units -= 3) < 0)
|
|
68
|
+
break;
|
|
69
|
+
bytes.push(codePoint >> 0xC | 0xE0, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
|
|
70
|
+
}
|
|
71
|
+
else if (codePoint < 0x110000) {
|
|
72
|
+
if ((units -= 4) < 0)
|
|
73
|
+
break;
|
|
74
|
+
bytes.push(codePoint >> 0x12 | 0xF0, codePoint >> 0xC & 0x3F | 0x80, codePoint >> 0x6 & 0x3F | 0x80, codePoint & 0x3F | 0x80);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new Error('Invalid code point');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return bytes;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=utf8ToBytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utf8ToBytes.js","sourceRoot":"","sources":["../../../../src/js/vendor/buffer/utf8ToBytes.ts"],"names":[],"mappings":"AAAA,oBAAoB;A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C9B,SAAS,IAAI,GAAG,GAAG,IAAI,GAAG,IAAI,EAC9B,SAAS,GAAG,IAAI,GAAG,IAAI,CACxB,CAAA;SACF;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;SACtC;KACF;IAED,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["/* eslint-disable */\n\n/**\n * Convert a string to a byte array\n *\n * This is a utf8ToBytes function from the buffer module (with added types)\n * https://github.com/feross/buffer/blob/795bbb5bda1b39f1370ebd784bea6107b087e3a7/index.js#L1956\n *\n * License: MIT (https://github.com/feross/buffer)\n */\nexport function utf8ToBytes(string: string, units?: number): number[] {\n units = units || Infinity\n let codePoint\n const length = string.length\n let leadSurrogate = null\n const bytes: number[] = []\n\n for (let i = 0; i < length; ++i) {\n codePoint = string.charCodeAt(i)\n\n // is surrogate component\n if (codePoint > 0xD7FF && codePoint < 0xE000) {\n // last char was a lead\n if (!leadSurrogate) {\n // no lead yet\n if (codePoint > 0xDBFF) {\n // unexpected trail\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n } else if (i + 1 === length) {\n // unpaired lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n continue\n }\n\n // valid lead\n leadSurrogate = codePoint\n\n continue\n }\n\n // 2 leads in a row\n if (codePoint < 0xDC00) {\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n leadSurrogate = codePoint\n continue\n }\n\n // valid surrogate pair\n codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000\n } else if (leadSurrogate) {\n // valid bmp char, but last char was a lead\n if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)\n }\n\n leadSurrogate = null\n\n // encode utf8\n if (codePoint < 0x80) {\n if ((units -= 1) < 0) break\n bytes.push(codePoint)\n } else if (codePoint < 0x800) {\n if ((units -= 2) < 0) break\n bytes.push(\n codePoint >> 0x6 | 0xC0,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x10000) {\n if ((units -= 3) < 0) break\n bytes.push(\n codePoint >> 0xC | 0xE0,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else if (codePoint < 0x110000) {\n if ((units -= 4) < 0) break\n bytes.push(\n codePoint >> 0x12 | 0xF0,\n codePoint >> 0xC & 0x3F | 0x80,\n codePoint >> 0x6 & 0x3F | 0x80,\n codePoint & 0x3F | 0x80\n )\n } else {\n throw new Error('Invalid code point')\n }\n }\n\n return bytes\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/js/vendor/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,GACZ,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/js/vendor/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,GACZ,MAAM,UAAU,CAAC","sourcesContent":["\nexport {\n utf8ToBytes,\n} from './buffer';\n"]}
|
package/dist/js/version.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const SDK_PACKAGE_NAME = "npm:@sentry/react-native";
|
|
1
2
|
export declare const SDK_NAME = "sentry.javascript.react-native";
|
|
2
|
-
export declare const SDK_VERSION = "5.0.0-alpha.
|
|
3
|
+
export declare const SDK_VERSION = "5.0.0-alpha.4";
|
|
3
4
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/js/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,mCAAmC,CAAC;AACzD,eAAO,MAAM,WAAW,kBAAkB,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,kBAAkB,CAAC"}
|
package/dist/js/version.js
CHANGED
package/dist/js/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/js/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,gCAAgC,CAAC;AACzD,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC","sourcesContent":["export const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.0.0-alpha.
|
|
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,eAAe,CAAC","sourcesContent":["export const SDK_PACKAGE_NAME = 'npm:@sentry/react-native';\nexport const SDK_NAME = 'sentry.javascript.react-native';\nexport const SDK_VERSION = '5.0.0-alpha.4';\n"]}
|
package/dist/js/wrapper.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Breadcrumb, Envelope, EnvelopeItem, Event, Package, SeverityLevel, User } from '@sentry/types';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import { NativeAppStartResponse, NativeDeviceContextsResponse, NativeFramesResponse, NativeReleaseResponse, SentryNativeBridgeModule } from './definitions';
|
|
4
4
|
import { ReactNativeOptions } from './options';
|
|
@@ -8,7 +8,7 @@ interface SentryNativeWrapper {
|
|
|
8
8
|
platform: typeof Platform.OS;
|
|
9
9
|
_NativeClientError: Error;
|
|
10
10
|
_DisabledNativeError: Error;
|
|
11
|
-
|
|
11
|
+
_processItem(envelopeItem: EnvelopeItem): EnvelopeItem;
|
|
12
12
|
_processLevels(event: Event): Event;
|
|
13
13
|
_processLevel(level: SeverityLevel): SeverityLevel;
|
|
14
14
|
_serializeObject(data: {
|
|
@@ -17,6 +17,7 @@ interface SentryNativeWrapper {
|
|
|
17
17
|
[key: string]: string;
|
|
18
18
|
};
|
|
19
19
|
_isModuleLoaded(module: SentryNativeBridgeModule | undefined): module is SentryNativeBridgeModule;
|
|
20
|
+
_getBreadcrumbs(event: Event): Breadcrumb[] | undefined;
|
|
20
21
|
isNativeTransportAvailable(): boolean;
|
|
21
22
|
initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;
|
|
22
23
|
closeNativeSdk(): PromiseLike<void>;
|
package/dist/js/wrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/js/wrapper.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,KAAK,EACL,OAAO,EACP,aAAa,EACb,IAAI,EACL,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAC;AAEvD,OAAO,EACL,sBAAsB,EACtB,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,wBAAwB,EACzB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAK/C,UAAU,mBAAmB;IAC3B,YAAY,EAAE,OAAO,CAAC;IACtB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,QAAQ,CAAC,EAAE,CAAC;IAE7B,kBAAkB,EAAE,KAAK,CAAC;IAC1B,oBAAoB,EAAE,KAAK,CAAC;IAE5B,YAA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AAgB,IAAI,IAAI,CAAC;IACzB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5C,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,WAAW,IAAI,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,mBA6dpB,CAAC"}
|
package/dist/js/wrapper.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { __awaiter, __rest } from "tslib";
|
|
2
2
|
import { logger, SentryError } from '@sentry/utils';
|
|
3
3
|
import { NativeModules, Platform } from 'react-native';
|
|
4
|
+
import { isHardCrash } from './misc';
|
|
5
|
+
import { utf8ToBytes } from './vendor';
|
|
4
6
|
const RNSentry = NativeModules.RNSentry;
|
|
5
7
|
/**
|
|
6
8
|
* Our internal interface for calling native functions
|
|
@@ -11,7 +13,6 @@ export const NATIVE = {
|
|
|
11
13
|
* @param envelope Envelope
|
|
12
14
|
*/
|
|
13
15
|
sendEnvelope(envelope) {
|
|
14
|
-
var _a, _b, _c, _d;
|
|
15
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
17
|
if (!this.enableNative) {
|
|
17
18
|
logger.warn('Event was skipped as native SDK is not enabled.');
|
|
@@ -20,62 +21,37 @@ export const NATIVE = {
|
|
|
20
21
|
if (!this._isModuleLoaded(RNSentry)) {
|
|
21
22
|
throw this._NativeClientError;
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs
|
|
35
|
-
from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs
|
|
36
|
-
sent through the scope sync feature. This causes duplicate breadcrumbs.
|
|
37
|
-
We then remove the breadcrumbs in all cases but if it is handled == false,
|
|
38
|
-
this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
|
|
39
|
-
the envelope.
|
|
40
|
-
*/
|
|
41
|
-
if (((_d = (_c = (_b = (_a = event.exception) === null || _a === void 0 ? void 0 : _a.values) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.mechanism) === null || _d === void 0 ? void 0 : _d.handled) != false && event.breadcrumbs) {
|
|
42
|
-
event.breadcrumbs = [];
|
|
43
|
-
}
|
|
44
|
-
envelopeItems[1] = event;
|
|
45
|
-
}
|
|
46
|
-
// Content type is not inside BaseEnvelopeItemHeaders.
|
|
47
|
-
envelopeItems[0].content_type = 'application/json';
|
|
48
|
-
const itemPayload = JSON.stringify(envelopeItems[1]);
|
|
49
|
-
let length = itemPayload.length;
|
|
50
|
-
try {
|
|
51
|
-
length = yield RNSentry.getStringBytesLength(itemPayload);
|
|
52
|
-
}
|
|
53
|
-
catch (_e) {
|
|
54
|
-
// The native call failed, we do nothing, we have payload.length as a fallback
|
|
55
|
-
}
|
|
56
|
-
envelopeItems[0].length = length;
|
|
57
|
-
const itemHeader = JSON.stringify(envelopeItems[0]);
|
|
58
|
-
envelopeItemsBuilder += `\n${itemHeader}\n${itemPayload}`;
|
|
24
|
+
const [EOL] = utf8ToBytes('\n');
|
|
25
|
+
const [envelopeHeader, envelopeItems] = envelope;
|
|
26
|
+
const headerString = JSON.stringify(envelopeHeader);
|
|
27
|
+
const envelopeBytes = utf8ToBytes(headerString);
|
|
28
|
+
envelopeBytes.push(EOL);
|
|
29
|
+
let hardCrashed = false;
|
|
30
|
+
for (const rawItem of envelopeItems) {
|
|
31
|
+
const [itemHeader, itemPayload] = this._processItem(rawItem);
|
|
32
|
+
let bytesPayload = [];
|
|
33
|
+
if (typeof itemPayload === 'string') {
|
|
34
|
+
bytesPayload = utf8ToBytes(itemPayload);
|
|
59
35
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
envelopeItems[1] = event;
|
|
36
|
+
else if (itemPayload instanceof Uint8Array) {
|
|
37
|
+
bytesPayload = [...itemPayload];
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
bytesPayload = utf8ToBytes(JSON.stringify(itemPayload));
|
|
41
|
+
if (!hardCrashed) {
|
|
42
|
+
hardCrashed = isHardCrash(itemPayload);
|
|
68
43
|
}
|
|
69
|
-
const itemPayload = JSON.parse(JSON.stringify(envelopeItems[1]));
|
|
70
|
-
// The envelope item is created (and its length determined) on the iOS side of the native bridge.
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
72
|
-
yield RNSentry.captureEnvelope({
|
|
73
|
-
header,
|
|
74
|
-
payload: itemPayload,
|
|
75
|
-
});
|
|
76
44
|
}
|
|
45
|
+
// Content type is not inside BaseEnvelopeItemHeaders.
|
|
46
|
+
itemHeader.content_type = 'application/json';
|
|
47
|
+
itemHeader.length = bytesPayload.length;
|
|
48
|
+
const serializedItemHeader = JSON.stringify(itemHeader);
|
|
49
|
+
envelopeBytes.push(...utf8ToBytes(serializedItemHeader));
|
|
50
|
+
envelopeBytes.push(EOL);
|
|
51
|
+
envelopeBytes.push(...bytesPayload);
|
|
52
|
+
envelopeBytes.push(EOL);
|
|
77
53
|
}
|
|
78
|
-
;
|
|
54
|
+
yield RNSentry.captureEnvelope(envelopeBytes, { store: hardCrashed });
|
|
79
55
|
});
|
|
80
56
|
},
|
|
81
57
|
/**
|
|
@@ -335,11 +311,20 @@ export const NATIVE = {
|
|
|
335
311
|
* @param data An envelope item containing the event.
|
|
336
312
|
* @returns The event from envelopeItem or undefined.
|
|
337
313
|
*/
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
314
|
+
_processItem(item) {
|
|
315
|
+
const [itemHeader, itemPayload] = item;
|
|
316
|
+
if (itemHeader.type == 'event' || itemHeader.type == 'transaction') {
|
|
317
|
+
const event = this._processLevels(itemPayload);
|
|
318
|
+
if (NATIVE.platform === 'android') {
|
|
319
|
+
if ('message' in event) {
|
|
320
|
+
// @ts-ignore Android still uses the old message object, without this the serialization of events will break.
|
|
321
|
+
event.message = { message: event.message };
|
|
322
|
+
}
|
|
323
|
+
event.breadcrumbs = this._getBreadcrumbs(event);
|
|
324
|
+
}
|
|
325
|
+
return [itemHeader, event];
|
|
341
326
|
}
|
|
342
|
-
return
|
|
327
|
+
return item;
|
|
343
328
|
},
|
|
344
329
|
/**
|
|
345
330
|
* Serializes all values of root-level keys into strings.
|
|
@@ -389,6 +374,26 @@ export const NATIVE = {
|
|
|
389
374
|
},
|
|
390
375
|
_DisabledNativeError: new SentryError('Native is disabled'),
|
|
391
376
|
_NativeClientError: new SentryError("Native Client is not available, can't start on native."),
|
|
377
|
+
/**
|
|
378
|
+
* Get breadcrumbs (removes breadcrumbs from handled exceptions on Android)
|
|
379
|
+
*
|
|
380
|
+
* We do this to avoid duplicate breadcrumbs on Android as sentry-android applies the breadcrumbs
|
|
381
|
+
* from the native scope onto every envelope sent through it. This scope will contain the breadcrumbs
|
|
382
|
+
* sent through the scope sync feature. This causes duplicate breadcrumbs.
|
|
383
|
+
* We then remove the breadcrumbs in all cases but if it is handled == false,
|
|
384
|
+
* this is a signal that the app would crash and android would lose the breadcrumbs by the time the app is restarted to read
|
|
385
|
+
* the envelope.
|
|
386
|
+
*/
|
|
387
|
+
_getBreadcrumbs(event) {
|
|
388
|
+
let breadcrumbs = event.breadcrumbs;
|
|
389
|
+
const hardCrashed = isHardCrash(event);
|
|
390
|
+
if (NATIVE.platform === 'android'
|
|
391
|
+
&& event.breadcrumbs
|
|
392
|
+
&& !hardCrashed) {
|
|
393
|
+
breadcrumbs = [];
|
|
394
|
+
}
|
|
395
|
+
return breadcrumbs;
|
|
396
|
+
},
|
|
392
397
|
enableNative: true,
|
|
393
398
|
nativeIsReady: false,
|
|
394
399
|
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":";AAeA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAYvD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAgD,CAAC;AA2ChF;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAwB;IACzC;;;OAGG;IACG,YAAY,CAAC,QAAkB;;;YACnC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;gBACtB,MAAM,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;gBAC/D,OAAO;aACR;YAED,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE;gBACnC,MAAM,IAAI,CAAC,kBAAkB,CAAC;aAC/B;YAED,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAE3B,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,EAAE;gBACjC,UAAU;gBAEV,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAE5C,IAAI,oBAAoB,GAAG,GAAG,YAAY,EAAE,CAAC;gBAE7C,KAAK,MAAM,aAAa,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE;oBAEvC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;oBAC5C,IAAI,KAAK,IAAI,SAAS,EAAE;wBAEtB,6GAA6G;wBAC7G,KAAK,CAAC,OAAO,GAAG,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;wBAE3C;;;;;;;0BAOE;wBACF,IAAI,yBAAA,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AS,IACb,IACH,CAAC;QAEF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;OAIG;IAEH,aAAa,CAAC,KAAoB;QAChC,IAAI,KAAK,IAAI,KAAsB,EAAE;YACnC,OAAO,OAAwB,CAAC;SACjC;aACI,IAAI,KAAK,IAAI,UAA2B,EAAE;YAC7C,OAAO,OAAwB,CAAC;SACjC;QAGD,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,eAAe,CACb,MAA4C;QAE5C,OAAO,CAAC,CAAC,MAAM,CAAC;IAClB,CAAC;IAED,oBAAoB,EAAE,IAAI,WAAW,CAAC,oBAAoB,CAAC;IAE3D,kBAAkB,EAAE,IAAI,WAAW,CACjC,wDAAwD,CACzD;IAED,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,KAAK;IACpB,QAAQ,EAAE,QAAQ,CAAC,EAAE;CACtB,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport {\n AttachmentItem,\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n ClientReportItem,\n Envelope,\n Event,\n EventItem,\n Package,\n SessionItem,\n SeverityLevel,\n User,\n UserFeedbackItem,\n} from '@sentry/types';\nimport { logger, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform } from 'react-native';\n\nimport {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n SentryNativeBridgeModule,\n} from './definitions';\nimport { ReactNativeOptions } from './options';\n\n\nconst RNSentry = NativeModules.RNSentry as SentryNativeBridgeModule | undefined;\n\ninterface SentryNativeWrapper {\n enableNative: boolean;\n nativeIsReady: boolean;\n platform: typeof Platform.OS;\n\n _NativeClientError: Error;\n _DisabledNativeError: Error;\n\n _getEvent(envelopeItem: EventItem | AttachmentItem | UserFeedbackItem | SessionItem | ClientReportItem): Event | undefined;\n _processLevels(event: Event): Event;\n _processLevel(level: SeverityLevel): SeverityLevel;\n _serializeObject(data: { [key: string]: unknown }): { [key: string]: string };\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule;\n\n isNativeTransportAvailable(): boolean;\n\n initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\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\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\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\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 header = envelope[0];\n\n if (NATIVE.platform === 'android') {\n // Android\n\n const headerString = JSON.stringify(header);\n\n let envelopeItemsBuilder = `${headerString}`;\n\n for (const envelopeItems of envelope[1]) {\n\n const event = this._getEvent(envelopeItems);\n if (event != undefined) {\n\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 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 if (event.exception?.values?.[0]?.mechanism?.handled != false && event.breadcrumbs) {\n event.breadcrumbs = [];\n }\n envelopeItems[1] = event;\n }\n\n // Content type is not inside BaseEnvelopeItemHeaders.\n (envelopeItems[0] as BaseEnvelopeItemHeaders).content_type = 'application/json';\n\n const itemPayload = JSON.stringify(envelopeItems[1]);\n\n let length = itemPayload.length;\n try {\n length = await RNSentry.getStringBytesLength(itemPayload);\n } catch {\n // The native call failed, we do nothing, we have payload.length as a fallback\n }\n\n (envelopeItems[0] as BaseEnvelopeItemHeaders).length = length;\n const itemHeader = JSON.stringify(envelopeItems[0]);\n\n envelopeItemsBuilder += `\\n${itemHeader}\\n${itemPayload}`;\n }\n\n await RNSentry.captureEnvelope(envelopeItemsBuilder);\n } else {\n // iOS/Mac\n\n for (const envelopeItems of envelope[1]) {\n const event = this._getEvent(envelopeItems);\n if (event != undefined) {\n envelopeItems[1] = event;\n }\n\n const itemPayload = JSON.parse(JSON.stringify(envelopeItems[1]));\n\n // The envelope item is created (and its length determined) on the iOS side of the native bridge.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\n await RNSentry.captureEnvelope({\n header,\n payload: itemPayload,\n });\n }\n };\n\n },\n\n /**\n * Starts native with the provided options.\n * @param options ReactNativeOptions\n */\n async initNativeSdk(originalOptions: ReactNativeOptions): Promise<boolean> {\n const options = {\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 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 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 {\n beforeSend,\n beforeBreadcrumb,\n integrations,\n ...filteredOptions\n } = 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\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 throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\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 serialze all non-default user keys.\n let defaultUserKeys = null;\n let otherUserKeys = null;\n if (user) {\n const { id, ip_address, email, username, ...otherKeys } = user;\n defaultUserKeys = this._serializeObject({\n email,\n id,\n ip_address,\n username,\n });\n otherUserKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(defaultUserKeys, otherUserKeys);\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 =\n 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 =\n 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\n ? this._processLevel(breadcrumb.level)\n : undefined,\n data: breadcrumb.data\n ? this._serializeObject(breadcrumb.data)\n : 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(\n key,\n context !== null ? this._serializeObject(context) : null\n );\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 isNativeTransportAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\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 _getEvent(envelopeItem: EventItem | AttachmentItem | UserFeedbackItem | SessionItem | ClientReportItem): Event | undefined {\n if (envelopeItem[0].type == 'event' || envelopeItem[0].type == 'transaction') {\n return this._processLevels(envelopeItem[1] as Event);\n }\n return undefined;\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: {\n [key: string]: unknown;\n }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach((dataKey) => {\n const value = data[dataKey];\n serialized[dataKey] =\n 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\n ? this._processLevel(breadcrumb.level)\n : 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 else if (level == 'critical' as SeverityLevel) {\n return 'fatal' as SeverityLevel;\n }\n\n\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\n \"Native Client is not available, can't start on native.\"\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,WAAW,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AASvD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAgD,CAAC;AA4ChF;;GAEG;AACH,MAAM,CAAC,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W,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS;eAC5B,KAAK,CAAC,WAAW;eACjB,CAAC,WAAW,EAAE;YACjB,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 {\n BaseEnvelopeItemHeaders,\n Breadcrumb,\n Envelope,\n EnvelopeItem,\n Event,\n Package,\n SeverityLevel,\n User,\n} from '@sentry/types';\nimport { logger, SentryError } from '@sentry/utils';\nimport { NativeModules, Platform } from 'react-native';\n\nimport {\n NativeAppStartResponse,\n NativeDeviceContextsResponse,\n NativeFramesResponse,\n NativeReleaseResponse,\n SentryNativeBridgeModule,\n} from './definitions';\nimport { isHardCrash } from './misc';\nimport { ReactNativeOptions } from './options';\nimport { utf8ToBytes } from './vendor';\n\nconst RNSentry = NativeModules.RNSentry as SentryNativeBridgeModule | undefined;\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(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule;\n _getBreadcrumbs(event: Event): Breadcrumb[] | undefined;\n\n isNativeTransportAvailable(): boolean;\n\n initNativeSdk(options: ReactNativeOptions): PromiseLike<boolean>;\n closeNativeSdk(): PromiseLike<void>;\n\n sendEnvelope(envelope: Envelope): Promise<void>;\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\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\n/**\n * Our internal interface for calling native functions\n */\nexport const NATIVE: SentryNativeWrapper = {\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 const 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 bytesPayload: number[] = [];\n if (typeof itemPayload === 'string') {\n bytesPayload = utf8ToBytes(itemPayload);\n } else if (itemPayload instanceof Uint8Array) {\n bytesPayload = [...itemPayload];\n } else {\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 = 'application/json';\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.push(...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 ReactNativeOptions\n */\n async initNativeSdk(originalOptions: ReactNativeOptions): Promise<boolean> {\n const options = {\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 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 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 {\n beforeSend,\n beforeBreadcrumb,\n integrations,\n ...filteredOptions\n } = 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\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 throw this._DisabledNativeError;\n }\n if (!this._isModuleLoaded(RNSentry)) {\n throw this._NativeClientError;\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 serialze all non-default user keys.\n let defaultUserKeys = null;\n let otherUserKeys = null;\n if (user) {\n const { id, ip_address, email, username, ...otherKeys } = user;\n defaultUserKeys = this._serializeObject({\n email,\n id,\n ip_address,\n username,\n });\n otherUserKeys = this._serializeObject(otherKeys);\n }\n\n RNSentry.setUser(defaultUserKeys, otherUserKeys);\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 =\n 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 =\n 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\n ? this._processLevel(breadcrumb.level)\n : undefined,\n data: breadcrumb.data\n ? this._serializeObject(breadcrumb.data)\n : 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(\n key,\n context !== null ? this._serializeObject(context) : null\n );\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 isNativeTransportAvailable(): boolean {\n return this.enableNative && this._isModuleLoaded(RNSentry);\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: {\n [key: string]: unknown;\n }): { [key: string]: string } {\n const serialized: { [key: string]: string } = {};\n\n Object.keys(data).forEach((dataKey) => {\n const value = data[dataKey];\n serialized[dataKey] =\n 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\n ? this._processLevel(breadcrumb.level)\n : 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 else if (level == 'critical' as SeverityLevel) {\n return 'fatal' as SeverityLevel;\n }\n\n\n return level;\n },\n\n /**\n * Checks whether the RNSentry module is loaded.\n */\n _isModuleLoaded(\n module: SentryNativeBridgeModule | undefined\n ): module is SentryNativeBridgeModule {\n return !!module;\n },\n\n _DisabledNativeError: new SentryError('Native is disabled'),\n\n _NativeClientError: new SentryError(\n \"Native Client is not available, can't start on native.\"\n ),\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'\n && event.breadcrumbs\n && !hardCrashed) {\n breadcrumbs = [];\n }\n\n return breadcrumbs;\n },\n\n enableNative: true,\n nativeIsReady: false,\n platform: Platform.OS,\n};\n"]}
|
package/ios/RNSentry.m
CHANGED
|
@@ -270,47 +270,34 @@ RCT_EXPORT_METHOD(fetchNativeRelease:(RCTPromiseResolveBlock)resolve
|
|
|
270
270
|
});
|
|
271
271
|
}
|
|
272
272
|
|
|
273
|
-
RCT_EXPORT_METHOD(captureEnvelope:(
|
|
273
|
+
RCT_EXPORT_METHOD(captureEnvelope:(NSArray * _Nonnull)bytes
|
|
274
|
+
options: (NSDictionary * _Nonnull)options
|
|
274
275
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
275
276
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
276
277
|
{
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
NSError *error;
|
|
284
|
-
NSData *envelopeItemData = [NSJSONSerialization dataWithJSONObject:envelopeDict[@"payload"] options:0 error:&error];
|
|
285
|
-
if (nil != error) {
|
|
286
|
-
reject(@"SentryReactNative", @"Cannot serialize event", error);
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
NSString *itemType = envelopeDict[@"payload"][@"type"];
|
|
290
|
-
if (itemType == nil) {
|
|
291
|
-
// Default to event type.
|
|
292
|
-
itemType = @"event";
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
SentryEnvelopeItemHeader *envelopeItemHeader = [[SentryEnvelopeItemHeader alloc] initWithType:itemType length:envelopeItemData.length];
|
|
296
|
-
SentryEnvelopeItem *envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:envelopeItemHeader data:envelopeItemData];
|
|
278
|
+
NSMutableData *data = [[NSMutableData alloc] initWithCapacity: [bytes count]];
|
|
279
|
+
for(NSNumber *number in bytes) {
|
|
280
|
+
char byte = [number charValue];
|
|
281
|
+
[data appendBytes: &byte length: 1];
|
|
282
|
+
}
|
|
297
283
|
|
|
298
|
-
|
|
284
|
+
SentryEnvelope *envelope = [PrivateSentrySDKOnly envelopeWithData:data];
|
|
285
|
+
if (envelope == nil) {
|
|
286
|
+
reject(@"SentryReactNative",@"Failed to parse envelope from byte array.", nil);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
299
289
|
|
|
300
|
-
|
|
290
|
+
#if DEBUG
|
|
291
|
+
[PrivateSentrySDKOnly captureEnvelope:envelope];
|
|
292
|
+
#else
|
|
293
|
+
if (options[@'store']) {
|
|
294
|
+
// Storing to disk happens asynchronously with captureEnvelope
|
|
295
|
+
[PrivateSentrySDKOnly storeEnvelope:envelope];
|
|
296
|
+
} else {
|
|
301
297
|
[PrivateSentrySDKOnly captureEnvelope:envelope];
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
[PrivateSentrySDKOnly storeEnvelope:envelope];
|
|
306
|
-
} else {
|
|
307
|
-
[PrivateSentrySDKOnly captureEnvelope:envelope];
|
|
308
|
-
}
|
|
309
|
-
#endif
|
|
310
|
-
resolve(@YES);
|
|
311
|
-
} else {
|
|
312
|
-
reject(@"SentryReactNative", @"Cannot serialize event", nil);
|
|
313
|
-
}
|
|
298
|
+
}
|
|
299
|
+
#endif
|
|
300
|
+
resolve(@YES);
|
|
314
301
|
}
|
|
315
302
|
|
|
316
303
|
RCT_EXPORT_METHOD(setUser:(NSDictionary *)user
|