@@ -13,47 +13,47 @@ import { NativescriptErrorHandlersOptions } from './integrations/nativescripterr
1313import { SdkInfo } from './integrations/sdkinfo' ;
1414// import { NativescriptScope } from './scope';
1515import { NativescriptTracing } from './tracing' ;
16- import { makeNativescriptTransport } from './transports/native' ;
16+ import { DEFAULT_BUFFER_SIZE , makeNativescriptTransport } from './transports/native' ;
1717import { makeUtf8TextEncoder } from './transports/TextEncoder' ;
1818import { safeFactory , safeTracesSampler } from './utils/safe' ;
1919import { NATIVE } from './wrapper' ;
2020import { parseErrorStack } from './integrations/debugsymbolicator' ;
2121import { Screenshot } from './integrations/screenshot' ;
22+ import { getDefaultEnvironment } from './utils/environment' ;
2223
2324
24- const STACKTRACE_LIMIT = 50 ;
25- function stripSentryFramesAndReverse ( stack ) {
26- if ( ! stack . length ) {
27- return [ ] ;
28- }
25+ // const STACKTRACE_LIMIT = 50;
26+ // function stripSentryFramesAndReverse(stack) {
27+ // if (!stack.length) {
28+ // return [];
29+ // }
2930
30- let localStack = stack ;
31+ // let localStack = stack;
3132
32- const firstFrameFunction = localStack [ 0 ] . function || '' ;
33- const lastFrameFunction = localStack [ localStack . length - 1 ] . function || '' ;
33+ // const firstFrameFunction = localStack[0].function || '';
34+ // const lastFrameFunction = localStack[localStack.length - 1].function || '';
3435
35- // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
36- if ( firstFrameFunction . indexOf ( 'captureMessage' ) !== - 1 || firstFrameFunction . indexOf ( 'captureException' ) !== - 1 ) {
37- localStack = localStack . slice ( 1 ) ;
38- }
36+ // // If stack starts with one of our API calls, remove it (starts, meaning it's the top of the stack - aka last call)
37+ // if (firstFrameFunction.indexOf('captureMessage') !== -1 || firstFrameFunction.indexOf('captureException') !== -1) {
38+ // localStack = localStack.slice(1);
39+ // }
3940
40- // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
41- if ( lastFrameFunction . indexOf ( 'sentryWrapped' ) !== - 1 ) {
42- localStack = localStack . slice ( 0 , - 1 ) ;
43- }
41+ // // If stack ends with one of our internal API calls, remove it (ends, meaning it's the bottom of the stack - aka top-most call)
42+ // if (lastFrameFunction.indexOf('sentryWrapped') !== -1) {
43+ // localStack = localStack.slice(0, -1);
44+ // }
4445
45- // The frame where the crash happened, should be the last entry in the array
46- return localStack
47- . slice ( 0 , STACKTRACE_LIMIT )
48- . map ( frame => ( {
49- ...frame ,
50- filename : frame . filename || localStack [ 0 ] . filename ,
51- function : frame . function || undefined ,
52- } ) ) ;
53- }
46+ // // The frame where the crash happened, should be the last entry in the array
47+ // return localStack
48+ // .slice(0, STACKTRACE_LIMIT)
49+ // .map(frame => ({
50+ // ...frame,
51+ // filename: frame.filename || localStack[0].filename,
52+ // function: frame.function || undefined,
53+ // }));
54+ // }
5455const defaultStackParser = ( stack , skipFirst = 0 ) => {
5556 let frames = parseErrorStack ( { stack } as any ) ;
56-
5757 if ( skipFirst ) {
5858 frames = frames . slice ( skipFirst ) ;
5959 }
@@ -78,6 +78,8 @@ const DEFAULT_OPTIONS: NativescriptOptions & NativescriptErrorHandlersOptions =
7878 textEncoder : makeUtf8TextEncoder ( ) ,
7979 } ,
8080 sendClientReports : true ,
81+ maxQueueSize : DEFAULT_BUFFER_SIZE ,
82+ attachStacktrace : true
8183} ;
8284
8385export let rewriteFrameIntegration : {
@@ -91,6 +93,10 @@ export function init(passedOptions: NativescriptOptions): void {
9193 const NativescriptHub = new Hub ( undefined , new Scope ( ) ) ;
9294 // const NativescriptHub = new Hub(undefined, new NativescriptScope());
9395 makeMain ( NativescriptHub ) ;
96+
97+ const maxQueueSize = passedOptions . maxQueueSize
98+ ?? passedOptions . transportOptions ?. bufferSize
99+ ?? DEFAULT_OPTIONS . maxQueueSize ;
94100 const options : NativescriptClientOptions & NativescriptOptions = {
95101 ...DEFAULT_OPTIONS ,
96102 ...passedOptions ,
@@ -99,14 +105,20 @@ export function init(passedOptions: NativescriptOptions): void {
99105 transportOptions : {
100106 ...DEFAULT_OPTIONS . transportOptions ,
101107 ...( passedOptions . transportOptions ?? { } ) ,
108+ bufferSize : maxQueueSize ,
102109 } ,
110+ maxQueueSize ,
103111 integrations : [ ] ,
104112 // integrations: getIntegrationsToSetup(passedOptions),
105113 stackParser : stackParserFromStackParserOptions ( passedOptions . stackParser || defaultStackParser ) ,
106114 beforeBreadcrumb : safeFactory ( passedOptions . beforeBreadcrumb , { loggerMessage : 'The beforeBreadcrumb threw an error' } ) ,
107115 initialScope : safeFactory ( passedOptions . initialScope , { loggerMessage : 'The initialScope threw an error' } ) ,
108116 tracesSampler : safeTracesSampler ( passedOptions . tracesSampler ) ,
109117 } ;
118+
119+ if ( ! ( 'environment' in options ) ) {
120+ options . environment = getDefaultEnvironment ( ) ;
121+ }
110122 // As long as tracing is opt in with either one of these options, then this is how we determine tracing is enabled.
111123 const tracingEnabled =
112124 typeof options . tracesSampler !== 'undefined' ||
@@ -202,7 +214,7 @@ export function nativeCrash(): void {
202214 * Use this before applying any realtime updates such as code-push or expo updates.
203215 * Not yet working on Android
204216 */
205- export async function flush ( timeout : number ) : Promise < boolean > {
217+ export async function flush ( timeout : number = 0 ) : Promise < boolean > {
206218 try {
207219 const client = getCurrentHub ( ) . getClient < NativescriptClient > ( ) ;
208220
0 commit comments