@sanseng/liveavatar-js-sdk-skywalking 1.0.1 → 1.1.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/dist/index.d.ts CHANGED
@@ -1,6 +1,91 @@
1
- import { AvSyncAlertEvent, AvSyncLogRetention, AvSyncAnalysisReport, SDKPlugin, SDKPluginRegistrar } from '@sanseng/liveavatar-js-sdk';
1
+ import { SDKLogRecordV2, SDKJsonObject, AvSyncTelemetryQuery, SDKLogEvidencePageV2, PlaybackStatus, SDKPlugin, SDKPluginRegistrar, VERSION } from '@sanseng/liveavatar-js-sdk';
2
+
3
+ /** Source-owned identities; server and diagnostic sessions are distinct. */
4
+ interface SkyWalkingCorrelation {
5
+ clientInstanceId?: string;
6
+ monitoringSessionId?: string;
7
+ serverSessionId?: string;
8
+ avsyncSessionId?: string;
9
+ }
10
+ interface SkyWalkingOperationalLogSource extends SkyWalkingCorrelation {
11
+ sourceSchema: "sdk.log";
12
+ sourceSchemaVersion: 2;
13
+ clientInstanceId: string;
14
+ eventId: string;
15
+ streamId: string;
16
+ sequence: number;
17
+ occurredAtMs: number;
18
+ observedAtMs?: number;
19
+ clockId?: string;
20
+ }
21
+ interface SkyWalkingSessionTimelinePayload extends SkyWalkingOperationalLogSource {
22
+ kind: "liveavatar.session.timeline";
23
+ schemaVersion: 4;
24
+ level: SDKLogRecordV2["level"];
25
+ module: SDKLogRecordV2["module"];
26
+ event: string;
27
+ trigger: SDKLogRecordV2["trigger"];
28
+ operation?: SDKLogRecordV2["operation"];
29
+ failureRef?: SDKLogRecordV2["failureRef"];
30
+ snapshot?: SDKJsonObject;
31
+ correlation?: SDKLogRecordV2["correlation"];
32
+ data?: SDKJsonObject;
33
+ }
34
+
35
+ type EvidenceRange = NonNullable<AvSyncTelemetryQuery["range"]>;
36
+ type JsonSafeAlert = SDKLogRecordV2;
37
+ /** Logical document reconstructed from the ordered transport fragments. */
38
+ interface AvSyncEvidence {
39
+ schema: "liveavatar.avsync.evidence";
40
+ schemaVersion: 4;
41
+ alert: SDKLogRecordV2;
42
+ query: {
43
+ range: EvidenceRange;
44
+ retrievedAtWallClockMs: number;
45
+ complete: boolean;
46
+ };
47
+ pages: readonly SDKLogEvidencePageV2[];
48
+ completeness: {
49
+ complete: boolean;
50
+ reasons: readonly string[];
51
+ };
52
+ }
53
+ /** Wire summary. Third-level containers such as reasons are JSON strings. */
54
+ interface AvSyncAlertEvidencePayload extends SkyWalkingOperationalLogSource {
55
+ kind: "liveavatar.avsync.alert-evidence";
56
+ schemaVersion: 4;
57
+ recordType: "summary";
58
+ evidenceId: string;
59
+ alertId: string;
60
+ evidence: {
61
+ complete: boolean;
62
+ reasons: string;
63
+ logChunkCount: number;
64
+ logRecordCount: number;
65
+ byteLength: number;
66
+ };
67
+ }
68
+ /** A fragment can end inside a source record, but never inside a Unicode pair. */
69
+ interface AvSyncEvidenceLogChunkPayload extends SkyWalkingOperationalLogSource {
70
+ kind: "liveavatar.avsync.alert-evidence";
71
+ schemaVersion: 4;
72
+ recordType: "log-chunk";
73
+ evidenceId: string;
74
+ alertId: string;
75
+ chunk: {
76
+ index: number;
77
+ total: number;
78
+ byteLength: number;
79
+ data: string;
80
+ };
81
+ }
82
+ interface AvSyncRecoveryPayload extends SkyWalkingOperationalLogSource {
83
+ kind: "liveavatar.avsync.recovery";
84
+ schemaVersion: 4;
85
+ alertId: string;
86
+ recoveredAtWallClockMs: number;
87
+ }
2
88
 
