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-community/sentry

v4.6.38

Published

A cross-platform application monitoring tool, with a focus on error reporting.

Downloads

3,260

Readme

npm npm GitHub forks GitHub stars

Installation

  • tns plugin add @nativescript-community/sentry

Be sure to run a new build after adding plugins to avoid any issues.

Configuration

Webpack

You will need to add something like this to your webpack config so that the source maps gets uploaded. I dont set auth or project in the options as i use a .sentryclirc config file.

  • SOURCEMAP_REL_DIR: i almost always set it to ../../sourcemaps
  • SENTRY_PREFIX: the default is app:///
if (!!sentry && !!uploadSentry) {
  config.devtool = false;
  config.plugins.push(
      new webpack.SourceMapDevToolPlugin({
          append: `\n//# sourceMappingURL=${process.env.SENTRY_PREFIX}[name].js.map`,
          filename: join(process.env.SOURCEMAP_REL_DIR, '[name].js.map')
      })
  );
  let appVersion;
  let buildNumber;
  if (isAndroid) {
      const gradlePath = `${appResourcesPath}/Android/app.gradle`;
      const gradleData = readFileSync(gradlePath, 'utf8');
      appVersion = gradleData.match(/versionName "((?:[0-9]+\.?)+)"/)[1];
      buildNumber = gradleData.match(/versionCode ([0-9]+)/)[1];
  } else if (isIOS) {
      const plistPath = `${appResourcesPath}/iOS/Info.plist`;
      const plistData = readFileSync(plistPath, 'utf8');
      appVersion = plistData.match(/<key>CFBundleShortVersionString<\/key>[\s\n]*<string>(.*?)<\/string>/)[1];
      buildNumber = plistData.match(/<key>CFBundleVersion<\/key>[\s\n]*<string>([0-9]*)<\/string>/)[1];
  }
  config.plugins.push(
      new SentryCliPlugin({
          release: appVersion,
          urlPrefix: 'app:///',
          rewrite: true,
          release: `${nconfig.id}@${appVersion}+${buildNumber}`,
          dist: `${buildNumber}.${platform}`,
          ignoreFile: '.sentrycliignore',
          include: [join(dist, process.env.SOURCEMAP_REL_DIR)]
      })
  );
}

###debug

For debug mode to work correctly you will need to add this to your webpack (see demo app)

nsWebpack.chainWebpack(config=>{
    config.entry('bundle').prepend('@nativescript-community/sentry/process');
});

Fastlane

If you use fastlane you can use it to create release and upload dsyms To do that you need to install it:

fastlane add_plugin sentry

Also for now you should install nativescript-set-version as it is needed to read app version, build number.

npm install -D nativescript-set-version

Now you can setup your Fastfile

  • create release
version = ""
versionCode = ""

Dir.chdir("..") do
  version  =  sh("./node_modules/.bin/get-version", platform, "version").gsub(/\n/,'')
  versionCode  =  sh("./node_modules/.bin/get-version", platform, "code").gsub(/\n/,'')
end
sentry_create_release(
  version: version, # release version to create
)
  • upload dsyms
sentry_upload_dsym

Usage in the app

import * as Sentry from '@nativescript-community/sentry';

const buildNumber = await getBuildNumber();
const versionName = await getVersionName();
const buildNumber = await getBuildNumber();
const appId = await getAppId();
Sentry.init({
    dsn: SENTRY_DSN,
    debug: true,
    enableAutoPerformanceTracking: true,
});

Reporting NativeScript errors

The onerror method ensures all unhandled NativeScript errors will be caught by Sentry in production, using a custom error handler.

Reporting handled errors

If you would like to send a handled error to Bugsnag, you can pass any Error object to Sentry notify method:

import * as Sentry from '@nativescript-community/sentry';
try {
  // potentially crashy code
} catch (error) {
  Sentry.captureException(error);
}

Reporting promise rejections

To report a promise rejection, use notify() as a part of the catch block:

import * as Sentry from '@nativescript-community/sentry';
new Promise(function(resolve, reject) {
  /* potentially failing code */
})
.then(function () { /* if the promise is resolved */ })
.catch(function (error) {
  Sentry.captureException(error);
});

Sending diagnostic data

Automatically captured diagnostics

Bugsnag will automatically capture and attach the following diagnostic data:

  • A full stacktrace
  • Battery state
  • Device model and OS version
  • Thread state for all threads
  • Release stage (production, debug, etc)
  • App running duration in the foreground and/or background
  • A device- and vendor-specific identifier

Identifying users

In order to correlate errors with customer reports, or to see a list of users who experienced each error, it is helpful to capture and display user information. Information set on the Bugsnag client is sent with each error report:

Sentry.setUser({"email": "[email protected]"});

Logging breadcrumbs

In order to understand what happened in your application before each crash, it can be helpful to leave short log statements that we call breadcrumbs. The last several breadcrumbs are attached to a crash to help diagnose what events lead to the error.

Automatically captured breadcrumbs

By default, Bugsnag captures common events including:

  • Low memory warnings
  • Device rotation (if applicable)
  • Menu presentation
  • Screenshot capture (not the screenshot itself)
  • Undo and redo
  • Table view selection
  • Window visibility changes
  • Non-fatal errors
  • Log messages (off by default, see configuration options)

Attaching custom breadcrumbs

To attach additional breadcrumbs, use the leaveBreadcrumb function:

Sentry.addBreadcrumb({
    category: 'ui',
    message: 'load main view',
    level: 'info'
  });