Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goenning/next-applicationinsights
React higher-order component for using Azure Application Insights inside Next.js
https://github.com/goenning/next-applicationinsights
Last synced: 3 months ago
JSON representation
React higher-order component for using Azure Application Insights inside Next.js
- Host: GitHub
- URL: https://github.com/goenning/next-applicationinsights
- Owner: goenning
- License: mit
- Created: 2019-07-07T16:11:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T04:24:16.000Z (about 2 years ago)
- Last Synced: 2024-10-10T05:37:26.066Z (3 months ago)
- Language: TypeScript
- Size: 515 KB
- Stars: 15
- Watchers: 3
- Forks: 7
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# next-applicationinsights
Automatically track page views, dependency calls and exceptions on you Next.js applications by using [Azure Application Insights](https://docs.microsoft.com/en-us/azure/azure-monitor/app/app-insights-overview).
## How to use
Install the package with npm
```sh
npm install next-applicationinsights
```Wrap Next's `App` in `pages/_app.js` with a call to `withApplicationInsights`.
```js
import App, { Container } from 'next/app'
import { withApplicationInsights } from 'next-applicationinsights';class MyApp extends App {
render() {
const { Component, pageProps } = this.propsreturn (
)
}
}export default withApplicationInsights({
instrumentationKey: 'YOUR_KEY_GOES_HERE',
isEnabled: true //process.env.NODE_ENV === 'production'
})(MyApp)
```That's it! 🎉
## Configuration
This package uses `@microsoft/applicationinsights-web`, so all configuration options from this package are supported by `withApplicationInsights`.
`isEnabled` is a custom property that can be used to enable/disable AI tracking. We recommend the usage of `process.env.NODE_ENV === 'production'` if you want to enable tracking in production builds only.