Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TrackPageView for page routing and set cloudRoleName #1

Closed
sowsan opened this issue Jan 24, 2019 · 1 comment
Closed

TrackPageView for page routing and set cloudRoleName #1

sowsan opened this issue Jan 24, 2019 · 1 comment

Comments

@sowsan
Copy link
Member

sowsan commented Jan 24, 2019

An e.g with couple of page routing for trackpageview will be very helpful, also setup the CloudRoleName. In my testing wondering where will be the best place to load the ApplicationInsight object to make it available globally for all componentes within the app. In my testing I was copy pasting the below code snipped in each component (newbie here with React)

import { ApplicationInsights, SeverityLevel } from '@microsoft/applicationinsights-web';

let INSTRUMENTATION_KEY = 'PICKING FROM ENV VARIABLE'; // Enter your instrumentation key here

let appInsights = new ApplicationInsights({config: {
instrumentationKey: INSTRUMENTATION_KEY,
maxBatchInterval: 0
}});
appInsights.loadAppInsights();

@markwolff
Copy link

markwolff commented Jan 26, 2019

You can paste it onto every component. You can also put it in your parent component and feed it down to each of your child components or some other form of abstraction. You will also need to "refresh" the SDK pageview/operation each time your router components remount.

By default the web SDK doesn't hook onto any react specific events, although I see you are checking out the react SDK, which does all of this for you 👍 (Azure/react-appinsights#38 (comment))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants