Open georgibakken opened 1 year ago
@georgibakken were you able to find a solution for this? I'm facing the same problem.
@mateubo : No unfortunately not, seems like the article resources are a bit out of date. Or there needs to be an example on how to deploy it to static web apps.
I was able to preload it using Next.js's instrumentation.
For example
load-appinsights.js
const appInsights = require("applicationinsights");
appInsights
.setup(process.env.APPINSIGHTS_CONNECTION_STRING)
.setAutoCollectConsole(true)
.setAutoCollectDependencies(true)
.setAutoCollectExceptions(true)
.setAutoCollectHeartbeat(true)
.setAutoCollectPerformance(true, true)
.setAutoCollectRequests(true)
.setAutoDependencyCorrelation(true)
.setDistributedTracingMode(appInsights.DistributedTracingModes.AI_AND_W3C)
.setSendLiveMetrics(true)
.setUseDiskRetryCaching(true);
appInsights.start();
instrumentation.ts
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
await import("src/utils/load-appinsights.js");
}
}
next.config.js
//...rest of your config
experimental: {
instrumentationHook: true,
}
@rbourdon ty for the config. how do you test this locally? is it possible?
I have this when running next dev
Describe the bug
I am trying to enable logging with nextjs and app insights, where I have followed this guide.
If I run the application locally with preloading app insights , I can see the improved logging in app insight from localhost. See screenshot below.
However, after deploying, I can't see the same type of logs as from my localhost.
This is my start script
Have also tried with
To Reproduce Steps to reproduce the behavior:
Expected behavior Would expect to see the API request, as the screenshot below from localhost.
Screenshots![image](https://github.com/Azure/static-web-apps/assets/16558100/d6e1a11d-6423-488c-98fd-c3ab3f6bbf1e)
Additional context Add any other context about the problem here.