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

react-native-newrelic

v1.1.1

Published

New Relic wrapper for React Native

Downloads

65

Readme

react-native-newrelic

New Relic event reporting for react native.

also check out https://github.com/wix/sentry-monitor

Features

  • overrideConsole will send all console.log, warn and errors to New Relic.
  • reportUncaughtExceptions will send uncaught Javascript exceptions to New Relic.

More to come!

Installation

Install react-native-newrelic

npm install react-native-newrelic --save

iOS

1. Install New RelicAgent in your project as a pod

In the Podfile for your project, add the following line: pod 'NewRelicAgent' Make sure Xcode is closed and run: pod install

2. Add the project to Xcode

In the project navigator:

  • Right click Libraries
  • Add Files to [your project's name]
  • Go to node_modules/react-native-newrelic
  • Add the .xcodeproj file In the project navigator, select your project.
  • Add the libRNNewRelic.a to your project's Build Phases ➜ Link Binary With Libraries
  • Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic').

3. In your AppDelegate.m

Add the following:

-(void)setupNewRelic{
  NSString* token;
  if(isDebug) {
    token = @"<your new relic dev token (optional)>";
  } else {
    token = @"<your new relic production token";
  }
  [NewRelicAgent startWithApplicationToken:token];
}

And add the following line to the top of your didFinishLaunchingWithOptions function:

  [self setupNewRelic];

4. Add a prefix header to your iOS project

Add a PrefixHeader.pch file as explained here Your file should look like this:

#ifdef __OBJC__ 

#import <NewRelicAgent/NewRelic.h>

#endif

Android (gradle only)

1. Add NewRelic agent to your Android project

This link describes how to add the original NewRelic agent to your project. This guide only requires a part of the original steps (some of the steps are already integrated in react-native-newrelic:

In MainApplication.java import Newrelic and override the following method:

import com.newrelic.agent.android.NewRelic;

public class MainApplication extends Application implements ReactApplication {

...

public void onCreate() {
	super.onCreate();
	NewRelic.withApplicationToken("yourApplicationToken").start(this);
}

...

}

Create newrelic.properties in your root android dir:

com.newrelic.application_token= yourApplicationToken

Get your application token from newrelic.com

2. Add the react-native-newrelic module to your Android project

In settings.gradle:

include ':react-native-newrelic'
project(':react-native-newrelic').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-newrelic/android')

In your project level build.gradle:

dependencies {
	...
	classpath "com.newrelic.agent.android:agent-gradle-plugin:5.11.+"
	...
 }

In your app level build.gradle:

apply plugin: 'newrelic'


dependencies {
	...
	compile project(":react-native-newrelic")
	compile fileTree(dir: "node_modules/react-native-newrelic/android/libs", include: ["*.jar"])
	...
}

Add new RNNewRelicPackage() to your list of packages in getPackages() in MainApplication.java :

@Override
public List<ReactPackage> getPackages() {
  return Arrays.<ReactPackage>asList(... new RNNewRelicPackage());
}

Configuration

Add the following to your app root (e.g. app.ios.js ):

import {default as newRelic} from 'react-native-newrelic';
newRelic.init({
  overrideConsole: true,
  reportUncaughtExceptions: true,
    globalAttributes: {
      'this-string': 'will be sent with every event that is being reported'
    }
});

Credits to @DanielZlotin for the initial version