gatsby-plugin-newrelic 2.2.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -39
- package/docs/CHANGELOG.md +7 -0
- package/gatsby/on-render-body.js +9 -12
- package/package.json +1 -1
- package/src/gatsby/on-render-body.js +10 -12
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[](https://github.com/newrelic/open-source-office/blob/master/examples/categories/index.md#community-project)
|
|
2
2
|
|
|
3
3
|
# New Relic Gatsby Plugin
|
|
4
|
+
|
|
4
5
|
[![Known Vulnerabilities][3]][4]
|
|
5
6
|
[![npm status badge][1]][2]
|
|
6
7
|
|
|
@@ -27,32 +28,11 @@ The New Relic Gatsby Plugin provides a simple to use configuration option for in
|
|
|
27
28
|
|
|
28
29
|
and turn it into a `gatsby-config`, adding it to `gatsby-config.js` as a plugin
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
```js
|
|
31
32
|
{
|
|
32
33
|
resolve: 'gatsby-plugin-newrelic',
|
|
33
34
|
options: {
|
|
34
|
-
|
|
35
|
-
dev: {
|
|
36
|
-
instrumentationType: 'proAndSPA',
|
|
37
|
-
accountId: '<some integer>',
|
|
38
|
-
trustKey: '<some integer>',
|
|
39
|
-
agentID: '<some integer>',
|
|
40
|
-
licenseKey: '<the license key>',
|
|
41
|
-
applicationID: '<some integer>',
|
|
42
|
-
beacon: 'bam.nr-data.net',
|
|
43
|
-
errorBeacon: 'bam.nr-data.net'
|
|
44
|
-
},
|
|
45
|
-
staging: {
|
|
46
|
-
instrumentationType: 'proAndSPA',
|
|
47
|
-
accountId: '<some integer>',
|
|
48
|
-
trustKey: '<some integer>',
|
|
49
|
-
agentID: '<some integer>',
|
|
50
|
-
licenseKey: '<the license key>',
|
|
51
|
-
applicationID: '<some integer>',
|
|
52
|
-
beacon: 'bam.nr-data.net',
|
|
53
|
-
errorBeacon: 'bam.nr-data.net'
|
|
54
|
-
},
|
|
55
|
-
production: {
|
|
35
|
+
config: {
|
|
56
36
|
instrumentationType: 'proAndSPA',
|
|
57
37
|
accountId: '<some integer>',
|
|
58
38
|
trustKey: '<some integer>',
|
|
@@ -61,25 +41,24 @@ The New Relic Gatsby Plugin provides a simple to use configuration option for in
|
|
|
61
41
|
applicationID: '<some integer>',
|
|
62
42
|
beacon: 'bam.nr-data.net',
|
|
63
43
|
errorBeacon: 'bam.nr-data.net'
|
|
64
|
-
}
|
|
65
44
|
}
|
|
66
45
|
}
|
|
67
46
|
}
|
|
68
47
|
```
|
|
69
48
|
|
|
70
|
-
If you have
|
|
49
|
+
If you have a need for multiple environments, you can configure this like:
|
|
71
50
|
|
|
72
51
|
```js
|
|
73
52
|
{
|
|
74
53
|
resolve: 'gatsby-plugin-newrelic',
|
|
75
54
|
options: {
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
config: {
|
|
56
|
+
instrumentationType: 'proAndSPA',
|
|
78
57
|
accountId: '<some integer>',
|
|
79
58
|
trustKey: '<some integer>',
|
|
80
59
|
agentID: '<some integer>',
|
|
81
60
|
licenseKey: '<the license key>',
|
|
82
|
-
applicationID: '<some integer>',
|
|
61
|
+
applicationID: process.env.YOUR_ENVIRONMENT_KEY === "production" ? '<some integer>' : '<some other integer>',
|
|
83
62
|
beacon: 'bam.nr-data.net',
|
|
84
63
|
errorBeacon: 'bam.nr-data.net'
|
|
85
64
|
}
|
|
@@ -87,17 +66,6 @@ The New Relic Gatsby Plugin provides a simple to use configuration option for in
|
|
|
87
66
|
}
|
|
88
67
|
```
|
|
89
68
|
|
|
90
|
-
|
|
91
|
-
1. Set the `GATSBY_NEWRELIC_ENV` to point at the appropriate config. For local dev you would add `GATSBY_NEWRELIC_ENV=dev` to the front of your "develop" script in your project's `package.json`. For "production" you would add `GATSBY_NEWRELIC_ENV=production` to the front of the Gatsby "build" command.
|
|
92
|
-
Ex. `package.json`:
|
|
93
|
-
|
|
94
|
-
```js
|
|
95
|
-
"scripts": {
|
|
96
|
-
"build": "GATSBY_NEWRELIC_ENV=production gatsby build",
|
|
97
|
-
"build:dev": "GATSBY_NEWRELIC_ENV=dev npm run build",
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
69
|
## Getting Started
|
|
102
70
|
|
|
103
71
|
Navigate to [https://one.newrelic.com](https://one.newrelic.com), select the _Entity Explorer_ and then select your browser application to monitor metrics of your site.
|
package/docs/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.2.1](https://github.com/newrelic/gatsby-plugin-newrelic/compare/v2.2.0...v2.2.1) (2022-02-08)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* bumps release ([c33fc1b](https://github.com/newrelic/gatsby-plugin-newrelic/commit/c33fc1b490f0ed45ff079f695cd4d0e784bfc810))
|
|
7
|
+
|
|
1
8
|
# [2.2.0](https://github.com/newrelic/gatsby-plugin-newrelic/compare/v2.1.1...v2.2.0) (2022-01-14)
|
|
2
9
|
|
|
3
10
|
|
package/gatsby/on-render-body.js
CHANGED
|
@@ -13,8 +13,9 @@ var _latest = require("../browser-agents/latest");
|
|
|
13
13
|
|
|
14
14
|
var _default = function _default(_ref, pluginOptions) {
|
|
15
15
|
var setHeadComponents = _ref.setHeadComponents;
|
|
16
|
-
var userConfigs = pluginOptions.configs
|
|
17
|
-
|
|
16
|
+
var userConfigs = pluginOptions.configs,
|
|
17
|
+
userConfig = pluginOptions.config;
|
|
18
|
+
var requiredConfig = {
|
|
18
19
|
accountId: '',
|
|
19
20
|
trustKey: '',
|
|
20
21
|
agentID: '',
|
|
@@ -26,19 +27,15 @@ var _default = function _default(_ref, pluginOptions) {
|
|
|
26
27
|
|
|
27
28
|
};
|
|
28
29
|
var env = process.env.GATSBY_NEWRELIC_ENV;
|
|
30
|
+
var userEnvConfig = env ? userConfigs[env] : userConfig;
|
|
29
31
|
|
|
30
|
-
if (!
|
|
31
|
-
|
|
32
|
-
console.warn('GATSBY_NEWRELIC_ENV env variable is not set');
|
|
32
|
+
if (!userEnvConfig) {
|
|
33
|
+
console.warn("gatsby-plugin-newrelic is missing the configuration" + (env ? " for the " + env + " environment" : ''));
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (!userEnvConfig) {
|
|
39
|
-
// TO DO - Error/Warn about missing config option for a given env
|
|
40
|
-
console.warn('gatsby-plugin-newrelic is missing the configuration for the ' + env + ' environment');
|
|
41
|
-
return;
|
|
37
|
+
if (env) {
|
|
38
|
+
console.warn('gatsby-plugin-newrelic has deprecated using GATSBY_NEWRELIC_ENV for multiple environments');
|
|
42
39
|
}
|
|
43
40
|
|
|
44
41
|
var allowedInstrumentationTypes = ['lite', 'pro', 'proAndSPA'];
|
|
@@ -49,7 +46,7 @@ var _default = function _default(_ref, pluginOptions) {
|
|
|
49
46
|
if (!itExists) {// TO DO - Error/Warn about wrong instrumentation type
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
var options = (0, _extends2["default"])({},
|
|
49
|
+
var options = (0, _extends2["default"])({}, requiredConfig, userEnvConfig);
|
|
53
50
|
var instrumentationType = options.instrumentationType;
|
|
54
51
|
var emptyOptions = Object.entries(options).filter(function (_ref2) {
|
|
55
52
|
var v = _ref2[1];
|
package/package.json
CHANGED
|
@@ -3,10 +3,11 @@ import { liteAgent, proAgent, proAndSpaAgent } from '../browser-agents/latest';
|
|
|
3
3
|
|
|
4
4
|
export default ({ setHeadComponents }, pluginOptions) => {
|
|
5
5
|
const {
|
|
6
|
-
configs: userConfigs
|
|
6
|
+
configs: userConfigs,
|
|
7
|
+
config: userConfig
|
|
7
8
|
} = pluginOptions;
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const requiredConfig = {
|
|
10
11
|
accountId: '',
|
|
11
12
|
trustKey: '',
|
|
12
13
|
agentID: '',
|
|
@@ -19,17 +20,14 @@ export default ({ setHeadComponents }, pluginOptions) => {
|
|
|
19
20
|
|
|
20
21
|
const env = process.env.GATSBY_NEWRELIC_ENV;
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
console.warn(
|
|
23
|
+
const userEnvConfig = env ? userConfigs[env] : userConfig;
|
|
24
|
+
if (!userEnvConfig) {
|
|
25
|
+
console.warn(`gatsby-plugin-newrelic is missing the configuration${env ? ` for the ${env} environment` : ''}`);
|
|
25
26
|
return;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// TO DO - Error/Warn about missing config option for a given env
|
|
31
|
-
console.warn('gatsby-plugin-newrelic is missing the configuration for the ' + env + ' environment');
|
|
32
|
-
return;
|
|
29
|
+
if (env) {
|
|
30
|
+
console.warn('gatsby-plugin-newrelic has deprecated using GATSBY_NEWRELIC_ENV for multiple environments');
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
const allowedInstrumentationTypes = ['lite', 'pro', 'proAndSPA'];
|
|
@@ -40,7 +38,7 @@ export default ({ setHeadComponents }, pluginOptions) => {
|
|
|
40
38
|
// TO DO - Error/Warn about wrong instrumentation type
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
const options = { ...
|
|
41
|
+
const options = { ...requiredConfig, ...userEnvConfig };
|
|
44
42
|
const instrumentationType = options.instrumentationType;
|
|
45
43
|
|
|
46
44
|
const emptyOptions = Object.entries(options).filter(([, v]) => v === '');
|
|
@@ -66,7 +64,7 @@ export default ({ setHeadComponents }, pluginOptions) => {
|
|
|
66
64
|
;NREUM.info={beacon:"${options.beacon}",errorBeacon:"${options.errorBeacon}",licenseKey:"${options.licenseKey}",applicationID:"${options.applicationID}",sa:1}
|
|
67
65
|
`;
|
|
68
66
|
|
|
69
|
-
if (agent && configs) {
|
|
67
|
+
if (agent && configs) {
|
|
70
68
|
setHeadComponents([
|
|
71
69
|
<script
|
|
72
70
|
key="gatsby-plugin-newrelic"
|