Azure / Azure/static-web-apps

Preloading app insights in nextjs

Open
#1,165 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

I am trying to enable [logging with nextjs](https://learn.microsoft.com/en-us/azure/static-web-apps/deploy-nextjs-hybrid#enable-logging-for-nextjs) and app insights, where I have followed [this guide](https://medium.com/microsoftazure/enabling-the-node-js-application-insights-sdk-in-next-js-746762d92507).

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
```
"start": "node --require ./load-appinsights.js .next/standalone/server.js",
```

Have also tried with
```
node --require ./load-appinsights.js node_modules/next/dist/bin/next start
```

**To Reproduce**
Steps to reproduce the behavior:
1. Follow the app insight guide
2. Deploy app to azure static web app
3. Go to app insights
4. Call API endpoint in the app
5. See no API requests in app insights

**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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.