Skip to content

Commit be9faa8

Browse files
docs: clarify re-grant page-view suppression and event race tradeoff
- appinsights-manager.js: add comment explaining no trackPageView() on consent re-grant within the same page lifetime (initial page view was already recorded; re-tracking would duplicate the same URL visit) - trydotnet-module.js: add comment acknowledging the SDK-loading race window where TryCodeRunner events may be dropped/unpaired (accepted v1 tradeoff for a low-frequency edge case)
1 parent 16f6280 commit be9faa8

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

EssentialCSharp.Web/wwwroot/js/appinsights-manager.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@
152152
} else {
153153
appInsights.config.disableTelemetry = false;
154154
setAuthenticatedContext();
155+
// Intentionally no trackPageView() here: the instance was created (and the
156+
// initial page view recorded) during a previous consent-granted cycle in this
157+
// same page lifetime. Re-tracking would produce a duplicate page view for
158+
// the same URL visit.
155159
}
156160
})
157161
.catch((error) => {

EssentialCSharp.Web/wwwroot/js/trydotnet-module.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ function getCorrelationContext() {
3434
function trackTryEvent(name, properties = {}, measurements = {}) {
3535
const appInsights = getAppInsights();
3636
if (!appInsights || typeof appInsights.trackEvent !== 'function') {
37+
// No-op when the SDK is unavailable (consent denied, or SDK still loading).
38+
// Known limitation: if consent is granted but the CDN script hasn't finished
39+
// downloading yet, TryCodeRunnerRequested/TryCodeRunnerCompleted for a run
40+
// started during that window may be dropped or mismatched. This is accepted
41+
// as a low-frequency edge case for v1.
3742
return;
3843
}
3944

0 commit comments

Comments
 (0)