iidrak-analytics-react 1.2.6 → 1.2.8

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
@@ -68,7 +68,7 @@ const iidrakConfig = {
68
68
  loggingLevel: 'INFO', // 'INFO', 'WARN', 'ERROR'
69
69
  silentMode: false, // If true, disables all logging
70
70
  sessionLength: 1800, // Session timeout in seconds (e.g. 30 mins)
71
- quality: 0.5, // Recording quality (0.1 - 1.0)
71
+ quality: 0.1, // Recording quality (0.1 - 1.0)
72
72
  fps: 2, // Frames Per Second for recording
73
73
  },
74
74
 
@@ -164,6 +164,11 @@ If you see this error, it means the native module `react-native-device-info` is
164
164
  1. Ensure you installed the peer dependency: `npm install react-native-device-info`
165
165
  2. Rebuild your native app: `cd android && ./gradlew clean && cd .. && npx react-native run-android`
166
166
 
167
+ ### "Network request failed" on Android
168
+ If your backend is running on HTTP (not HTTPS), Android will block the connection by default.
169
+ 1. Create a `network_security_config.xml` in `android/app/src/main/res/xml/` allowing cleartext traffic for your domain/IP.
170
+ 2. Or for development, add `android:usesCleartextTraffic="true"` to your `AndroidManifest.xml` `<application>` tag.
171
+
167
172
  ### "Cannot read property 'MetaStreamProvider' of undefined"
168
173
  Ensure you are importing correctly.
169
174
  Correct: `import { MetaStreamProvider } from 'iidrak-analytics-react';`
