A Nuxt 2 Module to add NewRelic APM / Browser monitoring to your project
- Add
nuxt-newrelic
dependency to your project
npm install @jaketig/nuxt-newrelic
- Add
nuxt-newrelic
to themodules
section ofnuxt.config.js
export default {
modules: [
'@jaketig/nuxt-newrelic'
]
}
- Add
newrelic.js
andnewrelic_agent.log
to .gitignore
newrelic.js
newrelic_agent.log
Runtime config allows the use of environment specific variable at startup. Only Private Runtime Config
is supported as license keys should not be exposed publicly
export default {
modules: [
'@jaketig/nuxt-newrelic'
],
privateRuntimeConfig: {
newrelic: {
apm: {
enabled: true,
appName: 'YOUR APP NAME HERE',
licenseKey: 'YOUR LICENSE KEY HERE',
// additional agent config can be added here
},
browser: {
enabled: false,
scriptId: 'newrelic',
accountId: 'YOUR NEW RELIC ACCOUNT ID HERE',
agentId: 'YOUR NEW RELIC AGENT ID HERE',
licenseKey: 'YOUR NEW RELIC LICENSE KEY HERE',
applicationId: 'YOUR NEW RELIC APPLICATION ID HERE'
}
}
},
}
Nuxt config values are hardcoded at build time
export default {
modules: [
'@jaketig/nuxt-newrelic'
],
newrelic: {
apm: {
enabled: true,
appName: 'YOUR APP NAME HERE',
licenseKey: 'YOUR LICENSE KEY HERE',
// additional agent config can be added here
},
browser: {
enabled: false,
scriptId: 'newrelic',
accountId: 'YOUR NEW RELIC ACCOUNT ID HERE',
agentId: 'YOUR NEW RELIC AGENT ID HERE',
licenseKey: 'YOUR NEW RELIC LICENSE KEY HERE',
applicationId: 'YOUR NEW RELIC APPLICATION ID HERE'
}
}
}
- Contents written to
newrelic.js
on build / startup - Accepts any of the standard newrelic config options
- Determines if newrelic APM is enabled or not.
- Defaults to true if production, false if development
- excluded from
newrelic.js
config file
export default {
newrelic: {
apm: {
enabled: true
}
}
}
- mapped to new relic agent app_name
export default {
newrelic: {
apm: {
app_name: `YOUR APP NAME HERE`
}
}
}
- mapped to new relic agent license_key
export default {
newrelic: {
apm: {
license_key: `YOUR NEWRELIC LICENSE KEY`
}
}
}
Any additional fields included in the apm
object will be included in the generated newrelic.js
config file. See New Relic docs for all available options.
For example, logging can be disabled:
export default {
newrelic: {
apm: {
logging: {
enabled: false
}
}
}
}
- Configures New Relic browser monitoring by adding a script to the page head at build/startup
- Requires APM to be enabled
- Does not support functional nuxt/head
- Determines if newrelic Browser Monitoring is enabled or not.
- Defaults to false
export default {
newrelic: {
browser: {
enabled: false
}
}
}
- Sets the unique identifier (hid) for the script
- Defaults to
newrelic
- See Nuxt Head Docs for more details
export default {
newrelic: {
browser: {
scriptId: 'newrelic'
}
}
}
- New Relic account id
- populated in browser script
export default {
newrelic: {
browser: {
accountId: 'YOUR NEW RELIC ACCOUNT ID HERE',
}
}
}
- New Relic agent id
- populated in browser script
export default {
newrelic: {
browser: {
agentId: 'YOUR NEW RELIC AGENT ID HERE',
}
}
}
- New Relic license key
- populated in browser script
export default {
newrelic: {
browser: {
licenseKey: 'YOUR NEW RELIC LICENSE KEY HERE',
}
}
}
- New Relic application id
- populated in browser script
export default {
newrelic: {
browser: {
applicationId: 'YOUR NEW RELIC APPLICATION ID HERE'
}
}
}
- Login to the New Relic portal
- Click Add Data
- Choose Browser Monitoring
- Select Copy/Paste Javascript Code
- Complete the Name your App section
- Copy the values from the provided script