@plasius/analytics 1.3.0 → 1.3.2

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.
@@ -0,0 +1,159 @@
1
+ /** A cryptographically random, episode-scoped journey identifier. */
2
+ type SemanticJourneyId = string;
3
+ /** A W3C-compatible trace identifier. */
4
+ type SemanticJourneyTraceId = string;
5
+ /** A W3C-compatible span identifier. */
6
+ type SemanticJourneySpanId = string;
7
+ /** A cryptographically random semantic event identifier. */
8
+ type SemanticJourneyEventId = string;
9
+ /** A cryptographically random, runtime-local producer identifier. */
10
+ type SemanticJourneyProducerId = string;
11
+ /** Package-owned strict privacy policy version used by every v2 event/batch. */
12
+ declare const SEMANTIC_JOURNEY_STRICT_POLICY_VERSION: "strict.v1";
13
+ /** The bounded categories understood by semantic journey reconstruction. */
14
+ type SemanticJourneyCategory = "interaction" | "navigation" | "request" | "command" | "state" | "presentation" | "dependency" | "error";
15
+ /** The lifecycle phase represented by a semantic event. */
16
+ type SemanticJourneyPhase = "intent" | "start" | "progress" | "end" | "effect";
17
+ /** The bounded outcome represented by a semantic event. */
18
+ type SemanticJourneyOutcome = "unknown" | "success" | "failure" | "cancelled" | "denied";
19
+ /** A privacy-safe interaction modality. */
20
+ type SemanticJourneyModality = "pointer" | "keyboard" | "touch" | "voice" | "gesture" | "system";
21
+ /** A catalogue-controlled semantic target. It never contains DOM-derived text. */
22
+ interface SemanticJourneyTarget {
23
+ readonly type: string;
24
+ readonly id: string;
25
+ }
26
+ /** The only value kinds admitted to semantic event attributes. */
27
+ type SemanticJourneyAttributeValue = boolean | number | string;
28
+ /** Privacy evidence attached to every accepted semantic event. */
29
+ interface SemanticJourneyPrivacyMetadata {
30
+ readonly mode: "strict";
31
+ readonly policyVersion: typeof SEMANTIC_JOURNEY_STRICT_POLICY_VERSION;
32
+ readonly droppedAttributeCount: number;
33
+ }
34
+ /**
35
+ * Version 2 semantic evidence. This is additive to the legacy
36
+ * `LocalSpaceAnalyticsEvent` contract and intentionally contains no arbitrary
37
+ * context object.
38
+ */
39
+ interface SemanticJourneyEvent {
40
+ readonly schemaVersion: "2.0";
41
+ readonly eventId: SemanticJourneyEventId;
42
+ readonly journeyId: SemanticJourneyId;
43
+ readonly traceId: SemanticJourneyTraceId;
44
+ readonly spanId: SemanticJourneySpanId;
45
+ readonly parentSpanId?: SemanticJourneySpanId;
46
+ readonly causedByEventId?: SemanticJourneyEventId;
47
+ readonly producerId: SemanticJourneyProducerId;
48
+ readonly producerSequence: number;
49
+ readonly occurredAtEpochMs: number;
50
+ readonly source: string;
51
+ readonly channel: "frontend" | "backend";
52
+ readonly runtime: "browser" | "server";
53
+ readonly name: string;
54
+ readonly category: SemanticJourneyCategory;
55
+ readonly phase: SemanticJourneyPhase;
56
+ readonly outcome: SemanticJourneyOutcome;
57
+ readonly modality?: SemanticJourneyModality;
58
+ readonly target?: SemanticJourneyTarget;
59
+ readonly attributes: Readonly<Record<string, SemanticJourneyAttributeValue>>;
60
+ readonly privacy: SemanticJourneyPrivacyMetadata;
61
+ }
62
+ /** Input accepted by the strict semantic catalogue validator. */
63
+ interface SemanticJourneyEventInput {
64
+ name: string;
65
+ category: SemanticJourneyCategory;
66
+ phase: SemanticJourneyPhase;
67
+ outcome: SemanticJourneyOutcome;
68
+ modality?: SemanticJourneyModality;
69
+ target?: SemanticJourneyTarget;
70
+ attributes?: Readonly<Record<string, unknown>>;
71
+ }
72
+ /** A normalized input proven to conform to one catalogue definition. */
73
+ interface ValidatedSemanticJourneyEventInput {
74
+ name: string;
75
+ category: SemanticJourneyCategory;
76
+ phase: SemanticJourneyPhase;
77
+ outcome: SemanticJourneyOutcome;
78
+ modality?: SemanticJourneyModality;
79
+ target?: SemanticJourneyTarget;
80
+ attributes: Readonly<Record<string, SemanticJourneyAttributeValue>>;
81
+ droppedAttributeCount: 0;
82
+ }
83
+ /** A registered, bounded enum attribute. */
84
+ interface SemanticJourneyEnumAttributeDefinition {
85
+ type: "enum";
86
+ values: readonly string[];
87
+ }
88
+ /** A registered boolean attribute. */
89
+ interface SemanticJourneyBooleanAttributeDefinition {
90
+ type: "boolean";
91
+ }
92
+ /** A registered number with mandatory finite lower and upper bounds. */
93
+ interface SemanticJourneyNumberAttributeDefinition {
94
+ type: "number";
95
+ min: number;
96
+ max: number;
97
+ integer?: boolean;
98
+ }
99
+ /** The closed set of supported catalogue attribute definitions. */
100
+ type SemanticJourneyAttributeDefinition = SemanticJourneyEnumAttributeDefinition | SemanticJourneyBooleanAttributeDefinition | SemanticJourneyNumberAttributeDefinition;
101
+ /** A semantic event definition registered by application developers. */
102
+ interface SemanticJourneyEventDefinition {
103
+ readonly category: SemanticJourneyCategory;
104
+ readonly attributes?: Readonly<Record<string, SemanticJourneyAttributeDefinition>>;
105
+ readonly targets?: readonly SemanticJourneyTarget[];
106
+ readonly effects?: readonly string[];
107
+ }
108
+ /** Reviewed, immutable dimensions shared by one semantic catalogue. */
109
+ interface SemanticJourneyCatalogOptions {
110
+ readonly sources: readonly string[];
111
+ }
112
+ /** An immutable, validated collection of semantic event definitions. */
113
+ interface SemanticJourneyCatalog {
114
+ readonly sources: readonly string[];
115
+ readonly definitions: Readonly<Record<string, Readonly<SemanticJourneyEventDefinition>>>;
116
+ }
117
+ /** British-English compatibility alias for `SemanticJourneyCatalog`. */
118
+ type SemanticJourneyCatalogue = SemanticJourneyCatalog;
119
+ /** W3C trace flags supported by the strict journey context parser. */
120
+ type SemanticJourneyTraceFlags = "00" | "01";
121
+ /** A strictly parsed W3C traceparent context. */
122
+ interface SemanticJourneyTraceContext {
123
+ version: "00";
124
+ traceId: SemanticJourneyTraceId;
125
+ spanId: SemanticJourneySpanId;
126
+ traceFlags: SemanticJourneyTraceFlags;
127
+ }
128
+ /**
129
+ * Local causal context. `journeyId` is private to the runtime and is never
130
+ * included by traceparent formatting.
131
+ */
132
+ interface SemanticJourneyContext {
133
+ journeyId: SemanticJourneyId;
134
+ traceId: SemanticJourneyTraceId;
135
+ spanId: SemanticJourneySpanId;
136
+ parentSpanId?: SemanticJourneySpanId;
137
+ traceFlags: SemanticJourneyTraceFlags;
138
+ }
139
+
140
+ /**
141
+ * Fixed useful-metric catalogue entries for host catalogue composition and
142
+ * collector allowlists. Buckets are part of event names so they survive the
143
+ * existing aggregate wire format, which deliberately does not carry attributes.
144
+ * This is not a collector or sender and has no browser/network side effects.
145
+ */
146
+ declare const USEFUL_METRIC_EVENT_DEFINITIONS: Readonly<Record<string, Readonly<SemanticJourneyEventDefinition>>>;
147
+ /**
148
+ * Projects one observation into a catalogue-controlled, identity-free event.
149
+ * Accepts exactly { metric } for a counter or { metric, value } for a duration
150
+ * in milliseconds (CLS is unitless). Rejects unknown/extra fields, accessors,
151
+ * invalid numbers and legacy raw NFR payloads without reflecting their values.
152
+ *
153
+ * The host evaluates remote enablement, bounds observation frequency, tracks
154
+ * this result with its semantic client, and owns disposal. Episode observations
155
+ * are anonymous in-memory activity counts, never unique users or sessions.
156
+ */
157
+ declare function projectUsefulMetric(input: unknown): SemanticJourneyEventInput | null;
158
+
159
+ export { type SemanticJourneyEventDefinition as S, USEFUL_METRIC_EVENT_DEFINITIONS as U, type ValidatedSemanticJourneyEventInput as V, type SemanticJourneyCatalogOptions as a, type SemanticJourneyCatalog as b, type SemanticJourneyEventInput as c, type SemanticJourneyContext as d, type SemanticJourneyTraceFlags as e, type SemanticJourneyTraceContext as f, SEMANTIC_JOURNEY_STRICT_POLICY_VERSION as g, type SemanticJourneyOutcome as h, type SemanticJourneyCatalogue as i, type SemanticJourneyEvent as j, type SemanticJourneyAttributeDefinition as k, type SemanticJourneyAttributeValue as l, type SemanticJourneyBooleanAttributeDefinition as m, type SemanticJourneyCategory as n, type SemanticJourneyEnumAttributeDefinition as o, type SemanticJourneyEventId as p, type SemanticJourneyId as q, type SemanticJourneyModality as r, type SemanticJourneyNumberAttributeDefinition as s, type SemanticJourneyPhase as t, type SemanticJourneyPrivacyMetadata as u, type SemanticJourneyProducerId as v, type SemanticJourneySpanId as w, type SemanticJourneyTarget as x, type SemanticJourneyTraceId as y, projectUsefulMetric as z };
@@ -0,0 +1,159 @@
1
+ /** A cryptographically random, episode-scoped journey identifier. */
2
+ type SemanticJourneyId = string;
3
+ /** A W3C-compatible trace identifier. */
4
+ type SemanticJourneyTraceId = string;
5
+ /** A W3C-compatible span identifier. */
6
+ type SemanticJourneySpanId = string;
7
+ /** A cryptographically random semantic event identifier. */
8
+ type SemanticJourneyEventId = string;
9
+ /** A cryptographically random, runtime-local producer identifier. */
10
+ type SemanticJourneyProducerId = string;
11
+ /** Package-owned strict privacy policy version used by every v2 event/batch. */
12
+ declare const SEMANTIC_JOURNEY_STRICT_POLICY_VERSION: "strict.v1";
13
+ /** The bounded categories understood by semantic journey reconstruction. */
14
+ type SemanticJourneyCategory = "interaction" | "navigation" | "request" | "command" | "state" | "presentation" | "dependency" | "error";
15
+ /** The lifecycle phase represented by a semantic event. */
16
+ type SemanticJourneyPhase = "intent" | "start" | "progress" | "end" | "effect";
17
+ /** The bounded outcome represented by a semantic event. */
18
+ type SemanticJourneyOutcome = "unknown" | "success" | "failure" | "cancelled" | "denied";
19
+ /** A privacy-safe interaction modality. */
20
+ type SemanticJourneyModality = "pointer" | "keyboard" | "touch" | "voice" | "gesture" | "system";
21
+ /** A catalogue-controlled semantic target. It never contains DOM-derived text. */
22
+ interface SemanticJourneyTarget {
23
+ readonly type: string;
24
+ readonly id: string;
25
+ }
26
+ /** The only value kinds admitted to semantic event attributes. */
27
+ type SemanticJourneyAttributeValue = boolean | number | string;
28
+ /** Privacy evidence attached to every accepted semantic event. */
29
+ interface SemanticJourneyPrivacyMetadata {
30
+ readonly mode: "strict";
31
+ readonly policyVersion: typeof SEMANTIC_JOURNEY_STRICT_POLICY_VERSION;
32
+ readonly droppedAttributeCount: number;
33
+ }
34
+ /**
35
+ * Version 2 semantic evidence. This is additive to the legacy
36
+ * `LocalSpaceAnalyticsEvent` contract and intentionally contains no arbitrary
37
+ * context object.
38
+ */
39
+ interface SemanticJourneyEvent {
40
+ readonly schemaVersion: "2.0";
41
+ readonly eventId: SemanticJourneyEventId;
42
+ readonly journeyId: SemanticJourneyId;
43
+ readonly traceId: SemanticJourneyTraceId;
44
+ readonly spanId: SemanticJourneySpanId;
45
+ readonly parentSpanId?: SemanticJourneySpanId;
46
+ readonly causedByEventId?: SemanticJourneyEventId;
47
+ readonly producerId: SemanticJourneyProducerId;
48
+ readonly producerSequence: number;
49
+ readonly occurredAtEpochMs: number;
50
+ readonly source: string;
51
+ readonly channel: "frontend" | "backend";
52
+ readonly runtime: "browser" | "server";
53
+ readonly name: string;
54
+ readonly category: SemanticJourneyCategory;
55
+ readonly phase: SemanticJourneyPhase;
56
+ readonly outcome: SemanticJourneyOutcome;
57
+ readonly modality?: SemanticJourneyModality;
58
+ readonly target?: SemanticJourneyTarget;
59
+ readonly attributes: Readonly<Record<string, SemanticJourneyAttributeValue>>;
60
+ readonly privacy: SemanticJourneyPrivacyMetadata;
61
+ }
62
+ /** Input accepted by the strict semantic catalogue validator. */
63
+ interface SemanticJourneyEventInput {
64
+ name: string;
65
+ category: SemanticJourneyCategory;
66
+ phase: SemanticJourneyPhase;
67
+ outcome: SemanticJourneyOutcome;
68
+ modality?: SemanticJourneyModality;
69
+ target?: SemanticJourneyTarget;
70
+ attributes?: Readonly<Record<string, unknown>>;
71
+ }
72
+ /** A normalized input proven to conform to one catalogue definition. */
73
+ interface ValidatedSemanticJourneyEventInput {
74
+ name: string;
75
+ category: SemanticJourneyCategory;
76
+ phase: SemanticJourneyPhase;
77
+ outcome: SemanticJourneyOutcome;
78
+ modality?: SemanticJourneyModality;
79
+ target?: SemanticJourneyTarget;
80
+ attributes: Readonly<Record<string, SemanticJourneyAttributeValue>>;
81
+ droppedAttributeCount: 0;
82
+ }
83
+ /** A registered, bounded enum attribute. */
84
+ interface SemanticJourneyEnumAttributeDefinition {
85
+ type: "enum";
86
+ values: readonly string[];
87
+ }
88
+ /** A registered boolean attribute. */
89
+ interface SemanticJourneyBooleanAttributeDefinition {
90
+ type: "boolean";
91
+ }
92
+ /** A registered number with mandatory finite lower and upper bounds. */
93
+ interface SemanticJourneyNumberAttributeDefinition {
94
+ type: "number";
95
+ min: number;
96
+ max: number;
97
+ integer?: boolean;
98
+ }
99
+ /** The closed set of supported catalogue attribute definitions. */
100
+ type SemanticJourneyAttributeDefinition = SemanticJourneyEnumAttributeDefinition | SemanticJourneyBooleanAttributeDefinition | SemanticJourneyNumberAttributeDefinition;
101
+ /** A semantic event definition registered by application developers. */
102
+ interface SemanticJourneyEventDefinition {
103
+ readonly category: SemanticJourneyCategory;
104
+ readonly attributes?: Readonly<Record<string, SemanticJourneyAttributeDefinition>>;
105
+ readonly targets?: readonly SemanticJourneyTarget[];
106
+ readonly effects?: readonly string[];
107
+ }
108
+ /** Reviewed, immutable dimensions shared by one semantic catalogue. */
109
+ interface SemanticJourneyCatalogOptions {
110
+ readonly sources: readonly string[];
111
+ }
112
+ /** An immutable, validated collection of semantic event definitions. */
113
+ interface SemanticJourneyCatalog {
114
+ readonly sources: readonly string[];
115
+ readonly definitions: Readonly<Record<string, Readonly<SemanticJourneyEventDefinition>>>;
116
+ }
117
+ /** British-English compatibility alias for `SemanticJourneyCatalog`. */
118
+ type SemanticJourneyCatalogue = SemanticJourneyCatalog;
119
+ /** W3C trace flags supported by the strict journey context parser. */
120
+ type SemanticJourneyTraceFlags = "00" | "01";
121
+ /** A strictly parsed W3C traceparent context. */
122
+ interface SemanticJourneyTraceContext {
123
+ version: "00";
124
+ traceId: SemanticJourneyTraceId;
125
+ spanId: SemanticJourneySpanId;
126
+ traceFlags: SemanticJourneyTraceFlags;
127
+ }
128
+ /**
129
+ * Local causal context. `journeyId` is private to the runtime and is never
130
+ * included by traceparent formatting.
131
+ */
132
+ interface SemanticJourneyContext {
133
+ journeyId: SemanticJourneyId;
134
+ traceId: SemanticJourneyTraceId;
135
+ spanId: SemanticJourneySpanId;
136
+ parentSpanId?: SemanticJourneySpanId;
137
+ traceFlags: SemanticJourneyTraceFlags;
138
+ }
139
+
140
+ /**
141
+ * Fixed useful-metric catalogue entries for host catalogue composition and
142
+ * collector allowlists. Buckets are part of event names so they survive the
143
+ * existing aggregate wire format, which deliberately does not carry attributes.
144
+ * This is not a collector or sender and has no browser/network side effects.
145
+ */
146
+ declare const USEFUL_METRIC_EVENT_DEFINITIONS: Readonly<Record<string, Readonly<SemanticJourneyEventDefinition>>>;
147
+ /**
148
+ * Projects one observation into a catalogue-controlled, identity-free event.
149
+ * Accepts exactly { metric } for a counter or { metric, value } for a duration
150
+ * in milliseconds (CLS is unitless). Rejects unknown/extra fields, accessors,
151
+ * invalid numbers and legacy raw NFR payloads without reflecting their values.
152
+ *
153
+ * The host evaluates remote enablement, bounds observation frequency, tracks
154
+ * this result with its semantic client, and owns disposal. Episode observations
155
+ * are anonymous in-memory activity counts, never unique users or sessions.
156
+ */
157
+ declare function projectUsefulMetric(input: unknown): SemanticJourneyEventInput | null;
158
+
159
+ export { type SemanticJourneyEventDefinition as S, USEFUL_METRIC_EVENT_DEFINITIONS as U, type ValidatedSemanticJourneyEventInput as V, type SemanticJourneyCatalogOptions as a, type SemanticJourneyCatalog as b, type SemanticJourneyEventInput as c, type SemanticJourneyContext as d, type SemanticJourneyTraceFlags as e, type SemanticJourneyTraceContext as f, SEMANTIC_JOURNEY_STRICT_POLICY_VERSION as g, type SemanticJourneyOutcome as h, type SemanticJourneyCatalogue as i, type SemanticJourneyEvent as j, type SemanticJourneyAttributeDefinition as k, type SemanticJourneyAttributeValue as l, type SemanticJourneyBooleanAttributeDefinition as m, type SemanticJourneyCategory as n, type SemanticJourneyEnumAttributeDefinition as o, type SemanticJourneyEventId as p, type SemanticJourneyId as q, type SemanticJourneyModality as r, type SemanticJourneyNumberAttributeDefinition as s, type SemanticJourneyPhase as t, type SemanticJourneyPrivacyMetadata as u, type SemanticJourneyProducerId as v, type SemanticJourneySpanId as w, type SemanticJourneyTarget as x, type SemanticJourneyTraceId as y, projectUsefulMetric as z };
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/journey/metrics.ts
21
+ var metrics_exports = {};
22
+ __export(metrics_exports, {
23
+ USEFUL_METRIC_EVENT_DEFINITIONS: () => USEFUL_METRIC_EVENT_DEFINITIONS,
24
+ projectUsefulMetric: () => projectUsefulMetric
25
+ });
26
+ module.exports = __toCommonJS(metrics_exports);
27
+ var durationBuckets = [
28
+ [100, "lt100ms"],
29
+ [250, "lt250ms"],
30
+ [500, "lt500ms"],
31
+ [1e3, "lt1000ms"],
32
+ [2500, "lt2500ms"],
33
+ [5e3, "lt5000ms"],
34
+ [1e4, "lt10000ms"],
35
+ [Infinity, "gte10000ms"]
36
+ ];
37
+ var duration = (category) => ({
38
+ category,
39
+ outcome: "unknown",
40
+ buckets: durationBuckets,
41
+ maximum: 864e5
42
+ });
43
+ var metrics = /* @__PURE__ */ (() => ({
44
+ "page.load": duration("presentation"),
45
+ "route.ready": duration("presentation"),
46
+ "world.ready": duration("presentation"),
47
+ "request.duration": duration("request"),
48
+ "vital.lcp": duration("presentation"),
49
+ "vital.fcp": duration("presentation"),
50
+ "vital.inp": duration("interaction"),
51
+ "vital.ttfb": duration("request"),
52
+ "vital.cls": {
53
+ category: "presentation",
54
+ outcome: "unknown",
55
+ maximum: 100,
56
+ buckets: [[0.1, "lt01"], [0.25, "lt025"], [Infinity, "gte025"]]
57
+ },
58
+ "episode.active-duration": {
59
+ category: "state",
60
+ outcome: "unknown",
61
+ maximum: 864e5,
62
+ buckets: [
63
+ [1e4, "lt10s"],
64
+ [6e4, "lt60s"],
65
+ [3e5, "lt300s"],
66
+ [9e5, "lt900s"],
67
+ [36e5, "lt3600s"],
68
+ [Infinity, "gte3600s"]
69
+ ]
70
+ },
71
+ "episode.started": { category: "state", outcome: "unknown" },
72
+ "episode.completed": { category: "state", outcome: "unknown" },
73
+ "request.started": { category: "request", outcome: "unknown" },
74
+ "request.completed": { category: "request", outcome: "success" },
75
+ "request.failed": { category: "request", outcome: "failure" },
76
+ "request.cancelled": { category: "request", outcome: "cancelled" },
77
+ "request.rejected": { category: "request", outcome: "denied" },
78
+ "error.runtime": { category: "error", outcome: "failure" },
79
+ "error.resource": { category: "error", outcome: "failure" },
80
+ "error.render": { category: "error", outcome: "failure" },
81
+ "error.unhandled": { category: "error", outcome: "failure" }
82
+ }))();
83
+ var USEFUL_METRIC_EVENT_DEFINITIONS = /* @__PURE__ */ (() => Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {
84
+ const names = definition.buckets ? definition.buckets.map(([, bucket]) => `metric.${metric}.${bucket}`) : [`metric.${metric}`];
85
+ return names.map((name) => [name, Object.freeze({ category: definition.category })]);
86
+ }))))();
87
+ function projectUsefulMetric(input) {
88
+ try {
89
+ if (typeof input !== "object" || input === null || Array.isArray(input)) return null;
90
+ const prototype = Object.getPrototypeOf(input);
91
+ if (prototype !== Object.prototype && prototype !== null) return null;
92
+ const keys = Reflect.ownKeys(input);
93
+ if (keys.length < 1 || keys.length > 2 || keys.some((key) => key !== "metric" && key !== "value")) return null;
94
+ const descriptors = Object.getOwnPropertyDescriptors(input);
95
+ const metric = descriptors.metric;
96
+ if (!metric || !("value" in metric) || typeof metric.value !== "string" || !Object.hasOwn(metrics, metric.value)) return null;
97
+ const definition = metrics[metric.value];
98
+ let name = `metric.${metric.value}`;
99
+ if (definition.buckets) {
100
+ const value = descriptors.value;
101
+ if (keys.length !== 2 || !value || !("value" in value) || typeof value.value !== "number" || !Number.isFinite(value.value) || value.value < 0 || value.value > definition.maximum) return null;
102
+ const bucket = definition.buckets.find(([upper]) => value.value < upper);
103
+ name += `.${bucket[1]}`;
104
+ } else if (keys.length !== 1) {
105
+ return null;
106
+ }
107
+ return Object.freeze({
108
+ name,
109
+ category: definition.category,
110
+ phase: metric.value.endsWith(".started") ? "start" : "end",
111
+ outcome: definition.outcome,
112
+ modality: "system"
113
+ });
114
+ } catch {
115
+ return null;
116
+ }
117
+ }
118
+ // Annotate the CommonJS export names for ESM import in node:
119
+ 0 && (module.exports = {
120
+ USEFUL_METRIC_EVENT_DEFINITIONS,
121
+ projectUsefulMetric
122
+ });
123
+ //# sourceMappingURL=metrics.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/journey/metrics.ts"],"sourcesContent":["import type {\n SemanticJourneyCategory,\n SemanticJourneyEventDefinition,\n SemanticJourneyEventInput,\n SemanticJourneyOutcome,\n} from \"./types.js\";\n\ntype Bucket = readonly [upperExclusive: number, token: string];\ninterface MetricDefinition {\n readonly category: SemanticJourneyCategory;\n readonly outcome: SemanticJourneyOutcome;\n readonly buckets?: readonly Bucket[];\n readonly maximum?: number;\n}\n\nconst durationBuckets: readonly Bucket[] = [\n [100, \"lt100ms\"], [250, \"lt250ms\"], [500, \"lt500ms\"],\n [1000, \"lt1000ms\"], [2500, \"lt2500ms\"], [5000, \"lt5000ms\"],\n [10000, \"lt10000ms\"], [Infinity, \"gte10000ms\"],\n];\nconst duration = (category: SemanticJourneyCategory): MetricDefinition => ({\n category, outcome: \"unknown\", buckets: durationBuckets, maximum: 86_400_000,\n});\n// Fixed literal initialization is pure so hosts importing unrelated analytics\n// APIs can drop this optional metric module from their initial bundle.\nconst metrics: Readonly<Record<string, MetricDefinition>> = /* @__PURE__ */ (() => ({\n \"page.load\": duration(\"presentation\"),\n \"route.ready\": duration(\"presentation\"),\n \"world.ready\": duration(\"presentation\"),\n \"request.duration\": duration(\"request\"),\n \"vital.lcp\": duration(\"presentation\"),\n \"vital.fcp\": duration(\"presentation\"),\n \"vital.inp\": duration(\"interaction\"),\n \"vital.ttfb\": duration(\"request\"),\n \"vital.cls\": {\n category: \"presentation\", outcome: \"unknown\", maximum: 100,\n buckets: [[0.1, \"lt01\"], [0.25, \"lt025\"], [Infinity, \"gte025\"]],\n },\n \"episode.active-duration\": {\n category: \"state\", outcome: \"unknown\", maximum: 86_400_000,\n buckets: [[10000, \"lt10s\"], [60000, \"lt60s\"], [300000, \"lt300s\"],\n [900000, \"lt900s\"], [3600000, \"lt3600s\"], [Infinity, \"gte3600s\"]],\n },\n \"episode.started\": { category: \"state\", outcome: \"unknown\" },\n \"episode.completed\": { category: \"state\", outcome: \"unknown\" },\n \"request.started\": { category: \"request\", outcome: \"unknown\" },\n \"request.completed\": { category: \"request\", outcome: \"success\" },\n \"request.failed\": { category: \"request\", outcome: \"failure\" },\n \"request.cancelled\": { category: \"request\", outcome: \"cancelled\" },\n \"request.rejected\": { category: \"request\", outcome: \"denied\" },\n \"error.runtime\": { category: \"error\", outcome: \"failure\" },\n \"error.resource\": { category: \"error\", outcome: \"failure\" },\n \"error.render\": { category: \"error\", outcome: \"failure\" },\n \"error.unhandled\": { category: \"error\", outcome: \"failure\" },\n}))();\n\n/**\n * Fixed useful-metric catalogue entries for host catalogue composition and\n * collector allowlists. Buckets are part of event names so they survive the\n * existing aggregate wire format, which deliberately does not carry attributes.\n * This is not a collector or sender and has no browser/network side effects.\n */\nexport const USEFUL_METRIC_EVENT_DEFINITIONS: Readonly<\n Record<string, Readonly<SemanticJourneyEventDefinition>>\n> = /* @__PURE__ */ (() => Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {\n const names = definition.buckets\n ? definition.buckets.map(([, bucket]) => `metric.${metric}.${bucket}`)\n : [`metric.${metric}`];\n return names.map(name => [name, Object.freeze({ category: definition.category })]);\n}))))();\n\n/**\n * Projects one observation into a catalogue-controlled, identity-free event.\n * Accepts exactly { metric } for a counter or { metric, value } for a duration\n * in milliseconds (CLS is unitless). Rejects unknown/extra fields, accessors,\n * invalid numbers and legacy raw NFR payloads without reflecting their values.\n *\n * The host evaluates remote enablement, bounds observation frequency, tracks\n * this result with its semantic client, and owns disposal. Episode observations\n * are anonymous in-memory activity counts, never unique users or sessions.\n */\nexport function projectUsefulMetric(input: unknown): SemanticJourneyEventInput | null {\n try {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) return null;\n const prototype = Object.getPrototypeOf(input);\n if (prototype !== Object.prototype && prototype !== null) return null;\n const keys = Reflect.ownKeys(input);\n if (keys.length < 1 || keys.length > 2 || keys.some(key => key !== \"metric\" && key !== \"value\")) return null;\n const descriptors = Object.getOwnPropertyDescriptors(input);\n const metric = descriptors.metric;\n if (!metric || !(\"value\" in metric) || typeof metric.value !== \"string\"\n || !Object.hasOwn(metrics, metric.value)) return null;\n const definition = metrics[metric.value]!;\n let name = `metric.${metric.value}`;\n if (definition.buckets) {\n const value = descriptors.value;\n if (keys.length !== 2 || !value || !(\"value\" in value)\n || typeof value.value !== \"number\" || !Number.isFinite(value.value)\n || value.value < 0 || value.value > definition.maximum!) return null;\n const bucket = definition.buckets.find(([upper]) => value.value < upper)!;\n name += `.${bucket[1]}`;\n } else if (keys.length !== 1) {\n return null;\n }\n return Object.freeze({\n name, category: definition.category,\n phase: metric.value.endsWith(\".started\") ? \"start\" : \"end\",\n outcome: definition.outcome, modality: \"system\",\n });\n } catch {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeA,IAAM,kBAAqC;AAAA,EACzC,CAAC,KAAK,SAAS;AAAA,EAAG,CAAC,KAAK,SAAS;AAAA,EAAG,CAAC,KAAK,SAAS;AAAA,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S,OAAO,KAAK,EAAG,QAAO;AACnD,UAAM,aAAa,QAAQ,OAAO,KAAK;AACvC,QAAI,OAAO,UAAU,OAAO,KAAK;AACjC,QAAI,WAAW,SAAS;AACtB,YAAM,QAAQ,YAAY;AAC1B,UAAI,KAAK,WAAW,KAAK,CAAC,SAAS,EAAE,WAAW,UAC3C,OAAO,MAAM,UAAU,YAAY,CAAC,OAAO,SAAS,MAAM,KAAK,KAC/D,MAAM,QAAQ,KAAK,MAAM,QAAQ,WAAW,QAAU,QAAO;AAClE,YAAM,SAAS,WAAW,QAAQ,KAAK,CAAC,CAAC,KAAK,MAAM,MAAM,QAAQ,KAAK;AACvE,cAAQ,IAAI,OAAO,CAAC,CAAC;AAAA,IACvB,WAAW,KAAK,WAAW,GAAG;AAC5B,aAAO;AAAA,IACT;AACA,WAAO,OAAO,OAAO;AAAA,MACnB;AAAA,MAAM,UAAU,WAAW;AAAA,MAC3B,OAAO,OAAO,MAAM,SAAS,UAAU,IAAI,UAAU;AAAA,MACrD,SAAS,WAAW;AAAA,MAAS,UAAU;AAAA,IACzC,CAAC;AAAA,EACH,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1 @@
1
+ export { U as USEFUL_METRIC_EVENT_DEFINITIONS, z as projectUsefulMetric } from './metrics-B7L9phdM.cjs';
@@ -0,0 +1 @@
1
+ export { U as USEFUL_METRIC_EVENT_DEFINITIONS, z as projectUsefulMetric } from './metrics-B7L9phdM.js';
@@ -0,0 +1,97 @@
1
+ // src/journey/metrics.ts
2
+ var durationBuckets = [
3
+ [100, "lt100ms"],
4
+ [250, "lt250ms"],
5
+ [500, "lt500ms"],
6
+ [1e3, "lt1000ms"],
7
+ [2500, "lt2500ms"],
8
+ [5e3, "lt5000ms"],
9
+ [1e4, "lt10000ms"],
10
+ [Infinity, "gte10000ms"]
11
+ ];
12
+ var duration = (category) => ({
13
+ category,
14
+ outcome: "unknown",
15
+ buckets: durationBuckets,
16
+ maximum: 864e5
17
+ });
18
+ var metrics = /* @__PURE__ */ (() => ({
19
+ "page.load": duration("presentation"),
20
+ "route.ready": duration("presentation"),
21
+ "world.ready": duration("presentation"),
22
+ "request.duration": duration("request"),
23
+ "vital.lcp": duration("presentation"),
24
+ "vital.fcp": duration("presentation"),
25
+ "vital.inp": duration("interaction"),
26
+ "vital.ttfb": duration("request"),
27
+ "vital.cls": {
28
+ category: "presentation",
29
+ outcome: "unknown",
30
+ maximum: 100,
31
+ buckets: [[0.1, "lt01"], [0.25, "lt025"], [Infinity, "gte025"]]
32
+ },
33
+ "episode.active-duration": {
34
+ category: "state",
35
+ outcome: "unknown",
36
+ maximum: 864e5,
37
+ buckets: [
38
+ [1e4, "lt10s"],
39
+ [6e4, "lt60s"],
40
+ [3e5, "lt300s"],
41
+ [9e5, "lt900s"],
42
+ [36e5, "lt3600s"],
43
+ [Infinity, "gte3600s"]
44
+ ]
45
+ },
46
+ "episode.started": { category: "state", outcome: "unknown" },
47
+ "episode.completed": { category: "state", outcome: "unknown" },
48
+ "request.started": { category: "request", outcome: "unknown" },
49
+ "request.completed": { category: "request", outcome: "success" },
50
+ "request.failed": { category: "request", outcome: "failure" },
51
+ "request.cancelled": { category: "request", outcome: "cancelled" },
52
+ "request.rejected": { category: "request", outcome: "denied" },
53
+ "error.runtime": { category: "error", outcome: "failure" },
54
+ "error.resource": { category: "error", outcome: "failure" },
55
+ "error.render": { category: "error", outcome: "failure" },
56
+ "error.unhandled": { category: "error", outcome: "failure" }
57
+ }))();
58
+ var USEFUL_METRIC_EVENT_DEFINITIONS = /* @__PURE__ */ (() => Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {
59
+ const names = definition.buckets ? definition.buckets.map(([, bucket]) => `metric.${metric}.${bucket}`) : [`metric.${metric}`];
60
+ return names.map((name) => [name, Object.freeze({ category: definition.category })]);
61
+ }))))();
62
+ function projectUsefulMetric(input) {
63
+ try {
64
+ if (typeof input !== "object" || input === null || Array.isArray(input)) return null;
65
+ const prototype = Object.getPrototypeOf(input);
66
+ if (prototype !== Object.prototype && prototype !== null) return null;
67
+ const keys = Reflect.ownKeys(input);
68
+ if (keys.length < 1 || keys.length > 2 || keys.some((key) => key !== "metric" && key !== "value")) return null;
69
+ const descriptors = Object.getOwnPropertyDescriptors(input);
70
+ const metric = descriptors.metric;
71
+ if (!metric || !("value" in metric) || typeof metric.value !== "string" || !Object.hasOwn(metrics, metric.value)) return null;
72
+ const definition = metrics[metric.value];
73
+ let name = `metric.${metric.value}`;
74
+ if (definition.buckets) {
75
+ const value = descriptors.value;
76
+ if (keys.length !== 2 || !value || !("value" in value) || typeof value.value !== "number" || !Number.isFinite(value.value) || value.value < 0 || value.value > definition.maximum) return null;
77
+ const bucket = definition.buckets.find(([upper]) => value.value < upper);
78
+ name += `.${bucket[1]}`;
79
+ } else if (keys.length !== 1) {
80
+ return null;
81
+ }
82
+ return Object.freeze({
83
+ name,
84
+ category: definition.category,
85
+ phase: metric.value.endsWith(".started") ? "start" : "end",
86
+ outcome: definition.outcome,
87
+ modality: "system"
88
+ });
89
+ } catch {
90
+ return null;
91
+ }
92
+ }
93
+ export {
94
+ USEFUL_METRIC_EVENT_DEFINITIONS,
95
+ projectUsefulMetric
96
+ };
97
+ //# sourceMappingURL=metrics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/journey/metrics.ts"],"sourcesContent":["import type {\n SemanticJourneyCategory,\n SemanticJourneyEventDefinition,\n SemanticJourneyEventInput,\n SemanticJourneyOutcome,\n} from \"./types.js\";\n\ntype Bucket = readonly [upperExclusive: number, token: string];\ninterface MetricDefinition {\n readonly category: SemanticJourneyCategory;\n readonly outcome: SemanticJourneyOutcome;\n readonly buckets?: readonly Bucket[];\n readonly maximum?: number;\n}\n\nconst durationBuckets: readonly Bucket[] = [\n [100, \"lt100ms\"], [250, \"lt250ms\"], [500, \"lt500ms\"],\n [1000, \"lt1000ms\"], [2500, \"lt2500ms\"], [5000, \"lt5000ms\"],\n [10000, \"lt10000ms\"], [Infinity, \"gte10000ms\"],\n];\nconst duration = (category: SemanticJourneyCategory): MetricDefinition => ({\n category, outcome: \"unknown\", buckets: durationBuckets, maximum: 86_400_000,\n});\n// Fixed literal initialization is pure so hosts importing unrelated analytics\n// APIs can drop this optional metric module from their initial bundle.\nconst metrics: Readonly<Record<string, MetricDefinition>> = /* @__PURE__ */ (() => ({\n \"page.load\": duration(\"presentation\"),\n \"route.ready\": duration(\"presentation\"),\n \"world.ready\": duration(\"presentation\"),\n \"request.duration\": duration(\"request\"),\n \"vital.lcp\": duration(\"presentation\"),\n \"vital.fcp\": duration(\"presentation\"),\n \"vital.inp\": duration(\"interaction\"),\n \"vital.ttfb\": duration(\"request\"),\n \"vital.cls\": {\n category: \"presentation\", outcome: \"unknown\", maximum: 100,\n buckets: [[0.1, \"lt01\"], [0.25, \"lt025\"], [Infinity, \"gte025\"]],\n },\n \"episode.active-duration\": {\n category: \"state\", outcome: \"unknown\", maximum: 86_400_000,\n buckets: [[10000, \"lt10s\"], [60000, \"lt60s\"], [300000, \"lt300s\"],\n [900000, \"lt900s\"], [3600000, \"lt3600s\"], [Infinity, \"gte3600s\"]],\n },\n \"episode.started\": { category: \"state\", outcome: \"unknown\" },\n \"episode.completed\": { category: \"state\", outcome: \"unknown\" },\n \"request.started\": { category: \"request\", outcome: \"unknown\" },\n \"request.completed\": { category: \"request\", outcome: \"success\" },\n \"request.failed\": { category: \"request\", outcome: \"failure\" },\n \"request.cancelled\": { category: \"request\", outcome: \"cancelled\" },\n \"request.rejected\": { category: \"request\", outcome: \"denied\" },\n \"error.runtime\": { category: \"error\", outcome: \"failure\" },\n \"error.resource\": { category: \"error\", outcome: \"failure\" },\n \"error.render\": { category: \"error\", outcome: \"failure\" },\n \"error.unhandled\": { category: \"error\", outcome: \"failure\" },\n}))();\n\n/**\n * Fixed useful-metric catalogue entries for host catalogue composition and\n * collector allowlists. Buckets are part of event names so they survive the\n * existing aggregate wire format, which deliberately does not carry attributes.\n * This is not a collector or sender and has no browser/network side effects.\n */\nexport const USEFUL_METRIC_EVENT_DEFINITIONS: Readonly<\n Record<string, Readonly<SemanticJourneyEventDefinition>>\n> = /* @__PURE__ */ (() => Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {\n const names = definition.buckets\n ? definition.buckets.map(([, bucket]) => `metric.${metric}.${bucket}`)\n : [`metric.${metric}`];\n return names.map(name => [name, Object.freeze({ category: definition.category })]);\n}))))();\n\n/**\n * Projects one observation into a catalogue-controlled, identity-free event.\n * Accepts exactly { metric } for a counter or { metric, value } for a duration\n * in milliseconds (CLS is unitless). Rejects unknown/extra fields, accessors,\n * invalid numbers and legacy raw NFR payloads without reflecting their values.\n *\n * The host evaluates remote enablement, bounds observation frequency, tracks\n * this result with its semantic client, and owns disposal. Episode observations\n * are anonymous in-memory activity counts, never unique users or sessions.\n */\nexport function projectUsefulMetric(input: unknown): SemanticJourneyEventInput | null {\n try {\n if (typeof input !== \"object\" || input === null || Array.isArray(input)) return null;\n const prototype = Object.getPrototypeOf(input);\n if (prototype !== Object.prototype && prototype !== null) return null;\n const keys = Reflect.ownKeys(input);\n if (keys.length < 1 || keys.length > 2 || keys.some(key => key !== \"metric\" && key !== \"value\")) return null;\n const descriptors = Object.getOwnPropertyDescriptors(input);\n const metric = descriptors.metric;\n if (!metric || !(\"value\" in metric) || typeof metric.value !== \"string\"\n || !Object.hasOwn(metrics, metric.value)) return null;\n const definition = metrics[metric.value]!;\n let name = `metric.${metric.value}`;\n if (definition.buckets) {\n const value = descriptors.value;\n if (keys.length !== 2 || !value || !(\"value\" in value)\n || typeof value.value !== \"number\" || !Number.isFinite(value.value)\n || value.value < 0 || value.value > definition.maximum!) return null;\n const bucket = definition.buckets.find(([upper]) => value.value < upper)!;\n name += `.${bucket[1]}`;\n } else if (keys.length !== 1) {\n return null;\n }\n return Object.freeze({\n name, category: definition.category,\n phase: metric.value.endsWith(\".started\") ? \"start\" : \"end\",\n outcome: definition.outcome, modality: \"system\",\n });\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UAAM,cAAc,OAAO,0BAA0B,KAAK;AAC1D,UAAM,SAAS,YAAY;AAC3B,QAAI,CAAC,UAAU,EAAE,WAAW,WAAW,OAAO,OAAO,UAAU,YAC1D,CAAC,OAAO,OAAO,SAAS,OAAO,KAAK,EAAG,QAAO;AACnD,UAAM,aAAa,QAAQ,OAAO,KAAK;AACvC,QAAI,OAAO,UAAU,OAAO,KAAK;AACjC,QAAI,WAAW,SAAS;AACtB,YAAM,QAAQ,YAAY;AAC1B,UAAI,KAAK,WAAW,KAAK,CAAC,SAAS,EAAE,WAAW,UAC3C,OAAO,MAAM,UAAU,YAAY,CAAC,OAAO,SAAS,MAAM,KAAK,KAC/D,MAAM,QAAQ,KAAK,MAAM,QAAQ,WAAW,QAAU,QAAO;AAClE,YAAM,SAAS,WAAW,QAAQ,KAAK,CAAC,CAAC,KAAK,MAAM,MAAM,QAAQ,KAAK;AACvE,cAAQ,IAAI,OAAO,CAAC,CAAC;AAAA,IACvB,WAAW,KAAK,WAAW,GAAG;AAC5B,aAAO;AAAA,IACT;AACA,WAAO,OAAO,OAAO;AAAA,MACnB;AAAA,MAAM,UAAU,WAAW;AAAA,MAC3B,OAAO,OAAO,MAAM,SAAS,UAAU,IAAI,UAAU;AAAA,MACrD,SAAS,WAAW;AAAA,MAAS,UAAU;AAAA,IACzC,CAAC;AAAA,EACH,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasius/analytics",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Local-space analytics client and React helpers for interaction/event tracking with configurable ingestion endpoints.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -16,6 +16,11 @@
16
16
  "import": "./dist/index.js",
17
17
  "require": "./dist/index.cjs"
18
18
  },
19
+ "./metrics": {
20
+ "types": "./dist/metrics.d.ts",
21
+ "import": "./dist/metrics.js",
22
+ "require": "./dist/metrics.cjs"
23
+ },
19
24
  "./package.json": "./package.json"
20
25
  },
21
26
  "scripts": {
@@ -63,6 +68,7 @@
63
68
  "@typescript-eslint/eslint-plugin": "^8.69.0",
64
69
  "@typescript-eslint/parser": "^8.69.0",
65
70
  "@vitest/coverage-v8": "^4.1.11",
71
+ "esbuild": "^0.28.1",
66
72
  "eslint": "^10.9.1",
67
73
  "globals": "^17.11.0",
68
74
  "jsdom": "^29.1.1",