@hyperframes/studio 0.9.64 → 0.9.66

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 (99) hide show
  1. package/dist/assets/hyperframes-player-VGx6ow_e.js +573 -0
  2. package/dist/assets/{index-CVmmHGol.js → index-B8Xt_Oyw.js} +190 -186
  3. package/dist/assets/{index-DN167Uqf.js → index-BH18TdX9.js} +1 -1
  4. package/dist/assets/{pausedVideoDecoder-C8rhpGPx.js → pausedVideoDecoder-Bx3fGNkU.js} +1 -1
  5. package/dist/{chunk-VDDEXNVX.js → chunk-ESTBKVCB.js} +8 -0
  6. package/dist/index.d.ts +2 -0
  7. package/dist/index.html +1 -1
  8. package/dist/index.js +1580 -882
  9. package/dist/player.js +1 -1
  10. package/package.json +8 -8
  11. package/src/captions/components/CaptionOverlay.sealed.test.ts +2 -25
  12. package/src/captions/hooks/useCaptionSync.ts +4 -1
  13. package/src/components/editor/LayersPanel.opaque.test.ts +4 -29
  14. package/src/components/editor/MotionPathOverlay.sealed.test.tsx +85 -0
  15. package/src/components/editor/MotionPathOverlay.tsx +26 -12
  16. package/src/components/editor/domEditOverlayCrop.ts +78 -15
  17. package/src/components/editor/domEditOverlayCropFrameLift.test.ts +64 -0
  18. package/src/components/editor/domEditOverlayStartGesture.ts +0 -14
  19. package/src/components/editor/gestureUndoRevert.ts +3 -6
  20. package/src/components/editor/gsapMoveSealedPreview.test.ts +247 -0
  21. package/src/components/editor/manualEditsSnapshot.ts +2 -0
  22. package/src/components/editor/manualOffsetDrag.ts +13 -18
  23. package/src/components/editor/plainTranslate.test.ts +22 -1
  24. package/src/components/editor/plainTranslate.ts +8 -6
  25. package/src/components/editor/previewDrafts.test.ts +13 -39
  26. package/src/components/editor/previewDrafts.ts +4 -0
  27. package/src/components/editor/previewGestureStartRead.test.ts +59 -32
  28. package/src/components/editor/previewGestureStartRead.ts +9 -0
  29. package/src/components/editor/previewLayers.test.ts +3 -20
  30. package/src/components/editor/previewOverlayRects.test.ts +3 -20
  31. package/src/components/editor/previewPointerTargets.test.ts +3 -20
  32. package/src/components/editor/previewSelection.test.ts +51 -35
  33. package/src/components/editor/previewSelection.ts +18 -0
  34. package/src/components/editor/useColorGradingController.sealed.test.ts +5 -30
  35. package/src/components/editor/useMotionPathData.reply.test.ts +40 -0
  36. package/src/components/editor/useMotionPathData.sealed.test.ts +57 -0
  37. package/src/components/editor/useMotionPathData.test.tsx +1 -1
  38. package/src/components/editor/useMotionPathData.ts +83 -33
  39. package/src/components/nle/CompositionBreadcrumb.tsx +2 -5
  40. package/src/components/nle/NLEContext.drillDown.test.ts +85 -0
  41. package/src/components/nle/NLEContext.tsx +21 -23
  42. package/src/components/nle/NLEPreview.test.ts +18 -3
  43. package/src/components/nle/NLEPreview.tsx +10 -1
  44. package/src/components/nle/audioSealedPreview.test.ts +5 -32
  45. package/src/components/panels/motionBlurPanelModel.sealed.test.ts +30 -0
  46. package/src/components/panels/motionBlurPanelModel.ts +37 -7
  47. package/src/hooks/appHotkeysDispatch.ts +38 -1
  48. package/src/hooks/domEditCommits.sealed.test.ts +191 -0
  49. package/src/hooks/domStyleCommit.ts +18 -7
  50. package/src/hooks/draggedGsapPosition.ts +20 -0
  51. package/src/hooks/gsapEditOutcome.ts +3 -0
  52. package/src/hooks/gsapFrameSnapshot.test.ts +113 -0
  53. package/src/hooks/gsapFrameSnapshot.ts +246 -0
  54. package/src/hooks/gsapParsedTween.ts +16 -9
  55. package/src/hooks/gsapResizeIntercept.ts +7 -2
  56. package/src/hooks/gsapRuntimeBridge.ts +4 -0
  57. package/src/hooks/gsapRuntimeKeyframes.ts +23 -15
  58. package/src/hooks/gsapShared.ts +4 -0
  59. package/src/hooks/gsapSnapshotReply.ts +105 -0
  60. package/src/hooks/useAppHotkeys.previewForwarding.test.tsx +134 -0
  61. package/src/hooks/useAppHotkeys.ts +36 -1
  62. package/src/hooks/useDomEditAttributeCommits.ts +43 -19
  63. package/src/hooks/useDomEditCommits.test.tsx +1 -1
  64. package/src/hooks/useDomEditPreviewSync.test.ts +36 -1
  65. package/src/hooks/useDomEditPreviewSync.ts +3 -3
  66. package/src/hooks/useEditorSave.ts +2 -1
  67. package/src/hooks/useEnableKeyframes.sealed.test.ts +70 -0
  68. package/src/hooks/useEnableKeyframes.ts +9 -2
  69. package/src/hooks/useGsapTweenCache.ts +9 -3
  70. package/src/hooks/usePreviewPersistence.ts +18 -11
  71. package/src/hooks/useSdkSession.lifecycle.test.tsx +1 -0
  72. package/src/hooks/useSdkSession.ts +2 -0
  73. package/src/hooks/useSlideshowTabState.test.ts +47 -3
  74. package/src/hooks/useSlideshowTabState.ts +32 -16
  75. package/src/player/hooks/timelinePlayerTestHarness.ts +2 -1
  76. package/src/player/hooks/usePlaybackKeyboard.ts +1 -1
  77. package/src/player/hooks/useTimelineSyncCallbacks.sealed.test.ts +2 -29
  78. package/src/player/lib/previewChannel.test.ts +10 -0
  79. package/src/player/lib/previewChannel.ts +9 -0
  80. package/src/player/lib/previewElements.test.ts +34 -1
  81. package/src/player/lib/previewElements.ts +101 -18
  82. package/src/player/lib/sealedPreviewFrame.test-helpers.ts +38 -0
  83. package/src/player/lib/timelineIframeHelpers.ts +1 -1
  84. package/src/telemetry/client.ts +4 -2
  85. package/src/telemetry/eventShape.test.ts +189 -0
  86. package/src/telemetry/eventShape.ts +192 -0
  87. package/src/utils/blockInstaller.test.ts +82 -48
  88. package/src/utils/blockInstaller.ts +6 -14
  89. package/src/utils/domEditSaveQueue.test.ts +12 -2
  90. package/src/utils/domEditSaveQueue.ts +4 -4
  91. package/src/utils/previewCompositionSize.test.ts +61 -0
  92. package/src/utils/previewCompositionSize.ts +21 -1
  93. package/src/utils/sdkEditTransaction.ts +6 -2
  94. package/src/utils/sdkResolverShadow.ts +16 -15
  95. package/src/utils/studioSaveDiagnostics.test.ts +21 -3
  96. package/src/utils/studioSaveDiagnostics.ts +71 -6
  97. package/src/utils/studioTelemetry.ts +6 -1
  98. package/dist/assets/hyperframes-player-mSF_GvRs.js +0 -573
  99. package/src/components/editor/motionPathHome.ts +0 -75
@@ -0,0 +1,61 @@
1
+ // @vitest-environment happy-dom
2
+
3
+ import { afterEach, describe, expect, it } from "vitest";
4
+ import { readPreviewCompositionSize } from "./previewCompositionSize";
5
+
6
+ type Player = HTMLElement & {
7
+ ready?: boolean;
8
+ compositionWidth?: number;
9
+ compositionHeight?: number;
10
+ };
11
+
12
+ /** A frame in a player's shadow root, as <hyperframes-player> holds it; a sealed one refuses its document. */
13
+ function frameInPlayer(sealed: boolean, player: Partial<Player>) {
14
+ const host = Object.assign(document.createElement("div"), player) as Player;
15
+ document.body.append(host);
16
+ const iframe = document.createElement("iframe");
17
+ host.attachShadow({ mode: "open" }).append(iframe);
18
+ if (sealed) {
19
+ const refusing = {
20
+ get document(): Document {
21
+ throw new DOMException("Blocked a frame with origin", "SecurityError");
22
+ },
23
+ };
24
+ Object.defineProperty(iframe, "contentWindow", { get: () => refusing });
25
+ Object.defineProperty(iframe, "contentDocument", { get: () => null });
26
+ }
27
+ return iframe;
28
+ }
29
+
30
+ afterEach(() => document.body.replaceChildren());
31
+
32
+ describe("readPreviewCompositionSize", () => {
33
+ it("reads a sealed frame's size from its player once the player is ready", () => {
34
+ const iframe = frameInPlayer(true, {
35
+ ready: true,
36
+ compositionWidth: 1080,
37
+ compositionHeight: 1920,
38
+ });
39
+ expect(readPreviewCompositionSize(iframe)).toEqual({ width: 1080, height: 1920 });
40
+ });
41
+
42
+ it("reads no size from a sealed frame's player before it is ready, whose numbers are only defaults", () => {
43
+ const iframe = frameInPlayer(true, {
44
+ ready: false,
45
+ compositionWidth: 1920,
46
+ compositionHeight: 1080,
47
+ });
48
+ expect(readPreviewCompositionSize(iframe)).toBeNull();
49
+ });
50
+
51
+ it("reads a frame Studio can script from its document, not its player", () => {
52
+ const iframe = frameInPlayer(false, {
53
+ ready: true,
54
+ compositionWidth: 1920,
55
+ compositionHeight: 1080,
56
+ });
57
+ iframe.contentDocument!.body.innerHTML =
58
+ '<div data-composition-id="main" data-width="720" data-height="1280"></div>';
59
+ expect(readPreviewCompositionSize(iframe)).toEqual({ width: 720, height: 1280 });
60
+ });
61
+ });
@@ -1,13 +1,33 @@
1
+ import { previewFrameOpaque } from "../player/lib/previewChannel";
2
+ import { resolvePreviewPlayerHost } from "../player/lib/timelineIframeHelpers";
3
+
1
4
  export interface PreviewCompositionSize {
2
5
  width: number;
3
6
  height: number;
4
7
  }
