@arcote.tech/platform 0.7.5 → 0.7.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +10 -4
  2. package/src/start-app.ts +20 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@arcote.tech/platform",
3
3
  "type": "module",
4
- "version": "0.7.5",
4
+ "version": "0.7.6",
5
5
  "private": false,
6
6
  "author": "Przemysław Krasiński [arcote.tech]",
7
7
  "description": "Arc Platform — module system, router, layout, theme, i18n, platform app shell",
@@ -14,11 +14,12 @@
14
14
  "type-check": "tsc --noEmit"
15
15
  },
16
16
  "dependencies": {
17
- "@arcote.tech/arc-ds": "^0.7.5",
18
- "@arcote.tech/arc-react": "^0.7.5"
17
+ "@arcote.tech/arc-ds": "^0.7.6",
18
+ "@arcote.tech/arc-react": "^0.7.6"
19
19
  },
20
20
  "peerDependencies": {
21
- "@arcote.tech/arc": "^0.7.5",
21
+ "@arcote.tech/arc": "^0.7.6",
22
+ "@arcote.tech/arc-otel": "^0.7.6",
22
23
  "@lingui/core": "^5.0.0",
23
24
  "@lingui/react": "^5.0.0",
24
25
  "framer-motion": "^12.0.0",
@@ -27,6 +28,11 @@
27
28
  "react-dom": "^18.0.0 || ^19.0.0",
28
29
  "typescript": "^5.0.0"
29
30
  },
31
+ "peerDependenciesMeta": {
32
+ "@arcote.tech/arc-otel": {
33
+ "optional": true
34
+ }
35
+ },
30
36
  "devDependencies": {
31
37
  "@lingui/core": "^5.9.2",
32
38
  "@types/react": "^19.2.7",
package/src/start-app.ts CHANGED
@@ -9,9 +9,28 @@ import { PlatformApp } from "./platform-app";
9
9
  * directly, Bun would copy them into the entry chunk alongside the existing
10
10
  * platform-chunk copy — producing two React instances and the classic
11
11
  * "Invalid hook call" crash.
12
+ *
13
+ * When `window.__ARC_OTEL_CONFIG` is present (injected by the server when
14
+ * observability is enabled), the OTel browser SDK is loaded as a separate
15
+ * chunk and initialised before render. Bundles that don't have it (default
16
+ * deploys) never download the SDK — zero LCP impact.
12
17
  */
13
18
  export function startApp(elementId: string): void {
14
19
  const el = document.getElementById(elementId);
15
20
  if (!el) throw new Error(`startApp: #${elementId} not found`);
16
- createRoot(el).render(createElement(PlatformApp));
21
+
22
+ const otelConfig = (globalThis as any).__ARC_OTEL_CONFIG;
23
+ const bootstrap = async () => {
24
+ if (otelConfig?.enabled) {
25
+ try {
26
+ const mod = await import("@arcote.tech/arc-otel/browser");
27
+ mod.initBrowserTelemetry(otelConfig);
28
+ } catch (e) {
29
+ // Telemetry must never block app startup — log + continue.
30
+ console.warn("[arc-otel] browser init failed", e);
31
+ }
32
+ }
33
+ createRoot(el).render(createElement(PlatformApp));
34
+ };
35
+ void bootstrap();
17
36
  }