MCPcopy Create free account
hub / github.com/NativeScript/firebase / Crashlytics

Class Crashlytics

packages/firebase-crashlytics/index.ios.ts:18–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17declare const TNSFirebaseCrashlytics;
18export class Crashlytics implements ICrashlytics {
19 _native: FIRCrashlytics;
20 constructor() {
21 if (defaultCrashlytics) {
22 return defaultCrashlytics;
23 }
24 defaultCrashlytics = this;
25 this._native = FIRCrashlytics.crashlytics();
26 }
27 get native() {
28 return this._native;
29 }
30 get ios() {
31 return this.native;
32 }
33 _app: FirebaseApp;
34 get app(): FirebaseApp {
35 if (!this._app) {
36 // @ts-ignore
37 this._app = FirebaseApp.fromNative(this.native.app);
38 }
39 return this._app;
40 }
41
42 get isCrashlyticsCollectionEnabled(): boolean {
43 return this.native.isCrashlyticsCollectionEnabled();
44 }
45 checkForUnsentReports(): Promise<boolean> {
46 return new Promise((resolve, reject) => {
47 this.native.checkForUnsentReportsWithCompletion((completed) => {
48 resolve(completed);
49 });
50 });
51 }
52 crash(): void {
53 TNSFirebaseCrashlytics.crash();
54 }
55 deleteUnsentReports() {
56 this.native.deleteUnsentReports();
57 }
58 didCrashOnPreviousExecution(): boolean {
59 return this.native.didCrashDuringPreviousExecution();
60 }
61 log(message: string): void {
62 this.native.log(message);
63 }
64
65 recordError(error: any): void {
66 if (error instanceof Error) {
67 StackTrace.fromError(error).then((stack) => {
68 const traceElements = stack.map((item) => FIRStackFrame.stackFrameWithSymbolFileLine(item.functionName || '(anonymous)', item.fileName ?? '', item.lineNumber ?? -1));
69 const e = FIRExceptionModel.exceptionModelWithNameReason(error.name || 'JavaScriptError', error.message);
70 e.stackTrace = NSArray.arrayWithArray(traceElements);
71 this.native.recordExceptionModel(e);
72 });
73 } else {
74 this.native.recordError(error);
75 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected