@datalyr/react-native 1.0.0 → 1.0.1
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 +255 -220
- package/examples/test-implementation.tsx +1 -1
- package/lib/datalyr-sdk.js +1 -1
- package/lib/http-client.js +3 -3
- package/package.json +1 -1
- package/src/datalyr-sdk.ts +1 -1
- package/src/http-client.ts +3 -3
package/README.md
CHANGED
|
@@ -1,300 +1,335 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @datalyr/react-native
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official Datalyr SDK for React Native & Expo - Server-side attribution tracking and analytics.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/@datalyr/react-native)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
## Features
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
- 🔒 **Server-side tracking** - Secure API key authentication
|
|
11
|
+
- 📱 **React Native & Expo** - Works with both platforms
|
|
12
|
+
- 🎯 **Attribution tracking** - UTM, referrer, and deep links
|
|
13
|
+
- 📊 **SKAdNetwork** - iOS 14+ attribution support
|
|
14
|
+
- 💾 **Offline queue** - Events saved and retried
|
|
15
|
+
- 🔄 **Session management** - Automatic session tracking
|
|
16
|
+
- ⚡ **Performance** - < 100KB, minimal battery impact
|
|
10
17
|
|
|
11
|
-
|
|
12
|
-
**Compete with AppsFlyer/Adjust at 90% cost savings:**
|
|
13
|
-
- Add `skadTemplate: 'ecommerce'` to your `initialize()` call for automatic iOS 14+ attribution
|
|
14
|
-
- Use `Datalyr.trackPurchase()` and `Datalyr.trackWithSKAdNetwork()` for conversion tracking
|
|
15
|
-
- Choose from 3 industry templates: `'ecommerce'`, `'gaming'`, `'subscription'`
|
|
16
|
-
- **Benefit**: Same SKAdNetwork functionality as enterprise MMPs at $49/month instead of $500/month
|
|
17
|
-
- See [SKAdNetwork Quick Setup](#-skadnetwork-quick-setup-ios-attribution) below for details
|
|
18
|
+
## Installation
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
```bash
|
|
21
|
+
npm install @datalyr/react-native
|
|
22
|
+
# or
|
|
23
|
+
yarn add @datalyr/react-native
|
|
24
|
+
```
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
- Add `enableAttribution: true` to your `initialize()` call to track deep link parameters
|
|
27
|
-
- This enables UTM parameters, click IDs (fbclid, gclid, ttclid), and LYR tags
|
|
28
|
-
- **Action Required**: Add this to your config to enable attribution tracking
|
|
26
|
+
### Additional Dependencies
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
For device information and attribution:
|
|
29
|
+
```bash
|
|
30
|
+
npm install react-native-device-info @react-native-async-storage/async-storage
|
|
31
|
+
```
|
|
33
32
|
|
|
34
|
-
|
|
33
|
+
### iOS Setup
|
|
35
34
|
|
|
36
|
-
|
|
35
|
+
```bash
|
|
36
|
+
cd ios && pod install
|
|
37
|
+
```
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
## Quick Start
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
| **React Native CLI** | [INSTALL.md](https://github.com/datalyr/react-native-sdk/blob/main/INSTALL.md) | 100% |
|
|
43
|
-
| **Expo Bare Workflow** | [INSTALL.md](https://github.com/datalyr/react-native-sdk/blob/main/INSTALL.md) | 100% |
|
|
44
|
-
| **Expo Managed Workflow** | [EXPO_INSTALL.md](https://github.com/datalyr/react-native-sdk/blob/main/EXPO_INSTALL.md) | 90% |
|
|
45
|
-
| **Expo Go** | [EXPO_INSTALL.md](https://github.com/datalyr/react-native-sdk/blob/main/EXPO_INSTALL.md) | 90% |
|
|
41
|
+
```typescript
|
|
42
|
+
import { Datalyr } from '@datalyr/react-native';
|
|
46
43
|
|
|
47
|
-
|
|
44
|
+
// Initialize SDK
|
|
45
|
+
await Datalyr.initialize({
|
|
46
|
+
apiKey: 'dk_your_api_key', // Required - get from Datalyr dashboard
|
|
47
|
+
debug: true, // Enable debug logs
|
|
48
|
+
enableAutoEvents: true, // Track sessions, app lifecycle
|
|
49
|
+
enableAttribution: true, // Track attribution data
|
|
50
|
+
});
|
|
48
51
|
|
|
49
|
-
|
|
52
|
+
// Track custom event
|
|
53
|
+
await Datalyr.track('Button Clicked', {
|
|
54
|
+
button_name: 'purchase',
|
|
55
|
+
value: 99.99,
|
|
56
|
+
});
|
|
50
57
|
|
|
51
|
-
|
|
58
|
+
// Identify user
|
|
59
|
+
await Datalyr.identify('user_123', {
|
|
60
|
+
email: 'user@example.com',
|
|
61
|
+
plan: 'premium',
|
|
62
|
+
});
|
|
63
|
+
```
|
|
52
64
|
|
|
53
|
-
##
|
|
65
|
+
## Configuration
|
|
54
66
|
|
|
55
|
-
### 🎯 **Complete Attribution**
|
|
56
67
|
```typescript
|
|
57
|
-
|
|
58
|
-
//
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
68
|
+
interface DatalyrConfig {
|
|
69
|
+
apiKey: string; // Required - Your API key
|
|
70
|
+
workspaceId?: string; // Optional - For legacy support
|
|
71
|
+
debug?: boolean; // Enable debug logging
|
|
72
|
+
endpoint?: string; // Custom API endpoint
|
|
73
|
+
useServerTracking?: boolean; // Default: true
|
|
74
|
+
enableAutoEvents?: boolean; // Track lifecycle events
|
|
75
|
+
enableAttribution?: boolean; // Track attribution data
|
|
76
|
+
skadTemplate?: 'ecommerce' | 'gaming' | 'subscription'; // SKAdNetwork
|
|
77
|
+
maxQueueSize?: number; // Default: 100
|
|
78
|
+
flushInterval?: number; // Default: 30000ms
|
|
79
|
+
}
|
|
62
80
|
```
|
|
63
81
|
|
|
64
|
-
|
|
82
|
+
## Core Methods
|
|
83
|
+
|
|
84
|
+
### Initialize
|
|
65
85
|
```typescript
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// ✅ Unified web + mobile analytics dashboard
|
|
86
|
+
await Datalyr.initialize({
|
|
87
|
+
apiKey: 'dk_your_api_key',
|
|
88
|
+
enableAutoEvents: true,
|
|
89
|
+
});
|
|
71
90
|
```
|
|
72
91
|
|
|
73
|
-
###
|
|
92
|
+
### Track Events
|
|
74
93
|
```typescript
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
// Simple event
|
|
95
|
+
await Datalyr.track('Product Viewed');
|
|
96
|
+
|
|
97
|
+
// Event with properties
|
|
98
|
+
await Datalyr.track('Purchase Completed', {
|
|
99
|
+
product_id: 'SKU123',
|
|
100
|
+
amount: 49.99,
|
|
101
|
+
currency: 'USD',
|
|
102
|
+
});
|
|
83
103
|
```
|
|
84
104
|
|
|
85
|
-
###
|
|
105
|
+
### Identify Users
|
|
86
106
|
```typescript
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
await Datalyr.identify('user_123', {
|
|
108
|
+
email: 'user@example.com',
|
|
109
|
+
name: 'John Doe',
|
|
110
|
+
plan: 'premium',
|
|
111
|
+
company: 'Acme Inc',
|
|
112
|
+
});
|
|
92
113
|
```
|
|
93
114
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
115
|
+
### Track Screen Views
|
|
116
|
+
```typescript
|
|
117
|
+
await Datalyr.screen('Product Details', {
|
|
118
|
+
product_id: 'SKU123',
|
|
119
|
+
category: 'Electronics',
|
|
120
|
+
});
|
|
121
|
+
```
|
|
97
122
|
|
|
98
|
-
###
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
123
|
+
### Track Revenue
|
|
124
|
+
```typescript
|
|
125
|
+
// Purchase tracking with SKAdNetwork
|
|
126
|
+
await Datalyr.trackPurchase(99.99, 'USD', 'premium_subscription');
|
|
102
127
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
- **[test-app/](https://github.com/datalyr/react-native-sdk/tree/main/test-app)** - 🧪 **Complete test app** - Ready-to-run Expo app demonstrating all features
|
|
106
|
-
- **[examples/skadnetwork-example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/skadnetwork-example.tsx)** - 🚀 **SKAdNetwork demo** - Complete interface for testing all templates
|
|
107
|
-
- **[examples/auto-events-example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/auto-events-example.tsx)** - Live demo of automatic events
|
|
108
|
-
- **[examples/attribution-example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/attribution-example.tsx)** - Attribution testing interface
|
|
109
|
-
- **[examples/example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/example.tsx)** - Basic SDK usage example
|
|
128
|
+
// Subscription tracking
|
|
129
|
+
await Datalyr.trackSubscription(9.99, 'USD', 'monthly_pro');
|
|
110
130
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
131
|
+
// Custom revenue event
|
|
132
|
+
await Datalyr.trackRevenue('In-App Purchase', {
|
|
133
|
+
product_id: 'coins_1000',
|
|
134
|
+
amount: 4.99,
|
|
135
|
+
currency: 'USD',
|
|
136
|
+
});
|
|
137
|
+
```
|
|
114
138
|
|
|
115
|
-
|
|
139
|
+
## Attribution Tracking
|
|
116
140
|
|
|
117
|
-
|
|
141
|
+
The SDK automatically tracks:
|
|
142
|
+
- Deep links and Universal Links
|
|
143
|
+
- UTM parameters
|
|
144
|
+
- Referrer data
|
|
145
|
+
- Install attribution
|
|
146
|
+
- Platform click IDs (fbclid, gclid, ttclid, etc.)
|
|
118
147
|
|
|
119
|
-
|
|
148
|
+
### Get Attribution Data
|
|
120
149
|
```typescript
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
trackScreenViews: true, // ✅ Automatic screen tracking
|
|
131
|
-
trackAppUpdates: true, // ✅ App version changes
|
|
132
|
-
trackPerformance: true, // ✅ App launch performance
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
// Manual events still work (but many are now automatic!)
|
|
137
|
-
await datalyr.track('purchase', { value: 29.99, currency: 'USD' });
|
|
138
|
-
await datalyr.identify('user_123', { email: 'user@example.com' });
|
|
139
|
-
await datalyr.screen('home_screen');
|
|
150
|
+
const attribution = Datalyr.getAttributionData();
|
|
151
|
+
console.log(attribution);
|
|
152
|
+
// {
|
|
153
|
+
// campaign: 'summer_sale',
|
|
154
|
+
// source: 'facebook',
|
|
155
|
+
// medium: 'social',
|
|
156
|
+
// fbclid: 'abc123',
|
|
157
|
+
// ...
|
|
158
|
+
// }
|
|
140
159
|
```
|
|
141
160
|
|
|
142
|
-
|
|
161
|
+
### Set Custom Attribution
|
|
143
162
|
```typescript
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
workspaceId: 'your-workspace-id',
|
|
149
|
-
apiKey: 'dk_your_api_key',
|
|
150
|
-
skadTemplate: 'ecommerce', // 'ecommerce', 'gaming', or 'subscription'
|
|
151
|
-
enableAttribution: true,
|
|
152
|
-
autoEvents: { trackSessions: true, trackScreenViews: true },
|
|
163
|
+
await Datalyr.setAttributionData({
|
|
164
|
+
campaign: 'email_campaign',
|
|
165
|
+
source: 'newsletter',
|
|
166
|
+
medium: 'email',
|
|
153
167
|
});
|
|
154
|
-
|
|
155
|
-
// Track events with automatic SKAdNetwork encoding
|
|
156
|
-
await Datalyr.trackPurchase(29.99, 'USD', 'premium_plan');
|
|
157
|
-
await Datalyr.trackWithSKAdNetwork('add_to_cart', { product_id: 'shirt_001' });
|
|
158
|
-
|
|
159
|
-
// 🎉 Automatic conversion value encoding sends to Apple!
|
|
160
168
|
```
|
|
161
169
|
|
|
162
|
-
##
|
|
170
|
+
## Session Management
|
|
163
171
|
|
|
164
|
-
|
|
172
|
+
Sessions are tracked automatically with a 30-minute timeout.
|
|
165
173
|
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
174
|
+
```typescript
|
|
175
|
+
// Get current session
|
|
176
|
+
const session = Datalyr.getCurrentSession();
|
|
177
|
+
|
|
178
|
+
// Manually end session
|
|
179
|
+
await Datalyr.endSession();
|
|
170
180
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
npx expo start
|
|
181
|
+
// Reset user (logout)
|
|
182
|
+
await Datalyr.reset();
|
|
174
183
|
```
|
|
175
184
|
|
|
176
|
-
|
|
185
|
+
## SKAdNetwork Support (iOS)
|
|
177
186
|
|
|
178
|
-
|
|
187
|
+
Enable SKAdNetwork conversion value tracking:
|
|
179
188
|
|
|
180
|
-
|
|
189
|
+
```typescript
|
|
190
|
+
await Datalyr.initialize({
|
|
191
|
+
apiKey: 'dk_your_api_key',
|
|
192
|
+
skadTemplate: 'ecommerce', // or 'gaming', 'subscription'
|
|
193
|
+
});
|
|
181
194
|
|
|
182
|
-
Events
|
|
195
|
+
// Events automatically update conversion values
|
|
196
|
+
await Datalyr.trackPurchase(99.99, 'USD');
|
|
183
197
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
- `app_install` - First app launch with full attribution
|
|
189
|
-
- `app_update` - App version changes
|
|
190
|
-
- `app_foreground` - App becomes active
|
|
191
|
-
- `app_background` - App goes to background
|
|
192
|
-
- `app_launch_performance` - App startup timing
|
|
193
|
-
- `revenue_event` - Purchase/subscription tracking
|
|
198
|
+
// Get conversion value for testing
|
|
199
|
+
const value = Datalyr.getConversionValue('purchase', { revenue: 50 });
|
|
200
|
+
console.log('Conversion value:', value); // 0-63
|
|
201
|
+
```
|
|
194
202
|
|
|
195
|
-
|
|
196
|
-
- Custom events from `datalyr.track()`
|
|
197
|
-
- User identification from `datalyr.identify()`
|
|
198
|
-
- Manual screen views from `datalyr.screen()`
|
|
203
|
+
## Automatic Events
|
|
199
204
|
|
|
200
|
-
|
|
205
|
+
When `enableAutoEvents` is true, the SDK tracks:
|
|
201
206
|
|
|
202
|
-
|
|
207
|
+
- `app_install` - First app open
|
|
208
|
+
- `app_open` - App launches
|
|
209
|
+
- `app_background` - App enters background
|
|
210
|
+
- `app_foreground` - App returns to foreground
|
|
211
|
+
- `app_update` - App version changes
|
|
212
|
+
- `session_start` - New session begins
|
|
213
|
+
- `session_end` - Session expires
|
|
203
214
|
|
|
204
|
-
|
|
205
|
-
|---------|-----------|--------|----------|-------------|
|
|
206
|
-
| SKAdNetwork | ✅ ($300/mo) | ✅ ($500/mo) | ❌ | **✅ ($49/mo)** |
|
|
207
|
-
| Attribution | ✅ | ✅ | ❌ | **✅** |
|
|
208
|
-
| Auto Events | ❌ | ❌ | ✅ | **✅** |
|
|
209
|
-
| Web + Mobile | ❌ | ❌ | ✅ | **✅** |
|
|
210
|
-
| Revenue Optimization | ✅ | ✅ | ✅ | **✅** |
|
|
211
|
-
| Industry Templates | ✅ | ✅ | ❌ | **✅** |
|
|
212
|
-
| Cost | $300-3000/mo | $500-5000/mo | $20-2000/mo | **$49-499/mo** |
|
|
215
|
+
## Offline Support
|
|
213
216
|
|
|
214
|
-
|
|
217
|
+
Events are automatically queued when offline and sent when connection is restored.
|
|
215
218
|
|
|
216
|
-
|
|
219
|
+
```typescript
|
|
220
|
+
// Manually flush queue
|
|
221
|
+
await Datalyr.flush();
|
|
217
222
|
|
|
218
|
-
|
|
223
|
+
// Get queue status
|
|
224
|
+
const status = Datalyr.getStatus();
|
|
225
|
+
console.log('Queue size:', status.queueStats.queueSize);
|
|
226
|
+
```
|
|
219
227
|
|
|
220
|
-
|
|
228
|
+
## Debug Mode
|
|
221
229
|
|
|
222
|
-
|
|
223
|
-
2. **🧪 Complete Test App:** Run the [test-app/](https://github.com/datalyr/react-native-sdk/tree/main/test-app) - Full Expo app with all features
|
|
224
|
-
3. **Auto Events Demo:** Run [examples/auto-events-example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/auto-events-example.tsx)
|
|
225
|
-
4. **Attribution Testing:** Use [examples/attribution-example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/attribution-example.tsx)
|
|
226
|
-
5. **Basic Integration:** Check out [examples/example.tsx](https://github.com/datalyr/react-native-sdk/blob/main/examples/example.tsx)
|
|
230
|
+
Enable debug logging during development:
|
|
227
231
|
|
|
228
|
-
|
|
232
|
+
```typescript
|
|
233
|
+
await Datalyr.initialize({
|
|
234
|
+
apiKey: 'dk_your_api_key',
|
|
235
|
+
debug: true, // Enable console logs
|
|
236
|
+
});
|
|
237
|
+
```
|
|
229
238
|
|
|
230
|
-
##
|
|
239
|
+
## TypeScript Support
|
|
231
240
|
|
|
232
|
-
|
|
233
|
-
2. **⚡ Quick install:** [INSTALL.md](https://github.com/datalyr/react-native-sdk/blob/main/INSTALL.md) or [EXPO_INSTALL.md](https://github.com/datalyr/react-native-sdk/blob/main/EXPO_INSTALL.md)
|
|
234
|
-
3. **🧪 Test attribution:** Your events appear at `https://app.datalyr.com`
|
|
235
|
-
4. **🎉 Launch:** Start tracking users from ad click to conversion!
|
|
241
|
+
Full TypeScript support with type definitions included:
|
|
236
242
|
|
|
237
|
-
|
|
243
|
+
```typescript
|
|
244
|
+
import {
|
|
245
|
+
Datalyr,
|
|
246
|
+
DatalyrConfig,
|
|
247
|
+
EventData,
|
|
248
|
+
UserProperties,
|
|
249
|
+
AttributionData
|
|
250
|
+
} from '@datalyr/react-native';
|
|
251
|
+
```
|
|
238
252
|
|
|
239
|
-
|
|
253
|
+
## Expo Support
|
|
240
254
|
|
|
241
|
-
|
|
255
|
+
Works with Expo managed and bare workflows:
|
|
242
256
|
|
|
243
|
-
|
|
257
|
+
```typescript
|
|
258
|
+
// expo.config.js
|
|
259
|
+
export default {
|
|
260
|
+
plugins: [
|
|
261
|
+
// No additional config needed
|
|
262
|
+
],
|
|
263
|
+
};
|
|
264
|
+
```
|
|
244
265
|
|
|
245
|
-
##
|
|
266
|
+
## Migration from v0.x
|
|
246
267
|
|
|
247
|
-
|
|
268
|
+
If migrating from an older version:
|
|
248
269
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
270
|
+
```typescript
|
|
271
|
+
// Old (v0.x)
|
|
272
|
+
import datalyr from '@datalyr/react-native-sdk';
|
|
273
|
+
datalyr.initialize({ workspaceId: 'ws_123' });
|
|
253
274
|
|
|
254
|
-
|
|
255
|
-
@
|
|
275
|
+
// New (v1.0+)
|
|
276
|
+
import { Datalyr } from '@datalyr/react-native';
|
|
277
|
+
await Datalyr.initialize({ apiKey: 'dk_your_api_key' });
|
|
278
|
+
```
|
|
256
279
|
|
|
257
|
-
|
|
258
|
-
|
|
280
|
+
## API Reference
|
|
281
|
+
|
|
282
|
+
### Methods
|
|
283
|
+
|
|
284
|
+
| Method | Description |
|
|
285
|
+
|--------|-------------|
|
|
286
|
+
| `initialize(config)` | Initialize SDK with configuration |
|
|
287
|
+
| `track(event, properties?)` | Track custom event |
|
|
288
|
+
| `identify(userId, properties?)` | Identify user |
|
|
289
|
+
| `screen(name, properties?)` | Track screen view |
|
|
290
|
+
| `alias(newUserId, previousId?)` | Create user alias |
|
|
291
|
+
| `reset()` | Reset user session |
|
|
292
|
+
| `flush()` | Flush event queue |
|
|
293
|
+
| `getStatus()` | Get SDK status |
|
|
294
|
+
| `getAttributionData()` | Get attribution data |
|
|
295
|
+
| `setAttributionData(data)` | Set attribution data |
|
|
296
|
+
| `getCurrentSession()` | Get current session |
|
|
297
|
+
| `endSession()` | End current session |
|
|
298
|
+
| `trackPurchase(value, currency, productId?)` | Track purchase |
|
|
299
|
+
| `trackSubscription(value, currency, plan?)` | Track subscription |
|
|
300
|
+
| `trackRevenue(event, properties?)` | Track revenue event |
|
|
301
|
+
|
|
302
|
+
## Troubleshooting
|
|
303
|
+
|
|
304
|
+
### Events not appearing?
|
|
305
|
+
1. Check your API key is correct
|
|
306
|
+
2. Enable debug mode to see logs
|
|
307
|
+
3. Verify network connectivity
|
|
308
|
+
4. Check `getStatus()` for queue information
|
|
309
|
+
|
|
310
|
+
### Authentication errors?
|
|
311
|
+
- Ensure API key starts with `dk_`
|
|
312
|
+
- Get your API key from: https://app.datalyr.com/settings/api-keys
|
|
313
|
+
|
|
314
|
+
### Build errors?
|
|
315
|
+
```bash
|
|
316
|
+
# Clear caches
|
|
317
|
+
npx react-native clean-project
|
|
259
318
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
reject:(RCTPromiseRejectBlock)reject) {
|
|
263
|
-
if (@available(iOS 14.0, *)) {
|
|
264
|
-
[SKAdNetwork updateConversionValue:value];
|
|
265
|
-
resolve(@(YES));
|
|
266
|
-
} else {
|
|
267
|
-
reject(@"ios_version_error", @"SKAdNetwork requires iOS 14.0+", nil);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
@end
|
|
319
|
+
# iOS specific
|
|
320
|
+
cd ios && pod install
|
|
271
321
|
```
|
|
272
322
|
|
|
273
|
-
|
|
274
|
-
```typescript
|
|
275
|
-
import { Datalyr } from '@datalyr/react-native-sdk';
|
|
323
|
+
## Support
|
|
276
324
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
skadTemplate: 'ecommerce', // Choose: 'ecommerce', 'gaming', 'subscription'
|
|
281
|
-
});
|
|
282
|
-
```
|
|
325
|
+
- 📧 Email: support@datalyr.com
|
|
326
|
+
- 📚 Docs: https://docs.datalyr.com
|
|
327
|
+
- 🐛 Issues: https://github.com/datalyr/react-native/issues
|
|
283
328
|
|
|
284
|
-
|
|
285
|
-
```typescript
|
|
286
|
-
// Automatic SKAdNetwork encoding for iOS 14+
|
|
287
|
-
await Datalyr.trackPurchase(29.99, 'USD', 'premium_plan');
|
|
288
|
-
await Datalyr.trackWithSKAdNetwork('add_to_cart', { product_id: 'shirt_001' });
|
|
329
|
+
## License
|
|
289
330
|
|
|
290
|
-
|
|
291
|
-
const value = Datalyr.getConversionValue('purchase', { revenue: 29.99 });
|
|
292
|
-
console.log('Conversion value:', value); // Example: 5
|
|
293
|
-
```
|
|
331
|
+
MIT © Datalyr
|
|
294
332
|
|
|
295
|
-
|
|
296
|
-
The SDK automatically maps revenue to 8 optimized tiers:
|
|
297
|
-
- $0-1 → Tier 0, $1-5 → Tier 1, $5-10 → Tier 2, $10-25 → Tier 3
|
|
298
|
-
- $25-50 → Tier 4, $50-100 → Tier 5, $100-250 → Tier 6, $250+ → Tier 7
|
|
333
|
+
---
|
|
299
334
|
|
|
300
|
-
|
|
335
|
+
Built with ❤️ by [Datalyr](https://datalyr.com)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { Button, View, Text, StyleSheet } from 'react-native';
|
|
3
|
-
import { Datalyr } from '@datalyr/react-native
|
|
3
|
+
import { Datalyr } from '@datalyr/react-native';
|
|
4
4
|
|
|
5
5
|
// Initialize SDK with server-side API
|
|
6
6
|
const initializeSDK = async () => {
|
package/lib/datalyr-sdk.js
CHANGED
|
@@ -121,7 +121,7 @@ export class DatalyrSDK {
|
|
|
121
121
|
const installData = await attributionManager.trackInstall();
|
|
122
122
|
await this.track('app_install', {
|
|
123
123
|
platform: Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'android',
|
|
124
|
-
sdk_version: '1.0.
|
|
124
|
+
sdk_version: '1.0.1',
|
|
125
125
|
...installData,
|
|
126
126
|
});
|
|
127
127
|
}
|
package/lib/http-client.js
CHANGED
|
@@ -45,7 +45,7 @@ export class HttpClient {
|
|
|
45
45
|
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
46
46
|
const headers = {
|
|
47
47
|
'Content-Type': 'application/json',
|
|
48
|
-
'User-Agent': `@datalyr/react-native/1.0.
|
|
48
|
+
'User-Agent': `@datalyr/react-native/1.0.1`,
|
|
49
49
|
};
|
|
50
50
|
// Server-side tracking uses X-API-Key header
|
|
51
51
|
if (this.config.useServerTracking !== false) {
|
|
@@ -151,8 +151,8 @@ export class HttpClient {
|
|
|
151
151
|
fingerprint: payload.fingerprintData,
|
|
152
152
|
},
|
|
153
153
|
context: {
|
|
154
|
-
library: 'datalyr
|
|
155
|
-
version: '1.0.
|
|
154
|
+
library: '@datalyr/react-native',
|
|
155
|
+
version: '1.0.1',
|
|
156
156
|
userProperties: payload.userProperties,
|
|
157
157
|
},
|
|
158
158
|
timestamp: payload.timestamp,
|
package/package.json
CHANGED
package/src/datalyr-sdk.ts
CHANGED
|
@@ -166,7 +166,7 @@ export class DatalyrSDK {
|
|
|
166
166
|
const installData = await attributionManager.trackInstall();
|
|
167
167
|
await this.track('app_install', {
|
|
168
168
|
platform: Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'android',
|
|
169
|
-
sdk_version: '1.0.
|
|
169
|
+
sdk_version: '1.0.1',
|
|
170
170
|
...installData,
|
|
171
171
|
});
|
|
172
172
|
}
|
package/src/http-client.ts
CHANGED
|
@@ -72,7 +72,7 @@ export class HttpClient {
|
|
|
72
72
|
|
|
73
73
|
const headers: Record<string, string> = {
|
|
74
74
|
'Content-Type': 'application/json',
|
|
75
|
-
'User-Agent': `@datalyr/react-native/1.0.
|
|
75
|
+
'User-Agent': `@datalyr/react-native/1.0.1`,
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
// Server-side tracking uses X-API-Key header
|
|
@@ -196,8 +196,8 @@ export class HttpClient {
|
|
|
196
196
|
fingerprint: payload.fingerprintData,
|
|
197
197
|
},
|
|
198
198
|
context: {
|
|
199
|
-
library: 'datalyr
|
|
200
|
-
version: '1.0.
|
|
199
|
+
library: '@datalyr/react-native',
|
|
200
|
+
version: '1.0.1',
|
|
201
201
|
userProperties: payload.userProperties,
|
|
202
202
|
},
|
|
203
203
|
timestamp: payload.timestamp,
|