5
8
 
6
- /** The root composition's authored size, read from the preview document itself. */
9
+ type SizedPlayer = HTMLElement & {
10
+ ready?: boolean;
11
+ compositionWidth?: number;
12
+ compositionHeight?: number;
13
+ };
14
+
15
+ const isPositive = (value: unknown): value is number =>
16
+ typeof value === "number" && Number.isFinite(value) && value > 0;
17
+
18
+ function readyPlayerCompositionSize(iframe: HTMLIFrameElement): PreviewCompositionSize | null {
19
+ const player = resolvePreviewPlayerHost(iframe) as SizedPlayer | null;
20
+ if (!player?.ready) return null;
21
+ const { compositionWidth: width, compositionHeight: height } = player;
22
+ return isPositive(width) && isPositive(height) ? { width, height } : null;
23
+ }
24
+
25
+ /** The root composition's authored size, from the preview document, or from its player when the frame is sealed. */
7
26
  // fallow-ignore-next-line complexity
8
27
  export function readPreviewCompositionSize(
9
28
  iframe: HTMLIFrameElement | null,
10
29
  ): PreviewCompositionSize | null {
30
+ if (iframe && previewFrameOpaque(iframe)) return readyPlayerCompositionSize(iframe);
11
31
  try {
12
32
  const doc = iframe?.contentDocument;
13
33
  const root =
@@ -140,6 +140,7 @@ export function failedCutover(
140
140
  family,
141
141
  error_kind: cutoverErrorKind(err),
142
142
  ...(err instanceof StudioSaveHttpError ? { status: err.statusCode } : {}),
143
+ error_name: err.name,
143
144
  error: err.message,
144
145
  });
145
146
  return { status: "failed", error: err };
@@ -273,7 +274,8 @@ function refreshCommittedEdit(after: string, deps: CutoverDeps, options?: Cutove
273
274
  if (deps.refresh) deps.refresh(after);
274
275
  else if (!options?.skipRefresh) deps.reloadPreview();
275
276
  } catch (error) {
276
- trackStudioEvent("sdk_cutover_refresh_failed", { error: asCutoverError(error).message });
277
+ const err = asCutoverError(error);
278
+ trackStudioEvent("sdk_cutover_refresh_failed", { error_name: err.name, error: err.message });
277
279
  }
278
280
  }
279
281
 
@@ -306,9 +308,11 @@ async function commitCandidateEdit(
306
308
  // candidate here can make all three authorities disagree (or dispose the
307
309
  // now-live session). Production publishers are non-throwing; keep the
308
310
  // durable commit authoritative and surface this post-commit fault.
311
+ const err = asCutoverError(error);
309
312
  trackStudioEvent("sdk_cutover_publish_failed", {
310
313
  path: targetPath,
311
- error: asCutoverError(error).message,
314
+ error_name: err.name,
315
+ error: err.message,
312
316
  });
313
317
  }
