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

nativescript-sentry

v2.0.1

Published

Sentry.io NativeScript plugin.

Downloads

26

Readme

Sentry.io for NativeScript

npm npm

NativeScript plugin that uses sentry-android and sentry-cocoa to catch native errors/stack traces and send them to a sentry server.


:seven: – This is the documentation of v2 which is compatible with NativeScript 7 :construction: – Currently in alpha state, use with caution! :six: – If you are using NativeScript 6, use a v1 release.


Installation

ns plugin add nativescript-sentry

Configuration

Android

Add the following line to your AndroidManifest.xml within the <application>-tag:

<meta-data android:name="io.sentry.dsn" android:value="__YOUR_DSN_HERE__" />

Without Angular

import { Sentry } from 'nativescript-sentry';
const dsn = 'https://<key>:<secret>@host/<project>';
Sentry.init(dsn);

With Angular

import { SentryModule } from 'nativescript-sentry/angular';

NgModule({
  // ...
  imports: [
    SentryModule.forRoot({
      dsn: 'https://<key>:<secret>@host/<project>',
      discardUncaughtJsExceptions: true
    })
  ]
  // ...
});

Note: this plugin adds a custom ErrorHandler to your angular app

Usage

Capture an exception

Sentry.captureException(exeption: Error, options?: ExceptionOptions);
export interface ExceptionOptions {
  // Object of additional Key/value pairs which generate breakdowns charts and search filters in Sentry.
  tags?: object;

  // Object of unstructured data which is stored with events.
  extra?: object;
}

Example:

try {
  throw new Error('Whoops!');
} catch (error) {
  Sentry.captureException(error, {});
}

Capture a message

Sentry.captureMessage(message: string, options?: MessageOptions)
export interface MessageOptions {
  level?: Level;

  // Object of additional Key/value pairs which generate breakdowns charts and search filters.
  tags?: object;

  // Object of unstructured data which is stored with events.
  extra?: object;
}

export enum Level {
  Fatal = 'fatal',
  Error = 'error',
  Warning = 'warning',
  Info = 'info',
  Debug = 'debug'
}

Capture navigation breadcrumb

Sentry.captureBreadcrumb(breadcrumb: BreadCrumb)
export interface BreadCrumb {
  message: string;
  category: string;
  level: Level;
}

Set user

Sentry.setContextUser(user: SentryUser)
export interface SentryUser {
  id: string;
  email?: string;
  username?: string;
}

Set tags

Sentry.setContextTags(tags: object)

Set extra information

Sentry.setContextExtra(extra: object)

Clear context (user, tags, extra information)

Sentry.clearContext();

Troubleshooting and important remarks

Native Exceptions / Crashes

If you have a native exception and the app exits, the plugin will save the log and send it in the next app startup, this is how the native plugins are implemented and it is expected behavior.

Android SLF4J Log Error

Sentry has an optional dependency on SLF4J on Android, which when not present will log an error about it not being in the application.

System.err: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
System.err: SLF4J: Defaulting to no-operation (NOP) logger implementation
System.err: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

To get rid of this log warning you can add a dependency to your app's app.gradle file located in App_Resources/Android/app.gradle to include:

compile 'org.slf4j:slf4j-nop:1.7.25'

in the dependencies. See the demo app.

Demo Apps

To run and test the demo apps you need to replace the placeholder __YOUR_DSN_HERE__ by your own DSN in the following files:

  • demo/App_Resources/Android/src/main/AndroidManifest.xml
  • demo/app/app.ts
  • demo-ng/App_Resources/Android/src/main/AndroidManifest.xml
  • demo-ng/src/app.module.ts

Changelog

2.0.1 - (25.03.2021)

  • fix issues with Angular
  • fix issues with user data on android

Thanks to @jeremypele and @jerbob92!

2.0.0-alpha.1 – (10.09.2020)

  • update Android SDK
  • update for NativeScript 7
  • add workflows for demo apps

Thanks to @bradmartin!

1.10.3 – (10.09.2020)

  • Release new version under original name on npmjs.org

1.10.2 – (17.04.2020)

  • Fix GitHub Workflow to use existing publishing scripts

1.10.1 – (17.04.2020)

  • Set up GitHub Workflow for npm publising

1.10.0 – (15.04.2020)

  • Bumps to latest native SDK releases
  • Stringifies data before writing it to Extras (Android)

Package was forked from the unmaintained package danielgek/nativescript-sentry. Access to original npm package has been transfered. Many thanks to @danielgek for his original work on this plugin!


1.8.0 – (02.02.2019)

  • bumps to latest native SDK releases
  • implements improved data converter(#22)
  • adds data to SentryUser

Thanks to @bradmartin and @jerbob92!

1.6.1 – (28.11.2018)

  • back to native approach thanks to @bradmartin
  • update dependencies
  • update test app
  • working native breadcrums for ios
  • fix dsn init thanks to @kvnvelasco

1.5.0 – (11.12.2017)

BREAKING CHANGES

  • capture() method was deprecated in favor of captureMessage/captureException

Features

  • Moving to an hybrid approach with both clients (web/native)
  • breadcrumbs
  • tags
  • user info
  • set tags and extra for each event

1.3.0 – (28.08.2017)

  • fix Aot compilation for angular apps
  • fix typos thanks to @muratcorlu

1.2.0 – (02.08.2017)

  • update demos dependencies
  • update ios and android native dependencies
  • fix ios event capture

1.1.0 – (24.07.2017)

  • fix stringify
  • fix angular error handler

Credits

  • @danielgek: for being the original author of this plugin danielgek/nativescript-sentry
  • @hypery2k: for his nativescript-fabric (helped the original author a lot!)