@observertc/observer-js 1.3.0-rc.3 → 1.3.0-rc.4
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 +28 -16
- package/dist/index.d.mts +25 -18
- package/dist/index.d.ts +25 -18
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -178,11 +178,11 @@ var SinkRegistry = class {
|
|
|
178
178
|
}
|
|
179
179
|
/** End every sink of this registry and of its descendants. */
|
|
180
180
|
clear() {
|
|
181
|
-
for (const sink of [...this._sinks.
|
|
181
|
+
for (const [id, sink] of [...this._sinks.entries()]) {
|
|
182
182
|
try {
|
|
183
183
|
sink.end();
|
|
184
184
|
} catch (err) {
|
|
185
|
-
logger.warn("Sink %s failed to end: %o",
|
|
185
|
+
logger.warn("Sink %s failed to end: %o", id, err);
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
188
|
}
|
|
@@ -3124,7 +3124,7 @@ var ObservedClient = class extends EventEmitter3 {
|
|
|
3124
3124
|
/** The distinct `publicAddress`es currently known by this client's open peer connections. */
|
|
3125
3125
|
/**
|
|
3126
3126
|
* The sink this client's samples are written to: whatever is registered under its client id in
|
|
3127
|
-
* `call.sinks` (the one `
|
|
3127
|
+
* `call.sinks` (the one created through `saveClientSamples`, or a sink the application added), if any.
|
|
3128
3128
|
*/
|
|
3129
3129
|
get sink() {
|
|
3130
3130
|
return this.call.sinks.get(this.clientId);
|
|
@@ -5277,17 +5277,26 @@ var ObservedCall = class extends EventEmitter4 {
|
|
|
5277
5277
|
if (!client.leftAt) return;
|
|
5278
5278
|
this.endedAt = Math.max(this.endedAt ?? client.leftAt, client.leftAt);
|
|
5279
5279
|
}
|
|
5280
|
-
/** Emit an Observer-bus event scoped to this call. */
|
|
5281
5280
|
_createClientSink(clientId) {
|
|
5282
|
-
const
|
|
5283
|
-
if (!
|
|
5281
|
+
const config = this.observer.config.saveClientSamples;
|
|
5282
|
+
if (!config || !config.jsonlPath && !config.sink) return void 0;
|
|
5283
|
+
if (config.jsonlPath && config.sink) {
|
|
5284
|
+
logger6.warn("saveClientSamples: give either jsonlPath or sink, not both; no client samples are saved");
|
|
5285
|
+
return void 0;
|
|
5286
|
+
}
|
|
5284
5287
|
if (this.observer.sinks.get(clientId)) {
|
|
5285
5288
|
logger6.warn("No sample sink for client %s in call %s: sink id %s is already in use", clientId, this.callId, clientId);
|
|
5286
5289
|
return void 0;
|
|
5287
5290
|
}
|
|
5288
|
-
const
|
|
5289
|
-
|
|
5291
|
+
const params = { id: clientId, observedCall: this, clientId };
|
|
5292
|
+
if (config.jsonlPath) {
|
|
5293
|
+
const jsonlPath = config.jsonlPath(params);
|
|
5294
|
+
return jsonlPath === void 0 ? void 0 : this.sinks.createFromDestination(clientId, { jsonlPath });
|
|
5295
|
+
}
|
|
5296
|
+
const sink = config.sink?.(params);
|
|
5297
|
+
return sink ? this.sinks.createFromDestination(clientId, { sink }) : void 0;
|
|
5290
5298
|
}
|
|
5299
|
+
/** Emit an Observer-bus event scoped to this call. */
|
|
5291
5300
|
_notify(type, ...args) {
|
|
5292
5301
|
this.observer.emit(type, ...args);
|
|
5293
5302
|
}
|