@spatius/avatarkit 1.3.7 → 1.3.9

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.
@@ -11,11 +11,6 @@ import { Attributes } from '@opentelemetry/api';
11
11
  * @param mono - the `performance.now()` value recorded at collection time
12
12
  */
13
13
  export declare function resolveMonoTimestamp(mono: number): number;
14
- /**
15
- * Whether clock calibration against the backend has completed. Timestamps
16
- * resolve either way; this only reports whether they are server-aligned yet.
17
- */
18
- export declare function isClockCalibrated(): boolean;
19
14
  /**
20
15
  * Handle for one round's trace.
21
16
  *
@@ -80,23 +75,22 @@ export declare function peekTraceparent(rawMessage: Uint8Array): string | undefi
80
75
  */
81
76
  export declare function recordMetric(name: string, value: number, attributes?: Attributes): void;
82
77
  /**
83
- * The client environment fields this SDK stamps on every OTel log record —
84
- * `host`, `domain`, `url`, `pathname`, `referrer`, `user_agent`, `locale`,
85
- * screen/viewport size and `timezone`.
78
+ * Emit one event onto avatarkit's OTel log channel.
79
+ *
80
+ * Must go through here rather than the RTC SDK calling `logs.getLogger().emit()`
81
+ * itself. Sharing the global LoggerProvider only carries Resource-level
82
+ * attributes (app_id / region / sdk.version); the record-level identity fields
83
+ * — `user_id`, `client_id` — are stamped inside this SDK's emit path, so a
84
+ * record emitted directly through the provider carries none of them. Routing
85
+ * through here is what the Android / iOS RTC SDKs already do via their
86
+ * `RTCTelemetry.track` entry, and it additionally picks up crash-replay
87
+ * persistence and the pre-calibration queue.
86
88
  *
87
- * Shared with the RTC SDK rather than re-derived there. These are record-level
88
- * fields, not Resource attributes: they are read from `window.location` at emit
89
- * time because `url`/`pathname` change as a single-page app routes. Sharing the
90
- * OTel providers therefore does not carry them across — the RTC SDK emits
91
- * through its own logger and would report no `host` at all, which is what
92
- * prompted this export. Re-implementing the collection on that side would let
93
- * the two drift apart in field names and in how each value is read, and the
94
- * backend aggregates on exactly these names.
95
- *
96
- * Call at emit time, once per record; spread the result before the caller's own
97
- * properties so an explicit value at the call site still wins.
89
+ * The timestamp is taken here rather than accepted from the caller: this path
90
+ * resolves it against the calibrated clock and stamps `server_timestamp`
91
+ * alongside, which a caller-supplied `Date.now()` cannot do.
98
92
  */
99
- export declare function clientContextFields(): Record<string, string | number>;
93
+ export declare function trackEvent(event: string, level?: 'debug' | 'info' | 'warning' | 'error', contents?: Record<string, unknown>): void;
100
94
  /**
101
95
  * Declare which SDK these records come from, as the `sdk.package` and
102
96
  * `sdk.version` resource attributes.
@@ -124,3 +118,15 @@ export declare function setSdkIdentity(identity: {
124
118
  sdkPackage?: string;
125
119
  sdkVersion?: string;
126
120
  }): void;
121
+ /**
122
+ * The client environment fields this SDK stamps on every OTel log record —
123
+ * `host`, `domain`, `url`, `pathname`, `referrer`, `user_agent`, `locale`,
124
+ * screen/viewport size and `timezone`.
125
+ *
126
+ * **Kept only for `@spatius/avatarkit-rtc` ≤ 1.1.3**, which imports it from this
127
+ * entry (RTC ≥ 1.1.4 routes through {@link trackEvent}, which stamps these fields
128
+ * itself, and no longer calls this). RTC's peer range is `>=1.3.7`, so a host
129
+ * still on 1.1.3 that upgrades this package would otherwise hit an undefined
130
+ * import. Remove once no 1.1.3 hosts remain in telemetry.
131
+ */
132
+ export declare function clientContextFields(): Record<string, string | number>;
@@ -1,4 +1,4 @@
1
- import { A as clockSync, I as recordMetric$1, o as startPlaybackTrace$1, u as Message, y as clientContextFields$1, z as setSdkIdentity$1 } from "./otel-trace-Y_BtH06z.js";
1
+ import { F as recordMetric$1, R as setSdkIdentity$1, T as trackEventOtel, g as clientContextFields$1, k as clockSync, o as startPlaybackTrace$1, u as Message } from "./otel-trace-DqXSWBaw.js";
2
2
  //#region internal-telemetry.ts
