@virex-tech/paywallo-sdk 2.0.0 → 2.0.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/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +85 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -72
- package/dist/index.mjs.map +1 -1
- package/ios/PaywalloNotifications.m +4 -1
- package/ios/PaywalloNotifications.swift +60 -73
- package/package.json +1 -1
- package/ios/PaywalloNotificationsSwizzle.swift +0 -126
package/dist/index.mjs
CHANGED
|
@@ -1539,7 +1539,7 @@ var init_QueueProcessor = __esm({
|
|
|
1539
1539
|
}
|
|
1540
1540
|
const allItems = offlineQueue.getQueue();
|
|
1541
1541
|
const eventItems = allItems.filter(
|
|
1542
|
-
(i) => (i.url.includes("/
|
|
1542
|
+
(i) => (i.url.includes("/events") || i.url.includes("/ingest")) && !i.url.includes("/batch")
|
|
1543
1543
|
);
|
|
1544
1544
|
const eventItemIds = new Set(eventItems.map((i) => i.id));
|
|
1545
1545
|
const { processed: batchProcessed, failed: batchFailed, retryIds } = await this.processEventBatches(eventItems);
|
|
@@ -1579,7 +1579,7 @@ var init_QueueProcessor = __esm({
|
|
|
1579
1579
|
const freshHeaders = this.config.getFreshHeaders?.() ?? {};
|
|
1580
1580
|
const headers = { ...persistedHeaders, ...freshHeaders };
|
|
1581
1581
|
this.log("Sending event batch", { size: batch.length, batchIndex: Math.floor(i / BATCH_SIZE) });
|
|
1582
|
-
const response = await this.httpClient.request("/
|
|
1582
|
+
const response = await this.httpClient.request("/sdk/events/batch", {
|
|
1583
1583
|
method: "POST",
|
|
1584
1584
|
body: { events: bodies },
|
|
1585
1585
|
headers,
|
|
@@ -4239,7 +4239,7 @@ var init_InstallTracker = __esm({
|
|
|
4239
4239
|
const baseUrl = apiClient.getBaseUrl();
|
|
4240
4240
|
const appKey = apiClient.getAppKey();
|
|
4241
4241
|
const referrer = await installReferrerManager.getReferrer();
|
|
4242
|
-
await fetch(`${baseUrl}/
|
|
4242
|
+
await fetch(`${baseUrl}/attribution/deferred-match/${appKey}`, {
|
|
4243
4243
|
method: "POST",
|
|
4244
4244
|
headers: { "Content-Type": "application/json", "X-App-Key": appKey },
|
|
4245
4245
|
body: JSON.stringify({
|
|
@@ -4420,8 +4420,15 @@ var init_NativePushBridge = __esm({
|
|
|
4420
4420
|
const mod = NativeModules7.PaywalloNotifications;
|
|
4421
4421
|
if (!mod) return -1;
|
|
4422
4422
|
const status = await mod.requestPermission(options ?? {});
|
|
4423
|
+
if (status === "granted" || status === "provisional") {
|
|
4424
|
+
try {
|
|
4425
|
+
await mod.registerForPush();
|
|
4426
|
+
} catch {
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4423
4429
|
return mapStatusToNumber(status);
|
|
4424
|
-
} catch {
|
|
4430
|
+
} catch (err) {
|
|
4431
|
+
console.warn("[NativePushBridge] requestPermission error:", err instanceof Error ? err.message : String(err));
|
|
4425
4432
|
return -1;
|
|
4426
4433
|
}
|
|
4427
4434
|
}
|
|
@@ -4490,6 +4497,7 @@ var init_BackgroundHandler = __esm({
|
|
|
4490
4497
|
});
|
|
4491
4498
|
|
|
4492
4499
|
// src/domains/notifications/NotificationEventTracker.ts
|
|
4500
|
+
import { Platform as Platform9 } from "react-native";
|
|
4493
4501
|
function getTimezone() {
|
|
4494
4502
|
try {
|
|
4495
4503
|
return Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC";
|
|
@@ -4498,12 +4506,7 @@ function getTimezone() {
|
|
|
4498
4506
|
}
|
|
4499
4507
|
}
|
|
4500
4508
|
function detectPlatform() {
|
|
4501
|
-
|
|
4502
|
-
const { Platform: Platform13 } = __require("react-native");
|
|
4503
|
-
return Platform13.OS === "ios" ? "ios" : "android";
|
|
4504
|
-
} catch {
|
|
4505
|
-
return "android";
|
|
4506
|
-
}
|
|
4509
|
+
return Platform9.OS === "ios" ? "ios" : "android";
|
|
4507
4510
|
}
|
|
4508
4511
|
var SEEN_MESSAGES_KEY, SEEN_TTL_MS, MAX_SEEN_SIZE, NotificationEventTracker;
|
|
4509
4512
|
var init_NotificationEventTracker = __esm({
|
|
@@ -4746,7 +4749,7 @@ var init_NotificationHandlerSetup = __esm({
|
|
|
4746
4749
|
});
|
|
4747
4750
|
|
|
4748
4751
|
// src/domains/notifications/PermissionManager.ts
|
|
4749
|
-
import { Platform as
|
|
4752
|
+
import { Platform as Platform10 } from "react-native";
|
|
4750
4753
|
function mapPermissionStatus(status) {
|
|
4751
4754
|
switch (status) {
|
|
4752
4755
|
case AUTH_STATUS.AUTHORIZED:
|
|
@@ -4760,7 +4763,7 @@ function mapPermissionStatus(status) {
|
|
|
4760
4763
|
}
|
|
4761
4764
|
}
|
|
4762
4765
|
function getPlatform() {
|
|
4763
|
-
return
|
|
4766
|
+
return Platform10;
|
|
4764
4767
|
}
|
|
4765
4768
|
function needsAndroidRuntimePermission(platform) {
|
|
4766
4769
|
if (platform.OS !== "android") return false;
|
|
@@ -4796,11 +4799,18 @@ var init_PermissionManager = __esm({
|
|
|
4796
4799
|
const platform = this.platformOverride ?? getPlatform();
|
|
4797
4800
|
if (this.debug) console.warn("[paywallo-push] platform detected:", platform.OS, "version:", String(platform.Version ?? "n/a"));
|
|
4798
4801
|
if (platform.OS === "ios") {
|
|
4799
|
-
if (this.debug) console.
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4802
|
+
if (this.debug) console.warn("[paywallo-push] requestPermission iOS \u2014 calling bridge...");
|
|
4803
|
+
try {
|
|
4804
|
+
const raw2 = await this.bridge.requestPermission(options);
|
|
4805
|
+
if (this.debug) console.warn("[paywallo-push] bridge returned raw:", raw2);
|
|
4806
|
+
const status2 = mapPermissionStatus(raw2);
|
|
4807
|
+
if (this.debug) console.warn("[paywallo-push] mapped status:", status2);
|
|
4808
|
+
this.emitOsEvent(status2);
|
|
4809
|
+
return status2;
|
|
4810
|
+
} catch (err) {
|
|
4811
|
+
console.warn("[paywallo-push] requestPermission iOS CRASHED:", err instanceof Error ? err.message : String(err));
|
|
4812
|
+
throw err;
|
|
4813
|
+
}
|
|
4804
4814
|
}
|
|
4805
4815
|
if (!needsAndroidRuntimePermission(platform)) {
|
|
4806
4816
|
if (this.debug) console.log("[paywallo-push] Android <13: auto-granted");
|
|
@@ -4925,6 +4935,7 @@ var init_NotificationsError = __esm({
|
|
|
4925
4935
|
});
|
|
4926
4936
|
|
|
4927
4937
|
// src/domains/notifications/utils.ts
|
|
4938
|
+
import { Platform as Platform11 } from "react-native";
|
|
4928
4939
|
function sleep(ms, signal) {
|
|
4929
4940
|
return new Promise((resolve, reject) => {
|
|
4930
4941
|
if (signal?.aborted) {
|
|
@@ -4980,12 +4991,7 @@ function mapPermissionStatus2(status) {
|
|
|
4980
4991
|
}
|
|
4981
4992
|
}
|
|
4982
4993
|
function detectPlatform2() {
|
|
4983
|
-
|
|
4984
|
-
const { Platform: Platform13 } = __require("react-native");
|
|
4985
|
-
return Platform13.OS === "ios" ? "ios" : "android";
|
|
4986
|
-
} catch {
|
|
4987
|
-
return "android";
|
|
4988
|
-
}
|
|
4994
|
+
return Platform11.OS === "ios" ? "ios" : "android";
|
|
4989
4995
|
}
|
|
4990
4996
|
async function getAppVersion() {
|
|
4991
4997
|
try {
|
|
@@ -5014,8 +5020,8 @@ var init_utils = __esm({
|
|
|
5014
5020
|
// src/core/version.ts
|
|
5015
5021
|
function resolveVersion() {
|
|
5016
5022
|
try {
|
|
5017
|
-
if ("2.0.
|
|
5018
|
-
return "2.0.
|
|
5023
|
+
if ("2.0.2") {
|
|
5024
|
+
return "2.0.2";
|
|
5019
5025
|
}
|
|
5020
5026
|
} catch {
|
|
5021
5027
|
}
|
|
@@ -5096,7 +5102,7 @@ var init_TokenRegistration = __esm({
|
|
|
5096
5102
|
init_utils();
|
|
5097
5103
|
init_version();
|
|
5098
5104
|
FCM_TOKEN_KEY = "@panel:push_token";
|
|
5099
|
-
TOKEN_ENDPOINT = "/
|
|
5105
|
+
TOKEN_ENDPOINT = "/push-tokens";
|
|
5100
5106
|
}
|
|
5101
5107
|
});
|
|
5102
5108
|
|
|
@@ -5293,14 +5299,23 @@ var init_NotificationsManager = __esm({
|
|
|
5293
5299
|
}
|
|
5294
5300
|
/** Requests OS permission and, on success, captures + registers the push token. */
|
|
5295
5301
|
async requestPushPermission(options) {
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
+
if (this.debug) console.warn("[Paywallo PUSH] requestPushPermission called");
|
|
5303
|
+
try {
|
|
5304
|
+
const status = await this.permissionManager.requestPermission(options);
|
|
5305
|
+
if (this.debug) console.warn("[Paywallo PUSH] permissionManager returned:", status);
|
|
5306
|
+
this.permissionStatus = status;
|
|
5307
|
+
if (status === "granted" || status === "provisional") {
|
|
5308
|
+
if (this.debug) console.warn("[Paywallo PUSH] permission granted \u2014 capturing token...");
|
|
5309
|
+
await this.captureAndRegisterToken();
|
|
5310
|
+
if (this.debug) console.warn("[Paywallo PUSH] token capture complete");
|
|
5311
|
+
} else {
|
|
5312
|
+
if (this.debug) console.warn("[Paywallo PUSH] permission not granted, skipping token register:", status);
|
|
5313
|
+
}
|
|
5314
|
+
return status;
|
|
5315
|
+
} catch (err) {
|
|
5316
|
+
console.warn("[Paywallo PUSH] requestPushPermission CRASHED:", err instanceof Error ? err.message : String(err));
|
|
5317
|
+
throw err;
|
|
5302
5318
|
}
|
|
5303
|
-
return status;
|
|
5304
5319
|
}
|
|
5305
5320
|
async captureAndRegisterToken() {
|
|
5306
5321
|
await captureAndRegisterToken(
|
|
@@ -5732,7 +5747,7 @@ function deriveWebUrl(baseUrl) {
|
|
|
5732
5747
|
}
|
|
5733
5748
|
}
|
|
5734
5749
|
function buildConditionalFlagUrl(baseUrl, flagKey, context) {
|
|
5735
|
-
const url = new URL(`${baseUrl}/
|
|
5750
|
+
const url = new URL(`${baseUrl}/sdk/conditional-flags/${flagKey}`);
|
|
5736
5751
|
if (context.platform) url.searchParams.set("platform", context.platform);
|
|
5737
5752
|
if (context.appVersion) url.searchParams.set("appVersion", context.appVersion);
|
|
5738
5753
|
if (context.country) url.searchParams.set("country", context.country);
|
|
@@ -5788,7 +5803,7 @@ async function getVariant(deps, flagKey, distinctId) {
|
|
|
5788
5803
|
return persisted;
|
|
5789
5804
|
}
|
|
5790
5805
|
try {
|
|
5791
|
-
const res = await deps.get(`/
|
|
5806
|
+
const res = await deps.get(`/sdk/flags/${flagKey}?distinctId=${encodeURIComponent(distinctId)}`);
|
|
5792
5807
|
if (res.status === 404) {
|
|
5793
5808
|
const v = { variant: null };
|
|
5794
5809
|
deps.cache.setVariant(key, v, deps.cache.nullTTL);
|
|
@@ -5809,7 +5824,7 @@ async function getVariant(deps, flagKey, distinctId) {
|
|
|
5809
5824
|
async function evaluateFlags(deps, keys, distinctId) {
|
|
5810
5825
|
const query = keys.map(encodeURIComponent).join(",");
|
|
5811
5826
|
try {
|
|
5812
|
-
const res = await deps.httpClient.get(`/
|
|
5827
|
+
const res = await deps.httpClient.get(`/sdk/flags/evaluate?keys=${query}`, {
|
|
5813
5828
|
headers: { "X-App-Key": deps.appKey, "x-distinct-id": distinctId }
|
|
5814
5829
|
});
|
|
5815
5830
|
if (!res.ok || typeof res.data !== "object" || res.data === null || Array.isArray(res.data)) return {};
|
|
@@ -5860,7 +5875,7 @@ var init_ApiClientFlags = __esm({
|
|
|
5860
5875
|
// src/domains/iap/apiPurchaseMethods.ts
|
|
5861
5876
|
async function validatePurchase(client, appKey, platform, receipt, productId, transactionId, priceLocal, currency, country, distinctId, paywallPlacement, variantKey) {
|
|
5862
5877
|
const response = await client.post(
|
|
5863
|
-
`/purchases/validate`,
|
|
5878
|
+
`/sdk/purchases/validate`,
|
|
5864
5879
|
{
|
|
5865
5880
|
platform,
|
|
5866
5881
|
receipt,
|
|
@@ -5886,7 +5901,7 @@ async function validatePurchase(client, appKey, platform, receipt, productId, tr
|
|
|
5886
5901
|
return response.data;
|
|
5887
5902
|
}
|
|
5888
5903
|
async function getSubscriptionStatus(client, baseUrl, appKey, distinctId) {
|
|
5889
|
-
const url = new URL(`${baseUrl}/purchases/status`);
|
|
5904
|
+
const url = new URL(`${baseUrl}/sdk/purchases/status`);
|
|
5890
5905
|
url.searchParams.set("distinctId", distinctId);
|
|
5891
5906
|
const response = await client.get(url.toString());
|
|
5892
5907
|
if (!response.ok) {
|
|
@@ -5896,7 +5911,7 @@ async function getSubscriptionStatus(client, baseUrl, appKey, distinctId) {
|
|
|
5896
5911
|
}
|
|
5897
5912
|
async function getEmergencyPaywall(client) {
|
|
5898
5913
|
try {
|
|
5899
|
-
const response = await client.get("/
|
|
5914
|
+
const response = await client.get("/emergency-paywall");
|
|
5900
5915
|
if (response.status === 404) return { enabled: false };
|
|
5901
5916
|
return response.data;
|
|
5902
5917
|
} catch {
|
|
@@ -5904,7 +5919,7 @@ async function getEmergencyPaywall(client) {
|
|
|
5904
5919
|
}
|
|
5905
5920
|
}
|
|
5906
5921
|
async function getCampaignData(client, baseUrl, placement, distinctId, context) {
|
|
5907
|
-
const url = new URL(`${baseUrl}/
|
|
5922
|
+
const url = new URL(`${baseUrl}/sdk/campaigns/${placement}`);
|
|
5908
5923
|
url.searchParams.set("distinctId", distinctId);
|
|
5909
5924
|
if (context) url.searchParams.set("context", JSON.stringify(context));
|
|
5910
5925
|
const response = await client.get(url.toString());
|
|
@@ -6394,7 +6409,7 @@ var init_events = __esm({
|
|
|
6394
6409
|
|
|
6395
6410
|
// src/core/eventEnvelopeV2.ts
|
|
6396
6411
|
import { z as z2 } from "zod";
|
|
6397
|
-
import { Platform as
|
|
6412
|
+
import { Platform as Platform12 } from "react-native";
|
|
6398
6413
|
function buildV2Envelope(events, providerContext) {
|
|
6399
6414
|
const context = { ...providerContext };
|
|
6400
6415
|
const v2Events = events.map((event) => {
|
|
@@ -6417,7 +6432,7 @@ function buildV2Envelope(events, providerContext) {
|
|
|
6417
6432
|
};
|
|
6418
6433
|
});
|
|
6419
6434
|
if (context.sdk_version === void 0) context.sdk_version = SDK_VERSION;
|
|
6420
|
-
if (context.platform === void 0) context.platform =
|
|
6435
|
+
if (context.platform === void 0) context.platform = Platform12.OS;
|
|
6421
6436
|
if (context.distinct_id === void 0 && events.length > 0) {
|
|
6422
6437
|
context.distinct_id = events[0].distinctId;
|
|
6423
6438
|
}
|
|
@@ -6503,7 +6518,7 @@ var init_eventEnvelopeV2 = __esm({
|
|
|
6503
6518
|
});
|
|
6504
6519
|
|
|
6505
6520
|
// src/core/EventBatcher.ts
|
|
6506
|
-
import { Platform as
|
|
6521
|
+
import { Platform as Platform13 } from "react-native";
|
|
6507
6522
|
var BATCH_MAX_SIZE, BATCH_FLUSH_MS, EVENT_NAME_REGEX, V2_BATCH_ENDPOINT, V1_BATCH_ENDPOINT, V1_SINGLE_ENDPOINT, EventBatcher;
|
|
6508
6523
|
var init_EventBatcher = __esm({
|
|
6509
6524
|
"src/core/EventBatcher.ts"() {
|
|
@@ -6513,9 +6528,9 @@ var init_EventBatcher = __esm({
|
|
|
6513
6528
|
BATCH_MAX_SIZE = 25;
|
|
6514
6529
|
BATCH_FLUSH_MS = 1e4;
|
|
6515
6530
|
EVENT_NAME_REGEX = /^(\$[a-zA-Z0-9_]+|[a-z][a-z0-9_]*)$/;
|
|
6516
|
-
V2_BATCH_ENDPOINT = "/
|
|
6517
|
-
V1_BATCH_ENDPOINT = "/
|
|
6518
|
-
V1_SINGLE_ENDPOINT = "/
|
|
6531
|
+
V2_BATCH_ENDPOINT = "/ingest/batch";
|
|
6532
|
+
V1_BATCH_ENDPOINT = "/sdk/events/batch";
|
|
6533
|
+
V1_SINGLE_ENDPOINT = "/sdk/events";
|
|
6519
6534
|
EventBatcher = class {
|
|
6520
6535
|
constructor(post, debug = false, contextProvider = null) {
|
|
6521
6536
|
this.criticalQueue = [];
|
|
@@ -6559,7 +6574,7 @@ var init_EventBatcher = __esm({
|
|
|
6559
6574
|
const event = {
|
|
6560
6575
|
eventName,
|
|
6561
6576
|
distinctId,
|
|
6562
|
-
properties: { ...properties, platform:
|
|
6577
|
+
properties: { ...properties, platform: Platform13.OS },
|
|
6563
6578
|
timestamp: timestamp ?? Date.now(),
|
|
6564
6579
|
environment: environment.toLowerCase()
|
|
6565
6580
|
};
|
|
@@ -6642,8 +6657,8 @@ var init_EventBatcher = __esm({
|
|
|
6642
6657
|
}
|
|
6643
6658
|
}
|
|
6644
6659
|
/**
|
|
6645
|
-
* POST the batch with V2 envelope semantics. Tries `/
|
|
6646
|
-
* first; on failure (404/network) falls back to `/
|
|
6660
|
+
* POST the batch with V2 envelope semantics. Tries `/ingest/batch`
|
|
6661
|
+
* first; on failure (404/network) falls back to `/events/batch`
|
|
6647
6662
|
* with the legacy per-event shape for retrocompat.
|
|
6648
6663
|
*
|
|
6649
6664
|
* After a single V2 failure we flip `v2Disabled` and stop trying V2 for
|
|
@@ -6673,7 +6688,7 @@ var init_EventBatcher = __esm({
|
|
|
6673
6688
|
this.v2Disabled = true;
|
|
6674
6689
|
if (this.debug) {
|
|
6675
6690
|
console.log(
|
|
6676
|
-
`[Paywallo EVENTS] V2 ingest unavailable, falling back to /
|
|
6691
|
+
`[Paywallo EVENTS] V2 ingest unavailable, falling back to /events/batch:`,
|
|
6677
6692
|
error
|
|
6678
6693
|
);
|
|
6679
6694
|
}
|
|
@@ -6726,7 +6741,7 @@ var init_ApiClientQueue = __esm({
|
|
|
6726
6741
|
});
|
|
6727
6742
|
|
|
6728
6743
|
// src/core/ApiClient.ts
|
|
6729
|
-
import { Platform as
|
|
6744
|
+
import { Platform as Platform14 } from "react-native";
|
|
6730
6745
|
var ApiClient;
|
|
6731
6746
|
var init_ApiClient = __esm({
|
|
6732
6747
|
"src/core/ApiClient.ts"() {
|
|
@@ -6832,7 +6847,7 @@ var init_ApiClient = __esm({
|
|
|
6832
6847
|
buildSdkHeaders() {
|
|
6833
6848
|
return {
|
|
6834
6849
|
"x-sdk-version": SDK_VERSION,
|
|
6835
|
-
"x-sdk-platform":
|
|
6850
|
+
"x-sdk-platform": Platform14.OS,
|
|
6836
6851
|
"x-sdk-environment": this.environment
|
|
6837
6852
|
};
|
|
6838
6853
|
}
|
|
@@ -6857,12 +6872,12 @@ var init_ApiClient = __esm({
|
|
|
6857
6872
|
}
|
|
6858
6873
|
async reportError(errorType, message, context) {
|
|
6859
6874
|
try {
|
|
6860
|
-
await this.post("/
|
|
6875
|
+
await this.post("/sdk/errors", {
|
|
6861
6876
|
errorType,
|
|
6862
6877
|
message,
|
|
6863
6878
|
context,
|
|
6864
6879
|
sdkVersion: SDK_VERSION,
|
|
6865
|
-
platform:
|
|
6880
|
+
platform: Platform14.OS
|
|
6866
6881
|
}, true);
|
|
6867
6882
|
} catch (err) {
|
|
6868
6883
|
if (this.debug) console.log("[Paywallo:ApiClient] reportError failed", err);
|
|
@@ -6885,8 +6900,8 @@ var init_ApiClient = __esm({
|
|
|
6885
6900
|
isDebug: () => this.debug,
|
|
6886
6901
|
post: (path, body, skipRetry) => this.post(path, body, skipRetry)
|
|
6887
6902
|
},
|
|
6888
|
-
"/
|
|
6889
|
-
{ distinctId, properties: properties ?? {}, email, platform:
|
|
6903
|
+
"/identify",
|
|
6904
|
+
{ distinctId, properties: properties ?? {}, email, platform: Platform14.OS, ...deviceId && { deviceId } },
|
|
6890
6905
|
"identify"
|
|
6891
6906
|
);
|
|
6892
6907
|
}
|
|
@@ -6901,7 +6916,7 @@ var init_ApiClient = __esm({
|
|
|
6901
6916
|
const hit = this.cache.getPaywall(placement);
|
|
6902
6917
|
if (hit !== void 0) return hit;
|
|
6903
6918
|
try {
|
|
6904
|
-
const res = await this.get(`/
|
|
6919
|
+
const res = await this.get(`/sdk/paywalls/${placement}`);
|
|
6905
6920
|
if (res.status === 404) {
|
|
6906
6921
|
this.cache.setPaywall(placement, null, this.cache.nullTTL);
|
|
6907
6922
|
return null;
|
|
@@ -7328,17 +7343,14 @@ async function resolveSessionFlags(state, keys, apiClient, distinctId) {
|
|
|
7328
7343
|
}
|
|
7329
7344
|
}
|
|
7330
7345
|
async function doInit(state, config) {
|
|
7331
|
-
console.warn("[Paywallo INIT] starting... debug=" + String(config.debug) + " env=" + String(config.environment ?? "auto"));
|
|
7332
7346
|
const environment = config.environment ?? (typeof __DEV__ !== "undefined" && __DEV__ ? "Sandbox" : "Production");
|
|
7333
7347
|
const offlineQueueEnabled = config.offlineQueueEnabled !== false;
|
|
7334
|
-
if (config.debug) console.warn("[Paywallo INIT] step 1: network + queue");
|
|
7335
7348
|
await Promise.all([
|
|
7336
7349
|
networkMonitor.initialize({ debug: config.debug }),
|
|
7337
7350
|
offlineQueue.initialize({ debug: config.debug }).then(
|
|
7338
7351
|
() => offlineQueue.clearItemsWithInvalidAppKey(config.appKey)
|
|
7339
7352
|
)
|
|
7340
7353
|
]);
|
|
7341
|
-
if (config.debug) console.warn("[Paywallo INIT] step 1 done");
|
|
7342
7354
|
const apiClient = new ApiClient(
|
|
7343
7355
|
config.appKey,
|
|
7344
7356
|
config.apiUrl ?? DEFAULT_API_URL2,
|
|
@@ -7361,9 +7373,7 @@ async function doInit(state, config) {
|
|
|
7361
7373
|
cacheTTL: config.subscriptionCacheTTL,
|
|
7362
7374
|
debug: config.debug
|
|
7363
7375
|
});
|
|
7364
|
-
if (config.debug) console.warn("[Paywallo INIT] step 2: identity");
|
|
7365
7376
|
await identityManager.initialize(apiClient, config.debug);
|
|
7366
|
-
if (config.debug) console.warn("[Paywallo INIT] step 2 done");
|
|
7367
7377
|
if (state.pendingIdentifies.length > 0) {
|
|
7368
7378
|
for (const pending of state.pendingIdentifies) {
|
|
7369
7379
|
try {
|
|
@@ -7406,22 +7416,18 @@ async function doInit(state, config) {
|
|
|
7406
7416
|
...attribution && Object.keys(attribution).length > 0 && { attribution }
|
|
7407
7417
|
};
|
|
7408
7418
|
});
|
|
7409
|
-
if (config.debug) console.warn("[Paywallo INIT] step 3: session");
|
|
7410
7419
|
await sessionManager.initialize(
|
|
7411
7420
|
apiClient,
|
|
7412
7421
|
config.sessionConfig,
|
|
7413
7422
|
config.debug,
|
|
7414
7423
|
() => identityManager.getDistinctId()
|
|
7415
7424
|
);
|
|
7416
|
-
if (config.debug) console.warn("[Paywallo INIT] step 3 done");
|
|
7417
7425
|
const eventPipeline = createEventPipelineBridge(apiClient);
|
|
7418
7426
|
onboardingManager.injectDeps({
|
|
7419
7427
|
pipeline: eventPipeline,
|
|
7420
7428
|
debug: config.debug
|
|
7421
7429
|
});
|
|
7422
|
-
if (config.debug) console.warn("[Paywallo INIT] step 4: notifications");
|
|
7423
7430
|
setupNotifications(apiClient, config, environment, eventPipeline);
|
|
7424
|
-
if (config.debug) console.warn("[Paywallo INIT] step 4 done");
|
|
7425
7431
|
if (config.autoStartSession !== false) {
|
|
7426
7432
|
sessionManager.startSession().catch((err) => {
|
|
7427
7433
|
if (config.debug) console.warn("[Paywallo INIT] autoStart session error", err);
|
|
@@ -7732,29 +7738,23 @@ var init_PaywalloClient = __esm({
|
|
|
7732
7738
|
}
|
|
7733
7739
|
async init(config) {
|
|
7734
7740
|
const s = this.state;
|
|
7735
|
-
console.warn("[Paywallo SDK] init() called, debug=" + String(config.debug) + ", appKey=" + (config.appKey ? config.appKey.substring(0, 8) + "..." : "EMPTY"));
|
|
7736
7741
|
if (!s.readyPromise) s.readyPromise = new Promise((resolve) => {
|
|
7737
7742
|
s.resolveReady = resolve;
|
|
7738
7743
|
});
|
|
7739
7744
|
if (s.config && s.apiClient) {
|
|
7740
|
-
console.warn("[Paywallo SDK] init() skipped \u2014 already initialized");
|
|
7741
7745
|
return;
|
|
7742
7746
|
}
|
|
7743
7747
|
if (s.initPromise) {
|
|
7744
|
-
console.warn("[Paywallo SDK] init() skipped \u2014 already in progress");
|
|
7745
7748
|
await s.initPromise;
|
|
7746
7749
|
return;
|
|
7747
7750
|
}
|
|
7748
7751
|
if (!config.appKey) throw new ClientError(CLIENT_ERROR_CODES.MISSING_APP_KEY, "appKey is required");
|
|
7749
7752
|
s.pendingConfig = config;
|
|
7750
7753
|
s.initAttempts = 0;
|
|
7751
|
-
console.warn("[Paywallo SDK] init() calling initWithRetry...");
|
|
7752
7754
|
s.initPromise = initWithRetry(s, config);
|
|
7753
7755
|
try {
|
|
7754
7756
|
await s.initPromise;
|
|
7755
|
-
console.warn("[Paywallo SDK] init() completed successfully");
|
|
7756
7757
|
} catch (error) {
|
|
7757
|
-
console.warn("[Paywallo SDK] init() FAILED:", error instanceof Error ? error.message : String(error));
|
|
7758
7758
|
s.initPromise = null;
|
|
7759
7759
|
s.config = null;
|
|
7760
7760
|
s.apiClient = null;
|