Invertase
Invertase

Notice: This documentation is currently a work in progress for the upcoming v6 release and some content may be missing or incomplete. If you're not interested in testing out the alpha version of v6 then please click here to be taken to the v5 documentation.

message  Send Feedback

crashlytics()

The Firebase Crashlytics service interface.

This module is available for the default app only.

Example

Get the Crashlytics service for the default app:

const defaultAppCrashlytics = firebase.crashlytics();

Properties

app

app: FirebaseApp;

isCrashlyticsCollectionEnabled

isCrashlyticsCollectionEnabled: true;

Whether Crashlytics reporting is enabled.

Example

const isEnabled = firebase.crashlytics().isCrashlyticsCollectionEnabled;

Methods

crash

crash(): void;

Cause your app to crash for testing purposes.

Example

firebase.crashlytics().crash();

log

log(message: string): void;

Log a message that will appear in any subsequent Crash or Non-fatal error reports.

Example

firebase.crashlytics().logEvent('Testing a crash');
firebase.crashlytics().crash();
Parameters
  • message

recordError

recordError(error: Error): void;

Record a JavaScript Error.

The JavaScript stack trace is converted into a mock native iOS or Android exception before submission.

Example

firebase.crashlytics().recordError(
new Error('An error was caught')
);
Parameters
  • error
    Expects an instance of Error; e.g. classes that extend Error will also be supported.

setAttribute

setAttribute(name: string, value: string): Promise<null>;

Sets a string value to be associated with the given attribute name which will be visible in the Firebase Crashlytics console.

Example

await firebase.crashlytics().setAttribute('role', 'admin');
Parameters
  • name
    The name of the attribute to set.
  • value
    A string value for the given attribute.

setAttributes

setAttributes(attributes: { [key: string]: string }): Promise<null>;

Like setAttribute but for multiple attributes.

Example

await firebase.crashlytics().setAttributes({
role: 'admin',
followers: '13',
});
Parameters
  • attributes
    An object of key/value attribute name and values.

setCrashlyticsCollectionEnabled

setCrashlyticsCollectionEnabled(enabled: boolean): Promise<null>;

Enable/disable Crashlytics reporting.

Use this for opt-in first user data collection flows combined with firebase.json settings to disable auto collection.

Example

// Disable crash reporting
await firebase.crashlytics().setCrashlyticsCollectionEnabled(false);
Parameters
  • enabled
    A boolean value representing whether to enable Crashlytics error collection.

setUserEmail

setUserEmail(userEmail: string): Promise<null>;

Optionally specify a user email which will be visible in the Firebase Crashlytics console.

If you choose to collect contact information it is strongly recommend that you disclose this in your apps privacy policy.

Example

firebase.crashlytics().setUserEmail('[email protected]');
Parameters
  • userEmail
    A users email address.

setUserId

setUserId(userId: string): Promise<null>;

Specify a user identifier which will be visible in the Firebase Crashlytics console.

It is recommended for privacy purposes that this value be a value that's meaningless to a third-party observer; such as an arbitrary string that ties an end-user to a record in your system e.g. a database record id.

Example

// Custom user id
await firebase.crashlytics().setUserId('123456789');
// Firebase auth uid
await firebase.crashlytics().setUserId(
firebase.auth().currentUser.uid
);
Parameters
  • userId
    An arbitrary string that ties an end-user to a record in your system e.g. a database record id.

setUserName

setUserName(userName: string): Promise<null>;

Optionally specify a user name which will be visible in the Firebase Crashlytics console.

If you choose to collect contact information it is strongly recommend that you disclose this in your apps privacy policy.

Example

await firebase.crashlytics().setUserName('Alias');
Parameters
  • userName
    A string representing an end-user's name or app username