3
- /** Stable identifier used by the LiveAvatar SDK plugin host. */
4
89
  declare const SKYWALKING_PLUGIN_ID = "liveavatar.skywalking";
5
90
  declare const SKYWALKING_SERVICE = "yy-tx::liveavatar-js-sdk";
6
91
  type SkyWalkingUrlMatcher = string | RegExp;
@@ -14,23 +99,29 @@ interface SkyWalkingSlowInteractionConfig {
14
99
  threshold?: number;
15
100
  reportInterval?: number;
16
101
  }
17
- /** Selects which SDK-generated records the plugin sends to SkyWalking. */
102
+ /** Selects automatic SDK fact reports and plugin playback samples. */
18
103
  interface SkyWalkingReportingConfig {
19
104
  /** Report SDK Operational Log errors. Defaults to `true`. */
20
105
  sdkError?: boolean;
106
+ /** Report allowlisted session lifecycle facts. Defaults to `true`. */
107
+ timeline?: boolean;
21
108
  /** Report terminal SDK first-frame Operational Logs. Defaults to `true`. */
22
109
  firstFrame?: boolean;
23
110
  /** Report SDK-generated A/V Sync alert lifecycles and evidence. Defaults to `true`. */
24
111
  avSync?: boolean;
112
+ /** Sample playback while connected. Defaults to `true`. */
113
+ playbackStatus?: boolean;
25
114
  }
26
115
  /**
27
116
  * Registration options accepted by SkyWalking js-sdk 1.1.27, plus the
28
- * plugin-level reporting controls and overseas switch. `service` is deliberately
29
- * fixed by the plugin.
117
+ * plugin-level reporting controls and overseas switch. `service` and
118
+ * `serviceVersion` are deliberately fixed by the plugin.
30
119
  */
