iidrak-analytics-react 1.2.5 → 1.2.6

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 CHANGED
@@ -58,6 +58,9 @@ const iidrakConfig = {
58
58
 
59
59
  // SDK Configuration
60
60
  config: {
61
+ // Application Name for Session Grouping (Recommended)
62
+ appName: "your-app-name",
63
+
61
64
  // Session Replay Endpoint (Required to enable recording)
62
65
  recordingEndpoint: "https://your-replay-server.com",
63
66
 
@@ -114,6 +114,7 @@ class MetaStreamIO {
114
114
  logger: this.logger,
115
115
  network: this.network,
116
116
  config: this.config,
117
+ user: this.userConfig,
117
118
  });
118
119
 
119
120
  // Init global variables
@@ -7,7 +7,7 @@ import { Platform, Dimensions } from "react-native";
7
7
  strf();
8
8
 
9
9
  class MetaStreamIORecorder {
10
- constructor({ constants, logger, network, config } = {}) {
10
+ constructor({ constants, logger, network, config, user } = {}) {
11
11
  this.constant = constants;
12
12
  this.logger = logger;
13
13
  this.network = network;
@@ -24,7 +24,10 @@ class MetaStreamIORecorder {
24
24
  // Use lower quality by default to save bandwidth
25
25
  this.quality = config.quality || 0.5;
26
26
  this.fps = config.fps || 2; // Frames per second (0.5s interval)
27
- this.app_id = config.app_id || "default"; // Default to 'default' app if not specified
27
+ // If user_id is provided in user config, use it as app_id (per user requirement)
28
+ // Otherwise fallback to app_id in general config or "default"
29
+ // Priority: config.appName > user.user_id > config.app_id > "default"
30
+ this.app_id = config.appName ? config.appName : ((user && user.user_id) ? user.user_id : (config.app_id || "default"));
28
31
  this.lastBase64 = null;
29
32
  }
30
33
 
@@ -103,11 +106,11 @@ class MetaStreamIORecorder {
103
106
  });
104
107
 
105
108
  let isDuplicate = false;
106
- if(this.lastBase64){
109
+ if (this.lastBase64) {
107
110
  if (this.lastBase64 === base64) {
108
111
  isDuplicate = true;
109
112
  console.log("DBG:: Duplicate frame");
110
- }else{
113
+ } else {
111
114
  console.log("DBG:: New frame");
112
115
  this.lastBase64 = base64;
113
116
  }
@@ -119,9 +122,9 @@ class MetaStreamIORecorder {
119
122
  // If DUPLICATE frame:
120
123
  // Only upload if it's been > 5 seconds since last upload (Keepalive)
121
124
  // This reduces chatter significantly.
122
-
125
+
123
126
  const timeSinceLastUpload = (now - this.lastUploadTime) / 1000;
124
-
127
+
125
128
  if (!isDuplicate || timeSinceLastUpload > 5.0) {
126
129
  console.log("DBG:: Uploading frame");
127
130
  this.uploadFrame(base64, isDuplicate);
@@ -143,7 +146,7 @@ class MetaStreamIORecorder {
143
146
 
144
147
  formData.append('timestamp', String(timestamp));
145
148
  formData.append('duration', String(duration));
146
-
149
+
147
150
  if (isDuplicate) {
148
151
  formData.append('is_duplicate', 'true');
149
152
  } else {
@@ -8,6 +8,7 @@ export class ConfigConstructorModel {
8
8
  sessionLength = null,
9
9
  silentMode = null,
10
10
  allowTrackCategories = [],
11
+ appName = null,
11
12
  } = {}) {
12
13
  this.logging = logging;
13
14
  this.loggingLevel = loggingLevel;
@@ -17,6 +18,7 @@ export class ConfigConstructorModel {
17
18
  this.sessionLength = sessionLength;
18
19
  this.silentMode = silentMode;
19
20
  this.allowTrackCategories = allowTrackCategories;
21
+ this.appName = appName;
20
22
  }
21
23
  json() {
22
24
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iidrak-analytics-react",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "react native client for metastreamio",
5
5
  "peerDependencies": {
6
6
  "@react-native-async-storage/async-storage": ">=2.2.0",