npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

boldtrn-capacitor-firebase-crashlytics

v5.4.2

Published

Capacitor plugin for Firebase Crashlytics.

Downloads

119

Readme

@capacitor-firebase/crashlytics

Unofficial Capacitor plugin for Firebase Crashlytics.[^1]

Installation

npm install @capacitor-firebase/crashlytics
npx cap sync

Add Firebase to your project if you haven't already (Android / iOS).

Android

See Add the Firebase Crashlytics plugin to your app and follow the instructions to set up your app correctly.

Variables

This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $firebaseCrashlyticsVersion version of com.google.firebase:firebase-crashlytics (default: 18.3.6)

iOS

To generate human readable crash reports, Crashlytics needs your project's debug symbol (dSYM) files. The following steps describe how to automatically upload dSYM files to Firebase whenever you build your app:

  1. Open your project's Xcode workspace, then select its project file in the left navigator.
  2. From the TARGETS list, select your main build target.
  3. Click the Build Settings tab, then complete the following steps so that Xcode produces dSYMs for your builds.
    1. Click All, then search for debug information format.
    2. Set Debug Information Format to DWARF with dSYM File for all your build types.
  4. Click the Build Phases tab and complete the following steps:
    1. Click the + button, then select New Run Script Phase.
    2. Expand the new Run Script section.
    3. In the script field (located under the Shell label), add the following run script:
      "${PODS_ROOT}/FirebaseCrashlytics/run"
    4. In the Input Files section, add the paths for the locations of the following files:
      ${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}
      $(SRCROOT)/$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-firebase-plugin-demo

Starter Templates

The following starter templates are available:

Usage

import { FirebaseCrashlytics } from '@capacitor-firebase/crashlytics';

const crash = async () => {
  await FirebaseCrashlytics.crash({ message: 'Test' });
};

const setCustomKey = async () => {
  await FirebaseCrashlytics.setCustomKey({
    key: 'page',
    value: 'home',
    type: 'string',
  });
};

const setUserId = async () => {
  await FirebaseCrashlytics.setUserId({
    userId: '123',
  });
};

const log = async () => {
  await FirebaseCrashlytics.log({
    message: 'Test',
  });
};

const setEnabled = async () => {
  await FirebaseCrashlytics.setEnabled({
    enabled: true,
  });
};

const isEnabled = async () => {
  const { enabled } = await FirebaseCrashlytics.isEnabled();
  return enabled;
};

const didCrashOnPreviousExecution = async () => {
  const { crashed } = await FirebaseCrashlytics.didCrashOnPreviousExecution();
  return crashed;
};

const sendUnsentReports = async () => {
  await FirebaseCrashlytics.sendUnsentReports();
};

const deleteUnsentReports = async () => {
  await FirebaseCrashlytics.deleteUnsentReports();
};

const recordException = async () => {
  await FirebaseCrashlytics.recordException({
    message: 'This is a non-fatal message.',
  });
};

import * as StackTrace from 'stacktrace-js';
const recordExceptionWithStacktrace = async (error: Error) => {
  const stacktrace = await StackTrace.fromError(error);
  await FirebaseCrashlytics.recordException({
    message: 'This is a non-fatal message.',
    stacktrace,
  });
};

API

crash(...)

crash(options: CrashOptions) => Promise<void>

Forces a crash to test the implementation.

Only available for Android and iOS.

| Param | Type | | ------------- | ----------------------------------------------------- | | options | CrashOptions |

Since: 0.1.0


setCustomKey(...)

setCustomKey(options: SetCustomKeyOptions) => Promise<void>

Sets a custom key and value that is associated with subsequent fatal and non-fatal reports.

Only available for Android and iOS.

| Param | Type | | ------------- | ------------------------------------------------------------------- | | options | SetCustomKeyOptions |

Since: 0.1.0


setUserId(...)

setUserId(options: SetUserIdOptions) => Promise<void>

Sets a user ID (identifier) that is associated with subsequent fatal and non-fatal reports.

Only available for Android and iOS.

| Param | Type | | ------------- | ------------------------------------------------------------- | | options | SetUserIdOptions |

Since: 0.1.0


log(...)

log(options: LogOptions) => Promise<void>

