Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Migrated Next.js instrumentation into agent #2409

Merged
merged 284 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
284 commits
Select commit Hold shift + click to select a range
70f0413
restore altered files from main
garbados Feb 11, 2022
ebe12f3
add comments
garbados Feb 12, 2022
cb37c06
register context in nr-hooks, updated unit tests to have more coverag…
bizob2828 Feb 15, 2022
441805d
Merge pull request #18 from garbados/middleware-tracking
bizob2828 Feb 16, 2022
98e8801
refactored segment tests to use t.segments
bizob2828 Feb 16, 2022
5c2d623
removed test that asserts middlewareName, many versioned tests do thi…
bizob2828 Feb 16, 2022
8092c8a
took a stab at updating the README
bizob2828 Feb 16, 2022
1d94f9a
Merge pull request #31 from newrelic/record-middleware
michaelgoin Feb 17, 2022
28a436c
added placeholder CHANGELOG, and workflows to prepare and create release
bizob2828 Feb 17, 2022
30a0332
Merge pull request #37 from newrelic/release-automation
michaelgoin Feb 17, 2022
9c74e99
fix link to community header
bizob2828 Feb 18, 2022
bb14715
Merge pull request #33 from newrelic/update-readme
bizob2828 Feb 18, 2022
a91226c
added our standard copy to CONTRIBUTING.md
bizob2828 Feb 17, 2022
5bc5df7
fixed copy around test extensions
bizob2828 Feb 18, 2022
6f6f454
Merge pull request #35 from newrelic/update-contributing
bizob2828 Feb 18, 2022
7b8506a
changed repolinter workflow to check for community plus rules
bizob2828 Feb 22, 2022
abcbf26
Merge pull request #39 from newrelic/community-plus
michaelgoin Feb 22, 2022
bc90d20
draft of doc updates
bizob2828 Feb 24, 2022
2894205
format fix
bizob2828 Feb 24, 2022
7a5b838
added injecting browser snippet to readme
bizob2828 Feb 24, 2022
0feab10
update docs based on feedback
bizob2828 Mar 1, 2022
7fd6fa9
updated instrumentation to require >=8.8.0 of agent, fixed files stan…
bizob2828 Mar 1, 2022
2e2a472
grab active segment from inContext cb
bizob2828 Mar 1, 2022
6d865b0
added a note about minimum supported Next.js version
bizob2828 Mar 1, 2022
3ac0e0a
fixed a sample span name
bizob2828 Mar 1, 2022
f3f5691
clean up files stanza in package.json
bizob2828 Mar 1, 2022
d638220
Merge pull request #42 from newrelic/pin-agent
michaelgoin Mar 1, 2022
4ab57dd
Merge pull request #40 from newrelic/add-moar-docs
michaelgoin Mar 1, 2022
381a512
fixed syntax of code snippets
bizob2828 Mar 1, 2022
45878d1
fix(Next.js): Provide tech writing review
rhetoric101 Mar 1, 2022
44ba424
Merge pull request #43 from newrelic/fix-snippet-syntax
michaelgoin Mar 1, 2022
e84722d
Fixes whitespace to improve formatting of code snippets in GitHub.
michaelgoin Mar 1, 2022
737648e
Merge pull request #45 from newrelic/fix-code-layout
bizob2828 Mar 1, 2022
2665d09
Merge pull request #44 from newrelic/rhs-tech-docs-review
michaelgoin Mar 1, 2022
4d7a835
Release v0.1.0
bizob2828 Mar 1, 2022
b159705
Merge pull request #46 from newrelic/release/v0.1.0
bizob2828 Mar 1, 2022
f491dbc
Fixes some docs items.
michaelgoin Mar 1, 2022
89cb39a
Merge pull request #47 from newrelic/docs-updates
bizob2828 Mar 2, 2022
abc87f5
Removes program from start snippet as it is not necessary.
michaelgoin Mar 2, 2022
667dc8e
Merge pull request #48 from michaelgoin/update-launch-snippet
bizob2828 Mar 2, 2022
369419b
check if getModuleContext is async and instrument accordingly
bizob2828 Mar 29, 2022
ce72645
Merge pull request #52 from newrelic/fix-middleware-instrumentation
michaelgoin Mar 30, 2022
7f996b1
Setting version to v0.1.1.
bizob2828 Apr 4, 2022
49efa8c
Adds auto-generated release notes.
bizob2828 Apr 4, 2022
d37a17d
CHANGELOG tweak
bizob2828 Apr 4, 2022
2d969c8
Merge pull request #53 from newrelic/release/v0.1.1
bizob2828 Apr 4, 2022
89b4690
fixed create-release.yml to pass in changelog_file as an element of w…
bizob2828 Apr 4, 2022
585475f
Merge pull request #54 from newrelic/fix-release-creation
bizob2828 Apr 4, 2022
41a92e4
Bump moment from 2.29.1 to 2.29.2
dependabot[bot] Apr 9, 2022
d14acf7
Merge pull request #55 from newrelic/dependabot/npm_and_yarn/moment-2…
michaelgoin Apr 11, 2022
8ff21cc
Bumps tap to ^16.0.1.
michaelgoin Apr 11, 2022
272a180
npm audit fix.
michaelgoin Apr 11, 2022
cd18c8e
Merge pull request #56 from michaelgoin/bump-tap
bizob2828 Apr 14, 2022
3de942c
Bump async from 2.6.3 to 2.6.4
dependabot[bot] Apr 29, 2022
4842eaa
Merge pull request #57 from newrelic/dependabot/npm_and_yarn/async-2.6.4
bizob2828 May 3, 2022
25b251b
Bump NPM dependencies to their latest version
github-dd-nicolas May 27, 2022
e3c8f6a
Merge pull request #61 from github-dd-nicolas/npm-dependencies-update
bizob2828 May 27, 2022
303d5f1
Bump protobufjs from 6.11.2 to 6.11.3
dependabot[bot] Jun 3, 2022
f745527
Merge pull request #63 from newrelic/dependabot/npm_and_yarn/protobuf…
bizob2828 Jun 3, 2022
7b51c36
(feat): add instructions on error handling
matewilk Jun 6, 2022
a901539
Update README.md
bizob2828 Jun 7, 2022
23106e1
Update README.md
bizob2828 Jun 7, 2022
3f8e277
Merge pull request #64 from matewilk/error_handling_readme_update
bizob2828 Jun 7, 2022
2642d2d
added additional instrumentation to handle the 12.2.0 changes in Next…
bizob2828 Jun 28, 2022
0f749d1
moved next apps by version, updated helpers to work in subfolders, up…
bizob2828 Jun 29, 2022
f26dfd3
fixed the middleware function to properly delay when matching URLs
bizob2828 Jun 29, 2022
0da20a0
updated middleware instrumentation to only register when >=12.2.0. re…
bizob2828 Jul 1, 2022
21106c5
flattened the versioned tests but added logic to assert the middlewar…
bizob2828 Jul 1, 2022
805e33e
restored glob for finding versioned tests
bizob2828 Jul 1, 2022
9de0b82
changed log level to middleware skipping from debug to warn, updated …
bizob2828 Jul 5, 2022
8448f19
Merge pull request #67 from newrelic/support-12-2
bizob2828 Jul 5, 2022
ccff24c
Adds an additional path to register next-server instrumentation
bizob2828 Jun 30, 2022
bd8751f
Merge pull request #70 from newrelic/add-server-path
bizob2828 Jul 5, 2022
ff5e263
Setting version to v0.2.0.
bizob2828 Jul 5, 2022
7ec5198
Adds auto-generated release notes.
bizob2828 Jul 5, 2022
c7b392b
tweaked changelog for 0.2.0
bizob2828 Jul 5, 2022
97b5aad
Merge pull request #71 from newrelic/release/v0.2.0
bizob2828 Jul 5, 2022
053f2f0
updated readme and docs to reflect new conventions for Next.js middle…
bizob2828 Jul 5, 2022
2a75dc6
Merge pull request #73 from newrelic/update-docs
bizob2828 Jul 6, 2022
ff8df60
swapped out using fetch for http to avoid agent context propagation b…
bizob2828 Jul 15, 2022
0a6259b
Merge pull request #76 from bizob2828/swap-out-fetch
michaelgoin Jul 15, 2022
e4d4018
Updates CI to run for Node 14-18.
michaelgoin Jul 12, 2022
9a37f0e
Merge pull request #75 from michaelgoin/node-18-ci
bizob2828 Jul 18, 2022
1ec1f27
Bump moment from 2.29.2 to 2.29.4
dependabot[bot] Jul 18, 2022
3dddc24
Merge pull request #77 from newrelic/dependabot/npm_and_yarn/moment-2…
bizob2828 Jul 18, 2022
7ff1bdd
fix typo
brnhensley Jul 19, 2022
acd635e
Merge pull request #78 from brnhensley/patch-1
bizob2828 Jul 19, 2022
45ebb93
Dropped Node 12.
mrickard Jul 26, 2022
733bf6a
Dropped Node 12 from versioned tests
mrickard Jul 26, 2022
5952956
Merge pull request #80 from mrickard/NR-35635/drop-node-12
bizob2828 Jul 26, 2022
08863eb
Setting version to v0.3.0.
mrickard Jul 27, 2022
051a42a
Adds auto-generated release notes.
mrickard Jul 27, 2022
35cdebb
Updated CHANGELOG.md
mrickard Jul 27, 2022
b4f9da8
Updated CHANGELOG.md
mrickard Jul 27, 2022
f13185d
Merge pull request #82 from newrelic/release/v0.3.0
bizob2828 Jul 27, 2022
8caba5e
fixed link to support section in troubleshooting link
bizob2828 Aug 29, 2022
34dc26a
Merge pull request #83 from bizob2828/fix-link
bizob2828 Sep 1, 2022
65c2ac9
updated example of injecting browser agent
bizob2828 Sep 7, 2022
0d5e6b6
fix variable name that was incorrect
bizob2828 Sep 7, 2022
73326b9
updated example project to use browser agent snippet. also updated re…
bizob2828 Sep 7, 2022
6d575b1
fixed test to not rely on real agent
bizob2828 Sep 7, 2022
5083613
Updated a blurb that explained the browser injection example
bizob2828 Sep 12, 2022
9346b4d
Merge pull request #84 from bizob2828/update-browser-agent-example
bizob2828 Sep 12, 2022
afd6cea
reverted providing example of injecting browser agent in versioned te…
bizob2828 Sep 13, 2022
22807a4
Merge pull request #85 from bizob2828/nextjs-fix
bizob2828 Sep 13, 2022
4f5cf62
fixed peerDependency newrelic
siuvdlec Oct 11, 2022
67b9400
Merge pull request #89 from siuvdlec/main
bizob2828 Oct 11, 2022
0bc8b37
Setting version to v0.3.1.
bizob2828 Oct 17, 2022
5863ab7
Adds auto-generated release notes.
bizob2828 Oct 17, 2022
693530e
changelog tweaks
bizob2828 Oct 17, 2022
65b74e9
Merge pull request #90 from newrelic/release/v0.3.1
bizob2828 Oct 17, 2022
43192d5
updated all deprecated actions
bizob2828 Oct 26, 2022
05d8d9d
Merge pull request #93 from bizob2828/update-deprecated-actions
bizob2828 Oct 27, 2022
2f33fd2
updates versioned tests to run tests on v13 of next.js
bizob2828 Oct 27, 2022
867be28
NR-60808 added c8, publish coverage to codecov, updated README badges 🚀
bizob2828 Oct 27, 2022
45f2307
fixed linting
bizob2828 Oct 27, 2022
22c97ab
updated badge url
bizob2828 Oct 27, 2022
c222887
Merge pull request #97 from bizob2828/code-coverage
bizob2828 Oct 28, 2022
ec6b7b6
Merge pull request #96 from bizob2828/next13-versioned-tests
bizob2828 Oct 28, 2022
a1270ed
docs: update slack invite link
coreyarnold Dec 9, 2022
5669296
Merge pull request #100 from newrelic/coreyarnold-patch-2
jmartin4563 Dec 9, 2022
ebc50b8
NEWRELIC-556 added CLM for Next.js middleware, getServerSideProps, an…
bizob2828 Dec 12, 2022
a475d04
NEWRELIC-5566 fixed linting errors, updated the versioned tests to ha…
bizob2828 Dec 14, 2022
e1f1056
NEWRELIC-5566 added unit tests for assignCLMAttrs util
bizob2828 Dec 15, 2022
7a53a45
Merge pull request #101 from bizob2828/clm
bizob2828 Dec 15, 2022
b4c3c06
Setting version to v0.4.0.
bizob2828 Dec 15, 2022
d43dd4e
Adds auto-generated release notes.
bizob2828 Dec 15, 2022
83c268e
Merge pull request #102 from newrelic/release/v0.4.0
bizob2828 Dec 15, 2022
27d8561
Change custom assertion name to avoid clash with test-utils
jmartin4563 Dec 20, 2022
e91f20e
Merge pull request #104 from jmartin4563/fix-clm-versioned-tests
bizob2828 Dec 20, 2022
1e75be2
NEWRELIC-5683 added lockfile checks/linting to CI workflow
jmartin4563 Dec 20, 2022
6a0b7e6
Merge pull request #105 from jmartin4563/NEWRELIC-5683-lockfile-lint
jmartin4563 Dec 20, 2022
23422ae
Bump json5 from 2.2.1 to 2.2.3
dependabot[bot] Jan 8, 2023
d92cc16
Merge pull request #107 from newrelic/dependabot/npm_and_yarn/json5-2…
bizob2828 Jan 9, 2023
dbe3e13
docs: update API docs to remove docs/ path component
Jan 20, 2023
0b59c9c
Merge pull request #108 from newrelic/api-docs
bizob2828 Jan 20, 2023
db20cc7
cleaned up the readme to no longer reference code snippets that are o…
bizob2828 Jan 27, 2023
68297bc
Merge pull request #109 from bizob2828/clarify-browser-injection
bizob2828 Jan 30, 2023
7f15c60
tests: remove accidentally-committed package-lock.json
Mar 9, 2023
27b6bf0
tests: add a .gitignore file
Mar 9, 2023
fbe6e47
Merge pull request #111 from newrelic/remove-package-lock.json
Mar 9, 2023
6ac1ac2
chore: update to newest community plus header
jmartin4563 Mar 13, 2023
3f0cb94
Merge pull request #113 from jmartin4563/fix-oss-header
jmartin4563 Mar 14, 2023
1ca0954
fix: updated next server setup to handle 13.3.0 changes
jmartin4563 Apr 10, 2023
a058817
Merge pull request #116 from jmartin4563/fix-versioned-test-setup
bizob2828 Apr 10, 2023
5a26f6a
Route/URL parameters are now stored on request.parameters.route.* att…
jmartin4563 Apr 13, 2023
6d599ec
bump to version 10 of agent
jmartin4563 Apr 19, 2023
feaae3b
Merge pull request #117 from jmartin4563/prefix-route-params
bizob2828 Apr 19, 2023
032449c
Setting version to v0.5.0.
jmartin4563 Apr 19, 2023
5da223e
Adds auto-generated release notes.
jmartin4563 Apr 19, 2023
29c9409
clean up 0.5.0 release notes
jmartin4563 Apr 19, 2023
ad47b7e
Merge pull request #119 from newrelic/release/v0.5.0
jmartin4563 Apr 19, 2023
d832957
test: pin versioned tests to < 13.3.1 until #120 is fixed
jmartin4563 Apr 24, 2023
3ed6eed
Merge pull request #121 from jmartin4563/pin-next-versioned-tests
jmartin4563 Apr 24, 2023
aaee78b
fix: updated readme to call out that this package is not bundled with…
bizob2828 May 10, 2023
f0de11c
Merge pull request #123 from bizob2828/readme-cleanup
bizob2828 May 10, 2023
4c5c41d
fix: updated instrumentation to work in versions >= 13.3.1 as the met…
bizob2828 May 18, 2023
5a4c7da
Merge pull request #124 from bizob2828/fix-13-3-1
bizob2828 May 22, 2023
5c32ddc
Setting version to v0.5.1.
bizob2828 May 22, 2023
f66e306
Adds auto-generated release notes.
bizob2828 May 22, 2023
bd7e0e0
Merge pull request #125 from newrelic/release/v0.5.1
bizob2828 May 22, 2023
3cac3c2
chore: update explorer hub link in readme
jmartin4563 May 31, 2023
1be4fa0
Merge pull request #127 from jmartin4563/fix-readme-forum-link
jmartin4563 May 31, 2023
2eff567
ci: skip Next.js versions >= 13.4.5. getServerSideProps instrumentati…
bizob2828 Jun 12, 2023
552fa44
Merge pull request #128 from bizob2828/skip-13-4-5
bizob2828 Jun 12, 2023
052d377
fix: update instrumentation to wrap getServerSideProps from renderToR…
jmartin4563 Jun 22, 2023
771f048
added semver checks for old instrumentation vs new instrumentation an…
jmartin4563 Jun 23, 2023
098abe8
Merge pull request #131 from jmartin4563/replace-render-html
jmartin4563 Jun 23, 2023
a518dbc
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot Jun 23, 2023
fd28857
Setting version to v0.5.2.
bizob2828 Jun 26, 2023
6239f76
Adds auto-generated release notes.
bizob2828 Jun 26, 2023
381be4d
chore: changelog tweaks
bizob2828 Jun 26, 2023
b6aed37
Merge pull request #133 from newrelic/release/v0.5.2
bizob2828 Jun 26, 2023
80dae19
Merge pull request #132 from newrelic/snyk-fix-fb661de285d90a3fb3d49f…
bizob2828 Jun 26, 2023
1e9163d
Bump fast-xml-parser and @aws-sdk/client-lambda
dependabot[bot] Jun 26, 2023
1fd1fbf
Merge pull request #134 from newrelic/dependabot/npm_and_yarn/fast-xm…
bizob2828 Jun 26, 2023
ed42360
Bump protobufjs from 7.2.3 to 7.2.4
dependabot[bot] Jul 8, 2023
f7e254e
Merge pull request #137 from newrelic/dependabot/npm_and_yarn/protobu…
bizob2828 Jul 10, 2023
773c1e0
chore: added node 20 and drop node 14 in CI
bizob2828 Jul 11, 2023
ae1ae84
chore: fixed deps with CVEs
bizob2828 Jul 14, 2023
0bda51e
Merge pull request #142 from newrelic/dep-fixes
bizob2828 Jul 17, 2023
8477c1d
Merge pull request #138 from bizob2828/node-20
bizob2828 Jul 18, 2023
20cff41
test: skip Next.js 13.4.13 until we can fix the instrumentation
bizob2828 Aug 7, 2023
d8ead8c
Merge pull request #145 from newrelic/skip-next-tests
bizob2828 Aug 7, 2023
be57a00
fix: updated instrumentation to skip registering middleware instrumen…
bizob2828 Aug 8, 2023
8dccc31
Merge pull request #148 from bizob2828/fix-13-4-13
bizob2828 Aug 8, 2023
3195ae0
chore: removes skipping of tests on 13.4.13 and above
bizob2828 Aug 8, 2023
f1c46fd
Merge pull request #149 from bizob2828/remove-13-4-3-skip
bizob2828 Aug 8, 2023
ce9b1ec
chore: change node engine to 16
mkotamies Aug 9, 2023
5a352b1
Merge pull request #147 from mkotamies/change-engine-to-16
bizob2828 Aug 9, 2023
cef669f
Setting version to v0.6.0.
mrickard Aug 9, 2023
40f3af1
Adds auto-generated release notes.
mrickard Aug 9, 2023
94d6ae0
chore: Edited CHANGELOG.md
mrickard Aug 9, 2023
e57389e
Merge pull request #150 from newrelic/release/v0.6.0
bizob2828 Aug 9, 2023
8e7a0ac
test: update versioned test helper to handle [email protected] changes
jmartin4563 Aug 14, 2023
cdf07ee
Merge pull request #153 from jmartin4563/update-start-server-helper
bizob2828 Aug 15, 2023
0e340cf
chore: update path for ritm
bizob2828 Aug 9, 2023
82933f7
remove slack link as it is decommissioned
nareshNishad Aug 10, 2023
ff9836f
Merge pull request #151 from nareshNishad/main
bizob2828 Aug 16, 2023
407ba0c
chore: updated peer dep to the unreleased version of agent that this …
bizob2828 Aug 16, 2023
d4336ae
chore: updated agent to latest
bizob2828 Aug 28, 2023
dbf82ba
Merge pull request #152 from newrelic/ritm-update
bizob2828 Aug 28, 2023
5189c41
Setting version to v0.7.0.
bizob2828 Aug 29, 2023
0ba1e03
Adds auto-generated release notes.
bizob2828 Aug 29, 2023
542abad
chore: changelog edits
bizob2828 Aug 29, 2023
223585c
Merge pull request #155 from newrelic/release/v0.7.0
bizob2828 Aug 29, 2023
54b6b4d
chore: updated @newrelic/test-utilities to latest
bizob2828 Aug 30, 2023
cc73472
Merge pull request #156 from bizob2828/main
bizob2828 Aug 30, 2023
870bcb1
chore(deps): bump @babel/traverse
dependabot[bot] Oct 17, 2023
8085bb6
Merge pull request #165 from newrelic/dependabot/npm_and_yarn/babel/t…
mrickard Oct 20, 2023
6020280
test: skip running Next 14+ versioned tests on Node 16 as support was…
bizob2828 Oct 27, 2023
4f2c259
Merge pull request #166 from bizob2828/skip-node-16
mrickard Oct 27, 2023
026d07f
fix: package.json & package-lock.json to reduce vulnerabilities
snyk-bot Oct 31, 2023
d311202
Merge pull request #168 from newrelic/snyk-fix-b2496d71343bcbd06bfe30…
mrickard Oct 31, 2023
8ee7903
chore(deps-dev): bump follow-redirects from 1.15.3 to 1.15.4
dependabot[bot] Jan 11, 2024
f45bbe4
Merge pull request #169 from newrelic/dependabot/npm_and_yarn/follow-…
mrickard Jan 11, 2024
ea15585
test: updated test assertions based on segment tree changes in 14.1.0…
bizob2828 Jan 19, 2024
ee09884
test: updated test assertions based on segment tree changes in 14.1.0…
bizob2828 Jan 19, 2024
ce04f9d
Merge pull request #170 from bizob2828/fix-tests
bizob2828 Jan 19, 2024
526e0a1
Merge remote-tracking branch 'upstream/main'
bizob2828 Feb 26, 2024
b43057e
refactor: Updated instrumentation to construct spec objects at instru…
bizob2828 Mar 7, 2024
fd27538
Merge pull request #174 from newrelic/update-specs
bizob2828 Mar 7, 2024
d8eecac
Setting version to v0.8.0.
Mar 12, 2024
b649296
Adds auto-generated release notes.
Mar 12, 2024
f622627
Update CHANGELOG.md
svetlanabrennan Mar 12, 2024
81e4079
Merge pull request #177 from newrelic/release/v0.8.0
svetlanabrennan Mar 12, 2024
b55d8e1
feat: Added a shim to externalize all 3rd party libraries the Node.js…
bizob2828 Mar 11, 2024
07f08de
feat: Added a test suite for App Router.
bizob2828 Oct 27, 2023
043679a
chore(deps-dev): bump follow-redirects from 1.15.5 to 1.15.6
dependabot[bot] Mar 17, 2024
3d104e2
Merge pull request #178 from newrelic/dependabot/npm_and_yarn/follow-…
svetlanabrennan Mar 18, 2024
9699c33
Merge pull request #176 from bizob2828/app-dir
bizob2828 Mar 19, 2024
35a5ec7
Merge pull request #175 from newrelic/externalize-libs
bizob2828 Mar 20, 2024
5e04f1d
chore: Updated CI process for releases (#183)
jsumners-nr Mar 28, 2024
8f225f3
chore: release v0.9.0 (#184)
github-actions[bot] Mar 28, 2024
d3a73fc
ci: removed changelog.json file (#185)
svetlanabrennan Apr 2, 2024
d761e5b
ci: Removed `use_new_release` input from prepare release workflow (#…
svetlanabrennan Apr 4, 2024
095d04f
test: Added targets for compatibility reporting (#187)
bizob2828 Apr 16, 2024
52f1989
chore: Enabled quiet mode for CI runs (#188)
jsumners-nr Apr 16, 2024
fa95515
docs: Updated targets to include minimum agent version for compatibil…
bizob2828 Apr 19, 2024
9695618
docs: Added FAQs to assist with common issues with next.js instrument…
bizob2828 Apr 26, 2024
b1d0497
chore: Made pre-commit hook require dependency changes (#191)
jsumners-nr Apr 30, 2024
34816c9
docs: updated FAQs and README with app router examples (#192)
bizob2828 May 3, 2024
3376bde
fix: add missing quotation mark in faq docs (#202)
alissonsleal Jun 6, 2024
1857804
chore(deps-dev): bump @grpc/grpc-js from 1.9.9 to 1.10.9 (#203)
dependabot[bot] Jun 11, 2024
522f8c3
chore(deps-dev): bump braces from 3.0.2 to 3.0.3 (#204)
dependabot[bot] Jun 12, 2024
7761a47
security(deps): bump ws (#206)
dependabot[bot] Jun 25, 2024
ed7daa2
chore: Added Node 22 to CI (#193)
bizob2828 Jun 26, 2024
0c4b476
chore: release v0.10.0 (#210)
github-actions[bot] Jun 28, 2024
bfdc9a5
Merge remote-tracking branch 'next-js/main' into merge-nextjs-instrum…
bizob2828 Jul 26, 2024
d0c3b96
refactor: Moved relevant nextjs instrumentation and rely on agent com…
bizob2828 Jul 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ module.exports = {
parserOptions: {
ecmaVersion: 2022
},
ignorePatterns: ['test/versioned-external'],
ignorePatterns: [
'test/versioned-external',
'test/versioned/nextjs/app',
'test/versioned/nextjs/app-dir'
],
overrides: [
{
files: ['**/*.mjs'],
Expand Down
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,37 @@ If you cannot control how your program is run, you can load the `newrelic` modul
/* ... the rest of your program ... */
```

## Next.js instrumentation
**Note**: The minimum supported Next.js version is [12.0.9](https://github.com/vercel/next.js/releases/tag/v12.0.9). If you are using Next.js middleware the minimum supported version is [12.2.0](https://github.com/vercel/next.js/releases/tag/v12.2.0).

The New Relic Node.js agent provides instrumentation for Next.js The instrumentation provides telemetry for server-side rendering via [getServerSideProps](https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props), [middleware](https://nextjs.org/docs/middleware), and New Relic transaction naming for both page and server requests. It does not provide any instrumentation for actions occurring during build or in client-side code. If you want telemetry data on actions occurring on the client (browser), you can [inject the browser agent](./documentation/nextjs/faqs/browser-agent.md).

Here are documents for more in-depth explanations about [transaction naming](./documentation/nextjs/transactions.md), and [segments/spans](./documentation/nextjs/segments-and-spans.md).


### Setup
Typically you are running a Next.js app with the `next` cli and you must load the agent via `NODE_OPTIONS`:

```sh
NODE_OPTIONS='-r newrelic' next start
```

If you are having trouble getting the `newrelic` package to instrument Next.js, take a look at our [FAQs](./documentation/nextjs/faqs/README.md).

### Next.js example projects
The following example applications show how to load the `newrelic` instrumentation, inject browser agent, and handle errors:

* [Pages Router example](https://github.com/newrelic/newrelic-node-examples/tree/58f760e828c45d90391bda3f66764d4420ba4990/nextjs-legacy)
* [App Router example](https://github.com/newrelic/newrelic-node-examples/tree/58f760e828c45d90391bda3f66764d4420ba4990/nextjs-app-router)

### Custom Next.js servers

If you are using next as a [custom server](https://nextjs.org/docs/advanced-features/custom-server), you're probably not running your application with the `next` CLI. In that scenario we recommend running the Next.js instrumentation as follows.

```sh
node -r newrelic your-program.js
```

## ECMAScript Modules

If your application is written with `import` and `export` statements in javascript, you are using [ES Modules](https://nodejs.org/api/esm.html#modules-ecmascript-modules) and must bootstrap the agent in a different way.
Expand Down
4 changes: 2 additions & 2 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ This product includes source derived from [@aws-sdk/client-s3](https://github.co

### @aws-sdk/s3-request-presigner

This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.616.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.616.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.616.0/LICENSE):
This product includes source derived from [@aws-sdk/s3-request-presigner](https://github.com/aws/aws-sdk-js-v3) ([v3.614.0](https://github.com/aws/aws-sdk-js-v3/tree/v3.614.0)), distributed under the [Apache-2.0 License](https://github.com/aws/aws-sdk-js-v3/blob/v3.614.0/LICENSE):

```
Apache License
Expand Down Expand Up @@ -3110,7 +3110,7 @@ THE SOFTWARE.

### eslint-plugin-jsdoc

This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v48.8.3](https://github.com/gajus/eslint-plugin-jsdoc/tree/v48.8.3)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v48.8.3/LICENSE):
This product includes source derived from [eslint-plugin-jsdoc](https://github.com/gajus/eslint-plugin-jsdoc) ([v48.7.0](https://github.com/gajus/eslint-plugin-jsdoc/tree/v48.7.0)), distributed under the [BSD-3-Clause License](https://github.com/gajus/eslint-plugin-jsdoc/blob/v48.7.0/LICENSE):

```
Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/)
Expand Down
8 changes: 8 additions & 0 deletions documentation/nextjs/faqs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# FAQs

Are you having an issue with New Relic Next.js Instrumentation? Take a look at the following FAQS:

* [Deploying Next.js to Cloud Provider](./cloud-providers.md)
* [Injecting New Relic Browser Agent](./browser-agent.md)
* [Instrumenting 3rd Party Libraries](./instrument-third-party-libraries.md)
* [Error Handling](./error-handling.md)
12 changes: 12 additions & 0 deletions documentation/nextjs/faqs/browser-agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Injecting Browser Agent

Q: How can I inject the [New Relic Browser Agent](https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/) into a Next.js project?

A: It depends on if you are using the Pages or App Router for Next.js.


## Inject Browser Agent
The following links demonstrates how to inject the browser agent.

* [Pages Router](https://github.com/newrelic/newrelic-node-examples/blob/e118117470ae9f9038c60d8a171a6f0d440f6291/nextjs-legacy/pages/_document.jsx)
* [App Router](https://github.com/newrelic/newrelic-node-examples/blob/58f760e828c45d90391bda3f66764d4420ba4990/nextjs-app-router/app/layout.js)
61 changes: 61 additions & 0 deletions documentation/nextjs/faqs/cloud-providers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Deploy Next.js to Cloud Provider

Q: Can Next.js instrumentation work when deploying to [Vercel](https://vercel.com/frameworks/nextjs), [AWS Amplify](https://aws.amazon.com/amplify/), [Netlify](https://www.netlify.com/with/nextjs/), [Azure Static Sites](https://azure.microsoft.com/en-us/products/app-service/static), etc?

A: The short answer is no. Most of these cloud providers lack the ability to control run options to load the New Relic Node.js agent. Also, most of these cloud providers execute code in a Function as a Service(FaaS) environment. Our agent requires a different setup and then additional processes to load the telemetry. Our recommendation is to rely on OpenTelemetry and load the telemetry via our OTLP endpoint.

## OpenTelemetry setup with New Relic

To setup Next.js to load OpenTelemetry data to New Relic you must do the following:

1. Enable [experimental instrumentation hook](https://nextjs.org/docs/app/building-your-application/optimizing/open-telemetry). In your `next.config.js` add:

```js
{
experimental: {
instrumentationHook: true
}
}
```

2. Install OpenTelemetry packages.

```sh
npm install @opentelemetry/sdk-node @opentelemetry/resources @opentelemetry/semantic-conventions @opentelemetry/sdk-trace-node @opentelemetry/exporter-trace-otlp-http
```

3. Setup OpenTelemetry configuration in `new-relic-instrumentation.js`

```js
const { NodeSDK } = require('@opentelemetry/sdk-node')
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node')
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http')
const { Resource } = require('@opentelemetry/resources')
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions')
const { SimpleSpanProcessor } = require('@opentelemetry/sdk-trace-node')

const sdk = new NodeSDK({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'next-app',
}),
spanProcessor: new SimpleSpanProcessor(new OTLPTraceExporter({
url: 'https://otlp.nr-data.net',
headers: {
'api-key': process.env.NEW_RELIC_API_KEY
}
})),
instrumentations: [getNodeAutoInstrumentations()]
})
sdk.start()
```

4. Add the following to `instrumentation.ts` in the root of your Next.js project:

```js
export async function register() {
if (process.env.NEXT_RUNTIME === 'nodejs') {
require('./new-relic-instrumentation.js')
}
}
```

15 changes: 15 additions & 0 deletions documentation/nextjs/faqs/error-handling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Injecting Browser Agent

Q: How can I get the Next.js instrumentation to log errors to [New Relic Errors Inbox](https://docs.newrelic.com/docs/errors-inbox/errors-inbox/)?

A: The Node.js agent has an API to log errors `newrelic.noticeError`. Next.js has an error page that can be used to add the API call.


## Log errors to Errors Inbox

The error page varies between [Pages Router](https://nextjs.org/docs/pages/building-your-application/routing/custom-error) and [App Router](https://nextjs.org/docs/app/building-your-application/routing/error-handling) Next.js projects.


* [Pages Router](https://github.com/newrelic/newrelic-node-examples/blob/e118117470ae9f9038c60d8a171a6f0d440f6291/nextjs-legacy/pages/_error.jsx) error handling example.


23 changes: 23 additions & 0 deletions documentation/nextjs/faqs/instrument-third-party-libraries.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Instrument 3rd Party Libraries within Next.js

Q: How can I get instrumentation to load for 3rd party libraries within my Next.js application like mysql, mongodb, pino, winston, etc?

A: Typically the New Relic Node.js agent auto-instruments all supported [3rd party libraries](https://docs.newrelic.com/docs/apm/agents/nodejs-agent/getting-started/compatibility-requirements-nodejs-agent/#instrument). Next.js, however, bundles your project and code spilts between server and client side via webpack. To get auto-instrumentation to work, you must externalize all libraries within webpack.

## Externalize 3rd party libraries in webpack

To externalize all supported 3rd party libraries, add the following to `next.config.js`:

```js
const nrExternals = require('newrelic/load-externals')

module.exports = {
// In order for newrelic to effectively instrument a Next.js application,
// the modules that newrelic supports should not be mangled by webpack. Thus,
// we need to "externalize" all of the modules that newrelic supports.
webpack: (config) => {
nrExternals(config)
return config
}
}
```
22 changes: 22 additions & 0 deletions documentation/nextjs/segments-and-spans.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Segments and spans

Segments and spans (when distributed tracing is enabled) are captured for Next.js middleware and `getServerSideProps`(Server-Side Rendering).

## Next.js middleware segments/spans

[Next.js middleware](https://nextjs.org/docs/middleware) was made stable in 12.2.0. As of v0.2.0 of `@newrelic/next`, it will only instrument Next.js middleware in versions greater than or equal to 12.2.0.

`/Nodejs/Middleware/Nextjs//middleware`

Since middleware executes for every request you will see the same span for every request if middleware is present even if you aren't executing any business logic for a given route. If you have middleware in a deeply nested application, segments and spans will be created for every unique middleware.

## Server-side rendering segments/spans

`/Nodejs/Nextjs/getServerSideProps/<Next.js page name>`

Next.js pages that contain server-side rendering must export a function called `getServerSideProps`. The function execution will be captured and an additional attribute will be added for the name of the page.

**Attributes**
| Name | Description |
| --------- | ---------------------------------------------------------- |
| next.page | Name of the page, including dynamic route where applicable |
39 changes: 39 additions & 0 deletions documentation/nextjs/transactions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Transactions

Transactions are captured as web transactions and named based on the Next.js page or API route. If you are using Next.js as a [custom server](https://nextjs.org/docs/advanced-features/custom-server), our Next.js instrumentation overrides the transaction naming of existing instrumentation for the custom server framework (for example, express, fastify, hapi, koa). Also, the transaction will be renamed based on the Next.js page or API route.

Let's say we have a Next.js app with the following application structure:

```
pages
index.js
dynamic
static.js
[id].js
api
hiya.js
dynamic
[id].js
```

The transactions will be named as follows:

| Request | Transaction Name |
| --------------------- | -------------------------------- |
| /pages/ | Nextjs/GET// |
| /pages/dynamic/static | Nextjs/GET//pages/dynamic/static |
| /pages/dynamic/example | Nextjs/GET//pages/dynamic/[id] |
| /api/hiya | Nextjs/GET//api/hiya |
| /api/dynamic/example | Nextjs/GET//api/dynamic/[id] |


## Errors
There are two exceptions to the transaction naming above.

### 404s
If a request to a non-existent page or API route is made, the transaction name will flow through the Next.js 404 page and will be named as `Nextjs/GET//404`.

### Non 404 errors
If a request is made that results in a 4xx or 5xx error, the transaction will flow through the Next.js error component and will be named as `Nextjs/GET//_error`.


Loading
Loading