Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisobriensp/a30d770133d56a5f6bd92d302b2e6daa to your computer and use it in GitHub Desktop.
Save chrisobriensp/a30d770133d56a5f6bd92d302b2e6daa to your computer and use it in GitHub Desktop.
Adds Azure App Insights to every page as part of an SPFx Application Customizer.
export default class AppInsightsCustomizerApplicationCustomizer
extends BaseApplicationCustomizer<IAppInsightsCustomizerApplicationCustomizerProperties> {
@override
public onInit(): Promise<void> {
/* update with YOUR App Insights key: */
let appInsightsKey: string = "bd755e10-2e26-4580-8d58-446c0dd329fe";
AppInsights.downloadAndSetup({ instrumentationKey: appInsightsKey });
// simple usage - all params will be derived..
AppInsights.trackPageView();
console.log(`OnInit: Called trackPageView().`);
return Promise.resolve<void>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment