From 7ee58d8b51815c1ef163ef4b7a77811a0cb228db Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Wed, 7 Sep 2022 12:56:03 -0400 Subject: [PATCH 1/5] updated example of injecting browser agent --- README.md | 91 ++++++++++++++++++++--------------- docs/inject-browser-agent.md | 93 ++++++++++++++++++++---------------- 2 files changed, 104 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 69c8dbf..0640455 100644 --- a/README.md +++ b/README.md @@ -52,47 +52,60 @@ Our [API and developer documentation](http://newrelic.github.io/node-newrelic/do Next.js is a full stack React Framework. This module augments the Node.js New Relic agent, thus any client-side actions will not be instrumented. However, below is a method of adding the [New Relic Browser agent](https://docs.newrelic.com/docs/browser/browser-monitoring/getting-started/introduction-browser-monitoring/) to get more information on client-side actions. -```js -import Head from 'next/head' -import Layout, { siteTitle } from '../../components/layout' -import utilStyles from '../../styles/utils.module.css' -import Link from 'next/link' - - -export async function getServerSideProps() { - // You must require agent and put it within this function - // otherwise it will try to get bundled by webpack and cause errors. - const newrelic = require('newrelic') - const browserTimingHeader = newrelic.getBrowserTimingHeader() - return { - props: { - browserTimingHeader - } - } +The most appropriate approach would be to follow the [beforeInteractive strategy](https://nextjs.org/docs/basic-features/script#beforeinteractive). Put the following in your `pages/_document.ts` + +```ts +const newrelic = require('newrelic'); +import Document, { + DocumentContext, + DocumentInitialProps, + Html, + Head, + Main, + NextScript, +} from 'next/document'; +import Script from 'next/script'; + +type DocumentProps = { + browserTimingHeader: string } -export default function Home({ browserTimingHeader }) { - return ( - - - {siteTitle} - -
-
-

It me

-

- This page uses server-side rendering and uses the newrelic API to inject - timing headers. -

-
- - ← Back to home - -
-
- - ) +class MyDocument extends Document { + static async getInitialProps( + ctx: DocumentContext + ): Promise { + const initialProps = await Document.getInitialProps(ctx); + + const browserTimingHeader = newrelic.getBrowserTimingHeader({ + hasToRemoveScriptWrapper: true, + }); + + return { + ...initialProps, + browserTimingHeader, + }; + } + + render() { + const { browserTimingScript } = this.props + + return ( + + {/* whatever you need here */} + +
+ + + + + ); + } } + +export default MyDocument; ``` For static compiled pages, you can use the [copy-paste method](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#copy-paste-app) for enabling the New Relic Browser agent. @@ -131,7 +144,7 @@ Error.getInitialProps = ({ res, err }) => { export default Error; ``` -The example above assumes that both the New Relic Browser and Node.js agents are integrated. `getInitialProps` function's `if` statement checks whether an error was thrown on the server side (`typeof window === "undefined"`) and if it was the case, it `requires` New Relic Node.js agent and sends an `err` with `noticeError` method. Otherwise it assumes the error was thrown on the front-end side, and uses the browser agent to send the error to New Relic by using `window.newrelic.noticeError(err)`. +The example above assumes that both the New Relic Browser and Node.js agents are [integrated](#client-side-instrumentation). `getInitialProps` function's `if` statement checks whether an error was thrown on the server side (`typeof window === "undefined"`) and if it was the case, it `requires` New Relic Node.js agent and sends an `err` with `noticeError` method. Otherwise it assumes the error was thrown on the front-end side, and uses the browser agent to send the error to New Relic by using `window.newrelic.noticeError(err)`. ## Testing diff --git a/docs/inject-browser-agent.md b/docs/inject-browser-agent.md index 5e5feae..8e157c9 100644 --- a/docs/inject-browser-agent.md +++ b/docs/inject-browser-agent.md @@ -2,49 +2,60 @@ **Note**: You must [install the New Relic browser agent](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/) in your account first before injecting it into a Next.js. -The process of setting up the browser agent on a Next.js requires a few lines of code. Below is an example component that injects the browser agent with a `getServerSideProps` call. - -```js -import Head from 'next/head' -import Layout, { siteTitle } from '../../components/layout' -import utilStyles from '../../styles/utils.module.css' -import Link from 'next/link' - - -export async function getServerSideProps() { - // You must require agent and put it within this function - // otherwise it will try to get bundled by webpack and cause errors. - const newrelic = require('newrelic') - const browserTimingHeader = newrelic.getBrowserTimingHeader() - return { - props: { - browserTimingHeader - } - } +The most appropriate approach would be to follow the [beforeInteractive strategy](https://nextjs.org/docs/basic-features/script#beforeinteractive). Put the following in your `pages/_document.ts` + +```ts +const newrelic = require('newrelic'); +import Document, { + DocumentContext, + DocumentInitialProps, + Html, + Head, + Main, + NextScript, +} from 'next/document'; +import Script from 'next/script'; + +type DocumentProps = { + browserTimingHeader: string } -export default function Home({ browserTimingHeader }) { - return ( - - - {siteTitle} - -
-
-

It me

-

- This page uses server-side rendering and uses the newrelic API to inject - timing headers. -

