@corbado/observe 1.13.0 → 1.14.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @corbado/observe
2
2
 
3
+ ## 1.14.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 8f563e2: New tracker plugin `eventTime(stamp)` for `initCore`: every tracked event is dated by the integration's clock, `stamp(explicitTimestamp)`, instead of `explicitTimestamp ?? Date.now()`, also for SDK methods that take no timestamp (`flowStarted`, `flowFinished`, decisions, an operation's `subflow_started`). For integrations that replay host signals late (e.g. from a host-side event buffer). A clock that throws or returns a non-finite number falls back to the SDK's own dating; telemetry and low events keep their capture time. `init()` / `CorbadoTracker` are unchanged.
8
+
3
9
  ## 1.13.0
4
10
 
5
11
  ### Minor Changes
@@ -12,6 +12,7 @@ export * from "./plugins/cross-origin-session.mjs";
12
12
  export * from "./plugins/raw-errors.mjs";
13
13
  export * from "./plugins/probes.mjs";
14
14
  export * from "./plugins/fixed-source-path.mjs";
15
+ export * from "./plugins/event-time.mjs";
15
16
  export * from "./probe-lane.mjs";
16
17
  export * from "./transport.mjs";
17
18
  export * from "./queue.mjs";
@@ -0,0 +1,18 @@
1
+ // src/plugins/event-time.ts
2
+ function eventTime(stamp) {
3
+ if (typeof stamp !== "function") return {};
4
+ return {
5
+ // Guarded here, not in the tracker: the core only pays for the hook call.
6
+ eventTime: (explicitTimestamp) => {
7
+ try {
8
+ const stamped = stamp(explicitTimestamp);
9
+ return typeof stamped === "number" && Number.isFinite(stamped) ? stamped : void 0;
10
+ } catch {
11
+ return void 0;
12
+ }
13
+ }
14
+ };
15
+ }
16
+ export {
17
+ eventTime
18
+ };
@@ -133,6 +133,7 @@ var CorbadoTrackerCore = class _CorbadoTrackerCore {
133
133
  if (plugin.session) this.bridge = plugin.session(this) || this.bridge;
134
134
  if (plugin.rawErrors) this.rawErrors = plugin.rawErrors;
135
135
  if (typeof plugin.sourcePath === "function") this.fixedSourcePath = plugin.sourcePath;
136
+ if (plugin.eventTime) this.eventClock = plugin.eventTime;
136
137
  });
137
138
  if (options.fixedDataConfig?.crossOriginSession && !this.bridge) {
138
139
  this.logger.warn("fixedDataConfig.crossOriginSession is ignored without the crossOriginSession() plugin");
@@ -273,6 +274,8 @@ var CorbadoTrackerCore = class _CorbadoTrackerCore {
273
274
  rawErrors;
274
275
  /** Fixed source path of a plugin; undefined = the server-driven `sourcePathQuery` policy. */
275
276
  fixedSourcePath;
277
+ /** Event clock of a plugin (never throws); undefined or an undefined result = `explicitTimestamp ?? Date.now()`. */
278
+ eventClock;
276
279
  /** @internal Shared passive page observation and per-operation context registration. */
277
280
  getWindowObserver() {
278
281
  return this.windowObserver ??= new SharedWindowObserver(
@@ -891,7 +894,7 @@ var CorbadoTrackerCore = class _CorbadoTrackerCore {
891
894
  if (name === AuthEventName.FlowFinished || name === AuthEventName.FlowAutoFinished || name === AuthEventName.FlowReset) {
892
895
  this.windowObserver?.flushInputs();
893
896
  }
894
- const timestamp = explicitTimestamp ?? Date.now();
897
+ const timestamp = this.eventClock?.(explicitTimestamp) ?? explicitTimestamp ?? Date.now();
895
898
  const capturedId = capture?.id ?? uuidv7();
896
899
  const capturedSessionId = capture?.sessionId ?? this.sessionId;
897
900
  const nextSeq = this.nextSeq();
@@ -1,6 +1,6 @@
1
1
  // src/version.ts
2
2
  var SDK_NAME = "@corbado/observe";
3
- var SDK_VERSION = true ? "1.13.0" : "0.0.0-dev";
3
+ var SDK_VERSION = true ? "1.14.0" : "0.0.0-dev";
4
4
  export {
5
5
  SDK_NAME,
6
6
  SDK_VERSION