1- import { Integrations , getCurrentHub , defaultIntegrations as sentryDefaultIntegrations } from '@sentry/browser' ;
2- import { Hub , Scope , getIntegrationsToSetup , initAndBind , makeMain , setExtra } from '@sentry/core' ;
3- import { RewriteFrames } from '@sentry/integrations' ;
4- import { Integration , StackFrame , UserFeedback } from '@sentry/types' ;
1+ import { getCurrentHub } from '@sentry/browser' ;
2+ import { Hub , Scope , withScope as coreWithScope , getClient , getIntegrationsToSetup , initAndBind , makeMain , setExtra } from '@sentry/core' ;
3+ import { Integration , UserFeedback } from '@sentry/types' ;
54import { logger , stackParserFromStackParserOptions } from '@sentry/utils' ;
65
76import { NativescriptClientOptions , NativescriptOptions } from './options' ;
87
98import { NativescriptClient } from './client' ;
10- import { DeviceContext , NativescriptErrorHandlers , Release } from './integrations' ;
11- import { EventOrigin } from './integrations/eventorigin' ;
12- import { NativescriptErrorHandlersOptions } from './integrations/nativescripterrorhandlers' ;
13- import { SdkInfo } from './integrations/sdkinfo' ;
149import { getDefaultIntegrations } from './integrations/default' ;
10+ import { NativescriptErrorHandlersOptions } from './integrations/nativescripterrorhandlers' ;
1511// import { NativescriptScope } from './scope';
16- import { NativescriptTracing } from './tracing' ;
12+ import { parseErrorStack } from './integrations/debugsymbolicator' ;
13+ import { NativescriptScope } from './scope' ;
1714import { DEFAULT_BUFFER_SIZE , makeNativescriptTransport } from './transports/native' ;
1815import { makeUtf8TextEncoder } from './transports/TextEncoder' ;
19- import { safeFactory , safeTracesSampler } from './utils/safe' ;
20- import { NATIVE } from './wrapper' ;
21- import { parseErrorStack } from './integrations/debugsymbolicator' ;
22- import { Screenshot } from './integrations/screenshot' ;
2316import { getDefaultEnvironment } from './utils/environment' ;
24- import { NativescriptScope } from './scope' ;
17+ import { safeFactory , safeTracesSampler } from './utils/safe' ;
18+ import { NATIVE } from './wrapper.ios' ;
2519
2620// const STACKTRACE_LIMIT = 50;
2721// function stripSentryFramesAndReverse(stack) {
@@ -201,10 +195,7 @@ export function setDist(dist: string): void {
201195 * Use this only for testing purposes.
202196 */
203197export function nativeCrash ( ) : void {
204- const client = getCurrentHub ( ) . getClient < NativescriptClient > ( ) ;
205- if ( client ) {
206- client . nativeCrash ( ) ;
207- }
198+ NATIVE . nativeCrash ( ) ;
208199}
209200
210201/**
@@ -214,7 +205,7 @@ export function nativeCrash(): void {
214205 */
215206export async function flush ( timeout : number = 0 ) : Promise < boolean > {
216207 try {
217- const client = getCurrentHub ( ) . getClient < NativescriptClient > ( ) ;
208+ const client = getClient < NativescriptClient > ( ) ;
218209
219210 if ( client ) {
220211 const result = await client . flush ( timeout ) ;
@@ -234,7 +225,7 @@ export async function flush(timeout: number = 0): Promise<boolean> {
234225 */
235226export async function close ( ) : Promise < void > {
236227 try {
237- const client = getCurrentHub ( ) . getClient < NativescriptClient > ( ) ;
228+ const client = getClient < NativescriptClient > ( ) ;
238229
239230 if ( client ) {
240231 await client . close ( ) ;
@@ -247,7 +238,7 @@ export async function close(): Promise<void> {
247238 * Captures user feedback and sends it to Sentry.
248239 */
249240export function captureUserFeedback ( feedback : UserFeedback ) : void {
250- getCurrentHub ( ) . getClient < NativescriptClient > ( ) ?. captureUserFeedback ( feedback ) ;
241+ getClient < NativescriptClient > ( ) ?. captureUserFeedback ( feedback ) ;
251242}
252243
253244/**
@@ -263,30 +254,21 @@ export function captureUserFeedback(feedback: UserFeedback): void {
263254 *
264255 * @param callback that will be enclosed into push/popScope.
265256 */
266- export function withScope ( callback : ( scope : Scope ) => void ) : ReturnType < Hub [ 'withScope' ] > {
267- const safeCallback = ( scope : Scope ) : void => {
257+ export function withScope < T > ( callback : ( scope : Scope ) => T ) : T | undefined {
258+ const safeCallback = ( scope : Scope ) : T | undefined => {
268259 try {
269- NATIVE . withScope ( ( nscope ) => {
270- callback ( scope ) ;
271- } ) ;
260+ return callback ( scope ) ;
272261 } catch ( e ) {
273262 logger . error ( 'Error while running withScope callback' , e ) ;
263+ return undefined ;
274264 }
275265 } ;
276- return getCurrentHub ( ) . withScope ( safeCallback ) ;
266+ return coreWithScope ( safeCallback ) ;
277267}
278268
279269/**
280- * Callback to set context information onto the scope.
281- * @param callback Callback function that receives Scope.
270+ * Returns if the app crashed in the last run.
282271 */
283- export function configureScope ( callback : ( scope : Scope ) => void ) : ReturnType < Hub [ 'configureScope' ] > {
284- const safeCallback = ( scope : Scope ) : void => {
285- try {
286- callback ( scope ) ;
287- } catch ( e ) {
288- logger . error ( 'Error while running configureScope callback' , e ) ;
289- }
290- } ;
291- getCurrentHub ( ) . configureScope ( safeCallback ) ;
272+ export async function crashedLastRun ( ) : Promise < boolean | null > {
273+ return NATIVE . crashedLastRun ( ) ;
292274}
0 commit comments