@creditas/new-relic-react-lib
Advanced tools
Comparing version 1.3.0 to 2.0.1
{ | ||
"name": "@creditas/new-relic-react-lib", | ||
"version": "1.3.0", | ||
"version": "2.0.1", | ||
"description": "React component for New Relic script", | ||
@@ -30,2 +30,3 @@ "author": "@creditas", | ||
"@babel/preset-env": "^7.5.5", | ||
"@testing-library/jest-dom": "^5.14.1", | ||
"@testing-library/react": "^11.2.7", | ||
@@ -32,0 +33,0 @@ "cross-env": "^5.2.1", |
@@ -12,6 +12,6 @@ # `@creditas/new-relic-react-lib` | ||
to instrument your app's webpages. The javascript provided in this library | ||
include all Pro and SPA features of | ||
include all **Pro and SPA features** of | ||
[new relic's browser agent](https://docs.newrelic.com/docs/browser/new-relic-browser/getting-started/introduction-new-relic-browser). | ||
It includes also [rollup.js](http://rollupjs.org/) to bundle source code as | ||
It also includes [rollup.js](http://rollupjs.org/) to bundle source code as | ||
React component. | ||
@@ -32,3 +32,6 @@ | ||
├── src # Source files | ||
│ ├── __tests__ # Test files | ||
│ │ └── index.test.js # Test cases for New Relic - React component | ||
│ ├── index.js # New Relic - React component source code | ||
│ ├── index.d.ts # Types for each accepted prop | ||
├── package.json # Package information with list of dependencies | ||
@@ -41,33 +44,40 @@ ├── LICENSE.md | ||
- licenseKey: String (required) | ||
- applicationID: String (required) | ||
- onlyConfig: Bool (optional) | ||
- Default: false | ||
- beacon: String (optional) | ||
- Default: 'bam.nr-data.net' | ||
- errorBeacon: String (optional) | ||
- Default: 'bam.nr-data.net' | ||
- sa: Number (optional) | ||
- Default: 1 | ||
- agent: String (optional) | ||
- Default: 'js-agent.newrelic.com/nr-1208.min.js' | ||
| Name | Type | Is Required | Default value | Notes | | ||
| ------------- | ------- | ----------- | ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | | ||
| accountID | String | `true` | - | (Recently Added) Different per environment (staging/prod). | | ||
| agentID | String | `true` | - | (Recently Added) Different per account and application. | | ||
| applicationID | String | `true` | - | - | | ||
| licenseKey | String | `true` | - | - | | ||
| agent | String | `false` | js-agent.newrelic.com/nr-spa-1210.min.js | - | | ||
| beacon | String | `false` | bam-cell.nr-data.net | (Recently Updated) With the new script version, the default domain value was changed from `bam.nr-data.net` to `bam-cell.nr-data.net`. | | ||
| errorBeacon | String | `false` | bam-cell.nr-data.net | (Recently Updated) With the new script version, the default domain value was changed from `bam.nr-data.net` to `bam-cell.nr-data.net`. | | ||
| onlyConfig | Boolean | `false` | `false` | Defines if it will return a component or only the script of New Relic. | | ||
| sa | Number | `false` | 1 | - | | ||
| trustKey | String | `false` | 735288 | (Recently Added) It does not change accross different envs/applications. | | ||
## Usage | ||
Just import `NewRelic` into your component | ||
### Retrieving information | ||
Retrieve this information from your New Relic account | ||
1. Go to [one.newrelic.com](one.newrelic.com) > Browser > (select an app) > | ||
Settings > Application settings. | ||
2. Retrieve this information from your New Relic account inside the "Agent and | ||
account" script: | ||
- `accountID`: Current New Relic account ID | ||
- `agentID`: Current New Relic agent ID | ||
- `licenseKey`: New Relic account license key | ||
- `applicationID`: Current New Relic application ID | ||
- licenseKey: New Relic account license key | ||
- applicationID: Current New Relic application ID | ||
### Using the component | ||
`<NewRelic licenseKey="{licenseKey}" applicationID="{applicationID}" onlyConfig />` | ||
where licenseKey and applicationID are real IDs you retrieved and onlyConfig | ||
defines if it will return a component or only the script of New Relic. | ||
Import `NewRelic` into your component and pass the information as props. | ||
Following code is a super simple example of integration | ||
> Make sure to change the `onlyConfig` prop if you want to get only the script | ||
> configuration, without the `<script />` tag. | ||
#### Example: using NewRelic component | ||
```jsx | ||
import React from 'react' | ||
import { NewRelic } from 'new-relic-agent-react' | ||
import { NewRelic } from '@creditas/new-relic-react-lib' | ||
@@ -81,3 +91,8 @@ const Html = () => { | ||
<meta httpEquiv="x-ua-compatible" content="ie=edge" /> | ||
<NewRelic licenseKey="xxxx" applicationID="yyyy" /> | ||
<NewRelic | ||
applicationID="www" | ||
licenseKey="xxx" | ||
agentID="yyy" | ||
accountID="zzz" | ||
/> | ||
<title>Web App</title> | ||
@@ -95,7 +110,7 @@ </head> | ||
or | ||
#### Example: using NewRelic component inside a `<script />` tag | ||
```jsx | ||
import React from 'react' | ||
import { NewRelic } from 'new-relic-agent-react' | ||
import { NewRelic } from '@creditas/new-relic-react-lib' | ||
@@ -110,3 +125,9 @@ const Html = () => { | ||
<script type="text/javascript"> | ||
<NewRelic licenseKey="xxxx" applicationID="yyyy" onlyConfig /> | ||
<NewRelic | ||
applicationID="www" | ||
licenseKey="xxx" | ||
agentID="yyy" | ||
accountID="zzz" | ||
onlyConfig | ||
/> | ||
</script> | ||
@@ -145,3 +166,3 @@ <title>Web App</title> | ||
Copyright (c) 2019 Creditas | ||
Copyright (c) 2021 Creditas | ||
@@ -152,2 +173,2 @@ MIT - http://opensource.org/licenses/mit-license.php | ||
based on https://github.com/wanderio/new-relic-react | ||
Based on https://github.com/wanderio/new-relic-react |
29608
167
12