Giter VIP home page Giter VIP logo

ember-new-relic's Introduction

Ember New Relic Build Status npm

This Ember addon adds New Relic Browser to your app. All PRs and issues are welcome.

Installation

ember install ember-new-relic

Usage

Basic Usage

Add your applicationId and licenseKey to config/environment.js:

/* config/environment.js */

module.exports = function(environment) {
  environment === 'development';

  var ENV = {
    newRelic: {
      applicationId: '97bfuo3FFd3',
      licenseKey: 'ef234SgE4'
    }
  };
}

Configuration

You might also want to specify your agent, beacon, or other properties:

/* config/environment.js */

module.exports = function(environment) {
  environment === 'development';

  var ENV = {
    newRelic: {
      agent: 'js-agent.newrelic.com/nr-1016.min.js',
      applicationId: '97bfuo3FFd3',
      beacon: 'bam.nr-data.net',
      errorBeacon: 'bam.nr-data.net',
      licenseKey: 'ef234SgE4',
      spaMonitoring: true,
      sa: 1,
    }
  };
}

Value and descriptions for all of the above can be found in your New Relic Browser's application settings.

It is likely you will only have to set applicationId, licenseKey, and agent to match your New Relic code snippet.

SPA Monitoring

New Relic released SPA Monitoring on July 12th 2016. By default, this addon does not use SPA Monitoring.

If you want to use New Relic SPA Monitoring, you must enable spaMonitoring in your configuration as follows:

/* config/environment.js */

module.exports = function(environment) {
  environment === 'development';

  var ENV = {
    newRelic: {
      spaMonitoring: true,
    }
  };
}

This will replace the default New Relic code snippet with the New Relic SPA code snippet.

Environments

To enable New Relic Browser in certain environments, just include applicationId for those environments only:

/* config/environment.js */

module.exports = function(environment) {
  environment === 'development';

  var ENV = {
    newRelic: {
      licenseKey: 'ef234SgE4'
    }
  };

  if (environment !== test) {
    ENV.newRelic.applicationId = '97bfuo3FFd3';
  }
}

You can also use different application IDs for different environments:

/* config/environment.js */

module.exports = function(environment) {
  environment === 'development';

  var ENV = {
    newRelic: {
      licenseKey: 'ef234SgE4'
    }
  };

  if (environment === 'development') {
    ENV.newRelic.applicationId = '97bfuo3FFd3';
  } else if (environment === 'production') {
    ENV.newRelic.applicationId = 'f99FJ930sp';
  }
}

Manual Script Loading

By default the New Relic code snippet is imported into vendor.js.

If you want to manually import the snippet from an external JS file, configure ember-cli-build.js with ember-new-relic options as follows:

/* ember-cli-build.js */
module.exports = function(defaults) {
    var app = new EmberApp(defaults, {
      'ember-new-relic': {
        importToVendor: false
      }
    });

    return app.toTree();
};

Prepare your app/index.html with the New Relic script, placed above the vendor.js script as follows:

<script src="new-relic.js"></script>
<script src="assets/vendor.js"></script>

Change the Script Path

The New Relic code's default output path is new-relic.js, accessible at the root of the output folder.

If you want to change the output path, configure ember-cli-build.js with ember-new-relic options as follows:

/* ember-cli-build.js */
module.exports = function(defaults) {
    var app = new EmberApp(defaults, {
      'ember-new-relic': {
        outputPath: 'assets/new-relic.js'
      }
    });

    return app.toTree();
};

When used in conjunction with importToVendor disabled, remember to update the path in app/index.html.

Content Security Policy

To avoid browser errors, add the following to your CSP:

/* config/environment.js */

module.exports = function(environment) {
  environment === 'development';

  var ENV = {
    newRelic: {
      licenseKey: 'ef234SgE4',
      applicationId: '97bfuo3FFd3',
    },

    contentSecurityPolicy: {
      'connect-src': "'self' https://*.nr-data.net",
      'img-src': "'self' https://*.nr-data.net",
      'script-src': "'self' http://*.newrelic.com https://*.nr-data.net http://*.nr-data.net",
    },
  };
}

Development

Run the tests using ember test or by navigating to the /tests route in the browser.

Please accompany PRs for bugs and new functionality with test coverage.

ember-new-relic's People

Contributors

akatov avatar boubalou avatar carylee avatar ember-tomster avatar jasonmit avatar jeremy-w avatar jimmay5469 avatar miguelcobain avatar sir-dunxalot avatar taylon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ember-new-relic's Issues

RangeError: Maximum call stack size exceeded with Ember 3.1

I'm seeing a "RangeError: Maximum call stack size exceeded" in Chrome with Ember 3.1.

new-relic.js:1 Uncaught RangeError: Maximum call stack size exceeded
    at Function.[Symbol.hasInstance] (<anonymous>)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)
    at r.getCtx.e.getCtx (new-relic.js:1)

Co-maintainer wanted

I am looking for a co-maintainer to help keep this addon up-to-date because I do not currently use New Relic for any products. Let me know if you're interested!

Current State of Maintainence

Is this addon being actively maintained?

If not, would you be willing to open up the scope of ownership to a few people? @jasonmit and I have been working on his fork, where we got things working again and made a bunch of clean-up improvements. I would love to upstream these changes, but there hasn't been any activity on this repo in the last year.

We'd love to take over support!

Replacing Ember.Logger

Seeing that in ember 4.0 the plan is to remove ember logger, we need another solution to globally listen for errors

Load New Relic script from external file

In the context of CSP, inline-unsafe is... unsafe. To make an app safer, a sha hash generated from the script can be placed into CSP, or the script can be loaded from an external JS file.

Getting error on 1044 NR script

    at Object.r [as mark] (nr-1044.min.js:1)
    at Object.t.10 (nr-1044.min.js:1)
    at r (nr-1044.min.js:1)
    at t.1 (nr-1044.min.js:1)
    at nr-1044.min.js:1```

loader.now is not a function

I created a brand new 2.16 Ember app, installed the addon, and I get the following error:

screenshot 2017-11-07 10 44 07

Here is the relevant section in my environment.js file:

  let ENV = {
    newRelic: {
      agent: 'js-agent.newrelic.com/nr-1044.js',
      licenseKey: 'my-key-here',
      applicationId: 'my-app-id-here',
      spaMonitoring: true
    }
  // ...
};

I did change the agent so that it is not the minified version so that I could see a better error message. I tried the minified version too and it produced the same error, but more cryptic.

message argument gets lost in Ember.Logger.error

in /instance-initializers/new-relic.js, Ember.Logger.error gets reassigned to a new function. message, cause, stack are passed in, but only cause and stack are used. Unless I'm missing something, message would never get used.

According to the Ember docs, Ember.Logger.error is supposed to be called with just one argument, for the message.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.