@stream-io/video-client 0.7.0 → 0.7.2

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.cjs.js CHANGED
@@ -9260,6 +9260,22 @@ const flatten$1 = (report) => {
9260
9260
  });
9261
9261
  return stats;
9262
9262
  };
9263
+ const getSdkSignature = (clientDetails) => {
9264
+ const { sdk, ...platform } = clientDetails;
9265
+ const sdkName = sdk && sdk.type === SdkType.REACT
9266
+ ? 'stream-react'
9267
+ : sdk && sdk.type === SdkType.REACT_NATIVE
9268
+ ? 'stream-react-native'
9269
+ : 'stream-js';
9270
+ const sdkVersion = sdk
9271
+ ? `${sdk.major}.${sdk.minor}.${sdk.patch}`
9272
+ : '0.0.0-development';
9273
+ return {
9274
+ sdkName,
9275
+ sdkVersion,
9276
+ ...platform,
9277
+ };
9278
+ };
9263
9279
 
9264
9280
  /**
9265
9281
  * Creates a new StatsReporter instance that collects metrics about the ongoing call and reports them to the state store
@@ -12611,6 +12627,37 @@ class Call {
12611
12627
  const endpoint = `${this.streamClientBasePath}/stats/${callSessionID}`;
12612
12628
  return this.streamClient.get(endpoint);
12613
12629
  };
12630
+ /**
12631
+ * Submit user feedback for the call
12632
+ *
12633
+ * @param rating Rating between 1 and 5 denoting the experience of the user in the call
12634
+ * @param reason The reason/description for the rating
12635
+ * @param custom Custom data
12636
+ * @returns
12637
+ */
12638
+ this.submitFeedback = async (rating, { reason, custom, } = {}) => {
12639
+ if (rating < 1 || rating > 5) {
12640
+ throw new Error('Rating must be between 1 and 5');
12641
+ }
12642
+ const userSessionId = this.sfuClient?.sessionId;
12643
+ const callSessionId = this.state.session?.id;
12644
+ if (!callSessionId || !userSessionId) {
12645
+ throw new Error('Feedback can be submitted only in the context of a call session');
12646
+ }
12647
+ const { sdkName, sdkVersion, ...platform } = getSdkSignature(getClientDetails());
12648
+ const endpoint = `${this.streamClientBasePath}/feedback/${callSessionId}`;
12649
+ return this.streamClient.post(endpoint, {
12650
+ rating,
12651
+ reason,
12652
+ user_session_id: userSessionId,
12653
+ sdk: sdkName,
12654
+ sdk_version: sdkVersion,
12655
+ custom: {
12656
+ ...custom,
12657
+ 'x-stream-platform-data': platform,
12658
+ },
12659
+ });
12660
+ };
12614
12661
  /**
12615
12662
  * Sends a custom event to all call participants.
12616
12663
  *
@@ -14433,7 +14480,7 @@ class StreamClient {
14433
14480
  });
14434
14481
  };
14435
14482
  this.getUserAgent = () => {
14436
- const version = "0.7.0" ;
14483
+ const version = "0.7.2" ;
14437
14484
  return (this.userAgent ||
14438
14485
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
14439
14486
  };