Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@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
We found that @nativescript-asharghi/firebase-crashlytics demonstrated a healthy version release cadence and project activity because the last version was released less than 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.