314
318
  if (refreshTarget) refreshCommittedEdit(edit.after, deps, options);
@@ -255,20 +255,23 @@ import { recordAttempt } from "./sdkResolverAttempts";
255
255
 
256
256
  // ─── Telemetry ────────────────────────────────────────────────────────────────
257
257
 
258
- // Redact all user-content values before telemetry: style values and text both
259
- // carry user data. Keep only the length so we can detect truncation without
260
- // leaking the actual bytes.
258
+ // User content leaves as its length only (style values, text, error words); the selector-built
259
+ // animationId goes too, as the event's own animationId is shaped.
261
260
  function redactValue(value: string | null | undefined): string | null | undefined {
262
261
  if (value == null) return value;
263
262
  return `[redacted len=${value.length}]`;
264
263
  }
265
264
 
266
- function redactMismatches(mismatches: SdkResolverMismatch[]): SdkResolverMismatch[] {
267
- return mismatches.map((m) => ({
268
- ...m,
269
- expected: redactValue(m.expected),
270
- actual: redactValue(m.actual),
271
- }));
265
+ function redactMismatches(mismatches: SdkResolverMismatch[]): string {
266
+ return JSON.stringify(
267
+ mismatches.map((m) => ({
268
+ ...m,
269
+ expected: redactValue(m.expected),
270
+ actual: redactValue(m.actual),
271
+ error: redactValue(m.error),
272
+ animationId: undefined,
273
+ })),
274
+ );
272
275
  }
273
276
 
274
277
  /**
@@ -303,7 +306,7 @@ function reportEmptySession(session: Composition, opLabel: string): boolean {
303
306
  sessionEmpty: true,
304
307
  sessionElementCount: 0,
305
308
  mismatchCount: 1,
306
- mismatches: JSON.stringify([{ kind: "session_empty" } satisfies SdkResolverMismatch]),
309
+ mismatches: redactMismatches([{ kind: "session_empty" } satisfies SdkResolverMismatch]),
307
310
  });
308
311
  }
309
312
  return true;
@@ -372,7 +375,7 @@ export function runResolverShadow(
372
375
  // attribute count came back 0 — see the sourceHfIdCount comment above.
373
376
  ...(strictCount === 0 ? { sourceLooseMatchOnly: true } : {}),
374
377
  mismatchCount: mismatches.length,
375
- mismatches: JSON.stringify(redactMismatches(mismatches)),
378
+ mismatches: redactMismatches(mismatches),
376
379
  });
377
380
  } catch {
378
381
  // never propagate from the shadow path
@@ -457,7 +460,7 @@ export async function recordResolverParity(
457
460
  // fail-open without the suppression/count checks" from "no reader wired".
458
461
  ...(sourceReadFailed ? { sourceReadFailed: true } : {}),
459
462
  mismatchCount: 1,
460
- mismatches: JSON.stringify([
463
+ mismatches: redactMismatches([
461
464
  { kind: "element_not_found", hfId } satisfies SdkResolverMismatch,
462
465
  ]),
463
466
  });
@@ -566,9 +569,7 @@ export async function recordAnimationResolverParity(
566
569
  ...(diskChecked ? { diskChecked: true } : {}),
567
570
  ...(sourceReadFailed ? { sourceReadFailed: true } : {}),
568
571
  mismatchCount: 1,
569
- mismatches: JSON.stringify([
570
- { kind: "animation_not_found", animationId } satisfies SdkResolverMismatch,
571
- ]),
572
+ mismatches: redactMismatches([{ kind: "animation_not_found" } satisfies SdkResolverMismatch]),
572
573
  });
573
574
  } catch {
574
575
  // never propagate from the shadow path
@@ -75,7 +75,7 @@ describe("studio save diagnostics", () => {
75
75
  });
76
76
  });
77
77
 
78
- it("builds save_failure properties with stable diagnostics", () => {
78
+ it("builds save_failure properties as fixed codes, never the error's words", () => {
79
79
  const error = new StudioSaveHttpError("Failed to save index.html (503)", 503);
80
80
 
81
81
  expect(
@@ -88,7 +88,9 @@ describe("studio save diagnostics", () => {
88
88
  }),
89
89
  ).toEqual({
90
90
  source: "code_editor",
91
- error_message: "Failed to save index.html (503)",
91
+ error_class: "StudioSaveHttpError",
92
+ error_key: "http",
93
+ server_why: "other",
92
94
  status_code: 503,
93
95
  file_path: "index.html",
94
96
  mutation_type: "put",
@@ -100,6 +102,21 @@ describe("studio save diagnostics", () => {
100
102
  });
101
103
  });
102
104
 
105
+ it("names the server's fixed refusal and keeps its words out", async () => {
106
+ const response = new Response(
107
+ JSON.stringify({ error: "forbidden path: compositions/x.html", why: "protected_path" }),
108
+ { status: 403 },
109
+ );
110
+ const error = await createStudioSaveHttpError(response, "Failed to save compositions/x.html");
111
+ const properties = buildStudioSaveFailureProperties({ source: "dom_edit", error });
112
+ expect(properties).toMatchObject({
113
+ error_key: "http",
114
+ server_why: "protected_path",
115
+ status_code: 403,
116
+ });
117
+ expect(JSON.stringify(properties)).not.toContain("compositions/x.html");
118
+ });
119
+
103
120
  it("emits expected direct-edit refusals on edit_blocked", () => {
104
121
  const error = new Error("This animation is computed at runtime");
105
122
 
@@ -112,7 +129,8 @@ describe("studio save diagnostics", () => {
112
129
 
113
130
  expect(trackStudioEvent).toHaveBeenCalledWith("edit_blocked", {
114
131
  source: "gsap_commit",
115
- error_message: error.message,
132
+ error_class: "Error",
133
+ error_key: "unknown",
116
134
  status_code: null,
117
135
  file_path: "index.html",
118
136
  mutation_type: "drag",
@@ -16,21 +16,37 @@ export interface StudioSaveFailureInput {
16
16
  targetSourceFile?: string | null;
17
17
  }
18
18
 
19
+ const SERVER_WHY = new Set([
20
+ "nul",
21
+ "dangling_symlink",
22
+ "outside_project",
23
+ "protected_path",
24
+ "busy",
25
+ "permission",
26
+ "not_a_file",
27
+ "too_large",
28
+ "binary",
29
+ "link",
30
+ "project_dir_missing",
31
+ ]);
32
+
19
33
  export class StudioSaveHttpError extends Error {
20
34
  readonly statusCode: number;
21
35
  readonly alreadyToasted: boolean;
22
36
  readonly heldFile: boolean;
37
+ readonly why: string | null;
23
38
 
24
39
  constructor(
25
40
  message: string,
26
41
  statusCode: number,
27
- options: { alreadyToasted?: boolean; heldFile?: boolean } = {},
42
+ options: { alreadyToasted?: boolean; heldFile?: boolean; why?: string | null } = {},
28
43
  ) {
29
44
  super(message);
30
45
  this.name = "StudioSaveHttpError";
31
46
  this.statusCode = statusCode;
32
47
  this.alreadyToasted = options.alreadyToasted ?? false;
33
48
  this.heldFile = options.heldFile ?? false;
49
+ this.why = options.why ?? null;
34
50
  }
35
51
  }
36
52
 
@@ -162,7 +178,7 @@ export function buildStudioSaveFailureProperties(
162
178
  const attempt = input.attempt ?? getStudioSaveAttempt(input.error) ?? undefined;
163
179
  return {
164
180
  source: input.source,
165
- error_message: getStudioSaveErrorMessage(input.error),
181
+ ...studioSaveErrorCodes(input.error),
166
182
  status_code: statusCode,
167
183
  file_path: input.filePath ?? input.targetSourceFile ?? undefined,
168
184
  mutation_type: input.mutationType ?? undefined,
@@ -175,10 +191,45 @@ export function buildStudioSaveFailureProperties(
175
191
  };
176
192
  }
177
193
 
194
+ const isNamed = (name: string) => (error: unknown) => error instanceof Error && error.name === name;
195
+ const ERROR_KEYS: ReadonlyArray<readonly [string, (error: unknown) => boolean]> = [
196
+ ["conflict", (error) => findCause(error, StudioFileConflictError) !== null],
197
+ ["held", (error) => findCause(error, StudioSaveHttpError)?.heldFile === true],
198
+ ["http", (error) => findCause(error, StudioSaveHttpError) !== null],
199
+ ["network", (error) => findCause(error, StudioSaveNetworkError) !== null],
200
+ ["aborted", isNamed("AbortError")],
201
+ ["blocked", isNamed("GsapEditBlockedError")],
202
+ ];
203
+
204
+ export function studioSaveErrorCodes(error: unknown): Record<string, StudioTelemetryValue> {
205
+ const failure = error instanceof Error ? error : null;
206
+ const http = findCause(error, StudioSaveHttpError);
207
+ const errorKey = ERROR_KEYS.find(([, matches]) => matches(error))?.[0] ?? "unknown";
208
+ return {
209
+ error_class: failure?.name ?? typeof error,
210
+ error_key: errorKey,
211
+ server_why: http ? (http.why ?? "other") : undefined,
212
+ block_reason: blockReason(error),
213
+ };
214
+ }
215
+
216
+ function findCause<T extends Error>(error: unknown, type: new (...args: never[]) => T): T | null {
217
+ for (let at = error, depth = 0; at && typeof at === "object" && depth < 5; depth++) {
218
+ if (at instanceof type) return at;
219
+ at = (at as { cause?: unknown }).cause;
220
+ }
221
+ return null;
222
+ }
223
+
224
+ function blockReason(error: unknown): string | undefined {
225
+ if (!(error instanceof Error) || error.name !== "GsapEditBlockedError") return undefined;
226
+ const reason = (error as { reason?: unknown }).reason;
227
+ return typeof reason === "string" ? reason : undefined;
228
+ }
229
+
178
230
  /**
179
- * The specific cause behind a blocked GSAP edit. `error_message` only carries
180
- * the coarse copy, and one of those strings covers six different situations,
181
- * so the message alone cannot say which one a user hit.
231
+ * The specific cause behind a blocked GSAP edit: one block reason covers six
232
+ * different situations, so the reason alone cannot say which one a user hit.
182
233
  */
183
234
  function gsapBlockDetail(error: unknown): string | undefined {
184
235
  if (!(error instanceof Error) || error.name !== "GsapEditBlockedError") return undefined;
@@ -234,12 +285,26 @@ export async function createStudioSaveHttpError(
234
285
  }
235
286
  const detail = body.trim().slice(0, 300);
236
287
  const held = heldFileMessage(body, options.path);
288
+ const why = serverWhy(body);
237
289
  const message =
238
290
  held ??
239
291
  (detail
240
292
  ? `${fallbackMessage} (${response.status}): ${detail}`
241
293
  : `${fallbackMessage} (${response.status})`);
242
- return new StudioSaveHttpError(message, response.status, { ...options, heldFile: held !== null });
294
+ return new StudioSaveHttpError(message, response.status, {
295
+ ...options,
296
+ heldFile: held !== null,
297
+ why,
298
+ });
299
+ }
300
+
301
+ function serverWhy(body: string): string | null {
302
+ try {
303
+ const why: unknown = (JSON.parse(body) as { why?: unknown }).why;
304
+ return typeof why === "string" && SERVER_WHY.has(why) ? why : null;
305
+ } catch {
306
+ return null;
307
+ }
243
308
  }
244
309
 
245
310
  export const heldFileWords = (error: unknown): string | null =>
@@ -5,6 +5,7 @@ import { canaryEventProperties } from "../telemetry/canary";
5
5
  import { agentRuntimeProperty } from "../telemetry/agentRuntime";
6
6
  import { tabIdProperty } from "../telemetry/tabId";
7
7
  import { studioApiFetch } from "./studioApiFetch";
8
+ import { shapeEventProperties } from "../telemetry/eventShape";
8
9
 
9
10
  // PostHog public ingest key — write-only, safe to ship in the client bundle
10
11
  const POSTHOG_API_KEY = "phc_zjjbX0PnWxERXrMHhkEJWj9A9BhGVLRReICgsfTMmpx";
@@ -120,7 +121,11 @@ export function trackStudioEvent(event: string, properties: EventProperties = {}
120
121
  // Canary assignments on every event, matching the CLI and the newer
121
122
  // studio client — "every telemetry event carries the assignment" has to
122
123
  // include this path or a cohort breakdown silently omits `studio:*`.
123
- properties: { ...getSessionProperties(), ...canaryEventProperties(), ...properties },
124
+ properties: {
125
+ ...canaryEventProperties(),
126
+ ...shapeEventProperties(`studio:${event}`, properties),
127
+ ...getSessionProperties(),
128
+ },
124
129
  timestamp: new Date().toISOString(),
125
130
  });
126
131