rn-prodeeplinks 0.1.1 → 0.1.2
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/lib/api.js +31 -1
- package/package.json +1 -1
package/lib/api.js
CHANGED
|
@@ -8,13 +8,17 @@ exports.matchFingerprintCustom = matchFingerprintCustom;
|
|
|
8
8
|
exports.trackCustomDeepLinkEvent = trackCustomDeepLinkEvent;
|
|
9
9
|
const license_1 = require("./license");
|
|
10
10
|
const BASE_API_URL = 'https://api.prodeeplinks.com';
|
|
11
|
+
const DEEP_LINK_ENDPOINT_PATH = '/custom-deep-link/fingerprint/match';
|
|
11
12
|
const ANALYTICS_ENDPOINT = `${BASE_API_URL}/custom-deep-link/track/event`;
|
|
12
13
|
/**
|
|
13
14
|
* Call API to get deep link URL
|
|
14
15
|
* This function sends device fingerprint and license key to server
|
|
15
16
|
*/
|
|
16
17
|
async function fetchDeepLinkUrl(licenseKey, fingerprint, apiEndpoint, timeout = 10000) {
|
|
17
|
-
const
|
|
18
|
+
const base = (apiEndpoint || BASE_API_URL).trim().replace(/\/+$/, '');
|
|
19
|
+
const endpoint = base.includes('/custom-deep-link/')
|
|
20
|
+
? base
|
|
21
|
+
: `${base}${DEEP_LINK_ENDPOINT_PATH}`;
|
|
18
22
|
try {
|
|
19
23
|
// Validate license key format first
|
|
20
24
|
const validation = (0, license_1.validateLicenseKeyFormat)(licenseKey);
|
|
@@ -185,9 +189,22 @@ async function matchFingerprintCustom(payload, baseUrl, licenseKey) {
|
|
|
185
189
|
body: JSON.stringify(payload),
|
|
186
190
|
});
|
|
187
191
|
const data = (await res.json().catch(() => ({})));
|
|
192
|
+
if (res.ok) {
|
|
193
|
+
console.log('[ProDeepLink] fingerprint match API success', {
|
|
194
|
+
matched: data?.matched,
|
|
195
|
+
matchConfidence: data?.matchConfidence,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
console.warn('[ProDeepLink] fingerprint match API non-OK response', {
|
|
200
|
+
status: res.status,
|
|
201
|
+
statusText: res.statusText,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
188
204
|
return data;
|
|
189
205
|
}
|
|
190
206
|
catch (e) {
|
|
207
|
+
console.error('[ProDeepLink] fingerprint match API error', e?.message || e);
|
|
191
208
|
return {
|
|
192
209
|
matched: false,
|
|
193
210
|
matchConfidence: 0,
|
|
@@ -206,9 +223,22 @@ async function trackCustomDeepLinkEvent(event, licenseKey) {
|
|
|
206
223
|
body: JSON.stringify(event),
|
|
207
224
|
});
|
|
208
225
|
const data = await res.json().catch(() => ({}));
|
|
226
|
+
if (res.ok) {
|
|
227
|
+
console.log('[ProDeepLink] track event API success', {
|
|
228
|
+
eventType: event?.eventType,
|
|
229
|
+
eventName: event?.eventName,
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
console.warn('[ProDeepLink] track event API non-OK response', {
|
|
234
|
+
status: res.status,
|
|
235
|
+
statusText: res.statusText,
|
|
236
|
+
});
|
|
237
|
+
}
|
|
209
238
|
return data;
|
|
210
239
|
}
|
|
211
240
|
catch (e) {
|
|
241
|
+
console.error('[ProDeepLink] track event API error', e?.message || e);
|
|
212
242
|
return { success: false, error: e?.message || 'Analytics event tracking failed' };
|
|
213
243
|
}
|
|
214
244
|
}
|
package/package.json
CHANGED