@virex-tech/paywallo-sdk 2.0.1 → 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 +49 -57
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -44
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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({
|
|
@@ -4497,6 +4497,7 @@ var init_BackgroundHandler = __esm({
|
|
|
4497
4497
|
});
|
|
4498
4498
|
|
|
4499
4499
|
// src/domains/notifications/NotificationEventTracker.ts
|
|
4500
|
+
import { Platform as Platform9 } from "react-native";
|
|
4500
4501
|
function getTimezone() {
|
|
4501
4502
|
try {
|
|
4502
4503
|
return Intl.DateTimeFormat().resolvedOptions().timeZone ?? "UTC";
|
|
@@ -4505,12 +4506,7 @@ function getTimezone() {
|
|
|
4505
4506
|
}
|
|
4506
4507
|
}
|
|
4507
4508
|
function detectPlatform() {
|
|
4508
|
-
|
|
4509
|
-
const { Platform: Platform13 } = __require("react-native");
|
|
4510
|
-
return Platform13.OS === "ios" ? "ios" : "android";
|
|
4511
|
-
} catch {
|
|
4512
|
-
return "android";
|
|
4513
|
-
}
|
|
4509
|
+
return Platform9.OS === "ios" ? "ios" : "android";
|
|
4514
4510
|
}
|
|
4515
4511
|
var SEEN_MESSAGES_KEY, SEEN_TTL_MS, MAX_SEEN_SIZE, NotificationEventTracker;
|
|
4516
4512
|
var init_NotificationEventTracker = __esm({
|
|
@@ -4753,7 +4749,7 @@ var init_NotificationHandlerSetup = __esm({
|
|
|
4753
4749
|
});
|
|
4754
4750
|
|
|
4755
4751
|
// src/domains/notifications/PermissionManager.ts
|
|
4756
|
-
import { Platform as
|
|
4752
|
+
import { Platform as Platform10 } from "react-native";
|
|
4757
4753
|
function mapPermissionStatus(status) {
|
|
4758
4754
|
switch (status) {
|
|
4759
4755
|
case AUTH_STATUS.AUTHORIZED:
|
|
@@ -4767,7 +4763,7 @@ function mapPermissionStatus(status) {
|
|
|
4767
4763
|
}
|
|
4768
4764
|
}
|
|
4769
4765
|
function getPlatform() {
|
|
4770
|
-
return
|
|
4766
|
+
return Platform10;
|
|
4771
4767
|
}
|
|
4772
4768
|
function needsAndroidRuntimePermission(platform) {
|
|
4773
4769
|
if (platform.OS !== "android") return false;
|
|
@@ -4939,6 +4935,7 @@ var init_NotificationsError = __esm({
|
|
|
4939
4935
|
});
|
|
4940
4936
|
|
|
4941
4937
|
// src/domains/notifications/utils.ts
|
|
4938
|
+
import { Platform as Platform11 } from "react-native";
|
|
4942
4939
|
function sleep(ms, signal) {
|
|
4943
4940
|
return new Promise((resolve, reject) => {
|
|
4944
4941
|
if (signal?.aborted) {
|
|
@@ -4994,12 +4991,7 @@ function mapPermissionStatus2(status) {
|
|
|
4994
4991
|
}
|
|
4995
4992
|
}
|
|
4996
4993
|
function detectPlatform2() {
|
|
4997
|
-
|
|
4998
|
-
const { Platform: Platform13 } = __require("react-native");
|
|
4999
|
-
return Platform13.OS === "ios" ? "ios" : "android";
|
|
5000
|
-
} catch {
|
|
5001
|
-
return "android";
|
|
5002
|
-
}
|
|
4994
|
+
return Platform11.OS === "ios" ? "ios" : "android";
|
|
5003
4995
|
}
|
|
5004
4996
|
async function getAppVersion() {
|
|
5005
4997
|
try {
|
|
@@ -5028,8 +5020,8 @@ var init_utils = __esm({
|
|
|
5028
5020
|
// src/core/version.ts
|
|
5029
5021
|
function resolveVersion() {
|
|
5030
5022
|
try {
|
|
5031
|
-
if ("2.0.
|
|
5032
|
-
return "2.0.
|
|
5023
|
+
if ("2.0.2") {
|
|
5024
|
+
return "2.0.2";
|
|
5033
5025
|
}
|
|
5034
5026
|
} catch {
|
|
5035
5027
|
}
|
|
@@ -5110,7 +5102,7 @@ var init_TokenRegistration = __esm({
|
|
|
5110
5102
|
init_utils();
|
|
5111
5103
|
init_version();
|
|
5112
5104
|
FCM_TOKEN_KEY = "@panel:push_token";
|
|
5113
|
-
TOKEN_ENDPOINT = "/
|
|
5105
|
+
TOKEN_ENDPOINT = "/push-tokens";
|
|
5114
5106
|
}
|
|
5115
5107
|
});
|
|
5116
5108
|
|
|
@@ -5755,7 +5747,7 @@ function deriveWebUrl(baseUrl) {
|
|
|
5755
5747
|
}
|
|
5756
5748
|
}
|
|
5757
5749
|
function buildConditionalFlagUrl(baseUrl, flagKey, context) {
|
|
5758
|
-
const url = new URL(`${baseUrl}/
|
|
5750
|
+
const url = new URL(`${baseUrl}/sdk/conditional-flags/${flagKey}`);
|
|
5759
5751
|
if (context.platform) url.searchParams.set("platform", context.platform);
|
|
5760
5752
|
if (context.appVersion) url.searchParams.set("appVersion", context.appVersion);
|
|
5761
5753
|
if (context.country) url.searchParams.set("country", context.country);
|
|
@@ -5811,7 +5803,7 @@ async function getVariant(deps, flagKey, distinctId) {
|
|
|
5811
5803
|
return persisted;
|
|
5812
5804
|
}
|
|
5813
5805
|
try {
|
|
5814
|
-
const res = await deps.get(`/
|
|
5806
|
+
const res = await deps.get(`/sdk/flags/${flagKey}?distinctId=${encodeURIComponent(distinctId)}`);
|
|
5815
5807
|
if (res.status === 404) {
|
|
5816
5808
|
const v = { variant: null };
|
|
5817
5809
|
deps.cache.setVariant(key, v, deps.cache.nullTTL);
|
|
@@ -5832,7 +5824,7 @@ async function getVariant(deps, flagKey, distinctId) {
|
|
|
5832
5824
|
async function evaluateFlags(deps, keys, distinctId) {
|
|
5833
5825
|
const query = keys.map(encodeURIComponent).join(",");
|
|
5834
5826
|
try {
|
|
5835
|
-
const res = await deps.httpClient.get(`/
|
|
5827
|
+
const res = await deps.httpClient.get(`/sdk/flags/evaluate?keys=${query}`, {
|
|
5836
5828
|
headers: { "X-App-Key": deps.appKey, "x-distinct-id": distinctId }
|
|
5837
5829
|
});
|
|
5838
5830
|
if (!res.ok || typeof res.data !== "object" || res.data === null || Array.isArray(res.data)) return {};
|
|
@@ -5883,7 +5875,7 @@ var init_ApiClientFlags = __esm({
|
|
|
5883
5875
|
// src/domains/iap/apiPurchaseMethods.ts
|
|
5884
5876
|
async function validatePurchase(client, appKey, platform, receipt, productId, transactionId, priceLocal, currency, country, distinctId, paywallPlacement, variantKey) {
|
|
5885
5877
|
const response = await client.post(
|
|
5886
|
-
`/purchases/validate`,
|
|
5878
|
+
`/sdk/purchases/validate`,
|
|
5887
5879
|
{
|
|
5888
5880
|
platform,
|
|
5889
5881
|
receipt,
|
|
@@ -5909,7 +5901,7 @@ async function validatePurchase(client, appKey, platform, receipt, productId, tr
|
|
|
5909
5901
|
return response.data;
|
|
5910
5902
|
}
|
|
5911
5903
|
async function getSubscriptionStatus(client, baseUrl, appKey, distinctId) {
|
|
5912
|
-
const url = new URL(`${baseUrl}/purchases/status`);
|
|
5904
|
+
const url = new URL(`${baseUrl}/sdk/purchases/status`);
|
|
5913
5905
|
url.searchParams.set("distinctId", distinctId);
|
|
5914
5906
|
const response = await client.get(url.toString());
|
|
5915
5907
|
if (!response.ok) {
|
|
@@ -5919,7 +5911,7 @@ async function getSubscriptionStatus(client, baseUrl, appKey, distinctId) {
|
|
|
5919
5911
|
}
|
|
5920
5912
|
async function getEmergencyPaywall(client) {
|
|
5921
5913
|
try {
|
|
5922
|
-
const response = await client.get("/
|
|
5914
|
+
const response = await client.get("/emergency-paywall");
|
|
5923
5915
|
if (response.status === 404) return { enabled: false };
|
|
5924
5916
|
return response.data;
|
|
5925
5917
|
} catch {
|
|
@@ -5927,7 +5919,7 @@ async function getEmergencyPaywall(client) {
|
|
|
5927
5919
|
}
|
|
5928
5920
|
}
|
|
5929
5921
|
async function getCampaignData(client, baseUrl, placement, distinctId, context) {
|
|
5930
|
-
const url = new URL(`${baseUrl}/
|
|
5922
|
+
const url = new URL(`${baseUrl}/sdk/campaigns/${placement}`);
|
|
5931
5923
|
url.searchParams.set("distinctId", distinctId);
|
|
5932
5924
|
if (context) url.searchParams.set("context", JSON.stringify(context));
|
|
5933
5925
|
const response = await client.get(url.toString());
|
|
@@ -6417,7 +6409,7 @@ var init_events = __esm({
|
|
|
6417
6409
|
|
|
6418
6410
|
// src/core/eventEnvelopeV2.ts
|
|
6419
6411
|
import { z as z2 } from "zod";
|
|
6420
|
-
import { Platform as
|
|
6412
|
+
import { Platform as Platform12 } from "react-native";
|
|
6421
6413
|
function buildV2Envelope(events, providerContext) {
|
|
6422
6414
|
const context = { ...providerContext };
|
|
6423
6415
|
const v2Events = events.map((event) => {
|
|
@@ -6440,7 +6432,7 @@ function buildV2Envelope(events, providerContext) {
|
|
|
6440
6432
|
};
|
|
6441
6433
|
});
|
|
6442
6434
|
if (context.sdk_version === void 0) context.sdk_version = SDK_VERSION;
|
|
6443
|
-
if (context.platform === void 0) context.platform =
|
|
6435
|
+
if (context.platform === void 0) context.platform = Platform12.OS;
|
|
6444
6436
|
if (context.distinct_id === void 0 && events.length > 0) {
|
|
6445
6437
|
context.distinct_id = events[0].distinctId;
|
|
6446
6438
|
}
|
|
@@ -6526,7 +6518,7 @@ var init_eventEnvelopeV2 = __esm({
|
|
|
6526
6518
|
});
|
|
6527
6519
|
|
|
6528
6520
|
// src/core/EventBatcher.ts
|
|
6529
|
-
import { Platform as
|
|
6521
|
+
import { Platform as Platform13 } from "react-native";
|
|
6530
6522
|
var BATCH_MAX_SIZE, BATCH_FLUSH_MS, EVENT_NAME_REGEX, V2_BATCH_ENDPOINT, V1_BATCH_ENDPOINT, V1_SINGLE_ENDPOINT, EventBatcher;
|
|
6531
6523
|
var init_EventBatcher = __esm({
|
|
6532
6524
|
"src/core/EventBatcher.ts"() {
|
|
@@ -6536,9 +6528,9 @@ var init_EventBatcher = __esm({
|
|
|
6536
6528
|
BATCH_MAX_SIZE = 25;
|
|
6537
6529
|
BATCH_FLUSH_MS = 1e4;
|
|
6538
6530
|
EVENT_NAME_REGEX = /^(\$[a-zA-Z0-9_]+|[a-z][a-z0-9_]*)$/;
|
|
6539
|
-
V2_BATCH_ENDPOINT = "/
|
|
6540
|
-
V1_BATCH_ENDPOINT = "/
|
|
6541
|
-
V1_SINGLE_ENDPOINT = "/
|
|
6531
|
+
V2_BATCH_ENDPOINT = "/ingest/batch";
|
|
6532
|
+
V1_BATCH_ENDPOINT = "/sdk/events/batch";
|
|
6533
|
+
V1_SINGLE_ENDPOINT = "/sdk/events";
|
|
6542
6534
|
EventBatcher = class {
|
|
6543
6535
|
constructor(post, debug = false, contextProvider = null) {
|
|
6544
6536
|
this.criticalQueue = [];
|
|
@@ -6582,7 +6574,7 @@ var init_EventBatcher = __esm({
|
|
|
6582
6574
|
const event = {
|
|
6583
6575
|
eventName,
|
|
6584
6576
|
distinctId,
|
|
6585
|
-
properties: { ...properties, platform:
|
|
6577
|
+
properties: { ...properties, platform: Platform13.OS },
|
|
6586
6578
|
timestamp: timestamp ?? Date.now(),
|
|
6587
6579
|
environment: environment.toLowerCase()
|
|
6588
6580
|
};
|
|
@@ -6665,8 +6657,8 @@ var init_EventBatcher = __esm({
|
|
|
6665
6657
|
}
|
|
6666
6658
|
}
|
|
6667
6659
|
/**
|
|
6668
|
-
* POST the batch with V2 envelope semantics. Tries `/
|
|
6669
|
-
* 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`
|
|
6670
6662
|
* with the legacy per-event shape for retrocompat.
|
|
6671
6663
|
*
|
|
6672
6664
|
* After a single V2 failure we flip `v2Disabled` and stop trying V2 for
|
|
@@ -6696,7 +6688,7 @@ var init_EventBatcher = __esm({
|
|
|
6696
6688
|
this.v2Disabled = true;
|
|
6697
6689
|
if (this.debug) {
|
|
6698
6690
|
console.log(
|
|
6699
|
-
`[Paywallo EVENTS] V2 ingest unavailable, falling back to /
|
|
6691
|
+
`[Paywallo EVENTS] V2 ingest unavailable, falling back to /events/batch:`,
|
|
6700
6692
|
error
|
|
6701
6693
|
);
|
|
6702
6694
|
}
|
|
@@ -6749,7 +6741,7 @@ var init_ApiClientQueue = __esm({
|
|
|
6749
6741
|
});
|
|
6750
6742
|
|
|
6751
6743
|
// src/core/ApiClient.ts
|
|
6752
|
-
import { Platform as
|
|
6744
|
+
import { Platform as Platform14 } from "react-native";
|
|
6753
6745
|
var ApiClient;
|
|
6754
6746
|
var init_ApiClient = __esm({
|
|
6755
6747
|
"src/core/ApiClient.ts"() {
|
|
@@ -6855,7 +6847,7 @@ var init_ApiClient = __esm({
|
|
|
6855
6847
|
buildSdkHeaders() {
|
|
6856
6848
|
return {
|
|
6857
6849
|
"x-sdk-version": SDK_VERSION,
|
|
6858
|
-
"x-sdk-platform":
|
|
6850
|
+
"x-sdk-platform": Platform14.OS,
|
|
6859
6851
|
"x-sdk-environment": this.environment
|
|
6860
6852
|
};
|
|
6861
6853
|
}
|
|
@@ -6880,12 +6872,12 @@ var init_ApiClient = __esm({
|
|
|
6880
6872
|
}
|
|
6881
6873
|
async reportError(errorType, message, context) {
|
|
6882
6874
|
try {
|
|
6883
|
-
await this.post("/
|
|
6875
|
+
await this.post("/sdk/errors", {
|
|
6884
6876
|
errorType,
|
|
6885
6877
|
message,
|
|
6886
6878
|
context,
|
|
6887
6879
|
sdkVersion: SDK_VERSION,
|
|
6888
|
-
platform:
|
|
6880
|
+
platform: Platform14.OS
|
|
6889
6881
|
}, true);
|
|
6890
6882
|
} catch (err) {
|
|
6891
6883
|
if (this.debug) console.log("[Paywallo:ApiClient] reportError failed", err);
|
|
@@ -6908,8 +6900,8 @@ var init_ApiClient = __esm({
|
|
|
6908
6900
|
isDebug: () => this.debug,
|
|
6909
6901
|
post: (path, body, skipRetry) => this.post(path, body, skipRetry)
|
|
6910
6902
|
},
|
|
6911
|
-
"/
|
|
6912
|
-
{ distinctId, properties: properties ?? {}, email, platform:
|
|
6903
|
+
"/identify",
|
|
6904
|
+
{ distinctId, properties: properties ?? {}, email, platform: Platform14.OS, ...deviceId && { deviceId } },
|
|
6913
6905
|
"identify"
|
|
6914
6906
|
);
|
|
6915
6907
|
}
|
|
@@ -6924,7 +6916,7 @@ var init_ApiClient = __esm({
|
|
|
6924
6916
|
const hit = this.cache.getPaywall(placement);
|
|
6925
6917
|
if (hit !== void 0) return hit;
|
|
6926
6918
|
try {
|
|
6927
|
-
const res = await this.get(`/
|
|
6919
|
+
const res = await this.get(`/sdk/paywalls/${placement}`);
|
|
6928
6920
|
if (res.status === 404) {
|
|
6929
6921
|
this.cache.setPaywall(placement, null, this.cache.nullTTL);
|
|
6930
6922
|
return null;
|