@stream-io/video-client 1.53.1 → 1.54.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 +17 -0
- package/dist/index.browser.es.js +41 -9
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +41 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +41 -9
- package/dist/index.es.js.map +1 -1
- package/dist/src/coordinator/connection/types.d.ts +6 -0
- package/dist/src/reporting/ClientEventReporter.d.ts +2 -0
- package/package.json +1 -1
- package/src/Call.ts +40 -5
- package/src/StreamVideoClient.ts +1 -0
- package/src/coordinator/connection/types.ts +7 -0
- package/src/reporting/ClientEventReporter.ts +6 -2
- package/src/reporting/__tests__/ClientEventReporter.test.ts +33 -0
- package/src/rtc/__tests__/Call.reconnect.test.ts +149 -2
package/dist/index.cjs.js
CHANGED
|
@@ -6660,7 +6660,7 @@ const getSdkVersion = (sdk) => {
|
|
|
6660
6660
|
return sdk ? `${sdk.major}.${sdk.minor}.${sdk.patch}` : '0.0.0-development';
|
|
6661
6661
|
};
|
|
6662
6662
|
|
|
6663
|
-
const version = "1.
|
|
6663
|
+
const version = "1.54.0";
|
|
6664
6664
|
const [major, minor, patch] = version.split('.');
|
|
6665
6665
|
let sdkInfo = {
|
|
6666
6666
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -14574,7 +14574,7 @@ class Call {
|
|
|
14574
14574
|
]);
|
|
14575
14575
|
const isReconnecting = this.reconnectStrategy !== WebsocketReconnectStrategy.UNSPECIFIED;
|
|
14576
14576
|
const reconnectDetails = isReconnecting
|
|
14577
|
-
? this.getReconnectDetails(
|
|
14577
|
+
? this.getReconnectDetails(previousSfuClient?.edgeName, previousSessionId)
|
|
14578
14578
|
: undefined;
|
|
14579
14579
|
const preferredPublishOptions = !isReconnecting
|
|
14580
14580
|
? this.getPreferredPublishOptions()
|
|
@@ -14943,6 +14943,7 @@ class Call {
|
|
|
14943
14943
|
const reconnectStartTime = Date.now();
|
|
14944
14944
|
this.reconnectStrategy = strategy;
|
|
14945
14945
|
this.reconnectReason = reason;
|
|
14946
|
+
const sfuRejoinFailures = new Map();
|
|
14946
14947
|
const markAsReconnectingFailed = async () => {
|
|
14947
14948
|
try {
|
|
14948
14949
|
// attempt to fetch the call data from the server, as the call
|
|
@@ -15001,7 +15002,8 @@ class Call {
|
|
|
15001
15002
|
if (this.reconnectStrategy !== WebsocketReconnectStrategy.FAST) {
|
|
15002
15003
|
this.reconnectAttempts++;
|
|
15003
15004
|
}
|
|
15004
|
-
const
|
|
15005
|
+
const attemptedStrategy = this.reconnectStrategy;
|
|
15006
|
+
const currentStrategy = WebsocketReconnectStrategy[attemptedStrategy];
|
|
15005
15007
|
try {
|
|
15006
15008
|
// wait until the network is available
|
|
15007
15009
|
await this.networkAvailableTask?.promise;
|
|
@@ -15014,9 +15016,24 @@ class Call {
|
|
|
15014
15016
|
case WebsocketReconnectStrategy.FAST:
|
|
15015
15017
|
await this.reconnectFast();
|
|
15016
15018
|
break;
|
|
15017
|
-
case WebsocketReconnectStrategy.REJOIN:
|
|
15018
|
-
|
|
15019
|
+
case WebsocketReconnectStrategy.REJOIN: {
|
|
15020
|
+
const confirmedBadSfus = Array.from(sfuRejoinFailures)
|
|
15021
|
+
.filter(([, failures]) => failures >= 2)
|
|
15022
|
+
.map(([sfu]) => sfu);
|
|
15023
|
+
if (this.joinCallData && confirmedBadSfus.length) {
|
|
15024
|
+
this.joinCallData.migrating_from =
|
|
15025
|
+
confirmedBadSfus[confirmedBadSfus.length - 1];
|
|
15026
|
+
this.joinCallData.migrating_from_list = confirmedBadSfus;
|
|
15027
|
+
}
|
|
15028
|
+
try {
|
|
15029
|
+
await this.reconnectRejoin();
|
|
15030
|
+
}
|
|
15031
|
+
finally {
|
|
15032
|
+
delete this.joinCallData?.migrating_from;
|
|
15033
|
+
delete this.joinCallData?.migrating_from_list;
|
|
15034
|
+
}
|
|
15019
15035
|
break;
|
|
15036
|
+
}
|
|
15020
15037
|
case WebsocketReconnectStrategy.MIGRATE:
|
|
15021
15038
|
await this.reconnectMigrate();
|
|
15022
15039
|
break;
|
|
@@ -15029,6 +15046,15 @@ class Call {
|
|
|
15029
15046
|
break; // do-while loop, reconnection worked, exit the loop
|
|
15030
15047
|
}
|
|
15031
15048
|
catch (error) {
|
|
15049
|
+
if (attemptedStrategy === WebsocketReconnectStrategy.REJOIN) {
|
|
15050
|
+
const failedSfu = this.credentials?.server.edge_name;
|
|
15051
|
+
if (failedSfu) {
|
|
15052
|
+
const switchSfu = error instanceof SfuJoinError &&
|
|
15053
|
+
SfuJoinError.isJoinErrorCode(error.errorEvent);
|
|
15054
|
+
const failures = (sfuRejoinFailures.get(failedSfu) ?? 0) + 1;
|
|
15055
|
+
sfuRejoinFailures.set(failedSfu, switchSfu ? Math.max(failures, 2) : failures);
|
|
15056
|
+
}
|
|
15057
|
+
}
|
|
15032
15058
|
if (this.state.callingState === exports.CallingState.OFFLINE) {
|
|
15033
15059
|
this.logger.debug(`[Reconnect] Can't reconnect while offline, stopping reconnection attempts`);
|
|
15034
15060
|
break;
|
|
@@ -15224,6 +15250,8 @@ class Call {
|
|
|
15224
15250
|
this.state.setCallingState(exports.CallingState.OFFLINE);
|
|
15225
15251
|
}
|
|
15226
15252
|
else {
|
|
15253
|
+
if (!this.networkAvailableTask)
|
|
15254
|
+
return;
|
|
15227
15255
|
this.logger.debug('[Reconnect] Going online');
|
|
15228
15256
|
this.sfuClient?.close(StreamSfuClient.DISPOSE_OLD_SOCKET, 'Closing WS to reconnect after going online');
|
|
15229
15257
|
// we went online, release the previous waiters and reset the state
|
|
@@ -17482,11 +17510,11 @@ class StreamClient {
|
|
|
17482
17510
|
return await this.wsConnection.connect(this.defaultWSTimeout);
|
|
17483
17511
|
};
|
|
17484
17512
|
this.getSdkVersion = () => this.options.clientAppIdentifier?.sdkVersion ||
|
|
17485
|
-
"1.
|
|
17513
|
+
"1.54.0";
|
|
17486
17514
|
this.getUserAgent = () => {
|
|
17487
17515
|
if (!this.cachedUserAgent) {
|
|
17488
17516
|
const { clientAppIdentifier = {} } = this.options;
|
|
17489
|
-
const { sdkName = 'js', sdkVersion = "1.
|
|
17517
|
+
const { sdkName = 'js', sdkVersion = "1.54.0", ...extras } = clientAppIdentifier;
|
|
17490
17518
|
this.cachedUserAgent = [
|
|
17491
17519
|
`stream-video-${sdkName}-v${sdkVersion}`,
|
|
17492
17520
|
...Object.entries(extras).map(([key, value]) => `${key}=${value}`),
|
|
@@ -17893,7 +17921,7 @@ class ClientEventReporter {
|
|
|
17893
17921
|
const coordinatorConnectId = this.coordinatorConnectId;
|
|
17894
17922
|
const ctx = this.callContexts.get(cid);
|
|
17895
17923
|
this.send({
|
|
17896
|
-
user_id: this.streamClient.userID,
|
|
17924
|
+
user_id: this.streamClient.userID || this.coordinatorConnectUserId,
|
|
17897
17925
|
type: ctx?.callType,
|
|
17898
17926
|
id: ctx?.callId,
|
|
17899
17927
|
call_cid: cid,
|
|
@@ -18146,7 +18174,7 @@ class ClientEventReporter {
|
|
|
18146
18174
|
const ctx = this.callContexts.get(cid);
|
|
18147
18175
|
const coordinatorConnectId = this.coordinatorConnectId;
|
|
18148
18176
|
return {
|
|
18149
|
-
user_id: this.streamClient.userID,
|
|
18177
|
+
user_id: this.streamClient.userID || this.coordinatorConnectUserId,
|
|
18150
18178
|
type: ctx?.callType ?? '',
|
|
18151
18179
|
id: ctx?.callId ?? '',
|
|
18152
18180
|
call_cid: cid,
|
|
@@ -18164,6 +18192,8 @@ class ClientEventReporter {
|
|
|
18164
18192
|
};
|
|
18165
18193
|
};
|
|
18166
18194
|
this.send = (body) => {
|
|
18195
|
+
if (!this.enabled)
|
|
18196
|
+
return;
|
|
18167
18197
|
void this.sendWithRetry(body);
|
|
18168
18198
|
};
|
|
18169
18199
|
this.sendWithRetry = async (body) => {
|
|
@@ -18189,6 +18219,7 @@ class ClientEventReporter {
|
|
|
18189
18219
|
return false;
|
|
18190
18220
|
};
|
|
18191
18221
|
this.streamClient = options.streamClient;
|
|
18222
|
+
this.enabled = options.enabled ?? true;
|
|
18192
18223
|
}
|
|
18193
18224
|
}
|
|
18194
18225
|
const readPermissionStatus = (permission) => {
|
|
@@ -18669,6 +18700,7 @@ class StreamVideoClient {
|
|
|
18669
18700
|
this.streamClient = createCoordinatorClient(apiKey, clientOptions);
|
|
18670
18701
|
this.clientEventReporter = new ClientEventReporter({
|
|
18671
18702
|
streamClient: this.streamClient,
|
|
18703
|
+
enabled: clientOptions?.clientEventsReportingEnabled ?? true,
|
|
18672
18704
|
});
|
|
18673
18705
|
this.writeableStateStore = new StreamVideoWriteableStateStore();
|
|
18674
18706
|
this.readOnlyStateStore = new StreamVideoReadOnlyStateStore(this.writeableStateStore);
|