Adds a custom log message that is sent with your crash data to give yourself more context for the events leading up to a crash.

Only available for Android and iOS.

| Param | Type | | ------------- | ------------------------------------------------- | | options | LogOptions |

Since: 0.1.0


setEnabled(...)

setEnabled(options: SetEnabledOptions) => Promise<void>

Enables/disables automatic data collection. The value does not apply until the next run of the app.

Only available for Android and iOS.

| Param | Type | | ------------- | --------------------------------------------------------------- | | options | SetEnabledOptions |

Since: 0.1.0


isEnabled()

isEnabled() => Promise<IsEnabledResult>

Returns whether or not automatic data collection is enabled.

Only available for iOS.

Returns: Promise<IsEnabledResult>

Since: 0.1.0


didCrashOnPreviousExecution()

didCrashOnPreviousExecution() => Promise<DidCrashOnPreviousExecutionResult>

Returns whether the app crashed during the previous execution.

Only available for Android and iOS.

Returns: Promise<DidCrashOnPreviousExecutionResult>

Since: 0.1.0


sendUnsentReports()

sendUnsentReports() => Promise<void>

Uploads any unsent reports to Crashlytics at next startup.

When automatic data collection is enabled, Crashlytics automatically uploads reports at startup.

Only available for Android and iOS.

Since: 0.1.0


deleteUnsentReports()

deleteUnsentReports() => Promise<void>

Deletes any unsent reports on the device.

Only available for Android and iOS.

Since: 0.1.0


recordException(...)

recordException(options: RecordExceptionOptions) => Promise<void>

Records a non-fatal report to send to Crashlytics.

Only available for Android and iOS.

| Param | Type | | ------------- | ------------------------------------------------------------------------- | | options | RecordExceptionOptions |

Since: 0.1.0


Interfaces

CrashOptions

| Prop | Type | Since | | ------------- | ------------------- | ----- | | message | string | 0.1.0 |

SetCustomKeyOptions

| Prop | Type | Since | | ----------- | ---------------------------------------------------------------------------- | ----- | | key | string | 0.1.0 | | value | string | number | boolean | 0.1.0 | | type | 'string' | 'boolean' | 'long' | 'double' | 'int' | 'float' | 0.1.0 |

SetUserIdOptions

| Prop | Type | Since | | ------------ | ------------------- | ----- | | userId | string | 0.1.0 |

LogOptions

| Prop | Type | Since | | ------------- | ------------------- | ----- | | message | string | 0.1.0 |

SetEnabledOptions

| Prop | Type | Since | | ------------- | -------------------- | ----- | | enabled | boolean | 0.1.0 |

IsEnabledResult

| Prop | Type | Since | | ------------- | -------------------- | ----- | | enabled | boolean | 0.1.0 |

DidCrashOnPreviousExecutionResult

| Prop | Type | Since | | ------------- | -------------------- | ----- | | crashed | boolean | 0.1.0 |

RecordExceptionOptions

| Prop | Type | Description | Since | | ---------------- | ------------------------- | ------------------------------------------------------------------------------------- | ----- | | message | string | | 0.1.0 | | code | number | Error code within a specific error domain. Only available for iOS. | 0.1.0 | | domain | string | A string containing the error domain. Only available for iOS. | 0.1.0 | | stacktrace | StackFrame[] | A stacktrace generated by stacktrace.js. Cannot be combined with code and domain. | 1.1.0 |

StackFrame

Subset of the Stacktrace generated by stacktrace.js.

| Prop | Type | | ------------------ | ------------------- | | lineNumber | number | | fileName | string | | functionName | string |

Test your implementation

Here you can find more information on how to test the Firebase Crashlytics implementation. Among other things, you will find information on how to correctly adjust the project's debug settings under iOS and how to test it out.

If you get obfuscated crash reports for iOS, make sure you have initialized Crashlytics correctly and take a look at this guide, which provides some ways to troubleshoot if Crashlytics can't find your app's dSYM.

Changelog

See CHANGELOG.md.

License

See LICENSE.

Credits

This plugin is based on the Capacitor Community Firebase Crashlytics plugin. Thanks to everyone who contributed to the project!

[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.