3
3
  /**
4
4
  * Internal telemetry surface for the companion RTC SDK.
@@ -35,13 +35,6 @@ function resolveMonoTimestamp(mono) {
35
35
  return clockSync.resolveMono(mono);
36
36
  }
37
37
  /**
38
- * Whether clock calibration against the backend has completed. Timestamps
39
- * resolve either way; this only reports whether they are server-aligned yet.
40
- */
41
- function isClockCalibrated() {
42
- return clockSync.isReady();
43
- }
44
- /**
45
38
  * Open one round's trace: `driven.request` → `playback` → the caller's spans.
46
39
  *
47
40
  * Shared with the RTC SDK rather than reimplemented there, so both packages
@@ -91,24 +84,23 @@ function recordMetric(name, value, attributes = {}) {
91
84
  recordMetric$1(name, value, attributes);
92
85
  }
93
86
  /**
94
- * The client environment fields this SDK stamps on every OTel log record —
95
- * `host`, `domain`, `url`, `pathname`, `referrer`, `user_agent`, `locale`,
96
- * screen/viewport size and `timezone`.
97
- *
98
- * Shared with the RTC SDK rather than re-derived there. These are record-level
99
- * fields, not Resource attributes: they are read from `window.location` at emit
100
- * time because `url`/`pathname` change as a single-page app routes. Sharing the
101
- * OTel providers therefore does not carry them across the RTC SDK emits
102
- * through its own logger and would report no `host` at all, which is what
103
- * prompted this export. Re-implementing the collection on that side would let
104
- * the two drift apart in field names and in how each value is read, and the
105
- * backend aggregates on exactly these names.
106
- *
107
- * Call at emit time, once per record; spread the result before the caller's own
108
- * properties so an explicit value at the call site still wins.
87
+ * Emit one event onto avatarkit's OTel log channel.
88
+ *
89
+ * Must go through here rather than the RTC SDK calling `logs.getLogger().emit()`
90
+ * itself. Sharing the global LoggerProvider only carries Resource-level
91
+ * attributes (app_id / region / sdk.version); the record-level identity fields
92
+ * `user_id`, `client_id` are stamped inside this SDK's emit path, so a
93
+ * record emitted directly through the provider carries none of them. Routing
94
+ * through here is what the Android / iOS RTC SDKs already do via their
95
+ * `RTCTelemetry.track` entry, and it additionally picks up crash-replay
96
+ * persistence and the pre-calibration queue.
97
+ *
98
+ * The timestamp is taken here rather than accepted from the caller: this path
99
+ * resolves it against the calibrated clock and stamps `server_timestamp`
100
+ * alongside, which a caller-supplied `Date.now()` cannot do.
109
101
  */
110
- function clientContextFields() {
111
- return clientContextFields$1();
102
+ function trackEvent(event, level = "info", contents = {}) {
103
+ trackEventOtel(event, level, contents);
112
104
  }
113
105
  /**
114
106
  * Declare which SDK these records come from, as the `sdk.package` and
@@ -136,5 +128,19 @@ function clientContextFields() {
136
128
  function setSdkIdentity(identity) {
137
129
  setSdkIdentity$1(identity);
138
130
  }
131
+ /**
132
+ * The client environment fields this SDK stamps on every OTel log record —
133
+ * `host`, `domain`, `url`, `pathname`, `referrer`, `user_agent`, `locale`,
134
+ * screen/viewport size and `timezone`.
135
+ *
136
+ * **Kept only for `@spatius/avatarkit-rtc` ≤ 1.1.3**, which imports it from this
137
+ * entry (RTC ≥ 1.1.4 routes through {@link trackEvent}, which stamps these fields
138
+ * itself, and no longer calls this). RTC's peer range is `>=1.3.7`, so a host
139
+ * still on 1.1.3 that upgrades this package would otherwise hit an undefined
140
+ * import. Remove once no 1.1.3 hosts remain in telemetry.
141
+ */
142
+ function clientContextFields() {
143
+ return clientContextFields$1();
144
+ }
139
145
  //#endregion
140
- export { clientContextFields, isClockCalibrated, peekTraceparent, recordMetric, resolveMonoTimestamp, setSdkIdentity, startPlaybackTrace };
146
+ export { clientContextFields, peekTraceparent, recordMetric, resolveMonoTimestamp, setSdkIdentity, startPlaybackTrace, trackEvent };