@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.
package/README.md CHANGED
@@ -259,6 +259,15 @@ function SaveButton() {
259
259
 
260
260
  ## Privacy-safe useful metrics
261
261
 
262
+ Lazy collectors should import `projectUsefulMetric` and
263
+ `USEFUL_METRIC_EVENT_DEFINITIONS` from `@plasius/analytics/metrics`. This standalone
264
+ ESM/CJS entry contains no React, collectors or transport. Existing root exports
265
+ remain compatible, but using the focused entry lets a bundler keep optional
266
+ metric code out of a host's initial analytics graph, including when that host
267
+ loads the metric entry dynamically. The published entries are independent bundles
268
+ from one source, avoiding an eager shared metric chunk. The host must
269
+ still verify its real application bundle and own flag evaluation and transport.
270
+
262
271
  Compose the fixed definitions into the host's semantic catalogue, then project
263
272
  one observation before tracking it with the existing bounded client:
264
273
 
package/dist/index.cjs CHANGED
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
20
  // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
23
  AnalyticsProvider: () => AnalyticsProvider,
24
24
  SEMANTIC_JOURNEY_AGGREGATE_SCHEMA_VERSION: () => SEMANTIC_JOURNEY_AGGREGATE_SCHEMA_VERSION,
25
25
  SEMANTIC_JOURNEY_RECEIPT_HEADER: () => SEMANTIC_JOURNEY_RECEIPT_HEADER,
@@ -71,7 +71,7 @@ __export(index_exports, {
71
71
  useComponentInteractionTracker: () => useComponentInteractionTracker,
72
72
  validateSemanticJourneyEventInput: () => validateSemanticJourneyEventInput
73
73
  });
74
- module.exports = __toCommonJS(index_exports);
74
+ module.exports = __toCommonJS(src_exports);
75
75
 
76
76
  // src/core/client.ts
77
77
  var import_schema = require("@plasius/schema");
@@ -2021,7 +2021,7 @@ var duration = (category) => ({
2021
2021
  buckets: durationBuckets,
2022
2022
  maximum: 864e5
2023
2023
  });
2024
- var metrics = {
2024
+ var metrics = /* @__PURE__ */ (() => ({
2025
2025
  "page.load": duration("presentation"),
2026
2026
  "route.ready": duration("presentation"),
2027
2027
  "world.ready": duration("presentation"),
@@ -2060,11 +2060,11 @@ var metrics = {
2060
2060
  "error.resource": { category: "error", outcome: "failure" },
2061
2061
  "error.render": { category: "error", outcome: "failure" },
2062
2062
  "error.unhandled": { category: "error", outcome: "failure" }
2063
- };
2064
- var USEFUL_METRIC_EVENT_DEFINITIONS = Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {
2063
+ }))();
2064
+ var USEFUL_METRIC_EVENT_DEFINITIONS = /* @__PURE__ */ (() => Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {
2065
2065
  const names = definition.buckets ? definition.buckets.map(([, bucket]) => `metric.${metric}.${bucket}`) : [`metric.${metric}`];
2066
2066
  return names.map((name) => [name, Object.freeze({ category: definition.category })]);
2067
- })));
2067
+ }))))();
2068
2068
  function projectUsefulMetric(input) {
2069
2069
  try {
2070
2070
  if (typeof input !== "object" || input === null || Array.isArray(input)) return null;