Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/sentry/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { mergeOutcomes } from './utils/outcome';
import { NATIVE } from './wrapper';
import { Screenshot } from './integrations/screenshot';
import { NativescriptTracing } from './tracing';
import { rewriteFrameIntegration } from './integrations/default';
import { frameIteratee } from './integrations/default';
import { parseErrorStack } from './integrations/debugsymbolicator';

function wrapNativeException(ex, errorType = typeof ex) {
Expand Down Expand Up @@ -97,7 +97,7 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
if (exception['nativeException']) {
try {
const stack = parseErrorStack({ stack: 'at ' + exception['stackTrace'] } as any).filter((f) => f.platform !== 'javascript');
stack.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
stack.forEach((frame) => frameIteratee(frame));
event.exception.values.unshift({
type: 'NativeException',
value: exception.toString(),
Expand All @@ -111,8 +111,8 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
} else if (__IOS__ && exception['stackTrace']) {
// try {
// const stack = parseErrorStack({ stack: 'at ' + exception['stackTrace'] } as any).filter((f) => f.platform !== 'javascript');
// stack.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
// event.exception.values[0].stacktrace.frames.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
// stack.forEach((frame) => frameIteratee(frame));
// event.exception.values[0].stacktrace.frames.forEach((frame) => frameIteratee(frame));
// event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames.reverse();
// event.exception.values.unshift({
// type: 'NativeException',
Expand Down Expand Up @@ -140,7 +140,7 @@ export class NativescriptClient extends BaseClient<NativescriptClientOptions> {
}
const values = event.exception.values.map((exception: Exception): Thread => {
if (exception.stacktrace) {
exception.stacktrace.frames.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
exception.stacktrace.frames.forEach((frame) => frameIteratee(frame));
}
return {
stacktrace: exception.stacktrace
Expand Down
17 changes: 10 additions & 7 deletions src/sentry/integrations/default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClient, RewriteFrames } from '@sentry/integrations';
import { httpClientIntegration, rewriteFramesIntegration } from '@sentry/integrations';
// import { Integrations as BrowserReactIntegrations } from '@sentry/react';
import type { Integration, StackFrame } from '@sentry/types';

Expand All @@ -20,9 +20,12 @@ import { SdkInfo } from './sdkinfo';
// import { Spotlight } from './spotlight';
// import { ViewHierarchy } from './viewhierarchy';

export let rewriteFrameIntegration: {
_iteratee: (frame: StackFrame) => StackFrame;
};
/**
* The frame iteratee function used to rewrite stack frames.
* Exported separately so it can be referenced without going through the integration object.
*/
export let frameIteratee: (frame: StackFrame) => StackFrame;

/**
* Returns the default ReactNative integrations based on the current environment.
*
Expand Down Expand Up @@ -57,7 +60,7 @@ export function getDefaultIntegrations(options: NativescriptClientOptions & Nati
return frame;
};

rewriteFrameIntegration = new RewriteFrames({ iteratee }) as any;
frameIteratee = iteratee;

// if (notWeb()) {
integrations.push(new NativescriptErrorHandlers(options));
Expand Down Expand Up @@ -85,7 +88,7 @@ export function getDefaultIntegrations(options: NativescriptClientOptions & Nati
// integrations.push(new DebugSymbolicator());
// }

integrations.push(rewriteFrameIntegration as any);
integrations.push(rewriteFramesIntegration({ iteratee }) as Integration);

if (options.enableNative) {
integrations.push(new DeviceContext());
Expand All @@ -109,7 +112,7 @@ export function getDefaultIntegrations(options: NativescriptClientOptions & Nati
integrations.push(new NativescriptTracing());
}
if (options.enableCaptureFailedRequests) {
integrations.push(new HttpClient());
integrations.push(httpClientIntegration() as Integration);
}

// if (isExpoGo()) {
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/wrapper.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NativescriptOptions } from './options';
import { utf8ToBytes } from './vendor';
import { SDK_NAME } from './version';
import { CLog, CLogTypes } from '.';
import { rewriteFrameIntegration } from './integrations/default';
import { frameIteratee } from './integrations/default';
import { splitObject } from './utils/object';

enum JavaType {
Expand Down Expand Up @@ -578,7 +578,7 @@ export namespace NATIVE {
const jsStackTrace: string = throwable.getIncomingStackTrace?.();
if (jsStackTrace) {
const stack = parseErrorStack({ stack: 'at ' + jsStackTrace } as any).reverse();
stack.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
stack.forEach((frame) => frameIteratee(frame));
addJavascriptExceptionInterface(event, 'Error', throwable.getMessage(), stack.reverse());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/sentry/wrapper.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { parseErrorStack } from './integrations/debugsymbolicator';
import { isHardCrash } from './misc';
import { NativescriptOptions } from './options';
import { utf8ToBytes } from './vendor';
import { rewriteFrameIntegration } from './integrations/default';
import { frameIteratee } from './integrations/default';
import { splitObject } from './utils/object';

const numberHasDecimals = function (value: number): boolean {
Expand Down Expand Up @@ -368,7 +368,7 @@ export namespace NATIVE {
const errorMessage = matches[1];
const jsStackTrace = exceptionvalue.substring(exceptionvalue.indexOf(matches[2]));
const stack = parseErrorStack({ stack: 'at ' + jsStackTrace } as any).reverse();
stack.forEach((frame) => rewriteFrameIntegration._iteratee(frame));
stack.forEach((frame) => frameIteratee(frame));
addJavascriptExceptionInterface(event, 'Error', errorMessage, stack.reverse());
exception.type = 'NativeScriptException';
exception.value = errorMessage;
Expand Down