31
120
  interface SkyWalkingPluginConfig {
32
- /** Select automatic SDK log types. Every type is enabled by default. */
121
+ /** Select automatic report types. Every type is enabled by default. */
33
122
  reporting?: SkyWalkingReportingConfig;
123
+ /** Positive integer milliseconds, at most 2147483647. Defaults to 5000. */
124
+ playbackStatusIntervalMs?: number;
34
125
  /** Explicit collector URL. It takes precedence over `isOverseas`. */
35
126
  collector?: string;
36
127
  /** `false` selects the domestic collector; `true` selects the overseas one. */
@@ -55,7 +146,6 @@ interface SkyWalkingPluginConfig {
55
146
  extraMsg?: string | (() => string);
56
147
  hooks?: SkyWalkingHooks;
57
148
  pagePath?: string;
58
- serviceVersion?: string;
59
149
  pageKey?: string;
60
150
  group?: string;
61
151
  subGroup?: string;
@@ -90,7 +180,7 @@ interface SkyWalkingRegistrationOptions {
90
180
  extraMsg?: string | (() => string);
91
181
  hooks: SkyWalkingHooks;
92
182
  pagePath: string;
93
- serviceVersion: string;
183
+ serviceVersion: typeof VERSION;
94
184
  pageKey: string;
95
185
  group: string;
96
186
  subGroup: string;
@@ -101,135 +191,6 @@ interface SkyWalkingRegistrationOptions {
101
191
  maxRequestBodySize: number;
102
192
  slowInteraction: Required<SkyWalkingSlowInteractionConfig>;
103
193
  }
104
- type EvidenceUnavailableReason = "initial-query-failed" | "session-mismatch" | "continuation-query-failed" | "cursor-did-not-advance";
105
- /** JSON-safe representation of an A/V Sync alert in an evidence payload. */
106
- interface JsonSafeAlert extends Omit<AvSyncAlertEvent, "sessionId"> {
107
- sessionId: string | null;
108
- }
109
- /** Evidence attached to one raised A/V-sync alert. */
110
- interface AvSyncEvidence {
111
- evidenceSchemaVersion: 2;
112
- /** Diagnostic session owning every compact evidence record. */
113
- sessionId: string | null;
114
- /** Query bounds and whether the SDK could read a complete window. */
115
- window: AvSyncEvidenceWindow;
116
- /** Only retention facts which affect whether absence can be interpreted. */
117
- retention: AvSyncEvidenceRetention | null;
118
- /** Small, structured platform-first attribution for the exact alert window. */
119
- triage: AvSyncTriage | null;
120
- /** Number of separately reported detailed-log records. */
121
- logChunkCount: number;
122
- /** Number of compact records across all log chunks. */
123
- logRecordCount: number;
124
- /** Detail projection; each detailed-log record carries its own manifest entry. */
125
- detail: AvSyncEvidenceDetail;
126
- /** @deprecated Detailed logs are now emitted as separate log records. */
127
- logs?: readonly AvSyncCompactLog[];
128
- /** @deprecated Detailed logs are now emitted as separate log records. */
129
- [logChunk: `logs_${number}`]: readonly AvSyncCompactLog[] | undefined;
130
- }
131
- interface AvSyncEvidenceWindow {
132
- mode: "recent" | "wall-clock";
133
- requestedFromWallClockMs: number | null;
134
- requestedToWallClockMs: number | null;
135
- availableFromWallClockMs: number | null;
136
- availableToWallClockMs: number | null;
137
- complete: boolean;
138
- truncated: boolean;
139
- unavailableReason?: EvidenceUnavailableReason;
140
- }
141
- type AvSyncEvidenceRetention = Pick<AvSyncLogRetention, "storageWriteFailed" | "droppedSegmentCount" | "droppedLogCount" | "oldestSegmentAtMs" | "newestSegmentAtMs">;
142
- /** The trigger is immutable; evaluation is the contemporaneous window result. */
143
- interface AvSyncTriage {
144
- trigger: Pick<JsonSafeAlert, "finding" | "status" | "confidence" | "capturedAtMs">;
145
- evaluation: {
146
- finding: AvSyncAnalysisReport["finding"];
147
- status: AvSyncAnalysisReport["status"];
148
- confidence: AvSyncAnalysisReport["confidence"];
149
- } | null;
150
- layers: Record<keyof AvSyncAnalysisReport["layers"], Pick<AvSyncAnalysisReport["layers"]["binding"], "status" | "finding" | "confidence">> | null;
151
- participants: Array<{
152
- participantId: string;
153
- status: AvSyncAnalysisReport["status"];
154
- finding: AvSyncAnalysisReport["finding"];
155
- confidence: AvSyncAnalysisReport["confidence"];
156
- audioTrackId: string | null;
157
- videoTrackId: string | null;
158
- metrics: AvSyncAnalysisReport["participants"][number]["metrics"];
159
- }>;
160
- limitations: readonly string[];
161
- }
162
- /** A compact causal fact. `q`, `t`, and `o` preserve source ordering and time domains. */
163
- interface AvSyncCompactLog {
164
- q: number;
165
- t: number;
166
- o: number;
167
- y: string;
168
- e: string;
169
- c?: Record<string, unknown>;
170
- d?: Record<string, unknown>;
171
- }
172
- interface AvSyncEvidenceDetail {
173
- projectionVersion: 2;
174
- sourceRecordCount: number;
175
- reportedRecordCount: number;
176
- timeSyncInputCount: number;
177
- timeSyncReportedCount: number;
178
- framePresentationReportedCount: number;
179
- verifiedMetadataTimestampCount: number;
180
- omittedSetupLifecycleCount: number;
181
- oversizeFallbackRecordCount: number;
182
- contentByteLimit: number;
183
- /** Present only while the plugin prepares the outgoing log records. */
184
- chunks?: readonly AvSyncLogChunkManifest[];
185
- }
186
- interface AvSyncLogChunkManifest {
187
- index: number;
188
- byteLength: number;
189
- recordCount: number;
190
- firstSequence: number | null;
191
- lastSequence: number | null;
192
- }
193
- /** A/V alert content handed to `ClientMonitor.reportFrameErrors`. */
194
- interface AvSyncAlertEvidencePayload {
195
- schemaVersion: 1;
196
- kind: "liveavatar.avsync.alert-evidence";
197
- sdkVersion: string;
198
- recordType: "summary";
199
- /** Correlates this summary with its separately reported log records. */
200
- evidenceId: string;
201
- /** True when optional summary detail was omitted to keep this record safe. */
202
- summaryTruncated?: boolean;
203
- alert: JsonSafeAlert;
204
- /** Structured A/V evidence; SkyWalking serializes the enclosing error log. */
205
- evidence: AvSyncEvidence;
206
- }
207
- /** One platform-safe detailed-log record belonging to an A/V alert snapshot. */
208
- interface AvSyncEvidenceLogChunkPayload {
209
- schemaVersion: 1;
210
- kind: "liveavatar.avsync.alert-evidence";
211
- sdkVersion: string;
212
- recordType: "log-chunk";
213
- evidenceId: string;
214
- alertId: string;
215
- sessionId: string | null;
216
- chunk: AvSyncLogChunkManifest & {
217
- total: number;
218
- logs: readonly AvSyncCompactLog[];
219
- };
220
- }
221
- /** Minimal lifecycle record sent when a previously raised alert recovers. */
222
- interface AvSyncRecoveryPayload {
223
- alertId: string;
224
- recoveredAtWallClockMs: number;
225
- }
226
- /** JSON-safe strings handed to `ClientMonitor.reportFrameErrors` for SDK errors. */
227
- interface SkyWalkingSdkErrorPayload {
228
- schemaVersion: 2;
229
- kind: "liveavatar.sdk.error";
230
- sdkVersion: string;
231
- error: string;
232
- }
233
194
  interface SkyWalkingFrameError {
234
195
  name: string;
235
196
  message: string;
@@ -267,10 +228,9 @@ interface SkyWalkingFirstFrameLogNodes {
267
228
  firstFrameMs?: number;
268
229
  }
269
230
  /** Structured content of one terminal SDK `performance.first-frame` log. */
270
- interface SkyWalkingFirstFrameLogPayload {
271
- schemaVersion: 1;
231
+ interface SkyWalkingFirstFrameLogPayload extends SkyWalkingOperationalLogSource {
232
+ schemaVersion: 4;
272
233
  kind: "liveavatar.performance.first-frame";
273
- sdkVersion: string;
274
234
  occurredAtMs: number;
275
235
  attemptId: number;
276
236
  outcome: SkyWalkingFirstFrameOutcome;
@@ -278,41 +238,55 @@ interface SkyWalkingFirstFrameLogPayload {
278
238
  timeoutAfterRtcMs?: number;
279
239
  nodes: SkyWalkingFirstFrameLogNodes;
280
240
  }
281
- /**
282
- * Reports LiveAvatar A/V-sync incident lifecycle events through the bundled or
283
- * externally provided SkyWalking client.
284
- */
241
+ interface SkyWalkingSdkErrorPayload extends SkyWalkingOperationalLogSource {
242
+ schemaVersion: 4;
243
+ kind: "liveavatar.sdk.error";
244
+ /** JSON-encoded, allowlisted v2 source failure. */
245
+ error: string;
246
+ }
247
+ /** Plugin-owned sample; nested SDK containers are lossless JSON text. */
248
+ interface SkyWalkingPlaybackStatusPayload extends SkyWalkingCorrelation {
249
+ schemaVersion: 4;
250
+ kind: "liveavatar.playback.status";
251
+ clientInstanceId: string;
252
+ occurredAtMs: number;
253
+ playback: {
254
+ sampledAtMs: number;
255
+ connection: string;
256
+ ice: string;
257
+ output: string | null;
258
+ tracks: string;
259
+ quality: PlaybackStatus["quality"];
260
+ qualityReasons: string;
261
+ presentationSamplingEnabled: boolean;
262
+ };
263
+ }
264
+ /** Consumes SDK facts and samples playback through the public Plugin API v1. */
285
265
  declare class SkyWalkingPlugin implements SDKPlugin {
286
266
  readonly id = "liveavatar.skywalking";
287
- /** SDK Plugin API v1 is the registrar-based public plugin contract. */
288
267
  readonly apiVersion = 1;
268
+ readonly terminalObserverDelivery = "sync-before-dispose";
289
269
  private readonly _skyWalkingConfig;
290
270
  private readonly _reporting;
291
- private _installation;
292
- private _nextInstallationGeneration;
271
+ private readonly _playbackStatusIntervalMs;
272
+ private _installation?;
293
273
  constructor(config?: SkyWalkingPluginConfig);
294
274
  setup(registrar: SDKPluginRegistrar): void;
295
275
  dispose(): void;
296
- private _handleAlertNotification;
297
- private _handleOperationalLog;
298
- private _enqueue;
299
- private _reportActiveAlert;
300
- private _reportRecovery;
301
- private _reportSdkError;
302
- private _reportFirstFrameLog;
303
276
  private _deactivateInstallation;
304
- private _isInvocationActive;
305
- private _runObserverTask;
306
- private _warnInvocationFailure;
307
- private _warnInvocation;
277
+ private _stopPlayback;
278
+ private _handlePlaybackLifecycle;
279
+ private _startPlayback;
280
+ private _samplePlayback;
281
+ private _isActive;
282
+ private _warn;
283
+ private _report;
284
+ private _handleOperationalLog;
285
+ private _queueAlert;
286
+ private _drainAlerts;
287
+ private _reportAlert;
308
288
  }
309
- /** Creates a fresh plugin instance suitable for `createClient({ plugins })`. */
310
289
  declare function createSkyWalkingPlugin(config?: SkyWalkingPluginConfig): SkyWalkingPlugin;
311
- /**
312
- * Loads the bundled browser client when needed and registers it exactly once.
313
- * An application-provided `window.ClientMonitor` is treated as already
314
- * registered and is never overwritten or registered again.
315
- */
316
290
  declare function registerSkyWalking(config?: SkyWalkingPluginConfig): void;
317
291
  /** Triggers a SkyWalking performance report through an already registered client. */
318
292
  declare function setSkyWalkingPerformance(config?: Partial<SkyWalkingPluginConfig>, customMetrics?: Record<string, unknown>): void;
@@ -322,4 +296,4 @@ declare function setSkyWalkingHRT(config?: Partial<SkyWalkingPluginConfig>, cust
322
296
  declare function reportSkyWalkingFrameErrors(config: SkyWalkingFrameErrorReportConfig, error: SkyWalkingFrameError): Promise<void>;
323
297
 
324
298
  export { SKYWALKING_PLUGIN_ID, SkyWalkingPlugin, createSkyWalkingPlugin, registerSkyWalking, reportSkyWalkingFrameErrors, setSkyWalkingHRT, setSkyWalkingPerformance };
325
- export type { AvSyncAlertEvidencePayload, AvSyncEvidence, AvSyncEvidenceLogChunkPayload, AvSyncRecoveryPayload, JsonSafeAlert, SkyWalkingFirstFrameLogNodes, SkyWalkingFirstFrameLogPayload, SkyWalkingFirstFrameOutcome, SkyWalkingFrameError, SkyWalkingFrameErrorReportConfig, SkyWalkingHooks, SkyWalkingPluginConfig, SkyWalkingRegistrationOptions, SkyWalkingReportingConfig, SkyWalkingSdkErrorPayload, SkyWalkingSlowInteractionConfig };
299
+ export type { AvSyncAlertEvidencePayload, AvSyncEvidence, AvSyncEvidenceLogChunkPayload, AvSyncRecoveryPayload, JsonSafeAlert, SkyWalkingCorrelation, SkyWalkingFirstFrameLogNodes, SkyWalkingFirstFrameLogPayload, SkyWalkingFirstFrameOutcome, SkyWalkingFrameError, SkyWalkingFrameErrorReportConfig, SkyWalkingHooks, SkyWalkingOperationalLogSource, SkyWalkingPlaybackStatusPayload, SkyWalkingPluginConfig, SkyWalkingRegistrationOptions, SkyWalkingReportingConfig, SkyWalkingSdkErrorPayload, SkyWalkingSessionTimelinePayload, SkyWalkingSlowInteractionConfig };