1

I have promoted my app from dev to stage environment App Service.

But now I cant see Page views,Custom events getting logged in my Application Insights which was logging fine in Dev.

Why is this happening?

Note:

1.I am using correct Instrumentation Key

2.Track calls are 200

3.The app is a Teams tab app built using React and using React plugin for App insights(working fine in dev)

4.Runtime Stack for dev environment was Node.Js but for Stage is .NET (Is this causing this issue?)

Also Note I have gone through all scenarios in Troubleshooting guide

Deb Jones
  • 11
  • 2
  • Can you please share the troubleshooting guide link/steps followed? Meanwhile, you can check these: [Application Insight not all logs are recording](https://stackoverflow.com/questions/64421579/application-insight-not-all-logs-are-recording) and [Application Insights not logging custom events](https://stackoverflow.com/questions/37551596/application-insights-not-logging-custom-events) – Ecstasy Jul 26 '21 at 09:32
  • https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-troubleshoot-no-data .I have followed this link for troubleshooting.The problem is its working fine in Dev tenant where Runtime stack for App service is Node.js..Is there some extra configuration needed if we host our React app in .NET runtime stack app service – Deb Jones Jul 26 '21 at 14:13

2 Answers2

0

Did the issue resolved for you ?

If not, Ensure that you install the npm package for React.js,

 npm install @microsoft/applicationinsights-react-js

 npm install @microsoft/applicationinsights-web

Initialize a connection to Application Insights:

in AppInsights.js

import { ApplicationInsights } from '@microsoft/applicationinsights-web';
import { ReactPlugin } from '@microsoft/applicationinsights-react-js';
import { createBrowserHistory } from 'history';

const browserHistory = createBrowserHistory({ basename: '' });
const reactPlugin = new ReactPlugin();
const appInsights = new ApplicationInsights({
    config: {
        instrumentationKey: 'YOUR_INSTRUMENTATION_KEY_GOES_HERE',
        extensions: [reactPlugin],
        extensionConfig: {
          [reactPlugin.identifier]: { history: browserHistory }
        }
    }
});
appInsights.loadAppInsights();
export { reactPlugin, appInsights };

And then Wrap your component with the higher-order component function to enable Application Insights on it:

import React from 'react';
import { withAITracking } from '@microsoft/applicationinsights-react-js';
import { reactPlugin, appInsights } from './AppInsights';

// To instrument various React components usage tracking, apply the `withAITracking` higher-order
// component function.

class MyComponent extends React.Component {
    ...
}

// withAITracking takes 4 parameters ( reactPlugin, Component, ComponentName, className) 
// the first two are required and the other two are optional.

export default withAITracking(reactPlugin, MyComponent);

This will help you track all the requests, page views and custom events.

Also take a look at this doc for more reference : Javascript React SDK Plugin

Monika Reddy
  • 943
  • 6
  • 11
  • Hi Monika.I have been using the same plugin and code for logging app insights.I think its a issue with app insights resource – Deb Jones Aug 05 '21 at 05:01
-1

Turns out it was a problem with the Application Insights instance itself and not in code or App service configuration. When ever you face such problem where problem is not with code or App service,please reach out to your organization's support Team.

Deb Jones
  • 11
  • 2
  • would it be possible to hint what went wrong with this particular one? – ZakiMa Aug 11 '21 at 18:55
  • Hi ZakiMa...The Resource group workspace mapping was done wrongly for this app insight – Deb Jones Aug 12 '21 at 12:35
  • Thank you Debi Jones! [I'm from Application Insights product] I'm not sure what above means and it doesn't sound right. Sounds like you opened a support ticket. I'd be interested to look into details of this case to understand whether we missed some case which can land our customers into this broken state. If you're interested (totally understand that you already solved the problem) - you can send ticket number to @microsoft.com. Thank you! – ZakiMa Aug 12 '21 at 19:57
  • Hi Zakima.I know the explanation sounds vague.But since details are confidential for our organization,we cant share much.But this isnt related to anything specific to AI product .For higher environments we have a separate team who create Resources.They misconfigured it so logs were going to some other endpoint.(I think its called ingestion endpoint). – Deb Jones Aug 13 '21 at 08:11
  • Got it. Misconfigured ingestion endpoint makes sense. – ZakiMa Aug 13 '21 at 08:22