@plasius/analytics 1.2.4 → 1.3.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/README.md +49 -0
- package/dist/index.cjs +97 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -434,6 +434,25 @@ declare class SemanticJourneyAggregateStore {
|
|
|
434
434
|
private sortedCounters;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Fixed useful-metric catalogue entries for host catalogue composition and
|
|
439
|
+
* collector allowlists. Buckets are part of event names so they survive the
|
|
440
|
+
* existing aggregate wire format, which deliberately does not carry attributes.
|
|
441
|
+
* This is not a collector or sender and has no browser/network side effects.
|
|
442
|
+
*/
|
|
443
|
+
declare const USEFUL_METRIC_EVENT_DEFINITIONS: Readonly<Record<string, Readonly<SemanticJourneyEventDefinition>>>;
|
|
444
|
+
/**
|
|
445
|
+
* Projects one observation into a catalogue-controlled, identity-free event.
|
|
446
|
+
* Accepts exactly { metric } for a counter or { metric, value } for a duration
|
|
447
|
+
* in milliseconds (CLS is unitless). Rejects unknown/extra fields, accessors,
|
|
448
|
+
* invalid numbers and legacy raw NFR payloads without reflecting their values.
|
|
449
|
+
*
|
|
450
|
+
* The host evaluates remote enablement, bounds observation frequency, tracks
|
|
451
|
+
* this result with its semantic client, and owns disposal. Episode observations
|
|
452
|
+
* are anonymous in-memory activity counts, never unique users or sessions.
|
|
453
|
+
*/
|
|
454
|
+
declare function projectUsefulMetric(input: unknown): SemanticJourneyEventInput | null;
|
|
455
|
+
|
|
437
456
|
/** Bounded aggregate request passed to an injectable transport. */
|
|
438
457
|
interface SemanticJourneyAggregateTransportRequest {
|
|
439
458
|
readonly endpoint: string;
|
|
@@ -674,4 +693,4 @@ interface TrackInteractionDetails extends Omit<LocalSpaceAnalyticsEvent, "compon
|
|
|
674
693
|
}
|
|
675
694
|
declare function useComponentInteractionTracker(component: string, baseContext?: AnalyticsContext): (action: string, details?: TrackInteractionDetails) => void;
|
|
676
695
|
|
|
677
|
-
export { type AnalyticsChannel, type AnalyticsContext, type AnalyticsContextValue, type AnalyticsErrorSeverity, type AnalyticsEventKind, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsRuntime, type AnalyticsTransport, type AnalyticsTransportRequest, type CreateSemanticJourneyAggregateBatchOptions, type DefaultSemanticJourneyTransportOptions, type LocalSpaceAnalyticsClient, type LocalSpaceAnalyticsConfig, type LocalSpaceAnalyticsErrorDetails, type LocalSpaceAnalyticsEvent, type LocalSpaceAnalyticsRecord, type LocalSpaceErrorReportInput, type LocalSpaceErrorReportingConfig, type LocalSpaceIssueReport, type LocalSpaceIssueThresholdTrigger, type RandomByteSource, type ResolvedLocalSpaceAnalyticsConfig, type ResolvedLocalSpaceErrorReportingConfig, SEMANTIC_JOURNEY_AGGREGATE_SCHEMA_VERSION, SEMANTIC_JOURNEY_RECEIPT_HEADER, SEMANTIC_JOURNEY_RECEIPT_MAX_BYTES, SEMANTIC_JOURNEY_RECEIPT_MAX_COUNT, SEMANTIC_JOURNEY_RECEIPT_VERSION, SEMANTIC_JOURNEY_STRICT_POLICY_VERSION, type SemanticJourneyAggregateBatch, type SemanticJourneyAggregateCounter, type SemanticJourneyAggregateSnapshot, SemanticJourneyAggregateStore, type SemanticJourneyAggregateStoreOptions, type SemanticJourneyAggregateTransport, type SemanticJourneyAggregateTransportRequest, type SemanticJourneyAttributeDefinition, type SemanticJourneyAttributeValue, type SemanticJourneyBooleanAttributeDefinition, type SemanticJourneyBrowserObserverConfig, type SemanticJourneyCatalog, type SemanticJourneyCatalogOptions, type SemanticJourneyCatalogue, type SemanticJourneyCategory, type SemanticJourneyClient, type SemanticJourneyClientConfig, type SemanticJourneyCompleteness, type SemanticJourneyConsequenceReceipt, type SemanticJourneyContext, type SemanticJourneyDropReason, type SemanticJourneyEnumAttributeDefinition, type SemanticJourneyEvent, type SemanticJourneyEventDefinition, type SemanticJourneyEventId, type SemanticJourneyEventInput, type SemanticJourneyEvidence, type SemanticJourneyEvidenceCode, type SemanticJourneyId, type SemanticJourneyModality, type SemanticJourneyNumberAttributeDefinition, type SemanticJourneyOutcome, type SemanticJourneyPhase, type SemanticJourneyPrivacyMetadata, type SemanticJourneyProducerId, type SemanticJourneyReplay, type SemanticJourneyRequestLink, type SemanticJourneyRetryDelay, type SemanticJourneySpanId, type SemanticJourneyStep, type SemanticJourneyTarget, type SemanticJourneyTraceContext, type SemanticJourneyTraceFlags, type SemanticJourneyTraceId, type SemanticJourneyTrackOptions, SemanticJourneyTransportError, type SemanticJourneyTransportErrorCode, SemanticJourneyValidationError, type SemanticJourneyValidationErrorCode, type TrackInteractionDetails, type ValidatedSemanticJourneyEventInput, assertSemanticSource, assertSemanticToken, createBackendAnalyticsClient, createChildJourneyContext, createDefaultSemanticJourneyAggregateTransport, createEventId, createFrontendAnalyticsClient, createJourneyContext, createJourneyId, createLocalSpaceAnalyticsClient, createNoopLocalSpaceAnalyticsClient, createProducerId, createRequestJourneyContext, createSecureRandomHex, createSemanticJourneyClient, createSpanId, createTraceId, defineJourneyEvent, defineSemanticJourneyCatalog, formatTraceparent, getJourneyEventDefinition, isEventId, isJourneyId, isJourneyToken, isProducerId, isSecureSemanticJourneyEndpoint, isSemanticSource, isSemanticToken, isSpanId, isTraceId, observeSemanticJourneyInteractions, parseSemanticJourneyReceipts, parseTraceparent, reconstructSemanticJourney, serializeSemanticJourneyReceipts, useAnalytics, useComponentInteractionTracker, validateSemanticJourneyEventInput };
|
|
696
|
+
export { type AnalyticsChannel, type AnalyticsContext, type AnalyticsContextValue, type AnalyticsErrorSeverity, type AnalyticsEventKind, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsRuntime, type AnalyticsTransport, type AnalyticsTransportRequest, type CreateSemanticJourneyAggregateBatchOptions, type DefaultSemanticJourneyTransportOptions, type LocalSpaceAnalyticsClient, type LocalSpaceAnalyticsConfig, type LocalSpaceAnalyticsErrorDetails, type LocalSpaceAnalyticsEvent, type LocalSpaceAnalyticsRecord, type LocalSpaceErrorReportInput, type LocalSpaceErrorReportingConfig, type LocalSpaceIssueReport, type LocalSpaceIssueThresholdTrigger, type RandomByteSource, type ResolvedLocalSpaceAnalyticsConfig, type ResolvedLocalSpaceErrorReportingConfig, SEMANTIC_JOURNEY_AGGREGATE_SCHEMA_VERSION, SEMANTIC_JOURNEY_RECEIPT_HEADER, SEMANTIC_JOURNEY_RECEIPT_MAX_BYTES, SEMANTIC_JOURNEY_RECEIPT_MAX_COUNT, SEMANTIC_JOURNEY_RECEIPT_VERSION, SEMANTIC_JOURNEY_STRICT_POLICY_VERSION, type SemanticJourneyAggregateBatch, type SemanticJourneyAggregateCounter, type SemanticJourneyAggregateSnapshot, SemanticJourneyAggregateStore, type SemanticJourneyAggregateStoreOptions, type SemanticJourneyAggregateTransport, type SemanticJourneyAggregateTransportRequest, type SemanticJourneyAttributeDefinition, type SemanticJourneyAttributeValue, type SemanticJourneyBooleanAttributeDefinition, type SemanticJourneyBrowserObserverConfig, type SemanticJourneyCatalog, type SemanticJourneyCatalogOptions, type SemanticJourneyCatalogue, type SemanticJourneyCategory, type SemanticJourneyClient, type SemanticJourneyClientConfig, type SemanticJourneyCompleteness, type SemanticJourneyConsequenceReceipt, type SemanticJourneyContext, type SemanticJourneyDropReason, type SemanticJourneyEnumAttributeDefinition, type SemanticJourneyEvent, type SemanticJourneyEventDefinition, type SemanticJourneyEventId, type SemanticJourneyEventInput, type SemanticJourneyEvidence, type SemanticJourneyEvidenceCode, type SemanticJourneyId, type SemanticJourneyModality, type SemanticJourneyNumberAttributeDefinition, type SemanticJourneyOutcome, type SemanticJourneyPhase, type SemanticJourneyPrivacyMetadata, type SemanticJourneyProducerId, type SemanticJourneyReplay, type SemanticJourneyRequestLink, type SemanticJourneyRetryDelay, type SemanticJourneySpanId, type SemanticJourneyStep, type SemanticJourneyTarget, type SemanticJourneyTraceContext, type SemanticJourneyTraceFlags, type SemanticJourneyTraceId, type SemanticJourneyTrackOptions, SemanticJourneyTransportError, type SemanticJourneyTransportErrorCode, SemanticJourneyValidationError, type SemanticJourneyValidationErrorCode, type TrackInteractionDetails, USEFUL_METRIC_EVENT_DEFINITIONS, type ValidatedSemanticJourneyEventInput, assertSemanticSource, assertSemanticToken, createBackendAnalyticsClient, createChildJourneyContext, createDefaultSemanticJourneyAggregateTransport, createEventId, createFrontendAnalyticsClient, createJourneyContext, createJourneyId, createLocalSpaceAnalyticsClient, createNoopLocalSpaceAnalyticsClient, createProducerId, createRequestJourneyContext, createSecureRandomHex, createSemanticJourneyClient, createSpanId, createTraceId, defineJourneyEvent, defineSemanticJourneyCatalog, formatTraceparent, getJourneyEventDefinition, isEventId, isJourneyId, isJourneyToken, isProducerId, isSecureSemanticJourneyEndpoint, isSemanticSource, isSemanticToken, isSpanId, isTraceId, observeSemanticJourneyInteractions, parseSemanticJourneyReceipts, parseTraceparent, projectUsefulMetric, reconstructSemanticJourney, serializeSemanticJourneyReceipts, useAnalytics, useComponentInteractionTracker, validateSemanticJourneyEventInput };
|
package/dist/index.d.ts
CHANGED
|
@@ -434,6 +434,25 @@ declare class SemanticJourneyAggregateStore {
|
|
|
434
434
|
private sortedCounters;
|
|
435
435
|
}
|
|
436
436
|
|
|
437
|
+
/**
|
|
438
|
+
* Fixed useful-metric catalogue entries for host catalogue composition and
|
|
439
|
+
* collector allowlists. Buckets are part of event names so they survive the
|
|
440
|
+
* existing aggregate wire format, which deliberately does not carry attributes.
|
|
441
|
+
* This is not a collector or sender and has no browser/network side effects.
|
|
442
|
+
*/
|
|
443
|
+
declare const USEFUL_METRIC_EVENT_DEFINITIONS: Readonly<Record<string, Readonly<SemanticJourneyEventDefinition>>>;
|
|
444
|
+
/**
|
|
445
|
+
* Projects one observation into a catalogue-controlled, identity-free event.
|
|
446
|
+
* Accepts exactly { metric } for a counter or { metric, value } for a duration
|
|
447
|
+
* in milliseconds (CLS is unitless). Rejects unknown/extra fields, accessors,
|
|
448
|
+
* invalid numbers and legacy raw NFR payloads without reflecting their values.
|
|
449
|
+
*
|
|
450
|
+
* The host evaluates remote enablement, bounds observation frequency, tracks
|
|
451
|
+
* this result with its semantic client, and owns disposal. Episode observations
|
|
452
|
+
* are anonymous in-memory activity counts, never unique users or sessions.
|
|
453
|
+
*/
|
|
454
|
+
declare function projectUsefulMetric(input: unknown): SemanticJourneyEventInput | null;
|
|
455
|
+
|
|
437
456
|
/** Bounded aggregate request passed to an injectable transport. */
|
|
438
457
|
interface SemanticJourneyAggregateTransportRequest {
|
|
439
458
|
readonly endpoint: string;
|
|
@@ -674,4 +693,4 @@ interface TrackInteractionDetails extends Omit<LocalSpaceAnalyticsEvent, "compon
|
|
|
674
693
|
}
|
|
675
694
|
declare function useComponentInteractionTracker(component: string, baseContext?: AnalyticsContext): (action: string, details?: TrackInteractionDetails) => void;
|
|
676
695
|
|
|
677
|
-
export { type AnalyticsChannel, type AnalyticsContext, type AnalyticsContextValue, type AnalyticsErrorSeverity, type AnalyticsEventKind, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsRuntime, type AnalyticsTransport, type AnalyticsTransportRequest, type CreateSemanticJourneyAggregateBatchOptions, type DefaultSemanticJourneyTransportOptions, type LocalSpaceAnalyticsClient, type LocalSpaceAnalyticsConfig, type LocalSpaceAnalyticsErrorDetails, type LocalSpaceAnalyticsEvent, type LocalSpaceAnalyticsRecord, type LocalSpaceErrorReportInput, type LocalSpaceErrorReportingConfig, type LocalSpaceIssueReport, type LocalSpaceIssueThresholdTrigger, type RandomByteSource, type ResolvedLocalSpaceAnalyticsConfig, type ResolvedLocalSpaceErrorReportingConfig, SEMANTIC_JOURNEY_AGGREGATE_SCHEMA_VERSION, SEMANTIC_JOURNEY_RECEIPT_HEADER, SEMANTIC_JOURNEY_RECEIPT_MAX_BYTES, SEMANTIC_JOURNEY_RECEIPT_MAX_COUNT, SEMANTIC_JOURNEY_RECEIPT_VERSION, SEMANTIC_JOURNEY_STRICT_POLICY_VERSION, type SemanticJourneyAggregateBatch, type SemanticJourneyAggregateCounter, type SemanticJourneyAggregateSnapshot, SemanticJourneyAggregateStore, type SemanticJourneyAggregateStoreOptions, type SemanticJourneyAggregateTransport, type SemanticJourneyAggregateTransportRequest, type SemanticJourneyAttributeDefinition, type SemanticJourneyAttributeValue, type SemanticJourneyBooleanAttributeDefinition, type SemanticJourneyBrowserObserverConfig, type SemanticJourneyCatalog, type SemanticJourneyCatalogOptions, type SemanticJourneyCatalogue, type SemanticJourneyCategory, type SemanticJourneyClient, type SemanticJourneyClientConfig, type SemanticJourneyCompleteness, type SemanticJourneyConsequenceReceipt, type SemanticJourneyContext, type SemanticJourneyDropReason, type SemanticJourneyEnumAttributeDefinition, type SemanticJourneyEvent, type SemanticJourneyEventDefinition, type SemanticJourneyEventId, type SemanticJourneyEventInput, type SemanticJourneyEvidence, type SemanticJourneyEvidenceCode, type SemanticJourneyId, type SemanticJourneyModality, type SemanticJourneyNumberAttributeDefinition, type SemanticJourneyOutcome, type SemanticJourneyPhase, type SemanticJourneyPrivacyMetadata, type SemanticJourneyProducerId, type SemanticJourneyReplay, type SemanticJourneyRequestLink, type SemanticJourneyRetryDelay, type SemanticJourneySpanId, type SemanticJourneyStep, type SemanticJourneyTarget, type SemanticJourneyTraceContext, type SemanticJourneyTraceFlags, type SemanticJourneyTraceId, type SemanticJourneyTrackOptions, SemanticJourneyTransportError, type SemanticJourneyTransportErrorCode, SemanticJourneyValidationError, type SemanticJourneyValidationErrorCode, type TrackInteractionDetails, type ValidatedSemanticJourneyEventInput, assertSemanticSource, assertSemanticToken, createBackendAnalyticsClient, createChildJourneyContext, createDefaultSemanticJourneyAggregateTransport, createEventId, createFrontendAnalyticsClient, createJourneyContext, createJourneyId, createLocalSpaceAnalyticsClient, createNoopLocalSpaceAnalyticsClient, createProducerId, createRequestJourneyContext, createSecureRandomHex, createSemanticJourneyClient, createSpanId, createTraceId, defineJourneyEvent, defineSemanticJourneyCatalog, formatTraceparent, getJourneyEventDefinition, isEventId, isJourneyId, isJourneyToken, isProducerId, isSecureSemanticJourneyEndpoint, isSemanticSource, isSemanticToken, isSpanId, isTraceId, observeSemanticJourneyInteractions, parseSemanticJourneyReceipts, parseTraceparent, reconstructSemanticJourney, serializeSemanticJourneyReceipts, useAnalytics, useComponentInteractionTracker, validateSemanticJourneyEventInput };
|
|
696
|
+
export { type AnalyticsChannel, type AnalyticsContext, type AnalyticsContextValue, type AnalyticsErrorSeverity, type AnalyticsEventKind, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsRuntime, type AnalyticsTransport, type AnalyticsTransportRequest, type CreateSemanticJourneyAggregateBatchOptions, type DefaultSemanticJourneyTransportOptions, type LocalSpaceAnalyticsClient, type LocalSpaceAnalyticsConfig, type LocalSpaceAnalyticsErrorDetails, type LocalSpaceAnalyticsEvent, type LocalSpaceAnalyticsRecord, type LocalSpaceErrorReportInput, type LocalSpaceErrorReportingConfig, type LocalSpaceIssueReport, type LocalSpaceIssueThresholdTrigger, type RandomByteSource, type ResolvedLocalSpaceAnalyticsConfig, type ResolvedLocalSpaceErrorReportingConfig, SEMANTIC_JOURNEY_AGGREGATE_SCHEMA_VERSION, SEMANTIC_JOURNEY_RECEIPT_HEADER, SEMANTIC_JOURNEY_RECEIPT_MAX_BYTES, SEMANTIC_JOURNEY_RECEIPT_MAX_COUNT, SEMANTIC_JOURNEY_RECEIPT_VERSION, SEMANTIC_JOURNEY_STRICT_POLICY_VERSION, type SemanticJourneyAggregateBatch, type SemanticJourneyAggregateCounter, type SemanticJourneyAggregateSnapshot, SemanticJourneyAggregateStore, type SemanticJourneyAggregateStoreOptions, type SemanticJourneyAggregateTransport, type SemanticJourneyAggregateTransportRequest, type SemanticJourneyAttributeDefinition, type SemanticJourneyAttributeValue, type SemanticJourneyBooleanAttributeDefinition, type SemanticJourneyBrowserObserverConfig, type SemanticJourneyCatalog, type SemanticJourneyCatalogOptions, type SemanticJourneyCatalogue, type SemanticJourneyCategory, type SemanticJourneyClient, type SemanticJourneyClientConfig, type SemanticJourneyCompleteness, type SemanticJourneyConsequenceReceipt, type SemanticJourneyContext, type SemanticJourneyDropReason, type SemanticJourneyEnumAttributeDefinition, type SemanticJourneyEvent, type SemanticJourneyEventDefinition, type SemanticJourneyEventId, type SemanticJourneyEventInput, type SemanticJourneyEvidence, type SemanticJourneyEvidenceCode, type SemanticJourneyId, type SemanticJourneyModality, type SemanticJourneyNumberAttributeDefinition, type SemanticJourneyOutcome, type SemanticJourneyPhase, type SemanticJourneyPrivacyMetadata, type SemanticJourneyProducerId, type SemanticJourneyReplay, type SemanticJourneyRequestLink, type SemanticJourneyRetryDelay, type SemanticJourneySpanId, type SemanticJourneyStep, type SemanticJourneyTarget, type SemanticJourneyTraceContext, type SemanticJourneyTraceFlags, type SemanticJourneyTraceId, type SemanticJourneyTrackOptions, SemanticJourneyTransportError, type SemanticJourneyTransportErrorCode, SemanticJourneyValidationError, type SemanticJourneyValidationErrorCode, type TrackInteractionDetails, USEFUL_METRIC_EVENT_DEFINITIONS, type ValidatedSemanticJourneyEventInput, assertSemanticSource, assertSemanticToken, createBackendAnalyticsClient, createChildJourneyContext, createDefaultSemanticJourneyAggregateTransport, createEventId, createFrontendAnalyticsClient, createJourneyContext, createJourneyId, createLocalSpaceAnalyticsClient, createNoopLocalSpaceAnalyticsClient, createProducerId, createRequestJourneyContext, createSecureRandomHex, createSemanticJourneyClient, createSpanId, createTraceId, defineJourneyEvent, defineSemanticJourneyCatalog, formatTraceparent, getJourneyEventDefinition, isEventId, isJourneyId, isJourneyToken, isProducerId, isSecureSemanticJourneyEndpoint, isSemanticSource, isSemanticToken, isSpanId, isTraceId, observeSemanticJourneyInteractions, parseSemanticJourneyReceipts, parseTraceparent, projectUsefulMetric, reconstructSemanticJourney, serializeSemanticJourneyReceipts, useAnalytics, useComponentInteractionTracker, validateSemanticJourneyEventInput };
|
package/dist/index.js
CHANGED
|
@@ -1929,6 +1929,99 @@ var SemanticJourneyAggregateStore = class {
|
|
|
1929
1929
|
}
|
|
1930
1930
|
};
|
|
1931
1931
|
|
|
1932
|
+
// src/journey/metrics.ts
|
|
1933
|
+
var durationBuckets = [
|
|
1934
|
+
[100, "lt100ms"],
|
|
1935
|
+
[250, "lt250ms"],
|
|
1936
|
+
[500, "lt500ms"],
|
|
1937
|
+
[1e3, "lt1000ms"],
|
|
1938
|
+
[2500, "lt2500ms"],
|
|
1939
|
+
[5e3, "lt5000ms"],
|
|
1940
|
+
[1e4, "lt10000ms"],
|
|
1941
|
+
[Infinity, "gte10000ms"]
|
|
1942
|
+
];
|
|
1943
|
+
var duration = (category) => ({
|
|
1944
|
+
category,
|
|
1945
|
+
outcome: "unknown",
|
|
1946
|
+
buckets: durationBuckets,
|
|
1947
|
+
maximum: 864e5
|
|
1948
|
+
});
|
|
1949
|
+
var metrics = {
|
|
1950
|
+
"page.load": duration("presentation"),
|
|
1951
|
+
"route.ready": duration("presentation"),
|
|
1952
|
+
"world.ready": duration("presentation"),
|
|
1953
|
+
"request.duration": duration("request"),
|
|
1954
|
+
"vital.lcp": duration("presentation"),
|
|
1955
|
+
"vital.fcp": duration("presentation"),
|
|
1956
|
+
"vital.inp": duration("interaction"),
|
|
1957
|
+
"vital.ttfb": duration("request"),
|
|
1958
|
+
"vital.cls": {
|
|
1959
|
+
category: "presentation",
|
|
1960
|
+
outcome: "unknown",
|
|
1961
|
+
maximum: 100,
|
|
1962
|
+
buckets: [[0.1, "lt01"], [0.25, "lt025"], [Infinity, "gte025"]]
|
|
1963
|
+
},
|
|
1964
|
+
"episode.active-duration": {
|
|
1965
|
+
category: "state",
|
|
1966
|
+
outcome: "unknown",
|
|
1967
|
+
maximum: 864e5,
|
|
1968
|
+
buckets: [
|
|
1969
|
+
[1e4, "lt10s"],
|
|
1970
|
+
[6e4, "lt60s"],
|
|
1971
|
+
[3e5, "lt300s"],
|
|
1972
|
+
[9e5, "lt900s"],
|
|
1973
|
+
[36e5, "lt3600s"],
|
|
1974
|
+
[Infinity, "gte3600s"]
|
|
1975
|
+
]
|
|
1976
|
+
},
|
|
1977
|
+
"episode.started": { category: "state", outcome: "unknown" },
|
|
1978
|
+
"episode.completed": { category: "state", outcome: "unknown" },
|
|
1979
|
+
"request.started": { category: "request", outcome: "unknown" },
|
|
1980
|
+
"request.completed": { category: "request", outcome: "success" },
|
|
1981
|
+
"request.failed": { category: "request", outcome: "failure" },
|
|
1982
|
+
"request.cancelled": { category: "request", outcome: "cancelled" },
|
|
1983
|
+
"request.rejected": { category: "request", outcome: "denied" },
|
|
1984
|
+
"error.runtime": { category: "error", outcome: "failure" },
|
|
1985
|
+
"error.resource": { category: "error", outcome: "failure" },
|
|
1986
|
+
"error.render": { category: "error", outcome: "failure" },
|
|
1987
|
+
"error.unhandled": { category: "error", outcome: "failure" }
|
|
1988
|
+
};
|
|
1989
|
+
var USEFUL_METRIC_EVENT_DEFINITIONS = Object.freeze(Object.fromEntries(Object.entries(metrics).flatMap(([metric, definition]) => {
|
|
1990
|
+
const names = definition.buckets ? definition.buckets.map(([, bucket]) => `metric.${metric}.${bucket}`) : [`metric.${metric}`];
|
|
1991
|
+
return names.map((name) => [name, Object.freeze({ category: definition.category })]);
|
|
1992
|
+
})));
|
|
1993
|
+
function projectUsefulMetric(input) {
|
|
1994
|
+
try {
|
|
1995
|
+
if (typeof input !== "object" || input === null || Array.isArray(input)) return null;
|
|
1996
|
+
const prototype = Object.getPrototypeOf(input);
|
|
1997
|
+
if (prototype !== Object.prototype && prototype !== null) return null;
|
|
1998
|
+
const keys = Reflect.ownKeys(input);
|
|
1999
|
+
if (keys.length < 1 || keys.length > 2 || keys.some((key) => key !== "metric" && key !== "value")) return null;
|
|
2000
|
+
const descriptors = Object.getOwnPropertyDescriptors(input);
|
|
2001
|
+
const metric = descriptors.metric;
|
|
2002
|
+
if (!metric || !("value" in metric) || typeof metric.value !== "string" || !Object.hasOwn(metrics, metric.value)) return null;
|
|
2003
|
+
const definition = metrics[metric.value];
|
|
2004
|
+
let name = `metric.${metric.value}`;
|
|
2005
|
+
if (definition.buckets) {
|
|
2006
|
+
const value = descriptors.value;
|
|
2007
|
+
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;
|
|
2008
|
+
const bucket = definition.buckets.find(([upper]) => value.value < upper);
|
|
2009
|
+
name += `.${bucket[1]}`;
|
|
2010
|
+
} else if (keys.length !== 1) {
|
|
2011
|
+
return null;
|
|
2012
|
+
}
|
|
2013
|
+
return Object.freeze({
|
|
2014
|
+
name,
|
|
2015
|
+
category: definition.category,
|
|
2016
|
+
phase: metric.value.endsWith(".started") ? "start" : "end",
|
|
2017
|
+
outcome: definition.outcome,
|
|
2018
|
+
modality: "system"
|
|
2019
|
+
});
|
|
2020
|
+
} catch {
|
|
2021
|
+
return null;
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
|
|
1932
2025
|
// src/journey/transport.ts
|
|
1933
2026
|
var SemanticJourneyTransportError = class extends Error {
|
|
1934
2027
|
constructor(code, retryable, status, retryAfterMs) {
|
|
@@ -3908,6 +4001,7 @@ export {
|
|
|
3908
4001
|
SemanticJourneyAggregateStore,
|
|
3909
4002
|
SemanticJourneyTransportError,
|
|
3910
4003
|
SemanticJourneyValidationError,
|
|
4004
|
+
USEFUL_METRIC_EVENT_DEFINITIONS,
|
|
3911
4005
|
assertSemanticSource,
|
|
3912
4006
|
assertSemanticToken,
|
|
3913
4007
|
createBackendAnalyticsClient,
|
|
@@ -3941,6 +4035,7 @@ export {
|
|
|
3941
4035
|
observeSemanticJourneyInteractions,
|
|
3942
4036
|
parseSemanticJourneyReceipts,
|
|
3943
4037
|
parseTraceparent,
|
|
4038
|
+
projectUsefulMetric,
|
|
3944
4039
|
reconstructSemanticJourney,
|
|
3945
4040
|
serializeSemanticJourneyReceipts,
|
|
3946
4041
|
useAnalytics,
|