@sanseng/liveavatar-js-sdk-skywalking 1.0.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.
@@ -0,0 +1,286 @@
1
+ import { AvSyncAlertEvent, AvSyncLogRetention, AvSyncAnalysisReport, SDKPlugin, SDKPluginRegistrar } from '@sanseng/liveavatar-js-sdk';
2
+
3
+ /** Stable identifier used by the LiveAvatar SDK plugin host. */
4
+ declare const SKYWALKING_PLUGIN_ID = "liveavatar.skywalking";
5
+ declare const SKYWALKING_SERVICE = "yy-tx::liveavatar-js-sdk";
6
+ type SkyWalkingUrlMatcher = string | RegExp;
7
+ interface SkyWalkingHooks {
8
+ reportHook?: (type: string, data: Array<Record<string, string>>) => boolean;
9
+ filterHook?: (data: Record<string, string>) => boolean;
10
+ requestParamsHook?: (params: unknown) => unknown;
11
+ }
12
+ interface SkyWalkingSlowInteractionConfig {
13
+ enable?: boolean;
14
+ threshold?: number;
15
+ reportInterval?: number;
16
+ }
17
+ /**
18
+ * Registration options accepted by SkyWalking js-sdk 1.1.27, plus the
19
+ * plugin-level overseas switch. `service` is deliberately fixed by the plugin.
20
+ */
21
+ interface SkyWalkingPluginConfig {
22
+ /** Explicit collector URL. It takes precedence over `isOverseas`. */
23
+ collector?: string;
24
+ /** `false` selects the domestic collector; `true` selects the overseas one. */
25
+ isOverseas?: boolean;
26
+ jsErrors?: boolean;
27
+ apiErrors?: boolean;
28
+ resourceErrors?: boolean;
29
+ autoTracePerf?: boolean;
30
+ useFmp?: boolean;
31
+ detailMode?: boolean;
32
+ perfEntries?: boolean;
33
+ rate?: number;
34
+ enableSPA?: boolean;
35
+ vue?: false | unknown;
36
+ traceSDKInternal?: boolean;
37
+ noTrace?: boolean;
38
+ noTraceUrls?: readonly SkyWalkingUrlMatcher[] | null;
39
+ noErrorPaths?: readonly SkyWalkingUrlMatcher[];
40
+ sendErrorTime?: number;
41
+ sendSegmentsTime?: number;
42
+ sendPerfTime?: number;
43
+ extraMsg?: string | (() => string);
44
+ hooks?: SkyWalkingHooks;
45
+ pagePath?: string;
46
+ serviceVersion?: string;
47
+ pageKey?: string;
48
+ group?: string;
49
+ subGroup?: string;
50
+ whiteScreen?: boolean;
51
+ whiteScreenTimeout?: number;
52
+ maxReqCostTime?: number;
53
+ collectRequestParams?: boolean;
54
+ maxRequestBodySize?: number;
55
+ slowInteraction?: SkyWalkingSlowInteractionConfig;
56
+ }
57
+ /** Fully normalized registration object passed to `ClientMonitor.register`. */
58
+ interface SkyWalkingRegistrationOptions {
59
+ collector: string;
60
+ service: typeof SKYWALKING_SERVICE;
61
+ jsErrors: boolean;
62
+ apiErrors: boolean;
63
+ resourceErrors: boolean;
64
+ autoTracePerf: boolean;
65
+ useFmp: boolean;
66
+ detailMode: boolean;
67
+ perfEntries: boolean;
68
+ rate: number;
69
+ enableSPA: boolean;
70
+ vue: false | unknown;
71
+ traceSDKInternal: boolean;
72
+ noTrace: boolean;
73
+ noTraceUrls: readonly SkyWalkingUrlMatcher[] | null;
74
+ noErrorPaths: readonly SkyWalkingUrlMatcher[];
75
+ sendErrorTime: number;
76
+ sendSegmentsTime: number;
77
+ sendPerfTime: number;
78
+ extraMsg?: string | (() => string);
79
+ hooks: SkyWalkingHooks;
80
+ pagePath: string;
81
+ serviceVersion: string;
82
+ pageKey: string;
83
+ group: string;
84
+ subGroup: string;
85
+ whiteScreen: boolean;
86
+ whiteScreenTimeout: number;
87
+ maxReqCostTime: number;
88
+ collectRequestParams: boolean;
89
+ maxRequestBodySize: number;
90
+ slowInteraction: Required<SkyWalkingSlowInteractionConfig>;
91
+ }
92
+ type EvidenceUnavailableReason = "initial-query-failed" | "session-mismatch" | "continuation-query-failed" | "cursor-did-not-advance";
93
+ /** JSON-safe representation of an A/V Sync alert in an evidence payload. */
94
+ interface JsonSafeAlert extends Omit<AvSyncAlertEvent, "sessionId"> {
95
+ sessionId: string | null;
96
+ }
97
+ /** Evidence attached to one raised A/V-sync alert. */
98
+ interface AvSyncEvidence {
99
+ evidenceSchemaVersion: 2;
100
+ /** Diagnostic session owning every compact evidence record. */
101
+ sessionId: string | null;
102
+ /** Query bounds and whether the SDK could read a complete window. */
103
+ window: AvSyncEvidenceWindow;
104
+ /** Only retention facts which affect whether absence can be interpreted. */
105
+ retention: AvSyncEvidenceRetention | null;
106
+ /** Small, structured platform-first attribution for the exact alert window. */
107
+ triage: AvSyncTriage | null;
108
+ /** Number of separately reported detailed-log records. */
109
+ logChunkCount: number;
110
+ /** Number of compact records across all log chunks. */
111
+ logRecordCount: number;
112
+ /** Detail projection; each detailed-log record carries its own manifest entry. */
113
+ detail: AvSyncEvidenceDetail;
114
+ /** @deprecated Detailed logs are now emitted as separate log records. */
115
+ logs?: readonly AvSyncCompactLog[];
116
+ /** @deprecated Detailed logs are now emitted as separate log records. */
117
+ [logChunk: `logs_${number}`]: readonly AvSyncCompactLog[] | undefined;
118
+ }
119
+ interface AvSyncEvidenceWindow {
120
+ mode: "recent" | "wall-clock";
121
+ requestedFromWallClockMs: number | null;
122
+ requestedToWallClockMs: number | null;
123
+ availableFromWallClockMs: number | null;
124
+ availableToWallClockMs: number | null;
125
+ complete: boolean;
126
+ truncated: boolean;
127
+ unavailableReason?: EvidenceUnavailableReason;
128
+ }
129
+ type AvSyncEvidenceRetention = Pick<AvSyncLogRetention, "storageWriteFailed" | "droppedSegmentCount" | "droppedLogCount" | "oldestSegmentAtMs" | "newestSegmentAtMs">;
130
+ /** The trigger is immutable; evaluation is the contemporaneous window result. */
131
+ interface AvSyncTriage {
132
+ trigger: Pick<JsonSafeAlert, "finding" | "status" | "confidence" | "capturedAtMs">;
133
+ evaluation: {
134
+ finding: AvSyncAnalysisReport["finding"];
135
+ status: AvSyncAnalysisReport["status"];
136
+ confidence: AvSyncAnalysisReport["confidence"];
137
+ } | null;
138
+ layers: Record<keyof AvSyncAnalysisReport["layers"], Pick<AvSyncAnalysisReport["layers"]["binding"], "status" | "finding" | "confidence">> | null;
139
+ participants: Array<{
140
+ participantId: string;
141
+ status: AvSyncAnalysisReport["status"];
142
+ finding: AvSyncAnalysisReport["finding"];
143
+ confidence: AvSyncAnalysisReport["confidence"];
144
+ audioTrackId: string | null;
145
+ videoTrackId: string | null;
146
+ metrics: AvSyncAnalysisReport["participants"][number]["metrics"];
147
+ }>;
148
+ limitations: readonly string[];
149
+ }
150
+ /** A compact causal fact. `q`, `t`, and `o` preserve source ordering and time domains. */
151
+ interface AvSyncCompactLog {
152
+ q: number;
153
+ t: number;
154
+ o: number;
155
+ y: string;
156
+ e: string;
157
+ c?: Record<string, unknown>;
158
+ d?: Record<string, unknown>;
159
+ }
160
+ interface AvSyncEvidenceDetail {
161
+ projectionVersion: 2;
162
+ sourceRecordCount: number;
163
+ reportedRecordCount: number;
164
+ timeSyncInputCount: number;
165
+ timeSyncReportedCount: number;
166
+ framePresentationReportedCount: number;
167
+ verifiedMetadataTimestampCount: number;
168
+ omittedSetupLifecycleCount: number;
169
+ oversizeFallbackRecordCount: number;
170
+ contentByteLimit: number;
171
+ /** Present only while the plugin prepares the outgoing log records. */
172
+ chunks?: readonly AvSyncLogChunkManifest[];
173
+ }
174
+ interface AvSyncLogChunkManifest {
175
+ index: number;
176
+ byteLength: number;
177
+ recordCount: number;
178
+ firstSequence: number | null;
179
+ lastSequence: number | null;
180
+ }
181
+ /** A/V alert content handed to `ClientMonitor.reportFrameErrors`. */
182
+ interface AvSyncAlertEvidencePayload {
183
+ schemaVersion: 1;
184
+ kind: "liveavatar.avsync.alert-evidence";
185
+ sdkVersion: string;
186
+ recordType: "summary";
187
+ /** Correlates this summary with its separately reported log records. */
188
+ evidenceId: string;
189
+ /** True when optional summary detail was omitted to keep this record safe. */
190
+ summaryTruncated?: boolean;
191
+ alert: JsonSafeAlert;
192
+ /** Structured A/V evidence; SkyWalking serializes the enclosing error log. */
193
+ evidence: AvSyncEvidence;
194
+ }
195
+ /** One platform-safe detailed-log record belonging to an A/V alert snapshot. */
196
+ interface AvSyncEvidenceLogChunkPayload {
197
+ schemaVersion: 1;
198
+ kind: "liveavatar.avsync.alert-evidence";
199
+ sdkVersion: string;
200
+ recordType: "log-chunk";
201
+ evidenceId: string;
202
+ alertId: string;
203
+ sessionId: string | null;
204
+ chunk: AvSyncLogChunkManifest & {
205
+ total: number;
206
+ logs: readonly AvSyncCompactLog[];
207
+ };
208
+ }
209
+ /** Minimal lifecycle record sent when a previously raised alert recovers. */
210
+ interface AvSyncRecoveryPayload {
211
+ alertId: string;
212
+ recoveredAtWallClockMs: number;
213
+ }
214
+ /** JSON-safe strings handed to `ClientMonitor.reportFrameErrors` for SDK errors. */
215
+ interface SkyWalkingSdkErrorPayload {
216
+ schemaVersion: 2;
217
+ kind: "liveavatar.sdk.error";
218
+ sdkVersion: string;
219
+ error: string;
220
+ }
221
+ interface SkyWalkingFrameError {
222
+ name: string;
223
+ message: string;
224
+ stack: string;
225
+ }
226
+ /** Configuration accepted by the exported frame-error reporting helper. */
227
+ interface SkyWalkingFrameErrorReportConfig {
228
+ category?: string;
229
+ grade?: string;
230
+ level?: string;
231
+ content?: unknown;
232
+ pagePath?: string;
233
+ pageKey?: string;
234
+ collector?: string;
235
+ serviceVersion?: string;
236
+ group?: string;
237
+ subGroup?: string;
238
+ extraMsg?: string | (() => string);
239
+ noErrorPaths?: readonly SkyWalkingUrlMatcher[];
240
+ hooks?: SkyWalkingHooks;
241
+ maxReqCostTime?: number;
242
+ timeout?: number;
243
+ }
244
+ /**
245
+ * Reports LiveAvatar A/V-sync incident lifecycle events through the bundled or
246
+ * externally provided SkyWalking client.
247
+ */
248
+ declare class SkyWalkingPlugin implements SDKPlugin {
249
+ readonly id = "liveavatar.skywalking";
250
+ /** SDK Plugin API v1 is the registrar-based public plugin contract. */
251
+ readonly apiVersion = 1;
252
+ private readonly _skyWalkingConfig;
253
+ private _installation;
254
+ private _nextInstallationGeneration;
255
+ constructor(config?: SkyWalkingPluginConfig);
256
+ setup(registrar: SDKPluginRegistrar): void;
257
+ dispose(): void;
258
+ private _handleAlertNotification;
259
+ private _handleOperationalLog;
260
+ private _enqueue;
261
+ private _reportActiveAlert;
262
+ private _reportRecovery;
263
+ private _reportSdkError;
264
+ private _deactivateInstallation;
265
+ private _isInvocationActive;
266
+ private _runObserverTask;
267
+ private _warnInvocationFailure;
268
+ private _warnInvocation;
269
+ }
270
+ /** Creates a fresh plugin instance suitable for `createClient({ plugins })`. */
271
+ declare function createSkyWalkingPlugin(config?: SkyWalkingPluginConfig): SkyWalkingPlugin;
272
+ /**
273
+ * Loads the bundled browser client when needed and registers it exactly once.
274
+ * An application-provided `window.ClientMonitor` is treated as already
275
+ * registered and is never overwritten or registered again.
276
+ */
277
+ declare function registerSkyWalking(config?: SkyWalkingPluginConfig): void;
278
+ /** Triggers a SkyWalking performance report through an already registered client. */
279
+ declare function setSkyWalkingPerformance(config?: Partial<SkyWalkingPluginConfig>, customMetrics?: Record<string, unknown>): void;
280
+ /** Triggers a SkyWalking HRT report through an already registered client. */
281
+ declare function setSkyWalkingHRT(config?: Partial<SkyWalkingPluginConfig>, customMetrics?: Record<string, unknown>): void;
282
+ /** Reports a frame error through an already registered SkyWalking client. */
283
+ declare function reportSkyWalkingFrameErrors(config: SkyWalkingFrameErrorReportConfig, error: SkyWalkingFrameError): Promise<void>;
284
+
285
+ export { SKYWALKING_PLUGIN_ID, SkyWalkingPlugin, createSkyWalkingPlugin, registerSkyWalking, reportSkyWalkingFrameErrors, setSkyWalkingHRT, setSkyWalkingPerformance };
286
+ export type { AvSyncAlertEvidencePayload, AvSyncEvidence, AvSyncEvidenceLogChunkPayload, AvSyncRecoveryPayload, JsonSafeAlert, SkyWalkingFrameError, SkyWalkingFrameErrorReportConfig, SkyWalkingHooks, SkyWalkingPluginConfig, SkyWalkingRegistrationOptions, SkyWalkingSdkErrorPayload, SkyWalkingSlowInteractionConfig };