@happyvertical/smrt-ui 0.57.21 → 0.57.23
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/AGENTS.md +1 -0
- package/dist/analytics/index.d.ts +17 -0
- package/dist/analytics/index.d.ts.map +1 -0
- package/dist/analytics/index.js +43 -0
- package/package.json +7 -2
package/AGENTS.md
CHANGED
|
@@ -58,6 +58,7 @@ components are exempt — they *are* the primitives.
|
|
|
58
58
|
| `.` permissions | `PermissionCheck` and the domain-agnostic `PermissionPicker` for grouped, searchable native role-grant forms over host-supplied catalog records |
|
|
59
59
|
| `./form-retry` | **Svelte-free** form retry (#3291): submission key, in-flight refusal, conditional reset, opt-in restore-after-reload, browser `runOnce()` digest. Also re-exported from `./forms`. Framework-free TS typed structurally against SvelteKit's `SubmitFunction` — never import `@sveltejs/kit` here. Guide: `docs/content/form-retry.md` |
|
|
60
60
|
| `./i18n` | i18n **client**: `useI18n`, `<Trans>`, `defineMessages`, `renderTemplate` (no `smrt-languages` import — the server resolver stays in `smrt-svelte/i18n/server`) |
|
|
61
|
+
| `./analytics` | Optional provider-neutral Svelte context for static shared component outcomes; noop without a host sink. No Matomo dependency. Browser provider lives in smrt-analytics. |
|
|
61
62
|
| `./registry` | `ModuleUIRegistry` for cross-package component discovery |
|
|
62
63
|
| `./theme` | deprecated compatibility path forwarding to the canonical theme system |
|
|
63
64
|
| `./themes` | canonical `ThemeProvider`, context, preset token system (material/glass/studio/smrt/happyvertical), and CSS generation |
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Static standard outcomes and engagement; never includes component data. */
|
|
2
|
+
export type StandardAnalyticsEvent = 'planner_opened' | 'planner_cookbook_applied' | 'project_question_answered' | 'project_decision_resolved' | 'project_preview_opened' | 'project_preview_approved' | 'project_preview_rejected';
|
|
3
|
+
/** Optional private receipt identity, used only for in-memory duplicate suppression. */
|
|
4
|
+
export interface AnalyticsEmissionOptions {
|
|
5
|
+
dedupeKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export type AnalyticsSink = (name: string, options?: AnalyticsEmissionOptions) => unknown;
|
|
8
|
+
/** Install once during the host root component's initialization. No SSR globals. */
|
|
9
|
+
export declare function setAnalyticsContext(sink: AnalyticsSink): void;
|
|
10
|
+
/** Capture during component initialization; absent configuration is a noop. */
|
|
11
|
+
export declare function getAnalyticsContext(): AnalyticsSink;
|
|
12
|
+
/** Observe only persisted status changes; initial/historical rows are not events. */
|
|
13
|
+
export declare function createAnalyticsTransitions(emit: (name: StandardAnalyticsEvent) => unknown): (rows: readonly {
|
|
14
|
+
id: string;
|
|
15
|
+
status: string;
|
|
16
|
+
}[], from: string, outcomes: Readonly<Record<string, StandardAnalyticsEvent>>) => void;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analytics/index.ts"],"names":[],"mappings":"AAEA,8EAA8E;AAC9E,MAAM,MAAM,sBAAsB,GAC9B,gBAAgB,GAChB,0BAA0B,GAC1B,2BAA2B,GAC3B,2BAA2B,GAC3B,wBAAwB,GACxB,0BAA0B,GAC1B,0BAA0B,CAAC;AAC/B,wFAAwF;AACxF,MAAM,WAAW,wBAAwB;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,wBAAwB,KAC/B,OAAO,CAAC;AAIb,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAE7D;AACD,+EAA+E;AAC/E,wBAAgB,mBAAmB,IAAI,aAAa,CASnD;AAED,qFAAqF;AACrF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,OAAO,IAI7C,MAAM,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,EAC/C,MAAM,MAAM,EACZ,UAAU,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC,UAmB7D"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getContext, setContext } from 'svelte';
|
|
2
|
+
const KEY = Symbol.for('@happyvertical/smrt-ui/analytics');
|
|
3
|
+
const noop = () => { };
|
|
4
|
+
/** Install once during the host root component's initialization. No SSR globals. */
|
|
5
|
+
export function setAnalyticsContext(sink) {
|
|
6
|
+
setContext(KEY, sink);
|
|
7
|
+
}
|
|
8
|
+
/** Capture during component initialization; absent configuration is a noop. */
|
|
9
|
+
export function getAnalyticsContext() {
|
|
10
|
+
const sink = getContext(KEY) ?? noop;
|
|
11
|
+
return (name, options) => {
|
|
12
|
+
try {
|
|
13
|
+
Promise.resolve(sink(name, options)).catch(() => { });
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
/* analytics never breaks UI */
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** Observe only persisted status changes; initial/historical rows are not events. */
|
|
21
|
+
export function createAnalyticsTransitions(emit) {
|
|
22
|
+
const seen = new Map();
|
|
23
|
+
return (rows, from, outcomes) => {
|
|
24
|
+
const present = new Set(rows.map((row) => row.id));
|
|
25
|
+
for (const id of seen.keys()) {
|
|
26
|
+
if (!present.has(id))
|
|
27
|
+
seen.delete(id);
|
|
28
|
+
}
|
|
29
|
+
for (const row of rows) {
|
|
30
|
+
const previous = seen.get(row.id);
|
|
31
|
+
seen.set(row.id, row.status);
|
|
32
|
+
const outcome = outcomes[row.status];
|
|
33
|
+
if (previous === from && outcome) {
|
|
34
|
+
try {
|
|
35
|
+
Promise.resolve(emit(outcome)).catch(() => { });
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
/* no UI failures */
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-ui",
|
|
3
|
-
"version": "0.57.
|
|
3
|
+
"version": "0.57.23",
|
|
4
4
|
"smrtJsdoc": "strict",
|
|
5
5
|
"description": "Domain-agnostic Svelte 5 UI runtime for SMRT: primitives, i18n client, theme system, and module UI registry",
|
|
6
6
|
"type": "module",
|
|
@@ -142,6 +142,11 @@
|
|
|
142
142
|
"./charts/format": {
|
|
143
143
|
"types": "./dist/charts/format.d.ts",
|
|
144
144
|
"import": "./dist/charts/format.js"
|
|
145
|
+
},
|
|
146
|
+
"./analytics": {
|
|
147
|
+
"types": "./dist/analytics/index.d.ts",
|
|
148
|
+
"import": "./dist/analytics/index.js",
|
|
149
|
+
"default": "./dist/analytics/index.js"
|
|
145
150
|
}
|
|
146
151
|
},
|
|
147
152
|
"files": [
|
|
@@ -170,7 +175,7 @@
|
|
|
170
175
|
"access": "public"
|
|
171
176
|
},
|
|
172
177
|
"dependencies": {
|
|
173
|
-
"@happyvertical/smrt-types": "0.57.
|
|
178
|
+
"@happyvertical/smrt-types": "0.57.23",
|
|
174
179
|
"esm-env": "^1.2.2"
|
|
175
180
|
},
|
|
176
181
|
"peerDependencies": {
|