Skip to content

Commit 3305c52

Browse files
committed
fix: disable PostHog service worker to prevent registration errors in VSCode webview
- Added configuration options to PostHog initialization to disable service worker features - Disabled session recording, toolbar metrics, and other features that may attempt service worker registration - Updated tests to reflect the new PostHog configuration - Fixes #6950: Error loading webview due to service worker registration failure
1 parent bce579f commit 3305c52

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

webview-ui/src/__tests__/TelemetryClient.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ describe("TelemetryClient", () => {
5858
api_host: "https://us.i.posthog.com",
5959
persistence: "localStorage",
6060
loaded: expect.any(Function),
61+
capture_pageview: false,
62+
capture_pageleave: false,
63+
autocapture: false,
64+
disable_session_recording: true,
65+
advanced_disable_decide: true,
66+
advanced_disable_toolbar_metrics: true,
6167
}),
6268
)
6369

webview-ui/src/utils/TelemetryClient.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ class TelemetryClient {
1919
capture_pageview: false,
2020
capture_pageleave: false,
2121
autocapture: false,
22+
// Disable service worker to prevent registration errors in VSCode webview
23+
disable_session_recording: true,
24+
disable_persistence: false,
25+
// Explicitly disable any service worker features
26+
opt_out_capturing_by_default: false,
27+
// Use XHR instead of fetch to avoid service worker issues
28+
xhr_headers: {
29+
"Content-Type": "application/json",
30+
},
31+
// Disable features that might try to use service workers
32+
bootstrap: {},
33+
// Ensure we're not using any advanced features that require service workers
34+
advanced_disable_decide: true,
35+
advanced_disable_feature_flags: false,
36+
advanced_disable_feature_flags_on_first_load: false,
37+
advanced_disable_toolbar_metrics: true,
2238
})
2339
} else {
2440
TelemetryClient.telemetryEnabled = false

webview-ui/src/utils/__tests__/TelemetryClient.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ describe("TelemetryClient", () => {
6363
api_host: "https://us.i.posthog.com",
6464
persistence: "localStorage",
6565
loaded: expect.any(Function),
66+
capture_pageview: false,
67+
capture_pageleave: false,
68+
autocapture: false,
69+
disable_session_recording: true,
70+
advanced_disable_decide: true,
71+
advanced_disable_toolbar_metrics: true,
6672
}),
6773
)
6874

0 commit comments

Comments
 (0)