- -
- - ) +class MyDocument extends Document { + static async getInitialProps( + ctx: DocumentContext + ): Promise { + const initialProps = await Document.getInitialProps(ctx); + + const browserTimingHeader = newrelic.getBrowserTimingHeader({ + hasToRemoveScriptWrapper: true, + }); + + return { + ...initialProps, + browserTimingHeader, + }; + } + + render() { + const { browserTimingScript } = this.props + + return ( + + {/* whatever you need here */} + +
+ + + + + ); + } } + +export default MyDocument; ``` -For static compiled pages, you can use the [copy-paste method](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#copy-paste-app) for enabling the New Relic browser agent. +**Note**: For static compiled pages, you can use the [copy-paste method](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/#copy-paste-app) for enabling the New Relic browser agent. From 106afffc557476eb5adbf079555a0b72e7ba1c40 Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Wed, 7 Sep 2022 14:18:04 -0400 Subject: [PATCH 2/5] fix variable name that was incorrect --- README.md | 2 +- docs/inject-browser-agent.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0640455..3efc148 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ class MyDocument extends Document { } render() { - const { browserTimingScript } = this.props + const { browserTimingHeader } = this.props return ( diff --git a/docs/inject-browser-agent.md b/docs/inject-browser-agent.md index 8e157c9..59137f9 100644 --- a/docs/inject-browser-agent.md +++ b/docs/inject-browser-agent.md @@ -37,7 +37,7 @@ class MyDocument extends Document { } render() { - const { browserTimingScript } = this.props + const { browserTimingHeader } = this.props return ( From e3f1e3c5e31937ecf3905a29f374f8c3cb79c942 Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Wed, 7 Sep 2022 16:26:06 -0400 Subject: [PATCH 3/5] updated example project to use browser agent snippet. also updated readme to reference the test app --- README.md | 33 ++ THIRD_PARTY_NOTICES.md | 2 +- package-lock.json | 123 +++-- package.json | 2 +- tests/versioned/app/pages/_document.js | 46 ++ tests/versioned/package-lock.json | 629 +++++++++++++++++++++++++ third_party_manifest.json | 12 +- 7 files changed, 774 insertions(+), 73 deletions(-) create mode 100644 tests/versioned/app/pages/_document.js create mode 100644 tests/versioned/package-lock.json diff --git a/README.md b/README.md index 3efc148..04c85be 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,39 @@ npm run unit npm run versioned ``` +## Example project + +The versioned tests referenced above use an example project that lives within `test/versioned/app`. It also contains a component that gets injected to connect the Browser and Node.js agent. + +### Build example project + +```sh +npm i +cd tests/versioned +npx next build app +``` + +### Test example project +**Note**: You must have a New Relic account setup with license key. Also you need to configure the [browser agent](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/). + +The following command will start the example app and load the New Relic Next.js plugin. + +```sh +NEW_RELIC_APP_NAME=my-next-example NEW_RELIC_LICENSE_KEY= NODE_OPTIONS='-r ../../index' npx next start app +``` + +You can now explore the app and see transactions, segments/spans, and browser events occurring. Here are a few URLs to request to get a good sampling of data: + +```sh +curl http://localhost:3000/ssr/people +curl http://localhost:3000/ssr/dynamic/person/2 +curl http://localhost:3000/person/1 +curl http://127.0.0.1:3000/person/1 +curl http://localhost:3000/invalid/page +curl http://localhost:3000/api/hello +curl http://localhost:3000/static/standard +``` + ## Support New Relic hosts and moderates an online forum where you can interact with New Relic employees as well as other customers to get help and share best practices. Like all official New Relic open source projects, there's a related community topic in the New Relic Explorers Hub. You can find this project's topic/threads here: diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md index 89dc4ff..aa1a14a 100644 --- a/THIRD_PARTY_NOTICES.md +++ b/THIRD_PARTY_NOTICES.md @@ -742,7 +742,7 @@ SOFTWARE. ### newrelic -This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v8.13.0](https://github.com/newrelic/node-newrelic/tree/v8.13.0)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v8.13.0/LICENSE): +This product includes source derived from [newrelic](https://github.com/newrelic/node-newrelic) ([v9.0.3](https://github.com/newrelic/node-newrelic/tree/v9.0.3)), distributed under the [Apache-2.0 License](https://github.com/newrelic/node-newrelic/blob/v9.0.3/LICENSE): ``` Apache License diff --git a/package-lock.json b/package-lock.json index 7d9ae40..f53772c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "@newrelic/test-utilities": "^6.5.3", "husky": "^8.0.1", "lint-staged": "^12.4.2", - "newrelic": "^8.13.0", + "newrelic": "^9.0.3", "sinon": "^14.0.0", "tap": "^16.2.0" }, @@ -448,15 +448,15 @@ } }, "node_modules/@grpc/proto-loader": { - "version": "0.6.12", - "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.12.tgz", - "integrity": "sha512-filTVbETFnxb9CyRX98zN18ilChTuf/C5scZ2xyaOTp0EHGq0/ufX8rjqXUcSb1Gpv7eZq4M2jDvbh9BogKnrg==", + "version": "0.6.13", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.13.tgz", + "integrity": "sha512-FjxPYDRTn6Ec3V0arm1FtSpmP6V50wuph2yILpyvTKzjc76oDdoihXqM1DzOW5ubvCC8GivfCnNtfaRE8myJ7g==", "dev": true, "dependencies": { "@types/long": "^4.0.1", "lodash.camelcase": "^4.3.0", "long": "^4.0.0", - "protobufjs": "^6.10.0", + "protobufjs": "^6.11.3", "yargs": "^16.2.0" }, "bin": { @@ -584,18 +584,15 @@ } }, "node_modules/@newrelic/aws-sdk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@newrelic/aws-sdk/-/aws-sdk-4.1.1.tgz", - "integrity": "sha512-HojNFnxf8psbpf7hlQmIeDR6d8pWYU1ZQR3lpDJtecFZYX5/LKIKRayuunw9ORCjIcf6MZNTnhmdhdeGb7LKrw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/aws-sdk/-/aws-sdk-5.0.0.tgz", + "integrity": "sha512-0aW1/c2m0tcX+lP0fw/cA0hctviLUo18uWsX1pwar7KAAciHBiiS/ytRyZdN78pbZi/9A25CmKB0YFx3Ct+RDg==", "dev": true, - "dependencies": { - "semver": "^7.3.5" - }, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" }, "peerDependencies": { - "newrelic": ">=6.11.0" + "newrelic": ">=8.7.0" } }, "node_modules/@newrelic/eslint-config": { @@ -616,31 +613,31 @@ } }, "node_modules/@newrelic/koa": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/@newrelic/koa/-/koa-6.1.1.tgz", - "integrity": "sha512-vWwMMuaU5qDualtIPYssrIcjA4Jfq2qWJ5LZ4VJL/BNU/xvFmKBNTdJU9UeKd7S2VAwXHqczEdPVcestdg5x/A==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/koa/-/koa-7.0.0.tgz", + "integrity": "sha512-kjH2w2Nutpl+gwTYSybiM3Y8gcoxbaCt8l9WUylPDjOVXtIdG2d8XCMNr/cN8GDDUjXDNqvlQVZteelSRrOLDA==", "dev": true, "engines": { - "node": ">=12.0.0" + "node": ">=14.0.0" }, "peerDependencies": { "newrelic": ">=6.11.0" } }, "node_modules/@newrelic/native-metrics": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@newrelic/native-metrics/-/native-metrics-8.0.0.tgz", - "integrity": "sha512-df/V1P6dxpX09PaA6Jx9pmkPbRrue5hDyRCc4w3bnqMbnybvwVwS+q1/QEPvjBPQJ5abTRlBcJ7UZ3sfGW1hzg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/native-metrics/-/native-metrics-9.0.0.tgz", + "integrity": "sha512-WYDRs4hlFerUyism2TjF1PIJfP8w50Nc9Kt61zWNrGM3QYOrKXZ5ibA3R0fQgU0+LM7UWtQ9g7onFpVUGsj8QQ==", "dev": true, "hasInstallScript": true, "optional": true, "dependencies": { "https-proxy-agent": "^5.0.0", - "nan": "^2.15.0", + "nan": "^2.16.0", "semver": "^5.5.1" }, "engines": { - "node": ">=12", + "node": ">=14", "npm": ">=6" } }, @@ -697,12 +694,12 @@ } }, "node_modules/@newrelic/superagent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@newrelic/superagent/-/superagent-5.1.0.tgz", - "integrity": "sha512-2akEsdymaDlV3GEReNTXaSbweaOJNuazrw+C/MhiogdBk97PCs6+MgIVxR+o/i+eftOVyGd3f+3lubqNm3/0Nw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/superagent/-/superagent-6.0.0.tgz", + "integrity": "sha512-5nClQp9ACd4BvLusAgFHjjKLDgAaC+dKmIsRNOPC82LOLFaoOgxxtbecnDIJ0NWCKQS+WOdmXdgYutwH+e5dsA==", "dev": true, "engines": { - "node": ">=12.0" + "node": ">=14.0" }, "peerDependencies": { "newrelic": ">=6.11.0" @@ -6228,18 +6225,17 @@ } }, "node_modules/newrelic": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/newrelic/-/newrelic-8.13.0.tgz", - "integrity": "sha512-nWthu+uhAl3S0Ia8DSBuiv3feEunSJM2soJP/JZ1xPwbwrTH9E7Vp1mOAykWfCqgup0NKUS83NSFlJutx2yHUg==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/newrelic/-/newrelic-9.0.3.tgz", + "integrity": "sha512-PGmEWBm0VgScTagcOYJWl/wM3ny5VhbB6T+1wfeRvgSt8yMKBFXPNspp0RwKEzkU6Q9jf7aevjPzD8nNnDxCpg==", "dev": true, "dependencies": { "@grpc/grpc-js": "^1.5.5", - "@grpc/proto-loader": "^0.6.12", - "@newrelic/aws-sdk": "^4.1.1", - "@newrelic/koa": "^6.1.1", - "@newrelic/superagent": "^5.1.0", + "@grpc/proto-loader": "^0.6.13", + "@newrelic/aws-sdk": "^5.0.0", + "@newrelic/koa": "^7.0.0", + "@newrelic/superagent": "^6.0.0", "@tyriar/fibonacci-heap": "^2.0.7", - "async": "^3.2.3", "concat-stream": "^2.0.0", "https-proxy-agent": "^5.0.0", "json-stringify-safe": "^5.0.0", @@ -6251,11 +6247,11 @@ "newrelic-naming-rules": "bin/test-naming-rules.js" }, "engines": { - "node": ">=12.0.0", + "node": ">=14", "npm": ">=6.0.0" }, "optionalDependencies": { - "@newrelic/native-metrics": "^8.0.0" + "@newrelic/native-metrics": "^9.0.0" } }, "node_modules/newrelic/node_modules/concat-stream": { @@ -10789,15 +10785,15 @@ } }, "@grpc/proto-loader": { - "version": "0.6.12", - "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.12.tgz", - "integrity": "sha512-filTVbETFnxb9CyRX98zN18ilChTuf/C5scZ2xyaOTp0EHGq0/ufX8rjqXUcSb1Gpv7eZq4M2jDvbh9BogKnrg==", + "version": "0.6.13", + "resolved": "https://registry.npmjs.org/@grpc/proto-loader/-/proto-loader-0.6.13.tgz", + "integrity": "sha512-FjxPYDRTn6Ec3V0arm1FtSpmP6V50wuph2yILpyvTKzjc76oDdoihXqM1DzOW5ubvCC8GivfCnNtfaRE8myJ7g==", "dev": true, "requires": { "@types/long": "^4.0.1", "lodash.camelcase": "^4.3.0", "long": "^4.0.0", - "protobufjs": "^6.10.0", + "protobufjs": "^6.11.3", "yargs": "^16.2.0" }, "dependencies": { @@ -10899,13 +10895,11 @@ } }, "@newrelic/aws-sdk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/@newrelic/aws-sdk/-/aws-sdk-4.1.1.tgz", - "integrity": "sha512-HojNFnxf8psbpf7hlQmIeDR6d8pWYU1ZQR3lpDJtecFZYX5/LKIKRayuunw9ORCjIcf6MZNTnhmdhdeGb7LKrw==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/aws-sdk/-/aws-sdk-5.0.0.tgz", + "integrity": "sha512-0aW1/c2m0tcX+lP0fw/cA0hctviLUo18uWsX1pwar7KAAciHBiiS/ytRyZdN78pbZi/9A25CmKB0YFx3Ct+RDg==", "dev": true, - "requires": { - "semver": "^7.3.5" - } + "requires": {} }, "@newrelic/eslint-config": { "version": "0.0.4", @@ -10915,21 +10909,21 @@ "requires": {} }, "@newrelic/koa": { - "version": "6.1.1", - "resolved": "https://registry.npmjs.org/@newrelic/koa/-/koa-6.1.1.tgz", - "integrity": "sha512-vWwMMuaU5qDualtIPYssrIcjA4Jfq2qWJ5LZ4VJL/BNU/xvFmKBNTdJU9UeKd7S2VAwXHqczEdPVcestdg5x/A==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/koa/-/koa-7.0.0.tgz", + "integrity": "sha512-kjH2w2Nutpl+gwTYSybiM3Y8gcoxbaCt8l9WUylPDjOVXtIdG2d8XCMNr/cN8GDDUjXDNqvlQVZteelSRrOLDA==", "dev": true, "requires": {} }, "@newrelic/native-metrics": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@newrelic/native-metrics/-/native-metrics-8.0.0.tgz", - "integrity": "sha512-df/V1P6dxpX09PaA6Jx9pmkPbRrue5hDyRCc4w3bnqMbnybvwVwS+q1/QEPvjBPQJ5abTRlBcJ7UZ3sfGW1hzg==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/native-metrics/-/native-metrics-9.0.0.tgz", + "integrity": "sha512-WYDRs4hlFerUyism2TjF1PIJfP8w50Nc9Kt61zWNrGM3QYOrKXZ5ibA3R0fQgU0+LM7UWtQ9g7onFpVUGsj8QQ==", "dev": true, "optional": true, "requires": { "https-proxy-agent": "^5.0.0", - "nan": "^2.15.0", + "nan": "^2.16.0", "semver": "^5.5.1" }, "dependencies": { @@ -10976,9 +10970,9 @@ } }, "@newrelic/superagent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/@newrelic/superagent/-/superagent-5.1.0.tgz", - "integrity": "sha512-2akEsdymaDlV3GEReNTXaSbweaOJNuazrw+C/MhiogdBk97PCs6+MgIVxR+o/i+eftOVyGd3f+3lubqNm3/0Nw==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@newrelic/superagent/-/superagent-6.0.0.tgz", + "integrity": "sha512-5nClQp9ACd4BvLusAgFHjjKLDgAaC+dKmIsRNOPC82LOLFaoOgxxtbecnDIJ0NWCKQS+WOdmXdgYutwH+e5dsA==", "dev": true, "requires": {} }, @@ -15244,19 +15238,18 @@ "dev": true }, "newrelic": { - "version": "8.13.0", - "resolved": "https://registry.npmjs.org/newrelic/-/newrelic-8.13.0.tgz", - "integrity": "sha512-nWthu+uhAl3S0Ia8DSBuiv3feEunSJM2soJP/JZ1xPwbwrTH9E7Vp1mOAykWfCqgup0NKUS83NSFlJutx2yHUg==", + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/newrelic/-/newrelic-9.0.3.tgz", + "integrity": "sha512-PGmEWBm0VgScTagcOYJWl/wM3ny5VhbB6T+1wfeRvgSt8yMKBFXPNspp0RwKEzkU6Q9jf7aevjPzD8nNnDxCpg==", "dev": true, "requires": { "@grpc/grpc-js": "^1.5.5", - "@grpc/proto-loader": "^0.6.12", - "@newrelic/aws-sdk": "^4.1.1", - "@newrelic/koa": "^6.1.1", - "@newrelic/native-metrics": "^8.0.0", - "@newrelic/superagent": "^5.1.0", + "@grpc/proto-loader": "^0.6.13", + "@newrelic/aws-sdk": "^5.0.0", + "@newrelic/koa": "^7.0.0", + "@newrelic/native-metrics": "^9.0.0", + "@newrelic/superagent": "^6.0.0", "@tyriar/fibonacci-heap": "^2.0.7", - "async": "^3.2.3", "concat-stream": "^2.0.0", "https-proxy-agent": "^5.0.0", "json-stringify-safe": "^5.0.0", diff --git a/package.json b/package.json index f09df43..240d008 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "@newrelic/test-utilities": "^6.5.3", "husky": "^8.0.1", "lint-staged": "^12.4.2", - "newrelic": "^8.13.0", + "newrelic": "^9.0.3", "sinon": "^14.0.0", "tap": "^16.2.0" }, diff --git a/tests/versioned/app/pages/_document.js b/tests/versioned/app/pages/_document.js new file mode 100644 index 0000000..792a4de --- /dev/null +++ b/tests/versioned/app/pages/_document.js @@ -0,0 +1,46 @@ +const newrelic = require('newrelic'); +import Document, { + Html, + Head, + Main, + NextScript, +} from 'next/document'; +import Script from 'next/script'; + +class MyDocument extends Document { + static async getInitialProps( + ctx + ) { + const initialProps = await Document.getInitialProps(ctx); + + const browserTimingHeader = newrelic.getBrowserTimingHeader({ + hasToRemoveScriptWrapper: true, + }); + + return { + ...initialProps, + browserTimingHeader, + }; + } + + render() { + const { browserTimingHeader } = this.props + + return ( + + {/* whatever you need here */} + +
+ + + + + ); + } +} + +export default MyDocument; + diff --git a/tests/versioned/package-lock.json b/tests/versioned/package-lock.json new file mode 100644 index 0000000..7e8651b --- /dev/null +++ b/tests/versioned/package-lock.json @@ -0,0 +1,629 @@ +{ + "name": "nextjs-tests", + "version": "0.0.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "nextjs-tests", + "version": "0.0.0" + }, + "node_modules/@next/env": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/env/-/env-12.2.2.tgz", + "integrity": "sha512-BqDwE4gDl1F608TpnNxZqrCn6g48MBjvmWFEmeX5wEXDXh3IkAOw6ASKUgjT8H4OUePYFqghDFUss5ZhnbOUjw==" + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.2.2.tgz", + "integrity": "sha512-JCoGySHKGt+YBk7xRTFGx1QjrnCcwYxIo3yGepcOq64MoiocTM3yllQWeOAJU2/k9MH0+B5E9WUSme4rOCBbpA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@swc/helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.2.tgz", + "integrity": "sha512-556Az0VX7WR6UdoTn4htt/l3zPQ7bsQWK+HqdG4swV7beUCxo/BqmvbOpUkTIm/9ih86LIf1qsUnywNL3obGHw==", + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001361", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001361.tgz", + "integrity": "sha512-ybhCrjNtkFji1/Wto6SSJKkWk6kZgVQsDq5QI83SafsF6FXv2JB4df9eEdH6g8sdGgqTXrFLjAxqBGgYoU3azQ==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/next": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/next/-/next-12.2.2.tgz", + "integrity": "sha512-zAYFY45aBry/PlKONqtlloRFqU/We3zWYdn2NoGvDZkoYUYQSJC8WMcalS5C19MxbCZLUVCX7D7a6gTGgl2yLg==", + "dependencies": { + "@next/env": "12.2.2", + "@swc/helpers": "0.4.2", + "caniuse-lite": "^1.0.30001332", + "postcss": "8.4.5", + "styled-jsx": "5.0.2", + "use-sync-external-store": "1.1.0" + }, + "bin": { + "next": "dist/bin/next" + }, + "engines": { + "node": ">=12.22.0" + }, + "optionalDependencies": { + "@next/swc-android-arm-eabi": "12.2.2", + "@next/swc-android-arm64": "12.2.2", + "@next/swc-darwin-arm64": "12.2.2", + "@next/swc-darwin-x64": "12.2.2", + "@next/swc-freebsd-x64": "12.2.2", + "@next/swc-linux-arm-gnueabihf": "12.2.2", + "@next/swc-linux-arm64-gnu": "12.2.2", + "@next/swc-linux-arm64-musl": "12.2.2", + "@next/swc-linux-x64-gnu": "12.2.2", + "@next/swc-linux-x64-musl": "12.2.2", + "@next/swc-win32-arm64-msvc": "12.2.2", + "@next/swc-win32-ia32-msvc": "12.2.2", + "@next/swc-win32-x64-msvc": "12.2.2" + }, + "peerDependencies": { + "fibers": ">= 3.1.0", + "node-sass": "^6.0.0 || ^7.0.0", + "react": "^17.0.2 || ^18.0.0-0", + "react-dom": "^17.0.2 || ^18.0.0-0", + "sass": "^1.3.0" + }, + "peerDependenciesMeta": { + "fibers": { + "optional": true + }, + "node-sass": { + "optional": true + }, + "sass": { + "optional": true + } + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "node_modules/postcss": { + "version": "8.4.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.5.tgz", + "integrity": "sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==", + "dependencies": { + "nanoid": "^3.1.30", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + } + }, + "node_modules/react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", + "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "scheduler": "^0.20.2" + }, + "peerDependencies": { + "react": "17.0.2" + } + }, + "node_modules/scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "dependencies": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "node_modules/source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/styled-jsx": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.2.tgz", + "integrity": "sha512-LqPQrbBh3egD57NBcHET4qcgshPks+yblyhPlH2GY8oaDgKs8SK4C3dBh3oSJjgzJ3G5t1SYEZGHkP+QEpX9EQ==", + "engines": { + "node": ">= 12.0.0" + }, + "peerDependencies": { + "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "babel-plugin-macros": { + "optional": true + } + } + }, + "node_modules/tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" + }, + "node_modules/use-sync-external-store": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.1.0.tgz", + "integrity": "sha512-SEnieB2FPKEVne66NpXPd1Np4R1lTNKfjuy3XdIoPQKYBAFdzbzSZlSn1KJZUiihQLQC5Znot4SBz1EOTBwQAQ==", + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0" + } + }, + "node_modules/@next/swc-android-arm-eabi": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.2.2.tgz", + "integrity": "sha512-VHjuCHeq9qCprUZbsRxxM/VqSW8MmsUtqB5nEpGEgUNnQi/BTm/2aK8tl7R4D0twGKRh6g1AAeFuWtXzk9Z/vQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-android-arm64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.2.2.tgz", + "integrity": "sha512-v5EYzXUOSv0r9mO/2PX6mOcF53k8ndlu9yeFHVAWW1Dhw2jaJcvTRcCAwYYN8Q3tDg0nH3NbEltJDLKmcJOuVA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.2.2.tgz", + "integrity": "sha512-dztDtvfkhUqiqpXvrWVccfGhLe44yQ5tQ7B4tBfnsOR6vxzI9DNPHTlEOgRN9qDqTAcFyPxvg86mn4l8bB9Jcw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-freebsd-x64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-12.2.2.tgz", + "integrity": "sha512-JUnXB+2xfxqsAvhFLPJpU1NeyDsvJrKoOjpV7g3Dxbno2Riu4tDKn3kKF886yleAuD/1qNTUCpqubTvbbT2VoA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm-gnueabihf": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.2.2.tgz", + "integrity": "sha512-XeYC/qqPLz58R4pjkb+x8sUUxuGLnx9QruC7/IGkK68yW4G17PHwKI/1njFYVfXTXUukpWjcfBuauWwxp9ke7Q==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.2.2.tgz", + "integrity": "sha512-d6jT8xgfKYFkzR7J0OHo2D+kFvY/6W8qEo6/hmdrTt6AKAqxs//rbbcdoyn3YQq1x6FVUUd39zzpezZntg9Naw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.2.2.tgz", + "integrity": "sha512-rIZRFxI9N/502auJT1i7coas0HTHUM+HaXMyJiCpnY8Rimbo0495ir24tzzHo3nQqJwcflcPTwEh/DV17sdv9A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.2.2.tgz", + "integrity": "sha512-ir1vNadlUDj7eQk15AvfhG5BjVizuCHks9uZwBfUgT5jyeDCeRvaDCo1+Q6+0CLOAnYDR/nqSCvBgzG2UdFh9A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.2.2.tgz", + "integrity": "sha512-bte5n2GzLN3O8JdSFYWZzMgEgDHZmRz5wiispiiDssj4ik3l8E7wq/czNi8RmIF+ioj2sYVokUNa/ekLzrESWw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.2.2.tgz", + "integrity": "sha512-ZUGCmcDmdPVSAlwJ/aD+1F9lYW8vttseiv4n2+VCDv5JloxiX9aY32kYZaJJO7hmTLNrprvXkb4OvNuHdN22Jg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.2.2.tgz", + "integrity": "sha512-v7ykeEDbr9eXiblGSZiEYYkWoig6sRhAbLKHUHQtk8vEWWVEqeXFcxmw6LRrKu5rCN1DY357UlYWToCGPQPCRA==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.2.2.tgz", + "integrity": "sha512-2D2iinWUL6xx8D9LYVZ5qi7FP6uLAoWymt8m8aaG2Ld/Ka8/k723fJfiklfuAcwOxfufPJI+nRbT5VcgHGzHAQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10" + } + } + }, + "dependencies": { + "@next/env": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/env/-/env-12.2.2.tgz", + "integrity": "sha512-BqDwE4gDl1F608TpnNxZqrCn6g48MBjvmWFEmeX5wEXDXh3IkAOw6ASKUgjT8H4OUePYFqghDFUss5ZhnbOUjw==" + }, + "@next/swc-darwin-arm64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.2.2.tgz", + "integrity": "sha512-JCoGySHKGt+YBk7xRTFGx1QjrnCcwYxIo3yGepcOq64MoiocTM3yllQWeOAJU2/k9MH0+B5E9WUSme4rOCBbpA==", + "optional": true + }, + "@swc/helpers": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.4.2.tgz", + "integrity": "sha512-556Az0VX7WR6UdoTn4htt/l3zPQ7bsQWK+HqdG4swV7beUCxo/BqmvbOpUkTIm/9ih86LIf1qsUnywNL3obGHw==", + "requires": { + "tslib": "^2.4.0" + } + }, + "caniuse-lite": { + "version": "1.0.30001361", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001361.tgz", + "integrity": "sha512-ybhCrjNtkFji1/Wto6SSJKkWk6kZgVQsDq5QI83SafsF6FXv2JB4df9eEdH6g8sdGgqTXrFLjAxqBGgYoU3azQ==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==" + }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, + "nanoid": { + "version": "3.3.4", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.4.tgz", + "integrity": "sha512-MqBkQh/OHTS2egovRtLk45wEyNXwF+cokD+1YPf9u5VfJiRdAiRwB2froX5Co9Rh20xs4siNPm8naNotSD6RBw==" + }, + "next": { + "version": "https://registry.npmjs.org/next/-/next-12.2.2.tgz", + "integrity": "sha512-zAYFY45aBry/PlKONqtlloRFqU/We3zWYdn2NoGvDZkoYUYQSJC8WMcalS5C19MxbCZLUVCX7D7a6gTGgl2yLg==", + "requires": { + "@next/env": "12.2.2", + "@next/swc-android-arm-eabi": "12.2.2", + "@next/swc-android-arm64": "12.2.2", + "@next/swc-darwin-arm64": "12.2.2", + "@next/swc-darwin-x64": "12.2.2", + "@next/swc-freebsd-x64": "12.2.2", + "@next/swc-linux-arm-gnueabihf": "12.2.2", + "@next/swc-linux-arm64-gnu": "12.2.2", + "@next/swc-linux-arm64-musl": "12.2.2", + "@next/swc-linux-x64-gnu": "12.2.2", + "@next/swc-linux-x64-musl": "12.2.2", + "@next/swc-win32-arm64-msvc": "12.2.2", + "@next/swc-win32-ia32-msvc": "12.2.2", + "@next/swc-win32-x64-msvc": "12.2.2", + "@swc/helpers": "0.4.2", + "caniuse-lite": "^1.0.30001332", + "postcss": "8.4.5", + "styled-jsx": "5.0.2", + "use-sync-external-store": "1.1.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + }, + "postcss": { + "version": "8.4.5", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.5.tgz", + "integrity": "sha512-jBDboWM8qpaqwkMwItqTQTiFikhs/67OYVvblFFTM7MrZjt6yMKd6r2kgXizEbTTljacm4NldIlZnhbjr84QYg==", + "requires": { + "nanoid": "^3.1.30", + "picocolors": "^1.0.0", + "source-map-js": "^1.0.1" + } + }, + "react": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react/-/react-17.0.2.tgz", + "integrity": "sha512-gnhPt75i/dq/z3/6q/0asP78D0u592D5L1pd7M8P+dck6Fu/jJeL6iVVK23fptSUZj8Vjf++7wXA8UNclGQcbA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "react-dom": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-17.0.2.tgz", + "integrity": "sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1", + "scheduler": "^0.20.2" + } + }, + "scheduler": { + "version": "0.20.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.20.2.tgz", + "integrity": "sha512-2eWfGgAqqWFGqtdMmcL5zCMK1U8KlXv8SQFGglL3CEtd0aDVDWgeF/YoCmvln55m5zSk3J/20hTaSBeSObsQDQ==", + "requires": { + "loose-envify": "^1.1.0", + "object-assign": "^4.1.1" + } + }, + "source-map-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", + "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" + }, + "styled-jsx": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.0.2.tgz", + "integrity": "sha512-LqPQrbBh3egD57NBcHET4qcgshPks+yblyhPlH2GY8oaDgKs8SK4C3dBh3oSJjgzJ3G5t1SYEZGHkP+QEpX9EQ==", + "requires": {} + }, + "tslib": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", + "integrity": "sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==" + }, + "use-sync-external-store": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.1.0.tgz", + "integrity": "sha512-SEnieB2FPKEVne66NpXPd1Np4R1lTNKfjuy3XdIoPQKYBAFdzbzSZlSn1KJZUiihQLQC5Znot4SBz1EOTBwQAQ==", + "requires": {} + }, + "@next/swc-android-arm-eabi": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm-eabi/-/swc-android-arm-eabi-12.2.2.tgz", + "integrity": "sha512-VHjuCHeq9qCprUZbsRxxM/VqSW8MmsUtqB5nEpGEgUNnQi/BTm/2aK8tl7R4D0twGKRh6g1AAeFuWtXzk9Z/vQ==", + "optional": true + }, + "@next/swc-android-arm64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.2.2.tgz", + "integrity": "sha512-v5EYzXUOSv0r9mO/2PX6mOcF53k8ndlu9yeFHVAWW1Dhw2jaJcvTRcCAwYYN8Q3tDg0nH3NbEltJDLKmcJOuVA==", + "optional": true + }, + "@next/swc-darwin-x64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.2.2.tgz", + "integrity": "sha512-dztDtvfkhUqiqpXvrWVccfGhLe44yQ5tQ7B4tBfnsOR6vxzI9DNPHTlEOgRN9qDqTAcFyPxvg86mn4l8bB9Jcw==", + "optional": true + }, + "@next/swc-freebsd-x64": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-freebsd-x64/-/swc-freebsd-x64-12.2.2.tgz", + "integrity": "sha512-JUnXB+2xfxqsAvhFLPJpU1NeyDsvJrKoOjpV7g3Dxbno2Riu4tDKn3kKF886yleAuD/1qNTUCpqubTvbbT2VoA==", + "optional": true + }, + "@next/swc-linux-arm-gnueabihf": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.2.2.tgz", + "integrity": "sha512-XeYC/qqPLz58R4pjkb+x8sUUxuGLnx9QruC7/IGkK68yW4G17PHwKI/1njFYVfXTXUukpWjcfBuauWwxp9ke7Q==", + "optional": true + }, + "@next/swc-linux-arm64-gnu": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.2.2.tgz", + "integrity": "sha512-d6jT8xgfKYFkzR7J0OHo2D+kFvY/6W8qEo6/hmdrTt6AKAqxs//rbbcdoyn3YQq1x6FVUUd39zzpezZntg9Naw==", + "optional": true + }, + "@next/swc-linux-arm64-musl": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.2.2.tgz", + "integrity": "sha512-rIZRFxI9N/502auJT1i7coas0HTHUM+HaXMyJiCpnY8Rimbo0495ir24tzzHo3nQqJwcflcPTwEh/DV17sdv9A==", + "optional": true + }, + "@next/swc-linux-x64-gnu": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.2.2.tgz", + "integrity": "sha512-ir1vNadlUDj7eQk15AvfhG5BjVizuCHks9uZwBfUgT5jyeDCeRvaDCo1+Q6+0CLOAnYDR/nqSCvBgzG2UdFh9A==", + "optional": true + }, + "@next/swc-linux-x64-musl": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.2.2.tgz", + "integrity": "sha512-bte5n2GzLN3O8JdSFYWZzMgEgDHZmRz5wiispiiDssj4ik3l8E7wq/czNi8RmIF+ioj2sYVokUNa/ekLzrESWw==", + "optional": true + }, + "@next/swc-win32-arm64-msvc": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.2.2.tgz", + "integrity": "sha512-ZUGCmcDmdPVSAlwJ/aD+1F9lYW8vttseiv4n2+VCDv5JloxiX9aY32kYZaJJO7hmTLNrprvXkb4OvNuHdN22Jg==", + "optional": true + }, + "@next/swc-win32-ia32-msvc": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.2.2.tgz", + "integrity": "sha512-v7ykeEDbr9eXiblGSZiEYYkWoig6sRhAbLKHUHQtk8vEWWVEqeXFcxmw6LRrKu5rCN1DY357UlYWToCGPQPCRA==", + "optional": true + }, + "@next/swc-win32-x64-msvc": { + "version": "12.2.2", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.2.2.tgz", + "integrity": "sha512-2D2iinWUL6xx8D9LYVZ5qi7FP6uLAoWymt8m8aaG2Ld/Ka8/k723fJfiklfuAcwOxfufPJI+nRbT5VcgHGzHAQ==", + "optional": true + } + } +} diff --git a/third_party_manifest.json b/third_party_manifest.json index bfb1a4c..9397271 100644 --- a/third_party_manifest.json +++ b/third_party_manifest.json @@ -1,5 +1,5 @@ { - "lastUpdated": "Tue Jul 26 2022 11:38:22 GMT-0400 (Eastern Daylight Time)", + "lastUpdated": "Wed Sep 07 2022 16:26:07 GMT-0400 (Eastern Daylight Time)", "projectName": "New Relic Next.js Instrumentation", "projectUrl": "https://github.com/newrelic/newrelic-node-nextjs", "includeOptDeps": false, @@ -83,15 +83,15 @@ "publisher": "Andrey Okonetchnikov", "email": "andrey@okonet.ru" }, - "newrelic@8.13.0": { + "newrelic@9.0.3": { "name": "newrelic", - "version": "8.13.0", - "range": "^8.13.0", + "version": "9.0.3", + "range": "^9.0.3", "licenses": "Apache-2.0", "repoUrl": "https://github.com/newrelic/node-newrelic", - "versionedRepoUrl": "https://github.com/newrelic/node-newrelic/tree/v8.13.0", + "versionedRepoUrl": "https://github.com/newrelic/node-newrelic/tree/v9.0.3", "licenseFile": "node_modules/newrelic/LICENSE", - "licenseUrl": "https://github.com/newrelic/node-newrelic/blob/v8.13.0/LICENSE", + "licenseUrl": "https://github.com/newrelic/node-newrelic/blob/v9.0.3/LICENSE", "licenseTextSource": "file", "publisher": "New Relic Node.js agent team", "email": "nodejs@newrelic.com" From d382da9d7a5aabdac57c0f0312bbb8821be9e08f Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Wed, 7 Sep 2022 16:48:42 -0400 Subject: [PATCH 4/5] fixed test to not rely on real agent --- tests/versioned/segments.tap.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/versioned/segments.tap.js b/tests/versioned/segments.tap.js index 995f24c..b45a23b 100644 --- a/tests/versioned/segments.tap.js +++ b/tests/versioned/segments.tap.js @@ -37,6 +37,13 @@ tap.test('Next.js', (t) => { t.before(async () => { agent = utils.TestAgent.makeInstrumented() + // assigning the fake agent to the require cache because in + // app/pages/_document we require the agent and want to not + // try to bootstrap a new, real one + agent.agent.getBrowserTimingHeader = function getBrowserTimingHeader() { + return '
stub
' + } + require.cache.__NR_cache = agent.agent helpers.registerInstrumentation(agent) await helpers.build(__dirname) app = await helpers.start(__dirname) From a6a88787f6a67af3981eb7c872e5e8b6ccc42972 Mon Sep 17 00:00:00 2001 From: Bob Evans Date: Mon, 12 Sep 2022 14:04:39 -0400 Subject: [PATCH 5/5] Updated a blurb that explained the browser injection example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04c85be..cfd6c41 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ Error.getInitialProps = ({ res, err }) => { export default Error; ``` -The example above assumes that both the New Relic Browser and Node.js agents are [integrated](#client-side-instrumentation). `getInitialProps` function's `if` statement checks whether an error was thrown on the server side (`typeof window === "undefined"`) and if it was the case, it `requires` New Relic Node.js agent and sends an `err` with `noticeError` method. Otherwise it assumes the error was thrown on the front-end side, and uses the browser agent to send the error to New Relic by using `window.newrelic.noticeError(err)`. +The example above assumes that both the New Relic Browser and Node.js agents are [integrated](#client-side-instrumentation). The `getInitialProps` function's `if` statement checks whether an error was thrown on the server side (`typeof window === "undefined"`) and if it was the case, it `requires` New Relic Node.js agent and sends an `err` with `noticeError` method. Otherwise it assumes the error was thrown on the front-end side, and uses the browser agent to send the error to New Relic by using `window.newrelic.noticeError(err)`. ## Testing