@nativescript-community/sentry 2.0.8 → 3.0.2
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 +49 -0
- package/README.md +88 -4
- package/backend.d.ts +28 -0
- package/backend.js +18 -3
- package/backend.js.map +1 -1
- package/client.d.ts +8 -10
- package/client.js +11 -18
- package/client.js.map +1 -1
- package/index.d.ts +9 -4
- package/index.js +11 -5
- package/index.js.map +1 -1
- package/integrations/devicecontext.js +0 -1
- package/integrations/devicecontext.js.map +1 -1
- package/integrations/eventorigin.d.ts +16 -0
- package/integrations/eventorigin.js +26 -0
- package/integrations/eventorigin.js.map +1 -0
- package/integrations/nativescripterrorhandlers.js +0 -22
- package/integrations/nativescripterrorhandlers.js.map +1 -1
- package/integrations/release.js +24 -14
- package/integrations/release.js.map +1 -1
- package/integrations/sdkinfo.d.ts +17 -0
- package/integrations/sdkinfo.js +48 -0
- package/integrations/sdkinfo.js.map +1 -0
- package/nssentry.android.d.ts +20 -8
- package/nssentry.android.js +264 -202
- package/nssentry.android.js.map +1 -1
- package/nssentry.d.ts +25 -2
- package/nssentry.ios.d.ts +22 -5
- package/nssentry.ios.js +176 -72
- package/nssentry.ios.js.map +1 -1
- package/package.json +10 -9
- package/platforms/android/buildscript.gradle +1 -2
- package/platforms/android/include.gradle +1 -1
- package/platforms/android/sentry.aar +0 -0
- package/platforms/ios/Podfile +1 -1
- package/platforms/ios/src/Info.plist +0 -0
- package/platforms/ios/src/NSSentry.h +11 -0
- package/platforms/ios/src/NSSentry.m +5 -0
- package/platforms/ios/src/module.modulemap +4 -0
- package/pnpm-lock.yaml +74 -43
- package/scope.d.ts +45 -0
- package/scope.js +72 -0
- package/scope.js.map +1 -0
- package/sdk.d.ts +9 -0
- package/sdk.js +46 -12
- package/sdk.js.map +1 -1
- package/tracing/index.d.ts +1 -0
- package/tracing/index.js +8 -0
- package/tracing/index.js.map +1 -0
- package/tracing/nstracing.d.ts +65 -0
- package/tracing/nstracing.js +92 -0
- package/tracing/nstracing.js.map +1 -0
- package/tracing/utils.d.ts +6 -0
- package/tracing/utils.js +21 -0
- package/tracing/utils.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"sdkinfo.js","sourceRoot":"","sources":["../../src/integrations/sdkinfo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,sCAAsC;AACtC,MAAM,OAAO,OAAO;IAApB;QAME;;WAEG;QACI,SAAI,GAAW,OAAO,CAAC,EAAE,CAAC;QAEzB,mBAAc,GAAmB,IAAI,CAAC;IAuChD,CAAC;IArCC;;OAEG;IACI,SAAS,CAAC,uBAAoD;QACnE,uBAAuB,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;YACtC,2GAA2G;YAC3G,+FAA+F;YAC/F,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE;gBAChD,IAAI;oBACF,IAAI,CAAC,cAAc,GAAG,MAAM,QAAQ,CAAC,kBAAkB,EAAE,CAAC;iBAC3D;gBAAC,OAAO,CAAC,EAAE;oBACV,qGAAqG;oBACrG,MAAM,CAAC,IAAI,CACT,sGAAsG,CACvG,CAAC;oBACF,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBAChB;aACF;YAED,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,IAAI,YAAY,CAAC;YAChD,KAAK,CAAC,GAAG,mCACJ,OAAC,KAAK,CAAC,GAAG,mCAAI,EAAE,CAAC,KACpB,IAAI,EAAE,QAAQ,EACd,QAAQ,EAAE;oBACR,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oBAC5C,GAAG,CAAC,CAAC,IAAI,CAAC,cAAc,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;oBACzD;wBACE,IAAI,EAAE,oCAAoC;wBAC1C,OAAO,EAAE,WAAW;qBACrB;iBACF,EACD,OAAO,EAAE,WAAW,GACrB,CAAC;YAEF,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;;AAhDD;;GAEG;AACW,UAAE,GAAW,SAAS,CAAC"}
|
package/nssentry.android.d.ts
CHANGED
@@ -1,17 +1,29 @@
|
|
1
|
-
import { Event, Response } from '@sentry/types';
|
1
|
+
import { Breadcrumb, Event, Response, User } from '@sentry/types';
|
2
2
|
import { NativescriptOptions } from './backend';
|
3
|
+
import { UserFeedback } from './nssentry';
|
3
4
|
export declare namespace NSSentry {
|
4
5
|
const nativeClientAvailable = true;
|
5
6
|
const nativeTransport = true;
|
6
|
-
function fetchRelease(): {
|
7
|
-
id: string;
|
8
|
-
version: string;
|
9
|
-
build: number;
|
10
|
-
};
|
11
7
|
function sendEvent(event: Event): Promise<Response>;
|
8
|
+
function captureEnvelope(envelope: string): Promise<void>;
|
12
9
|
function flush(timeout: number): void;
|
13
|
-
function startWithDsnString(dsnString: string, options
|
14
|
-
function
|
10
|
+
function startWithDsnString(dsnString: string, options?: NativescriptOptions): Promise<Response>;
|
11
|
+
function fetchNativeSdkInfo(): {};
|
12
|
+
function fetchNativeRelease(): {
|
13
|
+
id: any;
|
14
|
+
version: any;
|
15
|
+
build: string;
|
16
|
+
};
|
17
|
+
function closeNativeSdk(): void;
|
15
18
|
function crash(): void;
|
16
19
|
function deviceContexts(): Promise<any>;
|
20
|
+
function captureUserFeedback(feedback: UserFeedback): void;
|
21
|
+
function setUser(user: User | null, otherUserKeys: any): void;
|
22
|
+
function setTag(key: string, value: string): void;
|
23
|
+
function setExtra(key: string, extra: string): void;
|
24
|
+
function addBreadcrumb(breadcrumb: Breadcrumb, maxBreadcrumbs?: number): void;
|
25
|
+
function clearBreadcrumbs(): void;
|
26
|
+
function setContext(key: string, context: {
|
27
|
+
[key: string]: any;
|
28
|
+
} | null): void;
|
17
29
|
}
|
package/nssentry.android.js
CHANGED
@@ -1,35 +1,26 @@
|
|
1
1
|
import { Application } from '@nativescript/core';
|
2
|
+
import { android as androidApp } from '@nativescript/core/application';
|
2
3
|
import { Status } from '@sentry/types';
|
3
|
-
import {
|
4
|
+
import { _processLevel } from './backend';
|
4
5
|
import { convertNativescriptFramesToSentryFrames, parseErrorStack } from './integrations/debugsymbolicator';
|
6
|
+
import { rewriteFrameIntegration } from './sdk';
|
5
7
|
export var NSSentry;
|
6
8
|
(function (NSSentry) {
|
7
9
|
NSSentry.nativeClientAvailable = true;
|
8
10
|
NSSentry.nativeTransport = true;
|
9
|
-
function fetchRelease() {
|
10
|
-
const ctx = Application.android.context;
|
11
|
-
const packageInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
|
12
|
-
return {
|
13
|
-
id: packageInfo.packageName,
|
14
|
-
version: packageInfo.versionName,
|
15
|
-
build: packageInfo.versionCode,
|
16
|
-
};
|
17
|
-
}
|
18
|
-
NSSentry.fetchRelease = fetchRelease;
|
19
11
|
function eventLevel(level) {
|
20
12
|
switch (level) {
|
21
13
|
case 'fatal':
|
22
|
-
return io.sentry.
|
14
|
+
return io.sentry.SentryLevel.FATAL;
|
23
15
|
case 'warning':
|
24
|
-
return io.sentry.
|
16
|
+
return io.sentry.SentryLevel.WARNING;
|
25
17
|
case 'info':
|
26
|
-
return io.sentry.core.SentryLevel.INFO;
|
27
18
|
case 'log':
|
28
|
-
return io.sentry.
|
19
|
+
return io.sentry.SentryLevel.INFO;
|
29
20
|
case 'debug':
|
30
|
-
return io.sentry.
|
21
|
+
return io.sentry.SentryLevel.DEBUG;
|
31
22
|
default:
|
32
|
-
return io.sentry.
|
23
|
+
return io.sentry.SentryLevel.ERROR;
|
33
24
|
}
|
34
25
|
}
|
35
26
|
function getNativeHashMap(obj) {
|
@@ -69,7 +60,7 @@ export var NSSentry;
|
|
69
60
|
return result;
|
70
61
|
}
|
71
62
|
function getUser(user) {
|
72
|
-
const nUser = new io.sentry.
|
63
|
+
const nUser = new io.sentry.protocol.User();
|
73
64
|
if (user.email) {
|
74
65
|
nUser.setEmail(user.email);
|
75
66
|
}
|
@@ -90,10 +81,10 @@ export var NSSentry;
|
|
90
81
|
}
|
91
82
|
return nUser;
|
92
83
|
}
|
93
|
-
const mJsModuleIdPattern = new RegExp('(?:^|[/\\\\])(\\d+\\.js)$')
|
84
|
+
const mJsModuleIdPattern = new RegExp('(?:^|[/\\\\])(\\d+\\.js)$');
|
94
85
|
function stackFrameToModuleId(frame) {
|
95
86
|
if (!!frame.file) {
|
96
|
-
const matcher = frame.file
|
87
|
+
const matcher = mJsModuleIdPattern.exec(frame.file);
|
97
88
|
if (matcher) {
|
98
89
|
return matcher[1] + ':';
|
99
90
|
}
|
@@ -101,7 +92,7 @@ export var NSSentry;
|
|
101
92
|
return '';
|
102
93
|
}
|
103
94
|
function convertToNativeStacktrace(stack) {
|
104
|
-
const nStackTrace = new io.sentry.
|
95
|
+
const nStackTrace = new io.sentry.protocol.SentryStackTrace();
|
105
96
|
const frames = new java.util.ArrayList();
|
106
97
|
for (let i = 0; i < stack.length; i++) {
|
107
98
|
const frame = stack[i];
|
@@ -109,7 +100,7 @@ export var NSSentry;
|
|
109
100
|
const methodName = frame.methodName || frame.function || '';
|
110
101
|
const lineNumber = frame.lineNumber || frame.lineno || 0;
|
111
102
|
const column = frame.column || frame.colno || 0;
|
112
|
-
const stackFrame = new io.sentry.
|
103
|
+
const stackFrame = new io.sentry.protocol.SentryStackFrame();
|
113
104
|
stackFrame.setModule('');
|
114
105
|
stackFrame.setFunction(methodName.length > 0 ? methodName.split('.').pop() : methodName);
|
115
106
|
stackFrame.setFilename(stackFrameToModuleId(frame));
|
@@ -125,7 +116,7 @@ export var NSSentry;
|
|
125
116
|
}
|
126
117
|
function addExceptionInterface(nEvent, type, value, stack) {
|
127
118
|
const exceptions = nEvent.getExceptions() || new java.util.ArrayList();
|
128
|
-
const nException = new io.sentry.
|
119
|
+
const nException = new io.sentry.protocol.SentryException();
|
129
120
|
nException.setType(type);
|
130
121
|
nException.setValue(value);
|
131
122
|
nException.setModule('');
|
@@ -137,158 +128,81 @@ export var NSSentry;
|
|
137
128
|
}
|
138
129
|
function sendEvent(event) {
|
139
130
|
return new Promise((resolve) => {
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
// in case a `status_code` entry got accidentally stringified as a float
|
170
|
-
if (k === 'status_code') {
|
171
|
-
nBreadcumb.setData(k, value && value.endsWith('.0') ? value.replace('.0', '') : value);
|
172
|
-
}
|
173
|
-
else {
|
174
|
-
nBreadcumb.setData(k, value);
|
175
|
-
}
|
176
|
-
});
|
177
|
-
}
|
178
|
-
}
|
179
|
-
catch (e) {
|
180
|
-
console.warn('Discarded breadcrumb.data since it was not an object');
|
181
|
-
}
|
182
|
-
if (breadcrumb.message) {
|
183
|
-
nBreadcumb.setMessage(breadcrumb.message);
|
184
|
-
}
|
185
|
-
else {
|
186
|
-
nBreadcumb.setMessage('');
|
187
|
-
}
|
188
|
-
eventBreadcrumbs.add(i, nBreadcumb);
|
189
|
-
}
|
190
|
-
if (eventBreadcrumbs.size() > 0) {
|
191
|
-
nEvent.setBreadcrumbs(eventBreadcrumbs);
|
192
|
-
}
|
193
|
-
}
|
194
|
-
if (event.message) {
|
195
|
-
const nMsg = new io.sentry.core.protocol.Message();
|
196
|
-
nMsg.setMessage(event.message || '');
|
197
|
-
nEvent.setMessage(nMsg);
|
198
|
-
}
|
199
|
-
if (event.logger) {
|
200
|
-
nEvent.setLogger(event.logger);
|
201
|
-
}
|
202
|
-
if (event.user) {
|
203
|
-
nEvent.setUser(getUser(event.user));
|
204
|
-
}
|
205
|
-
if (event.extra) {
|
206
|
-
Object.keys(event.extra).forEach((k) => {
|
207
|
-
const value = event.extra[k];
|
208
|
-
nEvent.setExtra(k, typeof value === 'string' ? value : JSON.stringify(value));
|
209
|
-
});
|
131
|
+
var _a;
|
132
|
+
// Process and convert deprecated levels
|
133
|
+
event.level = event.level ? _processLevel(event.level) : undefined;
|
134
|
+
const header = {
|
135
|
+
event_id: event.event_id,
|
136
|
+
sdk: event.sdk,
|
137
|
+
};
|
138
|
+
const payload = Object.assign(Object.assign({}, event), { message: {
|
139
|
+
message: event.message,
|
140
|
+
} });
|
141
|
+
const headerString = JSON.stringify(header);
|
142
|
+
const payloadString = JSON.stringify(payload);
|
143
|
+
const length = payloadString.length;
|
144
|
+
// try {
|
145
|
+
// // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
146
|
+
// length = await RNSentry.getStringBytesLength(payloadString);
|
147
|
+
// } catch {
|
148
|
+
// // The native call failed, we do nothing, we have payload.length as a fallback
|
149
|
+
// }
|
150
|
+
const item = {
|
151
|
+
content_type: 'application/json',
|
152
|
+
length,
|
153
|
+
type: (_a = payload.type) !== null && _a !== void 0 ? _a : 'event',
|
154
|
+
};
|
155
|
+
const itemString = JSON.stringify(item);
|
156
|
+
const envelopeString = `${headerString}\n${itemString}\n${payloadString}`;
|
157
|
+
captureEnvelope(envelopeString);
|
158
|
+
if (sentryOptions.flushSendEvent === true) {
|
159
|
+
io.sentry.Sentry.flush(0);
|
210
160
|
}
|
211
|
-
|
212
|
-
const fingerprint = event.fingerprint;
|
213
|
-
const print = new java.util.ArrayList();
|
214
|
-
for (let i = 0; i < fingerprint.length; ++i) {
|
215
|
-
print.add(fingerprint[i]);
|
216
|
-
}
|
217
|
-
nEvent.setFingerprints(print);
|
218
|
-
}
|
219
|
-
if (event.tags) {
|
220
|
-
Object.keys(event.tags).forEach((k) => {
|
221
|
-
const value = event.tags[k];
|
222
|
-
nEvent.setTag(k, value || 'INVALID_TAG');
|
223
|
-
});
|
224
|
-
}
|
225
|
-
if (event.exception) {
|
226
|
-
const exceptionValues = event.exception.values;
|
227
|
-
const exception = exceptionValues[0];
|
228
|
-
if (exception.stacktrace) {
|
229
|
-
const stacktrace = exception.stacktrace;
|
230
|
-
const frames = stacktrace.frames;
|
231
|
-
if (exception.value) {
|
232
|
-
addExceptionInterface(nEvent, exception.type, exception.value, frames);
|
233
|
-
}
|
234
|
-
else {
|
235
|
-
// We use type/type here since this indicates an Unhandled Promise Rejection
|
236
|
-
// https://github.com/getsentry/react-native-sentry/issues/353
|
237
|
-
addExceptionInterface(nEvent, exception.type, exception.type, frames);
|
238
|
-
}
|
239
|
-
}
|
240
|
-
}
|
241
|
-
if (event.environment) {
|
242
|
-
nEvent.setEnvironment(event.environment);
|
243
|
-
}
|
244
|
-
if (event.platform) {
|
245
|
-
nEvent.setPlatform(event.platform);
|
246
|
-
}
|
247
|
-
if (event.release) {
|
248
|
-
nEvent.setRelease(event.release);
|
249
|
-
}
|
250
|
-
if (event.dist) {
|
251
|
-
nEvent.setDist(event.dist);
|
252
|
-
}
|
253
|
-
if (event.level) {
|
254
|
-
nEvent.setLevel(eventLevel(event.level));
|
255
|
-
}
|
256
|
-
if (event.contexts) {
|
257
|
-
Object.keys(event.contexts).forEach((k) => {
|
258
|
-
// const value = event.contexts[k];
|
259
|
-
// const context = new io.sentry.core.protocol.Contexts();
|
260
|
-
// nEvent.setTag(k, value || 'INVALID_TAG');
|
261
|
-
});
|
262
|
-
}
|
263
|
-
if (event.sdk) {
|
264
|
-
const sdk = event.sdk;
|
265
|
-
const nSdk = new io.sentry.core.protocol.SdkVersion();
|
266
|
-
nSdk.setName(sdk.name);
|
267
|
-
nSdk.setVersion(sdk.version);
|
268
|
-
if (sdk.integrations) {
|
269
|
-
const integrations = sdk.integrations;
|
270
|
-
for (let i = 0; i < integrations.length; ++i) {
|
271
|
-
nSdk.addIntegration(integrations[i]);
|
272
|
-
}
|
273
|
-
}
|
274
|
-
nEvent.setSdk(nSdk);
|
275
|
-
}
|
276
|
-
const id = io.sentry.core.Sentry.captureEvent(nEvent);
|
277
|
-
// io.sentry.core.Sentry.flush(0);
|
278
|
-
resolve({ status: Status.Success, id });
|
161
|
+
resolve({ status: Status.Success });
|
279
162
|
}).catch((err) => {
|
280
163
|
console.error('error sending sentry event', err, err.stack);
|
281
164
|
return Promise.reject(err);
|
282
165
|
});
|
283
166
|
}
|
284
167
|
NSSentry.sendEvent = sendEvent;
|
168
|
+
async function captureEnvelope(envelope) {
|
169
|
+
const installation = new java.io.File(nSentryOptions.getOutboxPath(), java.util.UUID.randomUUID().toString());
|
170
|
+
try {
|
171
|
+
const out = new java.io.FileOutputStream(installation);
|
172
|
+
out.write(new java.lang.String(envelope).getBytes(java.nio.charset.Charset.forName('UTF-8')));
|
173
|
+
}
|
174
|
+
catch (err) {
|
175
|
+
console.error('captureEnvelope error', err);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
NSSentry.captureEnvelope = captureEnvelope;
|
285
179
|
function flush(timeout) {
|
286
|
-
|
287
|
-
io.sentry.core.Sentry.flush(timeout);
|
180
|
+
io.sentry.Sentry.flush(timeout);
|
288
181
|
}
|
289
182
|
NSSentry.flush = flush;
|
290
183
|
let initialized = false;
|
291
|
-
|
184
|
+
let sentryOptions;
|
185
|
+
let nSentryOptions;
|
186
|
+
function addPackages(event, sdk) {
|
187
|
+
const eventSdk = event.getSdk();
|
188
|
+
if (eventSdk != null && eventSdk.getName() === 'sentry.javascript.react-native' && sdk != null) {
|
189
|
+
const sentryPackages = sdk.getPackages();
|
190
|
+
if (sentryPackages != null) {
|
191
|
+
for (let index = 0; index < sentryPackages.size(); index++) {
|
192
|
+
const sentryPackage = sentryPackages.get(index);
|
193
|
+
eventSdk.addPackage(sentryPackage.getName(), sentryPackage.getVersion());
|
194
|
+
}
|
195
|
+
}
|
196
|
+
const integrations = sdk.getIntegrations();
|
197
|
+
if (integrations != null) {
|
198
|
+
for (let index = 0; index < integrations.size(); index++) {
|
199
|
+
eventSdk.addIntegration(integrations.get(index));
|
200
|
+
}
|
201
|
+
}
|
202
|
+
event.setSdk(eventSdk);
|
203
|
+
}
|
204
|
+
}
|
205
|
+
function startWithDsnString(dsnString, options = {}) {
|
292
206
|
return new Promise((resolve, reject) => {
|
293
207
|
if (initialized) {
|
294
208
|
console.info('Already started, use existing client', dsnString);
|
@@ -296,16 +210,18 @@ export var NSSentry;
|
|
296
210
|
return;
|
297
211
|
}
|
298
212
|
try {
|
299
|
-
io.sentry.android.core.SentryAndroid.init(Application.android.context, new io.sentry.
|
213
|
+
io.sentry.android.core.SentryAndroid.init(Application.android.context, new io.sentry.Sentry.OptionsConfiguration({
|
300
214
|
configure(config) {
|
301
|
-
config.setLogger(new io.sentry.
|
302
|
-
// config.setDiagnosticLevel(io.sentry.
|
303
|
-
|
215
|
+
// config.setLogger(new io.sentry.SystemOutLogger());
|
216
|
+
// config.setDiagnosticLevel(io.sentry.SentryLevel.DEBUG);
|
217
|
+
io.sentry.Sentry.setLevel(io.sentry.SentryLevel.DEBUG);
|
304
218
|
config.setDsn(dsnString);
|
305
|
-
config.setEnvironment('javascript');
|
306
219
|
if (!!options.environment) {
|
307
220
|
config.setEnvironment(options.environment);
|
308
221
|
}
|
222
|
+
else {
|
223
|
+
config.setEnvironment('javascript');
|
224
|
+
}
|
309
225
|
if (!!options.debug) {
|
310
226
|
config.setDebug(options.debug);
|
311
227
|
}
|
@@ -318,20 +234,37 @@ export var NSSentry;
|
|
318
234
|
if (options.enableAutoSessionTracking !== undefined) {
|
319
235
|
config.setEnableSessionTracking(options.enableAutoSessionTracking);
|
320
236
|
}
|
321
|
-
|
237
|
+
if (options.sessionTrackingIntervalMillis !== undefined) {
|
238
|
+
config.setSessionTrackingIntervalMillis(options.sessionTrackingIntervalMillis);
|
239
|
+
}
|
240
|
+
if (options.enableNdkScopeSync !== undefined) {
|
241
|
+
config.setEnableScopeSync(options.enableNdkScopeSync);
|
242
|
+
}
|
243
|
+
if (options.attachStacktrace !== undefined) {
|
244
|
+
config.setAttachStacktrace(options.attachStacktrace);
|
245
|
+
}
|
246
|
+
if (options.attachThreads !== undefined) {
|
247
|
+
// JS use top level stacktraces and android attaches Threads which hides them so
|
248
|
+
// by default we hide.
|
249
|
+
config.setAttachThreads(options.attachThreads);
|
250
|
+
}
|
251
|
+
if (options.sendDefaultPii !== undefined) {
|
252
|
+
config.setSendDefaultPii(options.sendDefaultPii);
|
253
|
+
}
|
254
|
+
// config.setEnableNdk(true);
|
322
255
|
const integrations = config.getIntegrations();
|
323
256
|
const size = integrations.size();
|
324
257
|
if (options.enableNativeCrashHandling === false) {
|
325
258
|
for (let index = size - 1; index >= 0; index--) {
|
326
259
|
const inte = integrations.get(index);
|
327
|
-
if (inte instanceof io.sentry.
|
260
|
+
if (inte instanceof io.sentry.UncaughtExceptionHandlerIntegration ||
|
328
261
|
inte instanceof io.sentry.android.core.AnrIntegration ||
|
329
262
|
inte instanceof io.sentry.android.core.NdkIntegration) {
|
330
263
|
integrations.remove(index);
|
331
264
|
}
|
332
265
|
}
|
333
266
|
}
|
334
|
-
config.setBeforeSend(new io.sentry.
|
267
|
+
config.setBeforeSend(new io.sentry.SentryOptions.BeforeSendCallback({
|
335
268
|
execute(event, hint) {
|
336
269
|
if (options.beforeSend) {
|
337
270
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
@@ -346,27 +279,39 @@ export var NSSentry;
|
|
346
279
|
try {
|
347
280
|
const ex = event.getExceptions().get(0);
|
348
281
|
if (ex && ex.getType() === 'NativeScriptException') {
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
282
|
+
let mechanism = event.getThrowable && event.getThrowable();
|
283
|
+
if (!mechanism) {
|
284
|
+
const privateMethod = io.sentry.SentryEvent.class.getDeclaredMethod('getThrowable', null);
|
285
|
+
privateMethod.setAccessible(true);
|
286
|
+
mechanism = privateMethod.invoke(event, null);
|
287
|
+
}
|
288
|
+
let throwable;
|
289
|
+
if (mechanism instanceof io.sentry.exception.ExceptionMechanismException) {
|
290
|
+
throwable = mechanism.getThrowable();
|
291
|
+
}
|
292
|
+
else if (mechanism instanceof com.tns.NativeScriptException) {
|
293
|
+
throwable = mechanism;
|
294
|
+
}
|
295
|
+
if (throwable) {
|
296
|
+
const jsStackTrace = (throwable).getIncomingStackTrace();
|
297
|
+
if (jsStackTrace) {
|
298
|
+
const stack = parseErrorStack({ stack: jsStackTrace });
|
299
|
+
const convertedFrames = convertNativescriptFramesToSentryFrames(stack);
|
300
|
+
convertedFrames.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
|
301
|
+
addExceptionInterface(event, 'Error', throwable.getMessage(), convertedFrames.reverse());
|
362
302
|
}
|
363
303
|
}
|
364
304
|
}
|
365
305
|
}
|
366
306
|
catch (e) { }
|
307
|
+
event.setTag('event.origin', 'android');
|
308
|
+
event.setTag('event.environment', 'nativescript');
|
309
|
+
addPackages(event, config.getSdkVersion());
|
367
310
|
return event;
|
368
311
|
},
|
369
312
|
}));
|
313
|
+
nSentryOptions = config;
|
314
|
+
sentryOptions = options;
|
370
315
|
},
|
371
316
|
}));
|
372
317
|
initialized = true;
|
@@ -380,30 +325,47 @@ export var NSSentry;
|
|
380
325
|
});
|
381
326
|
}
|
382
327
|
NSSentry.startWithDsnString = startWithDsnString;
|
383
|
-
function setLogLevel(level) {
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
328
|
+
// export function setLogLevel(level: number) {
|
329
|
+
// switch (level) {
|
330
|
+
// case 1:
|
331
|
+
// io.sentry.Sentry.setLevel(null);
|
332
|
+
// break;
|
333
|
+
// case 2:
|
334
|
+
// io.sentry.Sentry.setLevel(io.sentry.SentryLevel.ERROR);
|
335
|
+
// break;
|
336
|
+
// case 3:
|
337
|
+
// io.sentry.Sentry.setLevel(io.sentry.SentryLevel.DEBUG);
|
338
|
+
// break;
|
339
|
+
// case 4:
|
340
|
+
// io.sentry.Sentry.setLevel(io.sentry.SentryLevel.INFO);
|
341
|
+
// break;
|
342
|
+
// }
|
343
|
+
// }
|
344
|
+
function fetchNativeSdkInfo() {
|
345
|
+
return {};
|
346
|
+
}
|
347
|
+
NSSentry.fetchNativeSdkInfo = fetchNativeSdkInfo;
|
348
|
+
function fetchNativeRelease() {
|
349
|
+
const context = androidApp.context;
|
350
|
+
const packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
351
|
+
return {
|
352
|
+
'id': packageInfo.packageName,
|
353
|
+
'version': packageInfo.versionName,
|
354
|
+
'build': packageInfo.versionCode + ''
|
355
|
+
};
|
356
|
+
}
|
357
|
+
NSSentry.fetchNativeRelease = fetchNativeRelease;
|
358
|
+
function closeNativeSdk() {
|
359
|
+
io.sentry.Sentry.close();
|
398
360
|
}
|
399
|
-
NSSentry.
|
361
|
+
NSSentry.closeNativeSdk = closeNativeSdk;
|
400
362
|
function crash() {
|
401
363
|
throw new java.lang.RuntimeException('TEST - Sentry Client Crash');
|
402
364
|
}
|
403
365
|
NSSentry.crash = crash;
|
404
366
|
function deviceContexts() {
|
405
367
|
return new Promise((resolve) => {
|
406
|
-
const nEvent = new io.sentry.
|
368
|
+
const nEvent = new io.sentry.SentryEvent();
|
407
369
|
const params = {};
|
408
370
|
const it = nEvent.getContexts().entrySet().iterator();
|
409
371
|
let value, pair, key;
|
@@ -417,5 +379,105 @@ export var NSSentry;
|
|
417
379
|
});
|
418
380
|
}
|
419
381
|
NSSentry.deviceContexts = deviceContexts;
|
382
|
+
function captureUserFeedback(feedback) {
|
383
|
+
const userFeedback = new io.sentry.UserFeedback(new io.sentry.protocol.SentryId(feedback.eventId));
|
384
|
+
if (feedback.comments) {
|
385
|
+
userFeedback.setComments(feedback.comments);
|
386
|
+
}
|
387
|
+
if (feedback.email) {
|
388
|
+
userFeedback.setEmail(feedback.email);
|
389
|
+
}
|
390
|
+
if (feedback.name) {
|
391
|
+
userFeedback.setName(feedback.name);
|
392
|
+
}
|
393
|
+
io.sentry.Sentry.captureUserFeedback(userFeedback);
|
394
|
+
}
|
395
|
+
NSSentry.captureUserFeedback = captureUserFeedback;
|
396
|
+
function setUser(user, otherUserKeys) {
|
397
|
+
io.sentry.Sentry.configureScope(new io.sentry.ScopeCallback({
|
398
|
+
run(scope) {
|
399
|
+
if (user == null && otherUserKeys == null) {
|
400
|
+
scope.setUser(null);
|
401
|
+
}
|
402
|
+
else {
|
403
|
+
const userInstance = new io.sentry.protocol.User();
|
404
|
+
if (user) {
|
405
|
+
if (user.email) {
|
406
|
+
userInstance.setEmail(user.email);
|
407
|
+
}
|
408
|
+
if (user.id) {
|
409
|
+
userInstance.setId(user.id);
|
410
|
+
}
|
411
|
+
if (user.username) {
|
412
|
+
userInstance.setUsername(user.username);
|
413
|
+
}
|
414
|
+
if (user.ip_address) {
|
415
|
+
userInstance.setIpAddress(user.ip_address);
|
416
|
+
}
|
417
|
+
}
|
418
|
+
if (otherUserKeys) {
|
419
|
+
userInstance.setOthers(getNativeHashMap(otherUserKeys));
|
420
|
+
}
|
421
|
+
scope.setUser(userInstance);
|
422
|
+
}
|
423
|
+
}
|
424
|
+
}));
|
425
|
+
}
|
426
|
+
NSSentry.setUser = setUser;
|
427
|
+
function setTag(key, value) {
|
428
|
+
io.sentry.Sentry.configureScope(new io.sentry.ScopeCallback({
|
429
|
+
run(scope) {
|
430
|
+
scope.setTag(key, value);
|
431
|
+
}
|
432
|
+
}));
|
433
|
+
}
|
434
|
+
NSSentry.setTag = setTag;
|
435
|
+
function setExtra(key, extra) {
|
436
|
+
io.sentry.Sentry.configureScope(new io.sentry.ScopeCallback({
|
437
|
+
run(scope) {
|
438
|
+
scope.setExtra(key, extra);
|
439
|
+
}
|
440
|
+
}));
|
441
|
+
}
|
442
|
+
NSSentry.setExtra = setExtra;
|
443
|
+
function addBreadcrumb(breadcrumb, maxBreadcrumbs) {
|
444
|
+
io.sentry.Sentry.configureScope(new io.sentry.ScopeCallback({
|
445
|
+
run(scope) {
|
446
|
+
const breadcrumbInstance = new io.sentry.Breadcrumb();
|
447
|
+
if (breadcrumb.message) {
|
448
|
+
breadcrumbInstance.setMessage(breadcrumb.message);
|
449
|
+
}
|
450
|
+
if (breadcrumb.type) {
|
451
|
+
breadcrumbInstance.setType(breadcrumb.type);
|
452
|
+
}
|
453
|
+
if (breadcrumb.category) {
|
454
|
+
breadcrumbInstance.setCategory(breadcrumb.category);
|
455
|
+
}
|
456
|
+
if (breadcrumb.level) {
|
457
|
+
breadcrumbInstance.setLevel(eventLevel(breadcrumb.level));
|
458
|
+
}
|
459
|
+
if (breadcrumb.data) {
|
460
|
+
Object.keys(breadcrumb.data).forEach(key => {
|
461
|
+
breadcrumbInstance.setData(key, breadcrumb.data[key]);
|
462
|
+
});
|
463
|
+
}
|
464
|
+
scope.addBreadcrumb(breadcrumbInstance);
|
465
|
+
}
|
466
|
+
}));
|
467
|
+
}
|
468
|
+
NSSentry.addBreadcrumb = addBreadcrumb;
|
469
|
+
function clearBreadcrumbs() {
|
470
|
+
io.sentry.Sentry.configureScope(new io.sentry.ScopeCallback({
|
471
|
+
run(scope) {
|
472
|
+
scope.clearBreadcrumbs();
|
473
|
+
}
|
474
|
+
}));
|
475
|
+
}
|
476
|
+
NSSentry.clearBreadcrumbs = clearBreadcrumbs;
|
477
|
+
function setContext(key, context) {
|
478
|
+
// setContext not available on the Android SDK yet.
|
479
|
+
setExtra(key, context ? JSON.stringify(context) : null);
|
480
|
+
}
|
481
|
+
NSSentry.setContext = setContext;
|
420
482
|
})(NSSentry || (NSSentry = {}));
|
421
483
|
//# sourceMappingURL=nssentry.android.js.map
|