Replies: 4 comments 12 replies
-
It looks to me like the |
Beta Was this translation helpful? Give feedback.
-
@jorupp I'm just looking at adding App Insights to a Next 13 app and stumbled across this discussion. I thought I would add another possible option for monitoring on the server is using OpenTelemetry. The app I'm adding it to is just the create next app output so I don't have anything "real world" to test this with yet, but I can at least see data coming through into app insights OK by using the Azure Monitor OpenTelemetry library from inside Here's the commit where I added it to my app if you're interested - no worries if not, I just thought I would add to this discussion as it was good to see other people working on this problem too! If you do look into it and have some thoughts it'd be great to hear what you think. On the client I think I will do as you suggested with a client component and the |
Beta Was this translation helpful? Give feedback.
-
@jorupp I am looking to setup AppInsights in a NextJS 12 app, where do you initialize the server side analytics? |
Beta Was this translation helpful? Give feedback.
-
I am adding Application Insights to my nextjs13+ app and for the client side, it seems to work to render a component like this inside my main
|
Beta Was this translation helpful? Give feedback.
-
Summary
I have a NextJS 13 application using the app router, and am trying to configure Application Insights to monitor both the client and server side of this application.
In NextJS 12 applications, it's just been a matter of adding some client-side code like this:
And some server-side code like this:
So far, I've hit the following issues:
error ./node_modules/applicationinsights-native-metrics/build/Release/native_metrics.node Module parse failed: Unexpected character '�' (1:2)
Critical dependency: the request of a dependency is an expression
innode_modules/@opentelemetry/instrumentation/build/src/platform/node/instrumentation.js
Can't resolve '@azure/functions-core' in '<...>\node_modules\applicationinsights\out\AutoCollection'
'use client'
component to a function exported from a'use server'
file are using GET instead of POST.1-3 I was able to avoid by overriding
webpack
innext.config.js
to usewebpack.NormalModuleReplacementPlugin
to supply dummy implementations ofapplicationinsights-native-metrics
,@opentelemetry/instrumentation
, and@azure/functions-core
. All three of those appear to be due to Next/Webpack looking atrequire()
calls in modules, even if those are in atry/catch
or hidden behind a conditional.4 though is causing me some problems. I assume it's something related to whatever Application Insights does to track
fetch
calls as dependencies, but I don't understand enough of what magic Next is doing to make this'use client'
->'use server'
magic happen to debug why AppInsights is breaking things.Anyone had luck setting up NextJS 13 w/ app router w/ Application Insights client+server monitoring?
Additional information
Beta Was this translation helpful? Give feedback.
All reactions