Documentation for addTelemetryInitializer is unclear
See original GitHub issueI am trying to use addTelemetryInitializer as per the documentation but it is unclear because the docs (API-reference.md) refer to:
window.appInsights = appInsights;
// Add telemetry initializer
appInsights.trackPageView();
but the JS code from the portal does not look like that, it looks like this:
var sdkInstance="appInsightsSDK";window[sdkInstance]="appInsights";var etc...
{
instrumentationKey:"key"
}); window[aiName] = aisdk,aisdk.queue && aisdk.queue.length ===0 && aisdk.trackPageView({});;
I tried splitting the last line and ended up with
}); window[aiName];
// Add my initializer here
aisdk.queue && aisdk.trackPageView({});
But this doesn’t seem to work. The initializer is not called and I cannot see the call to track in the network monitor. Is there some more clear documentation about how this works with the new JS snippet?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:13 (3 by maintainers)
Top Results From Across the Web
How can I call addTelemetryInitializer when using the latest ...
Please try the code below, I can add a custom property by using the latest javascript code snippet: var sdkInstance="appInsightsSDK" ...
Read more >D365 TypeScript Web Resources - Part 6 - Application Insights
It can monitor and analyze telemetry from mobile apps by integrating with Visual Studio App Center. https://docs.microsoft.com/en-us/azure/azure ...
Read more >Azure Application Insights for JavaScript web apps
The input argument to addTelemetryInitializer is a callback that takes a ITelemetryItem as an argument and returns boolean or void . If false...
Read more >Renovate Bot Package Diff
+ of this software and associated documentation files (the "Software"), to deal ... string"&&(Dy.diag.error("Cannot create baggage metadata from unknown ...
Read more >Automated Malware Analysis Report for https://forms.office.com/r ...
Source: unknown, Network traffic detected: HTTP traffic on port 443 -> 49722. Source: unknown, Network traffic detected: HTTP ... Sec-Fetch-Dest: document
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Aha! Here is one that works… I left in the check for an empty queue as it seems like a safety check to make sure a duplicate snippet doesn’t cause the page to track twice… Turns out the non-minified snippet (here) sets up the addTelemetryInitializer function to automatically queue calls so you can use it right away rather than pushing your own function on the queue.
Same here. Searched all of github for someone adding an application version to telemetry and there’s not a single instance of someone using the new snippet and adding any custom initializers. All my attempts to add a TelemetryInitializer with the current snippet result in the page going untracked (even when the queue empty test is removed). Really odd since this has to be the #1 method for people using AI.