rn-prodeeplinks 0.0.2 → 0.0.3
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 +30 -6
- package/lib/api.js +2 -2
- package/lib/fingerprint.js +4 -2
- package/lib/index.js +8 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> ⚠️ **License Required**: This package requires a valid license key purchased from our portal. Without a license key, the package will not function.
|
|
6
6
|
|
|
7
|
-
> ℹ️ **Versioning**: Current version is 0.0.
|
|
7
|
+
> ℹ️ **Versioning**: Current version is 0.0.3 (in-progress). It will move to 1.x after stable.
|
|
8
8
|
|
|
9
9
|
## Features
|
|
10
10
|
|
|
@@ -137,12 +137,14 @@ This SDK can optionally send deep link analytics events to our tracking service.
|
|
|
137
137
|
- When a deep link is opened via React Native `Linking.getInitialURL()`, the SDK:
|
|
138
138
|
- Resolves the URL
|
|
139
139
|
- Collects device fingerprint data
|
|
140
|
-
- Sends an internal
|
|
140
|
+
- Sends an internal analytics event with the resolved short URL and fingerprint
|
|
141
141
|
- When a deep link is resolved via the fingerprint API, the SDK:
|
|
142
142
|
- Resolves the URL from the server
|
|
143
|
-
- Sends the same
|
|
143
|
+
- Sends the same internal analytics event with the short URL and fingerprint
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
These internal events are handled by the SDK and are not part of the public API.
|
|
146
|
+
|
|
147
|
+
You can also send custom tracking events manually after calling `init`:
|
|
146
148
|
|
|
147
149
|
```typescript
|
|
148
150
|
import {
|
|
@@ -151,20 +153,22 @@ import {
|
|
|
151
153
|
} from 'rn-prodeeplinks';
|
|
152
154
|
|
|
153
155
|
const event: CustomDeepLinkAnalyticsEvent = {
|
|
154
|
-
licenseKey: 'your-license-key',
|
|
155
156
|
eventType: 'deeplink',
|
|
156
|
-
eventName: '
|
|
157
|
+
eventName: 'my_custom_event',
|
|
157
158
|
category: 'custom',
|
|
158
159
|
action: 'open',
|
|
159
160
|
label: 'My custom event',
|
|
160
161
|
properties: {
|
|
161
162
|
shortUrl: 'https://your-short-url',
|
|
163
|
+
foo: 'bar',
|
|
162
164
|
},
|
|
163
165
|
};
|
|
164
166
|
|
|
165
167
|
await trackAnalyticsEvent(event);
|
|
166
168
|
```
|
|
167
169
|
|
|
170
|
+
The license key provided to `init` is automatically included in the request headers. You do not need to include the license key in the analytics event payload.
|
|
171
|
+
|
|
168
172
|
## API Reference
|
|
169
173
|
|
|
170
174
|
### Functions
|
|
@@ -217,6 +221,26 @@ getDeepLink((url) => {
|
|
|
217
221
|
});
|
|
218
222
|
```
|
|
219
223
|
|
|
224
|
+
#### `trackAnalyticsEvent(event: CustomDeepLinkAnalyticsEvent): Promise<any>`
|
|
225
|
+
|
|
226
|
+
Sends a custom analytics event to the tracking service.
|
|
227
|
+
|
|
228
|
+
`init()` must be called successfully first; the stored license key from `init` is sent in the request headers.
|
|
229
|
+
|
|
230
|
+
**Parameters:**
|
|
231
|
+
- `event` (CustomDeepLinkAnalyticsEvent, required): Event describing what happened. You can use any `eventName` and add any custom properties.
|
|
232
|
+
|
|
233
|
+
**Example:**
|
|
234
|
+
```typescript
|
|
235
|
+
await trackAnalyticsEvent({
|
|
236
|
+
eventType: 'deeplink',
|
|
237
|
+
eventName: 'button_click',
|
|
238
|
+
properties: {
|
|
239
|
+
buttonId: 'cta_start',
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
220
244
|
#### `isReady(): boolean`
|
|
221
245
|
|
|
222
246
|
Checks if the package has been initialized with a license key.
|
package/lib/api.js
CHANGED
|
@@ -26,7 +26,7 @@ async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout =
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
const PACKAGE_NAME = 'react-native-pro-deeplink';
|
|
29
|
-
const PACKAGE_VERSION = '0.0.
|
|
29
|
+
const PACKAGE_VERSION = '0.0.3';
|
|
30
30
|
const payload = {
|
|
31
31
|
licenseKey,
|
|
32
32
|
fingerprint: fingerprint,
|
|
@@ -39,7 +39,7 @@ async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout =
|
|
|
39
39
|
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
40
40
|
try {
|
|
41
41
|
const PACKAGE_NAME = 'react-native-pro-deeplink';
|
|
42
|
-
const PACKAGE_VERSION = '0.0.
|
|
42
|
+
const PACKAGE_VERSION = '0.0.3';
|
|
43
43
|
const response = await fetch(endpoint, {
|
|
44
44
|
method: 'POST',
|
|
45
45
|
headers: {
|
package/lib/fingerprint.js
CHANGED
|
@@ -26,8 +26,10 @@ async function generateDeviceFingerprint() {
|
|
|
26
26
|
const isRooted = react_native_1.Platform.OS === 'android'
|
|
27
27
|
? (await (react_native_device_info_1.default.isDeviceRooted?.() ?? false))
|
|
28
28
|
: false;
|
|
29
|
-
|
|
30
|
-
const locale =
|
|
29
|
+
const deviceLocales = react_native_device_info_1.default.getDeviceLocales?.();
|
|
30
|
+
const locale = (Array.isArray(deviceLocales) && deviceLocales.length > 0
|
|
31
|
+
? deviceLocales[0]
|
|
32
|
+
: Intl.DateTimeFormat().resolvedOptions().locale) || 'en';
|
|
31
33
|
const language = (locale || '').split('-')[0] || 'en';
|
|
32
34
|
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
33
35
|
// Get network info
|
package/lib/index.js
CHANGED
|
@@ -170,8 +170,14 @@ function reset() {
|
|
|
170
170
|
isInitialized = false;
|
|
171
171
|
}
|
|
172
172
|
async function trackAnalyticsEvent(event) {
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
if (!isInitialized || !storedLicenseKey) {
|
|
174
|
+
return {
|
|
175
|
+
success: false,
|
|
176
|
+
error: 'Please call init() first with your license key',
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const { licenseKey: _ignored, ...payload } = event;
|
|
180
|
+
return (0, api_1.trackCustomDeepLinkEvent)(payload, storedLicenseKey);
|
|
175
181
|
}
|
|
176
182
|
// Keep backward compatibility - export class for advanced users (optional)
|
|
177
183
|
class ProDeepLink {
|
package/package.json
CHANGED