Skip to content

Commit 7b2c5ee

Browse files
fix(Sky): Configure OTEL endpoint for Tauri and further reduce PostHog network overhead
Three telemetry and security configurations for the editor bootstrap: 1. OTELBridge.ts: Detect Tauri environment using `__TAURI_INTERNALS__` to route OTLP traces directly to localhost:4318 in desktop builds, while continuing to use the Vite-proxied `/v1/traces` endpoint in development. This fixes trace collection in production builds. 2. PostHogBridge.ts: Add `disable_external_dependency_loading: true` to further minimize PostHog's network footprint during startup. This follows the recent per-component buffering and survey/disable_decide optimizations. 3. index.astro: Add `vscode-file:` and `vscode-file://vscode-app` to the CSP font-src directive to enable proper VS Code file URL handling in the editor. These changes ensure telemetry works correctly in both dev and production while minimizing unnecessary network requests during editor boot.
1 parent 2a5780f commit 7b2c5ee

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

Source/Workbench/Electron/OTELBridge.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717

1818
const ServiceName = "land-editor";
1919
const ServiceVersion = "0.0.1";
20-
// Same-origin path - proxied by Vite (dev) or Mountain (prod) to the real
21-
// OTLP collector. No CORS preflight, no cross-origin issues.
22-
const OTLPEndpoint = "/v1/traces";
20+
// In Vite dev server, /v1/traces is proxied. In Tauri desktop (localhost:PORT),
21+
// we must use the real collector URL directly. CSP allows http://localhost:*.
22+
const OTLPEndpoint =
23+
typeof (window as any).__TAURI_INTERNALS__ !== "undefined"
24+
? "http://localhost:4318/v1/traces"
25+
: "/v1/traces";
2326
const BatchIntervalMs = 2000;
2427
const TraceId = Array.from(crypto.getRandomValues(new Uint8Array(16)))
2528
.map((B) => B.toString(16).padStart(2, "0"))

Source/Workbench/Electron/PostHogBridge.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ const LoadPostHog = async (): Promise<any> => {
4141
disable_session_recording: true,
4242
disable_surveys: true,
4343
advanced_disable_decide: true,
44+
disable_external_dependency_loading: true,
4445
persistence: "memory",
4546
bootstrap: {
4647
distinctID: `land-dev-${Date.now()}`,

Source/pages/index.astro

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ const Worker = `/Worker.js?BASE_REMOTE=${encodeURIComponent(Astro.url.origin)}`;
118118
],
119119
"font-src": [
120120
"'self'",
121+
"vscode-file:",
122+
"vscode-file://vscode-app",
121123
"vscode-remote-resource:",
122124
"vscode-managed-remote-resource:",
123125
"http://localhost:*",

0 commit comments

Comments
 (0)