
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
@nativescript-asharghi/firebase-crashlytics
Advanced tools
A plugin that allows you to add Firebase Crashlytics to your NativeScript app.
Note: Use this plugin with the @nativescript-asharghi/firebase-core plugin to initialize Firebase.
Crashlytics helps you to collect analytics and details about crashes and errors that occur in your app. It does this through three aspects:
Install the plugin by running the following command in the root directory of your project.
npm install @nativescript-asharghi/firebase-crashlytics
Use the log method throughout your app to accumulate extra context for possible crashes that can happen.
import { firebase } from '@nativescript-asharghi/firebase-core';
import '@nativescript-asharghi/firebase-crashlytics'; // only needs to be imported 1x
const crashlytics = firebase().crashlytics();
crashlytics.log('User signed in.');
For additional context, Crashlytics also offers various methods to set attributes for the crash report.
setAttribute method passing it the attribute name as the first argument and its value as the second argument.import { firebase } from '@nativescript-asharghi/firebase-core';
import '@nativescript-asharghi/firebase-crashlytics'; // only needs to be imported 1x
const crashlytics = firebase().crashlytics();
crashlytics().setAttribute('credits', String(user.credits));
setAttributes method with an object containing the attributes.import { firebase } from '@nativescript-asharghi/firebase-core';
import '@nativescript-asharghi/firebase-crashlytics'; // only needs to be imported 1x
const crashlytics = firebase().crashlytics();
crashlytics().setAttributes({
role: 'admin',
followers: '13',
email: user.email,
username: user.username,
});
You can use set methods to set predefined attributes, but you can also set your own custom attributes.
setUserId method on firebase().crashlytics()import { firebase } from '@nativescript-asharghi/firebase-core';
import '@nativescript-asharghi/firebase-crashlytics'; // only needs to be imported 1x
const crashlytics = firebase().crashlytics();
crashlytics.setUserId(user.uid);
To test Crashlytics for your app, call the crash method to force a crash and in Firebase Console, see if the crash is logged.
firebase().crashlytics().crash();
Crashlytics also supports sending JavaScript stack traces to the Firebase console. This can be used in any situation where an error occurs but is caught by your code to recover gracefully.
To send a stack trace, pass a JavaScript Error to the recordError method.
Even if you catch unexpected errors, for your app to recover and behave smoothly you can still report them through Crashlytics using the recordError method. This will also provide you with the associated stack trace.
import { firebase } from '@nativescript-asharghi/firebase-core';
firebase().crashlytics().log('Updating user count.');
try {
if (users) {
someMethodToCatch();
}
} catch (error) {
crashlytics().recordError(error);
console.log(error);
}
As Crashlytics will be sending certain information regarding the user, users may want to opt out of the crash reporting. To disable crashlytics collection, call the setCrashlyticsCollectionEnabled method on firebase().crashlytics() passing it false This can be done throughout the app with a simple method call to setCrashlyticsCollectionEnabled:
import { firebase } from '@nativescript-asharghi/firebase-core';
firebase().crashlytics().setCrashlyticsCollectionEnabled(false);
The Crashlytics class has the following members.
| Property | Type | Description |
|---|---|---|
ios | readonly | |
android | readonly | |
app | FirebaseApp | readonly |
| Method | Returns | Description |
|---|---|---|
checkForUnsentReports() | Promise<boolean> | |
crash() | void | |
deleteUnsentReports() | void | |
didCrashOnPreviousExecution() | boolean | |
log(message: string) | void | |
recordError(error: any) | void | |
sendUnsentReports() | void | |
setAttribute(name: string, value: string | number | boolean) | void | |
setAttributes(attributes: { [key: string]: string | number | boolean }) | void | |
setCrashlyticsCollectionEnabled(enabled: boolean) | void | |
setUserId(userId: string) | void |
Apache License Version 2.0
FAQs
NativeScript Firebase - Crashlytics
The npm package @nativescript-asharghi/firebase-crashlytics receives a total of 1 weekly downloads. As such, @nativescript-asharghi/firebase-crashlytics popularity was classified as not popular.
We found that @nativescript-asharghi/firebase-crashlytics demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.