Skip to content

Instantly share code, notes, and snippets.

@mcsolha
Last active February 6, 2024 13:07
Show Gist options
  • Save mcsolha/f8042f88258f5a5ab4a9069e8ce10eeb to your computer and use it in GitHub Desktop.
Save mcsolha/f8042f88258f5a5ab4a9069e8ce10eeb to your computer and use it in GitHub Desktop.
new-relic-browser global typing
/**
* Ensure the browser agent is present on every page you want to monitor!
*
* Refs:
* https://forum.newrelic.com/s/hubtopic/aAX8W0000008eQTWAY/how-to-import-newrelic-for-react-app-on-typescript
* https://docs.newrelic.com/docs/browser/browser-monitoring/installation/install-browser-monitoring-agent/
* https://www.typescriptlang.org/docs/handbook/declaration-files/templates/global-d-ts.html
*
* Steps:
* Enable browser agent on the page to be monitored
*
* npm install --save @types/new-relic-browser
* (https://www.npmjs.com/package/@types/new-relic-browser)
*
* Use this global type file to enable newrelic namespace on every typescript file in the project
*/
import NewRelicBrowser from "new-relic-browser"
declare global {
interface Window {
newrelic: typeof NewRelicBrowser
}
}
@mncorreia
Copy link

🚀 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment