rn-prodeeplinks 0.0.2 → 0.0.4

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
@@ -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.1 (in-progress). It will move to 1.x after stable.
7
+ > ℹ️ **Versioning**: Current version is 0.0.4 (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 tracking event named `pro_track` with the resolved short URL and fingerprint
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 `pro_track` event with the short URL and fingerprint
143
+ - Sends the same internal analytics event with the short URL and fingerprint
144
144
 
145
- You can also send custom tracking events manually:
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: 'pro_track',
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.2';
29
+ const PACKAGE_VERSION = '0.0.4';
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.2';
42
+ const PACKAGE_VERSION = '0.0.4';
43
43
  const response = await fetch(endpoint, {
44
44
  method: 'POST',
45
45
  headers: {
@@ -60,12 +60,22 @@ async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout =
60
60
  };
61
61
  }
62
62
  const data = await response.json();
63
- if (data.success && data.url) {
64
- return {
65
- success: true,
66
- url: data.url,
67
- message: data.message,
68
- };
63
+ if (data.success) {
64
+ if (data.url) {
65
+ return {
66
+ success: true,
67
+ url: data.url,
68
+ message: data.message,
69
+ };
70
+ }
71
+ else {
72
+ // Success true but no URL means no match found - this is not an error
73
+ return {
74
+ success: true,
75
+ url: null,
76
+ message: data.message || 'No deep link available',
77
+ };
78
+ }
69
79
  }
70
80
  else {
71
81
  return {
@@ -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
- // Get locale info
30
- const locale = react_native_device_info_1.default.getDeviceLocale?.() || Intl.DateTimeFormat().resolvedOptions().locale;
29
+ const deviceLocales = react_native_device_info_1.default.getDeviceLocales?.();
30
+ const primaryLocale = Array.isArray(deviceLocales) && deviceLocales.length > 0 ? deviceLocales[0] : undefined;
31
+ const legacyLocale = react_native_device_info_1.default.getDeviceLocale?.();
32
+ const locale = (primaryLocale || legacyLocale || 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
@@ -142,7 +142,8 @@ async function getDeepLink(callback) {
142
142
  callback(result.url);
143
143
  }
144
144
  // If API didn't return a usable URL, return null as per requirements
145
- if (!result.success || !result.url) {
145
+ // But if success is false, propagate the error
146
+ if (result.success && !result.url) {
146
147
  return { success: true, url: null, message: 'No deep link available' };
147
148
  }
148
149
  return result;
@@ -170,8 +171,14 @@ function reset() {
170
171
  isInitialized = false;
171
172
  }
172
173
  async function trackAnalyticsEvent(event) {
173
- const licenseKey = storedLicenseKey;
174
- return (0, api_1.trackCustomDeepLinkEvent)(event, licenseKey || undefined);
174
+ if (!isInitialized || !storedLicenseKey) {
175
+ return {
176
+ success: false,
177
+ error: 'Please call init() first with your license key',
178
+ };
179
+ }
180
+ const { licenseKey: _ignored, ...payload } = event;
181
+ return (0, api_1.trackCustomDeepLinkEvent)(payload, storedLicenseKey);
175
182
  }
176
183
  // Keep backward compatibility - export class for advanced users (optional)
177
184
  class ProDeepLink {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rn-prodeeplinks",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Secure deep linking package with license key validation and device fingerprinting for React Native",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",