@hyperframes/studio 0.7.95 → 0.7.96

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/studio",
3
- "version": "0.7.95",
3
+ "version": "0.7.96",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -47,11 +47,11 @@
47
47
  "gsap": "^3.13.0",
48
48
  "marked": "^14.1.4",
49
49
  "mediabunny": "^1.45.3",
50
- "@hyperframes/parsers": "0.7.95",
51
- "@hyperframes/core": "0.7.95",
52
- "@hyperframes/player": "0.7.95",
53
- "@hyperframes/sdk": "0.7.95",
54
- "@hyperframes/studio-server": "0.7.95"
50
+ "@hyperframes/core": "0.7.96",
51
+ "@hyperframes/player": "0.7.96",
52
+ "@hyperframes/parsers": "0.7.96",
53
+ "@hyperframes/sdk": "0.7.96",
54
+ "@hyperframes/studio-server": "0.7.96"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/react": "19",
@@ -67,7 +67,7 @@
67
67
  "vite": "^6.4.2",
68
68
  "vitest": "^3.2.4",
69
69
  "zustand": "^5.0.0",
70
- "@hyperframes/producer": "0.7.95"
70
+ "@hyperframes/producer": "0.7.96"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "react": "19",
@@ -194,6 +194,8 @@ describe("telemetry", () => {
194
194
  expect(canaryEventProperties()).toEqual({
195
195
  "$feature/canary-on-everywhere": "true",
196
196
  "$feature/canary-off-everywhere": "false",
197
+ canary_reason_on_everywhere: "in_cohort",
198
+ canary_reason_off_everywhere: "out_of_cohort",
197
199
  });
198
200
 
199
201
  __resetStudioCanaryCacheForTests();
@@ -235,6 +237,8 @@ describe("telemetry opt-out is canary opt-out", () => {
235
237
  expect(canaryEventProperties()).toEqual({
236
238
  "$feature/canary-on-everywhere": "false",
237
239
  "$feature/canary-off-everywhere": "false",
240
+ canary_reason_on_everywhere: "telemetry_opt_out",
241
+ canary_reason_off_everywhere: "telemetry_opt_out",
238
242
  });
239
243
  });
240
244
  });
@@ -323,3 +327,24 @@ describe("CLI-launched Studio adopts the CLI's decisions", () => {
323
327
  });
324
328
  });
325
329
  });
330
+
331
+ // A CLI-launched Studio shares the CLI's bucket seed, so a cohort flip can
332
+ // surface on either surface. Attribution on only one of them makes the two
333
+ // flip counts irreconcilable — which is why this is not a CLI-only property.
334
+ describe("Studio attribution matches the CLI", () => {
335
+ it("distinguishes a local URL override from a cohort roll at the same value", () => {
336
+ setSearch("?hf_canary_off_everywhere=on");
337
+ const props = canaryEventProperties();
338
+ expect(props["$feature/canary-off-everywhere"]).toBe("true");
339
+ expect(props["canary_reason_off_everywhere"]).toBe("forced_on");
340
+ // Same assignment `on-everywhere` reaches by an ordinary roll.
341
+ expect(props["$feature/canary-on-everywhere"]).toBe("true");
342
+ expect(props["canary_reason_on_everywhere"]).toBe("in_cohort");
343
+ });
344
+
345
+ it("never puts a reason inside the $feature namespace", () => {
346
+ for (const [key, value] of Object.entries(canaryEventProperties())) {
347
+ if (key.startsWith("$feature/")) expect(value).toMatch(/^(true|false)$/);
348
+ }
349
+ });
350
+ });
@@ -257,12 +257,22 @@ export function isCanaryEnabled(name: string): boolean {
257
257
  }
258
258
 
259
259
  /**
260
- * Canary assignments as PostHog flag properties (`$feature/canary-<name>`),
261
- * attached to every Studio event so any metric can be split by cohort —
262
- * identical shape to the CLI, so a rollout spanning both reads as one flag.
260
+ * Canary assignments as PostHog flag properties (`$feature/canary-<name>`)
261
+ * plus their `canary_reason_<name>`, attached to every Studio event so any
262
+ * metric can be split by cohort — identical shape to the CLI, so a rollout
263
+ * spanning both reads as one flag.
264
+ *
265
+ * The reason has to be here too, not just CLI-side. A CLI-launched Studio
266
+ * adopts the CLI's decisions and shares its bucket seed, so a cohort flip can
267
+ * surface on either surface; emitting attribution on only one of them makes
268
+ * the two flip counts irreconcilable and leaves Studio-observed flips
269
+ * unattributable — the exact ambiguity this property exists to remove.
263
270
  */
264
271
  export function canaryEventProperties(): Record<string, string> {
265
272
  return canaryFeatureProperties(
266
- CANARIES.map((c) => ({ name: c.name, enabled: resolveCanary(c.name).enabled })),
273
+ CANARIES.map((c) => {
274
+ const { enabled, reason } = resolveCanary(c.name);
275
+ return { name: c.name, enabled, reason };
276
+ }),
267
277
  );
268
278
  }