iidrak-analytics-react 1.6.0 → 1.7.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/README.md +45 -6
- package/metastreamio/metastreamio.provider.js +27 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
# Iidrak Analytics (React Native)
|
|
2
2
|
|
|
3
|
+
**NPM Package**: [iidrak-analytics-react](https://www.npmjs.com/package/iidrak-analytics-react)
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
A powerful, offline-first analytics SDK for React Native applications that includes **Session Replay**. Track events, manage shopping carts, record user sessions (screens & touches), and persist data reliably even when the network is down.
|
|
4
7
|
|
|
5
8
|
## Features
|
|
6
9
|
|
|
7
10
|
- 📊 **Event Tracking**: Log custom events with arbitrary parameters.
|
|
8
|
-
-
|
|
11
|
+
- ⚡ **Automatic Interaction Tracking**: All screen taps/clicks are automatically captured with zero manual instrumentation.
|
|
12
|
+
- 🚀 **Optimized Bandwidth**: Uses a Minimal Payload architecture for auto-clicks to save battery, data, and database costs, only sending full telemetry on session starts and custom events.
|
|
9
13
|
- 🎥 **Session Replay**: Record screen interactions and touch events for playback analysis.
|
|
10
|
-
- 🎯 **Advanced Touch Context**: Automatically maps React Fiber tree to extract clicked text, component paths (e.g. `TouchableOpacity > Text`), and testing IDs
|
|
14
|
+
- 🎯 **Advanced Touch Context**: Automatically maps React Fiber tree to extract clicked text, component paths (e.g. `TouchableOpacity > Text`), and testing IDs.
|
|
11
15
|
- 🛒 **Cart Management**: Built-in shopping cart state management.
|
|
12
16
|
- 📴 **Offline Support**: Automatically queues events when offline and flushes them when connection is restored.
|
|
13
17
|
- 🆔 **User & Session Management**: Auto-generates session IDs and supports user identification.
|
|
14
|
-
- ⚡ **
|
|
18
|
+
- ⚡ **Zero Performance Impact**: Minimal overhead due to payload optimization and background processing.
|
|
15
19
|
|
|
16
20
|
## Installation
|
|
17
21
|
|
|
@@ -154,7 +158,20 @@ tracker.trackEvent({
|
|
|
154
158
|
```
|
|
155
159
|
*Note: `eventParameters` creates a flexible dictionary of data associated with the event.*
|
|
156
160
|
|
|
157
|
-
### 3.
|
|
161
|
+
### 3. Automatic Event Tracking (Zero Config)
|
|
162
|
+
|
|
163
|
+
The SDK automatically tracks all user interactions (clicks/taps) without any manual coding. When a user interacts with the app, the SDK captures:
|
|
164
|
+
|
|
165
|
+
- **Component Path**: The hierarchy of the clicked element (e.g., `TouchableOpacity > View > Text`).
|
|
166
|
+
- **Text Content**: Any text visible within the clicked element.
|
|
167
|
+
- **Test ID**: The `testID` prop, if defined (ideal for automated testing analysis).
|
|
168
|
+
- **Coordinates**: The exact `x, y` position of the tap.
|
|
169
|
+
- **Metadata**: Component type, accessibility labels, and timestamps.
|
|
170
|
+
|
|
171
|
+
**Performance Optimization (Minimal Payload):**
|
|
172
|
+
To ensure high performance and low data usage, `auto_click` events use a "Minimal Payload" architecture. They omit redundant device and application metadata, which is instead captured once during the `session_start` event.
|
|
173
|
+
|
|
174
|
+
### 4. Screen Tracking
|
|
158
175
|
|
|
159
176
|
Though `MetaStreamProvider` captures the video, you can manually log screen views for analytics:
|
|
160
177
|
|
|
@@ -162,7 +179,7 @@ Though `MetaStreamProvider` captures the video, you can manually log screen view
|
|
|
162
179
|
tracker.screen("HomeScreen", {});
|
|
163
180
|
```
|
|
164
181
|
|
|
165
|
-
###
|
|
182
|
+
### 5. Privacy & Redaction
|
|
166
183
|
|
|
167
184
|
To protect sensitive user data (PII) like passwords or credit card numbers during session replay, wrap your sensitive components with the `<Redact>` component.
|
|
168
185
|
|
|
@@ -180,7 +197,29 @@ import { Redact } from 'iidrak-analytics-react';
|
|
|
180
197
|
|
|
181
198
|
This ensures the wrapped area is covered by a privacy mask in the recorded video, while remaining fully functional for the user.
|
|
182
199
|
|
|
183
|
-
###
|
|
200
|
+
### 6. Suppressing Auto-Capture
|
|
201
|
+
|
|
202
|
+
By default, the SDK captures every tap on the application as an `auto_click` event. To prevent this for a specific component (e.g., when you are already manually tracking a custom event on that button), add the `autoTrack={false}` prop.
|
|
203
|
+
|
|
204
|
+
**Example:**
|
|
205
|
+
|
|
206
|
+
```javascript
|
|
207
|
+
/*
|
|
208
|
+
This button will trigger 'login_success' but will NOT trigger
|
|
209
|
+
a redundant 'auto_click' event.
|
|
210
|
+
*/
|
|
211
|
+
<TouchableOpacity
|
|
212
|
+
onPress={handleLogin}
|
|
213
|
+
autoTrack={false}
|
|
214
|
+
>
|
|
215
|
+
<Text>Sign In</Text>
|
|
216
|
+
</TouchableOpacity>
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
This ensures your server doesn't receive duplicate data for the same interaction.
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
### 6. Shopping Cart
|
|
184
223
|
|
|
185
224
|
Manage a persistent shopping cart state:
|
|
186
225
|
|
|
@@ -35,11 +35,33 @@ class MetaStreamProvider extends Component {
|
|
|
35
35
|
let componentPath = [];
|
|
36
36
|
|
|
37
37
|
// Traverse the React Fiber tree to extract component names, text, and testIDs
|
|
38
|
+
let suppressAutoClick = false;
|
|
38
39
|
try {
|
|
39
40
|
let fiber = e._targetInst;
|
|
40
41
|
while (fiber) {
|
|
42
|
+
const name = typeof fiber.elementType === 'string' ? fiber.elementType : (fiber.elementType?.name || fiber.elementType?.displayName || fiber.type?.name || 'Unknown');
|
|
43
|
+
|
|
44
|
+
const p1 = fiber.memoizedProps || {};
|
|
45
|
+
const p2 = fiber.pendingProps || {};
|
|
46
|
+
|
|
47
|
+
const suppressValue =
|
|
48
|
+
p1['autoTrack'] ?? p1['auto-track'] ?? p1['data-auto-track'] ??
|
|
49
|
+
p2['autoTrack'] ?? p2['auto-track'] ?? p2['data-auto-track'];
|
|
50
|
+
|
|
51
|
+
if (suppressValue !== undefined) {
|
|
52
|
+
if (String(suppressValue) === 'false' || suppressValue === false) {
|
|
53
|
+
suppressAutoClick = true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
41
57
|
if (fiber.memoizedProps) {
|
|
42
|
-
|
|
58
|
+
const tid = fiber.memoizedProps.testID || fiber.memoizedProps.accessibilityLabel;
|
|
59
|
+
if (testID === 'none' && tid) testID = tid;
|
|
60
|
+
|
|
61
|
+
// FAIL-SAFE: If we see 'no-track' in the testID or Label, suppress it!
|
|
62
|
+
if (typeof tid === 'string' && tid.toLowerCase().includes('no-track')) {
|
|
63
|
+
suppressAutoClick = true;
|
|
64
|
+
}
|
|
43
65
|
if (accessibilityLabel === 'none' && fiber.memoizedProps.accessibilityLabel) accessibilityLabel = fiber.memoizedProps.accessibilityLabel;
|
|
44
66
|
|
|
45
67
|
// Extract text content if available
|
|
@@ -54,7 +76,6 @@ class MetaStreamProvider extends Component {
|
|
|
54
76
|
|
|
55
77
|
// Try to get the component's name (e.g., 'Text', 'RCTImageView', 'Button')
|
|
56
78
|
if (fiber.elementType) {
|
|
57
|
-
let name = typeof fiber.elementType === 'string' ? fiber.elementType : (fiber.elementType.name || fiber.elementType.displayName);
|
|
58
79
|
if (name) {
|
|
59
80
|
if (name !== 'View' && name !== 'RCTView' && componentType === 'unknown') {
|
|
60
81
|
componentType = name;
|
|
@@ -71,6 +92,10 @@ class MetaStreamProvider extends Component {
|
|
|
71
92
|
// Ignore any errors if structure changes in future RN versions
|
|
72
93
|
}
|
|
73
94
|
|
|
95
|
+
if (suppressAutoClick) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
|
|
74
99
|
this.tracker.trackEvent({
|
|
75
100
|
eventName: 'auto_click',
|
|
76
101
|
eventParameters: [
|