@virex-tech/paywallo-sdk 2.4.0 → 2.4.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/dist/index.js +45 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2421,8 +2421,8 @@ var init_NotificationHandlerSetup = __esm({
|
|
|
2421
2421
|
// src/core/version.ts
|
|
2422
2422
|
function resolveVersion() {
|
|
2423
2423
|
try {
|
|
2424
|
-
if ("2.4.
|
|
2425
|
-
return "2.4.
|
|
2424
|
+
if ("2.4.1") {
|
|
2425
|
+
return "2.4.1";
|
|
2426
2426
|
}
|
|
2427
2427
|
} catch {
|
|
2428
2428
|
}
|
|
@@ -4536,11 +4536,11 @@ var init_OfflineQueue = __esm({
|
|
|
4536
4536
|
});
|
|
4537
4537
|
return true;
|
|
4538
4538
|
}
|
|
4539
|
-
const
|
|
4539
|
+
const delay2 = Math.min(
|
|
4540
4540
|
this.config.baseRetryDelayMs * Math.pow(2, item.attempts - 1),
|
|
4541
4541
|
this.config.maxRetryDelayMs
|
|
4542
4542
|
);
|
|
4543
|
-
item.nextRetryAt = Date.now() +
|
|
4543
|
+
item.nextRetryAt = Date.now() + delay2;
|
|
4544
4544
|
await this.storage.saveToStorage(this.queue);
|
|
4545
4545
|
return false;
|
|
4546
4546
|
}
|
|
@@ -7813,8 +7813,8 @@ var init_HttpClient = __esm({
|
|
|
7813
7813
|
if (this.shouldRetry(response.status, retryConfig)) {
|
|
7814
7814
|
if (state.attempt < retryConfig.maxRetries) {
|
|
7815
7815
|
state.attempt++;
|
|
7816
|
-
const
|
|
7817
|
-
await this.sleep(
|
|
7816
|
+
const delay2 = this.calculateDelayForResponse(state.attempt, response.headers, retryConfig);
|
|
7817
|
+
await this.sleep(delay2);
|
|
7818
7818
|
continue;
|
|
7819
7819
|
}
|
|
7820
7820
|
}
|
|
@@ -7823,8 +7823,8 @@ var init_HttpClient = __esm({
|
|
|
7823
7823
|
state.lastError = error instanceof Error ? error : new ClientError(CLIENT_ERROR_CODES.UNKNOWN, String(error));
|
|
7824
7824
|
if (this.isNetworkError(state.lastError) && state.attempt < retryConfig.maxRetries) {
|
|
7825
7825
|
state.attempt++;
|
|
7826
|
-
const
|
|
7827
|
-
await this.sleep(
|
|
7826
|
+
const delay2 = this.calculateDelay(state.attempt, retryConfig);
|
|
7827
|
+
await this.sleep(delay2);
|
|
7828
7828
|
continue;
|
|
7829
7829
|
}
|
|
7830
7830
|
throw state.lastError;
|
|
@@ -8475,8 +8475,8 @@ async function initWithRetry(state, config) {
|
|
|
8475
8475
|
} catch (error) {
|
|
8476
8476
|
state.initAttempts++;
|
|
8477
8477
|
if (state.initAttempts > MAX_INIT_RETRIES) throw error;
|
|
8478
|
-
const
|
|
8479
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
8478
|
+
const delay2 = RETRY_DELAYS[state.initAttempts - 1] ?? 1e4;
|
|
8479
|
+
await new Promise((resolve) => setTimeout(resolve, delay2));
|
|
8480
8480
|
}
|
|
8481
8481
|
}
|
|
8482
8482
|
}
|
|
@@ -9832,12 +9832,17 @@ init_paywall();
|
|
|
9832
9832
|
|
|
9833
9833
|
// src/domains/paywall/SuperwallAttributeBridge.ts
|
|
9834
9834
|
init_identity();
|
|
9835
|
+
var CONFIG_POLL_INTERVAL_MS = 250;
|
|
9836
|
+
var CONFIG_POLL_MAX_ATTEMPTS = 40;
|
|
9835
9837
|
var lastSignature = null;
|
|
9836
9838
|
function log(debug, msg, data) {
|
|
9837
9839
|
if (!debug) return;
|
|
9838
9840
|
if (data !== void 0) console.log(`[Paywallo:SuperwallAttr] ${msg}`, data);
|
|
9839
9841
|
else console.log(`[Paywallo:SuperwallAttr] ${msg}`);
|
|
9840
9842
|
}
|
|
9843
|
+
function delay(ms) {
|
|
9844
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
9845
|
+
}
|
|
9841
9846
|
var PAID_MEDIUM = /cpc|ppc|cpm|cpa|paid|display/i;
|
|
9842
9847
|
function deriveIsPaid(a) {
|
|
9843
9848
|
if (a.fbclid || a.gclid || a.ttclid || a.tiktokCampaignId) return true;
|
|
@@ -9876,24 +9881,38 @@ function buildSuperwallAttributes(a) {
|
|
|
9876
9881
|
out.pw_attributed_at = a.capturedAt;
|
|
9877
9882
|
return out;
|
|
9878
9883
|
}
|
|
9879
|
-
function
|
|
9880
|
-
const
|
|
9881
|
-
return
|
|
9884
|
+
function pickNative(mod) {
|
|
9885
|
+
const native = mod?.SuperwallExpoModule ?? mod?.default?.SuperwallExpoModule;
|
|
9886
|
+
return native && typeof native.setUserAttributes === "function" && typeof native.getConfigurationStatus === "function" ? native : null;
|
|
9882
9887
|
}
|
|
9883
|
-
async function
|
|
9884
|
-
try {
|
|
9885
|
-
const shared = pickShared(await import("expo-superwall/compat"));
|
|
9886
|
-
if (shared) return shared;
|
|
9887
|
-
} catch {
|
|
9888
|
-
}
|
|
9888
|
+
async function resolveSuperwallNativeModule(debug) {
|
|
9889
9889
|
try {
|
|
9890
|
-
const
|
|
9891
|
-
if (
|
|
9890
|
+
const native = pickNative(await import("expo-superwall"));
|
|
9891
|
+
if (native) return native;
|
|
9892
9892
|
} catch {
|
|
9893
9893
|
}
|
|
9894
|
-
log(debug, "expo-superwall not available \u2014 attribute push skipped");
|
|
9894
|
+
log(debug, "expo-superwall native module not available \u2014 attribute push skipped");
|
|
9895
9895
|
return null;
|
|
9896
9896
|
}
|
|
9897
|
+
async function waitForConfigured(mod, debug) {
|
|
9898
|
+
for (let attempt = 0; attempt < CONFIG_POLL_MAX_ATTEMPTS; attempt++) {
|
|
9899
|
+
let status;
|
|
9900
|
+
try {
|
|
9901
|
+
status = String(await mod.getConfigurationStatus());
|
|
9902
|
+
} catch (err) {
|
|
9903
|
+
log(debug, "getConfigurationStatus error", { err: String(err) });
|
|
9904
|
+
return false;
|
|
9905
|
+
}
|
|
9906
|
+
if (status === "CONFIGURED") return true;
|
|
9907
|
+
if (status === "FAILED") {
|
|
9908
|
+
log(debug, "Superwall configuration FAILED \u2014 skipping attribute push");
|
|
9909
|
+
return false;
|
|
9910
|
+
}
|
|
9911
|
+
await delay(CONFIG_POLL_INTERVAL_MS);
|
|
9912
|
+
}
|
|
9913
|
+
log(debug, "Superwall not configured within timeout \u2014 skipping attribute push");
|
|
9914
|
+
return false;
|
|
9915
|
+
}
|
|
9897
9916
|
async function pushAttributionToSuperwall(debug = false) {
|
|
9898
9917
|
const attrs = buildSuperwallAttributes(attributionTracker.get());
|
|
9899
9918
|
const signature = JSON.stringify(attrs);
|
|
@@ -9901,10 +9920,11 @@ async function pushAttributionToSuperwall(debug = false) {
|
|
|
9901
9920
|
log(debug, "attributes unchanged \u2014 skipping push");
|
|
9902
9921
|
return;
|
|
9903
9922
|
}
|
|
9904
|
-
const
|
|
9905
|
-
if (!
|
|
9923
|
+
const native = await resolveSuperwallNativeModule(debug);
|
|
9924
|
+
if (!native) return;
|
|
9925
|
+
if (!await waitForConfigured(native, debug)) return;
|
|
9906
9926
|
try {
|
|
9907
|
-
await
|
|
9927
|
+
await native.setUserAttributes(attrs);
|
|
9908
9928
|
lastSignature = signature;
|
|
9909
9929
|
log(debug, "attributes pushed to Superwall", attrs);
|
|
9910
9930
|
} catch (err) {
|