@@ -27,7 +27,7 @@ class MetaStreamProvider extends Component {
27
27
  const { children, style } = this.props;
28
28
 
29
29
  return (
30
- <ViewShot ref={this.viewShotRef} style={{ flex: 1 }} options={{ format: "jpg", quality: 0.5 }}>
30
+ <ViewShot ref={this.viewShotRef} style={{ flex: 1 }} options={{ format: "jpg", quality: 0.3 }}>
31
31
  <View
32
32
  style={[styles.container, style]}
33
33
  onTouchStart={(e) => this.handleTouch(e, 'touch_start')}
@@ -22,7 +22,7 @@ class MetaStreamIORecorder {
22
22
  this.endpoint = config.recordingEndpoint || (this.network.endpoints.length > 0 ? this.network.endpoints[0].replace(/:[0-9]+/, "") + ":8000" : null);
23
23
 
24
24
  // Use lower quality by default to save bandwidth
25
- this.quality = config.quality || 0.5;
25
+ this.quality = config.quality || 0.3;
26
26
  this.fps = config.fps || 2; // Frames per second (0.5s interval)
27
27
  // If user_id is provided in user config, use it as app_id (per user requirement)
28
28
  // Otherwise fallback to app_id in general config or "default"
@@ -46,10 +46,13 @@ class MetaStreamIORecorder {
46
46
 
47
47
  // 1. Initialize Session on Python Server
48
48
  // Note: We use a separate fetch here because the payload format is different from standard analytics
49
- await fetch(`${this.endpoint}/apps/${this.app_id}/sessions`, {
49
+ const url = `${this.endpoint}/api/apps/${this.app_id}/sessions`;
50
+ this.logger.log("recorder", `Sending session creation request to: ${url}`);
51
+ await fetch(url, {
50
52
  method: 'POST',
51
53
  headers: { 'Content-Type': 'application/json' },
52
54
  body: JSON.stringify({
55
+ session_id: this.sessionId,
53
56
  device_info: {
54
57
  width: Dimensions.get('window').width,
55
58
  height: Dimensions.get('window').height,
@@ -58,19 +61,19 @@ class MetaStreamIORecorder {
58
61
  }
59
62
  })
60
63
  }).then(async res => {
64
+ this.logger.log("recorder", "Session creation response status: " + res.status);
61
65
  if (res.ok) {
62
66
  const data = await res.json();
63
67
  // Server might return its own ID, but we want to map them.
64
- // For simplicity, we assume server respects ours or we track the mapping.
65
- // In this demo, the server generates a timestamp ID. That's fine.
66
68
  this.recorderSessionId = data.session_id;
67
69
  this.isRecording = true;
68
70
  this.startLoop(viewRef);
71
+ this.logger.log("recorder", "Session created successfully with ID: " + this.recorderSessionId);
69
72
  } else {
70
- this.logger.error("recorder", "Failed to start session on recording server");
73
+ this.logger.error("recorder", "Failed to start session on recording server: " + res.status);
71
74
  }
72
- }).catch(err => {
73
- this.logger.error("recorder", "Connection error to recording server: " + err);
75
+ }).catch(e => {
76
+ this.logger.error("recorder", "Connection error to recording server: " + e + " to " + url);
74
77
  });
75
78
 
76
79
  } catch (err) {
@@ -99,9 +102,9 @@ class MetaStreamIORecorder {
99
102
  // Resize to width 400px (height maintained automatically) to reduce size
100
103
  // Use PNG to ensure deterministic output for diffing
101
104
  const base64 = await captureRef(viewRef, {
102
- format: "png",
105
+ format: "jpg",
103
106
  quality: this.quality,
104
- width: 400,
107
+ width: 350,
105
108
  result: "base64"
106
109
  });
107
110
 
@@ -151,14 +154,14 @@ class MetaStreamIORecorder {
151
154
  formData.append('is_duplicate', 'true');
152
155
  } else {
153
156
  formData.append('file', {
154
- uri: 'data:image/png;base64,' + data,
155
- type: 'image/png',
156
- name: 'screenshot.png',
157
+ uri: 'data:image/jpeg;base64,' + data,
158
+ type: 'image/jpeg',
159
+ name: 'screenshot.jpg',
157
160
  });
158
161
  }
159
162
 
160
163
  try {
161
- await fetch(`${this.endpoint}/apps/${this.app_id}/sessions/${this.recorderSessionId}/screenshot`, {
164
+ await fetch(`${this.endpoint}/api/apps/${this.app_id}/sessions/${this.recorderSessionId}/screenshot`, {
162
165
  method: 'POST',
163
166
  body: formData,
164
167
  headers: {
@@ -185,7 +188,7 @@ class MetaStreamIORecorder {
185
188
  };
186
189
 
187
190
  try {
188
- fetch(`${this.endpoint}/apps/${this.app_id}/sessions/${this.recorderSessionId}/events`, {
191
+ fetch(`${this.endpoint}/api/apps/${this.app_id}/sessions/${this.recorderSessionId}/events`, {
189
192
  method: 'POST',
190
193
  headers: { 'Content-Type': 'application/json' },
191
194
  body: JSON.stringify([event])
@@ -9,6 +9,9 @@ export class ConfigConstructorModel {
9
9
  silentMode = null,
10
10
  allowTrackCategories = [],
11
11
  appName = null,
12
+ quality = null,
13
+ fps = null,
14
+ recordingEndpoint = null,
12
15
  } = {}) {
13
16
  this.logging = logging;
14
17
  this.loggingLevel = loggingLevel;
@@ -18,7 +21,11 @@ export class ConfigConstructorModel {
18
21
  this.sessionLength = sessionLength;
19
22
  this.silentMode = silentMode;
20
23
  this.allowTrackCategories = allowTrackCategories;
24
+ // correctly assign appName
21
25
  this.appName = appName;
26
+ this.quality = quality;
27
+ this.fps = fps;
28
+ this.recordingEndpoint = recordingEndpoint;
22
29
  }
23
30
  json() {
24
31
  return {
@@ -30,6 +37,10 @@ export class ConfigConstructorModel {
30
37
  sessionLength: this.sessionLength,
31
38
  silentMode: this.silentMode,
32
39
  allowTrackCategories: this.allowTrackCategories,
40
+ appName: this.appName,
41
+ quality: this.quality,
42
+ fps: this.fps,
43
+ recordingEndpoint: this.recordingEndpoint,
33
44
  };
34
45
  }
35
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iidrak-analytics-react",
3
- "version": "1.2.6",
3
+ "version": "1.2.8",
4
4
  "description": "react native client for metastreamio",
5
5
  "peerDependencies": {
6
6
  "@react-native-async-storage/async-storage": ">=2.2.0",