@supersuit/artifacts 0.53.0 → 0.54.0
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/CHANGELOG.md +20 -0
- package/lib/reader/page-analytics.js +17 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
`@supersuit/artifacts`. One entry per version, newest first. Each entry says what changed, how a
|
|
4
4
|
host can tell whether it is affected (DETECTOR), what a host does about it (REMEDY), and the tests.
|
|
5
5
|
|
|
6
|
+
## 0.54.0 (2026-10-25)
|
|
7
|
+
|
|
8
|
+
**A page no longer records under a reader left on the browser by another page.** posthog-js keeps
|
|
9
|
+
the last identity it was given on an origin, and `PageAnalytics` never cleared it, so a browser that
|
|
10
|
+
opened one per-reader link sent every password or public page it opened afterward under that
|
|
11
|
+
reader's recipient id and label, and a per-reader page's init-time `$pageview` went out under the
|
|
12
|
+
previous reader before `identify()` switched it.
|
|
13
|
+
|
|
14
|
+
- `PageAnalytics` calls `posthog.reset()` when the browser is identified as anyone other than the
|
|
15
|
+
page's own reader, before `register` (reset clears registered properties). An anonymous browser
|
|
16
|
+
is not reset, so its first visit still joins the reader it becomes; the device id survives.
|
|
17
|
+
- `capture_pageview` is now `false`; the page captures `$pageview` itself once the reader is settled.
|
|
18
|
+
- DETECTOR: in PostHog, a `password` or `public` `page_kind` event whose `distinct_id` starts with
|
|
19
|
+
`recipient:`, or whose person has a `name`, came from a host on an older version.
|
|
20
|
+
- REMEDY: update the host. Events already recorded keep the leftover identity; a dashboard should
|
|
21
|
+
name a reader only by an id of the page's own kind (a recipient id on `per-reader`, an email on
|
|
22
|
+
`gated`) and count everything else by device.
|
|
23
|
+
- Tests: `page-analytics-identity.test.tsx` mounts the component against a stand-in posthog-js
|
|
24
|
+
holding a leftover identity and checks the call order on every page kind.
|
|
25
|
+
|
|
6
26
|
## 0.53.0 (2026-10-25)
|
|
7
27
|
|
|
8
28
|
**Every per-reader link can record who minted it, on whose authority, when, and the funnel step it
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
// than a gated one: the replay still shows where the reader went, how far and how fast, without the
|
|
12
12
|
// words. Autocapture is told not to collect element text for the same reason. There is no opt-out:
|
|
13
13
|
// the options come from posthogInitOptions, which a test holds to RECORDING_MASK for every kind.
|
|
14
|
+
//
|
|
15
|
+
// posthog-js keeps the last identity it was given on this origin, and a page that names nobody does
|
|
16
|
+
// not clear it. So a browser that opened one reader's per-reader link reported every page it opened
|
|
17
|
+
// after under that reader's id and label, and a per-reader page's init-time view went out under the
|
|
18
|
+
// previous reader before identify switched it. The page now drops an identity it was not given
|
|
19
|
+
// before it records anything, and captures its own page view once it has settled who the reader is.
|
|
14
20
|
import { useEffect } from 'react';
|
|
15
21
|
import { currentSection } from '../artifacts/toc-spy.js';
|
|
16
22
|
/** Sections read for less than this are passed over, not read. */
|
|
@@ -65,7 +71,8 @@ export function posthogInitOptions(plan) {
|
|
|
65
71
|
return {
|
|
66
72
|
api_host: plan.host,
|
|
67
73
|
person_profiles: 'identified_only',
|
|
68
|
-
|
|
74
|
+
// Captured by the page once it has settled who the reader is (see PageAnalytics).
|
|
75
|
+
capture_pageview: false,
|
|
69
76
|
capture_pageleave: true,
|
|
70
77
|
autocapture: true,
|
|
71
78
|
// Autocapture records a clicked element's text; on these pages that text is the page.
|
|
@@ -85,11 +92,17 @@ export function PageAnalytics({ plan, rootId = 'artifact-narration-root' }) {
|
|
|
85
92
|
if (cancelled)
|
|
86
93
|
return;
|
|
87
94
|
posthog.init(key, posthogInitOptions({ host }));
|
|
95
|
+
const who = identity ? JSON.parse(identity) : null;
|
|
96
|
+
// A reader left on this browser by another page is dropped first: reset also clears the
|
|
97
|
+
// registered properties, so it comes before register. An anonymous browser is left alone, so
|
|
98
|
+
// its first visit still joins the reader it becomes.
|
|
99
|
+
const left = posthog.get_property('$user_state') === 'identified' ? posthog.get_distinct_id() : null;
|
|
100
|
+
if (left && left !== who?.distinctId)
|
|
101
|
+
posthog.reset();
|
|
88
102
|
posthog.register({ artifact_id: pageId, page_kind: kind, ...(tenant ? { tenant } : {}) });
|
|
89
|
-
if (
|
|
90
|
-
const who = JSON.parse(identity);
|
|
103
|
+
if (who)
|
|
91
104
|
posthog.identify(who.distinctId, { ...(who.email ? { email: who.email } : {}), ...(who.name ? { name: who.name } : {}) });
|
|
92
|
-
|
|
105
|
+
posthog.capture('$pageview');
|
|
93
106
|
const capture = (e, p) => posthog.capture(e, p);
|
|
94
107
|
const root = document.getElementById(rootId);
|
|
95
108
|
const ids = root ? Array.from(root.querySelectorAll('h2[id], h3[id]'), (h) => h.id) : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supersuit/artifacts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.54.0",
|
|
4
4
|
"description": "Publish markdown as branded, read-aloud pages from a Next.js app: the artifacts store, the route factory, the read-along reader, brand packs, password and confidential pages, and share cards.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|