@virex-tech/paywallo-sdk 2.0.1 → 2.1.0
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 +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +72 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +59 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -530,8 +530,8 @@ interface EventContext {
|
|
|
530
530
|
* `lifecycle` (foreground/background/session), `onboarding`,
|
|
531
531
|
* `notification`, `custom`.
|
|
532
532
|
*
|
|
533
|
-
* Both priorities post to `/
|
|
534
|
-
* automatic fallback to `/
|
|
533
|
+
* Both priorities post to `/ingest/batch` (Phase 3.1 envelope) with
|
|
534
|
+
* automatic fallback to `/events/batch` when the V2 endpoint is
|
|
535
535
|
* absent (old server) or rejects the request. `OfflineQueue` handles
|
|
536
536
|
* network-failure durability for both queues via the `PostFn` injected by
|
|
537
537
|
* `ApiClient.postWithQueue`.
|
|
@@ -843,6 +843,7 @@ interface DeviceTokenRegistration {
|
|
|
843
843
|
deviceId?: string;
|
|
844
844
|
locale?: string;
|
|
845
845
|
timezone?: string;
|
|
846
|
+
environment?: "sandbox" | "production";
|
|
846
847
|
}
|
|
847
848
|
interface NotificationPayload {
|
|
848
849
|
notificationId: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -530,8 +530,8 @@ interface EventContext {
|
|
|
530
530
|
* `lifecycle` (foreground/background/session), `onboarding`,
|
|
531
531
|
* `notification`, `custom`.
|
|
532
532
|
*
|
|
533
|
-
* Both priorities post to `/
|
|
534
|
-
* automatic fallback to `/
|
|
533
|
+
* Both priorities post to `/ingest/batch` (Phase 3.1 envelope) with
|
|
534
|
+
* automatic fallback to `/events/batch` when the V2 endpoint is
|
|
535
535
|
* absent (old server) or rejects the request. `OfflineQueue` handles
|
|
536
536
|
* network-failure durability for both queues via the `PostFn` injected by
|
|
537
537
|
* `ApiClient.postWithQueue`.
|
|
@@ -843,6 +843,7 @@ interface DeviceTokenRegistration {
|
|
|
843
843
|
deviceId?: string;
|
|
844
844
|
locale?: string;
|
|
845
845
|
timezone?: string;
|
|
846
|
+
environment?: "sandbox" | "production";
|
|
846
847
|
}
|
|
847
848
|
interface NotificationPayload {
|
|
848
849
|
notificationId: string;
|
package/dist/index.js
CHANGED
|
@@ -1555,7 +1555,7 @@ var init_QueueProcessor = __esm({
|
|
|
1555
1555
|
}
|
|
1556
1556
|
const allItems = offlineQueue.getQueue();
|
|
1557
1557
|
const eventItems = allItems.filter(
|
|
1558
|
-
(i) => (i.url.includes("/
|
|
1558
|
+
(i) => (i.url.includes("/events") || i.url.includes("/ingest")) && !i.url.includes("/batch")
|
|
1559
1559
|
);
|
|
1560
1560
|
const eventItemIds = new Set(eventItems.map((i) => i.id));
|
|
1561
1561
|
const { processed: batchProcessed, failed: batchFailed, retryIds } = await this.processEventBatches(eventItems);
|
|
@@ -1595,7 +1595,7 @@ var init_QueueProcessor = __esm({
|
|
|
1595
1595
|
const freshHeaders = this.config.getFreshHeaders?.() ?? {};
|
|
1596
1596
|
const headers = { ...persistedHeaders, ...freshHeaders };
|
|
1597
1597
|
this.log("Sending event batch", { size: batch.length, batchIndex: Math.floor(i / BATCH_SIZE) });
|
|
1598
|
-
const response = await this.httpClient.request("/
|
|
1598
|
+
const response = await this.httpClient.request("/sdk/events/batch", {
|
|
1599
1599
|
method: "POST",
|
|
1600
1600
|
body: { events: bodies },
|
|
1601
1601
|
headers,
|
|
@@ -4243,7 +4243,7 @@ var init_InstallTracker = __esm({
|
|
|
4243
4243
|
const baseUrl = apiClient.getBaseUrl();
|
|
4244
4244
|
const appKey = apiClient.getAppKey();
|
|
4245
4245
|
const referrer = await installReferrerManager.getReferrer();
|
|
4246
|
-
await fetch(`${baseUrl}/
|
|
4246
|
+
await fetch(`${baseUrl}/attribution/deferred-match/${appKey}`, {
|
|
4247
4247
|
method: "POST",
|
|
4248
4248
|
headers: { "Content-Type": "application/json", "X-App-Key": appKey },
|
|
4249
4249
|
body: JSON.stringify({
|
|
@@ -4509,17 +4509,13 @@ function getTimezone() {
|
|
|
4509
4509
|
}
|
|
4510
4510
|
}
|
|
4511
4511
|
function detectPlatform() {
|
|
4512
|
-
|
|
4513
|
-
const { Platform: Platform13 } = require("react-native");
|
|
4514
|
-
return Platform13.OS === "ios" ? "ios" : "android";
|
|
4515
|
-
} catch {
|
|
4516
|
-
return "android";
|
|
4517
|
-
}
|
|
4512
|
+
return import_react_native18.Platform.OS === "ios" ? "ios" : "android";
|
|
4518
4513
|
}
|
|
4519
|
-
var SEEN_MESSAGES_KEY, SEEN_TTL_MS, MAX_SEEN_SIZE, NotificationEventTracker;
|
|
4514
|
+
var import_react_native18, SEEN_MESSAGES_KEY, SEEN_TTL_MS, MAX_SEEN_SIZE, NotificationEventTracker;
|
|
4520
4515
|
var init_NotificationEventTracker = __esm({
|
|
4521
4516
|
"src/domains/notifications/NotificationEventTracker.ts"() {
|
|
4522
4517
|
"use strict";
|
|
4518
|
+
import_react_native18 = require("react-native");
|
|
4523
4519
|
SEEN_MESSAGES_KEY = "seen_messages";
|
|
4524
4520
|
SEEN_TTL_MS = 60 * 60 * 1e3;
|
|
4525
4521
|
MAX_SEEN_SIZE = 1e3;
|
|
@@ -4770,18 +4766,18 @@ function mapPermissionStatus(status) {
|
|
|
4770
4766
|
}
|
|
4771
4767
|
}
|
|
4772
4768
|
function getPlatform() {
|
|
4773
|
-
return
|
|
4769
|
+
return import_react_native19.Platform;
|
|
4774
4770
|
}
|
|
4775
4771
|
function needsAndroidRuntimePermission(platform) {
|
|
4776
4772
|
if (platform.OS !== "android") return false;
|
|
4777
4773
|
const v = typeof platform.Version === "string" ? parseInt(platform.Version, 10) : platform.Version ?? 0;
|
|
4778
4774
|
return Number.isFinite(v) && v >= ANDROID_TIRAMISU_API;
|
|
4779
4775
|
}
|
|
4780
|
-
var
|
|
4776
|
+
var import_react_native19, AUTH_STATUS, ANDROID_TIRAMISU_API, PermissionManager;
|
|
4781
4777
|
var init_PermissionManager = __esm({
|
|
4782
4778
|
"src/domains/notifications/PermissionManager.ts"() {
|
|
4783
4779
|
"use strict";
|
|
4784
|
-
|
|
4780
|
+
import_react_native19 = require("react-native");
|
|
4785
4781
|
AUTH_STATUS = {
|
|
4786
4782
|
NOT_DETERMINED: -1,
|
|
4787
4783
|
DENIED: 0,
|
|
@@ -4895,6 +4891,16 @@ var init_PermissionManager = __esm({
|
|
|
4895
4891
|
}
|
|
4896
4892
|
});
|
|
4897
4893
|
|
|
4894
|
+
// src/core/constants.ts
|
|
4895
|
+
var DEFAULT_API_URL, DEFAULT_WEB_URL;
|
|
4896
|
+
var init_constants = __esm({
|
|
4897
|
+
"src/core/constants.ts"() {
|
|
4898
|
+
"use strict";
|
|
4899
|
+
DEFAULT_API_URL = "https://panel.lucasqueiroga.shop";
|
|
4900
|
+
DEFAULT_WEB_URL = "https://paywallo.com.br";
|
|
4901
|
+
}
|
|
4902
|
+
});
|
|
4903
|
+
|
|
4898
4904
|
// src/domains/notifications/config.ts
|
|
4899
4905
|
function resolveApiBaseUrl(config) {
|
|
4900
4906
|
if (config.apiBaseUrl) return config.apiBaseUrl;
|
|
@@ -4905,8 +4911,9 @@ var DEFAULT_API_BASE_URL, SANDBOX_API_BASE_URL;
|
|
|
4905
4911
|
var init_config = __esm({
|
|
4906
4912
|
"src/domains/notifications/config.ts"() {
|
|
4907
4913
|
"use strict";
|
|
4908
|
-
|
|
4909
|
-
|
|
4914
|
+
init_constants();
|
|
4915
|
+
DEFAULT_API_BASE_URL = DEFAULT_API_URL;
|
|
4916
|
+
SANDBOX_API_BASE_URL = DEFAULT_API_URL;
|
|
4910
4917
|
}
|
|
4911
4918
|
});
|
|
4912
4919
|
|
|
@@ -4998,12 +5005,10 @@ function mapPermissionStatus2(status) {
|
|
|
4998
5005
|
}
|
|
4999
5006
|
}
|
|
5000
5007
|
function detectPlatform2() {
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
return "android";
|
|
5006
|
-
}
|
|
5008
|
+
return import_react_native20.Platform.OS === "ios" ? "ios" : "android";
|
|
5009
|
+
}
|
|
5010
|
+
function detectEnvironment() {
|
|
5011
|
+
return typeof __DEV__ !== "undefined" && __DEV__ ? "sandbox" : "production";
|
|
5007
5012
|
}
|
|
5008
5013
|
async function getAppVersion() {
|
|
5009
5014
|
try {
|
|
@@ -5014,10 +5019,11 @@ async function getAppVersion() {
|
|
|
5014
5019
|
return "unknown";
|
|
5015
5020
|
}
|
|
5016
5021
|
}
|
|
5017
|
-
var AUTH_STATUS2, LOCALE_WHITELIST;
|
|
5022
|
+
var import_react_native20, AUTH_STATUS2, LOCALE_WHITELIST;
|
|
5018
5023
|
var init_utils = __esm({
|
|
5019
5024
|
"src/domains/notifications/utils.ts"() {
|
|
5020
5025
|
"use strict";
|
|
5026
|
+
import_react_native20 = require("react-native");
|
|
5021
5027
|
init_NotificationsError();
|
|
5022
5028
|
AUTH_STATUS2 = {
|
|
5023
5029
|
NOT_DETERMINED: -1,
|
|
@@ -5032,8 +5038,8 @@ var init_utils = __esm({
|
|
|
5032
5038
|
// src/core/version.ts
|
|
5033
5039
|
function resolveVersion() {
|
|
5034
5040
|
try {
|
|
5035
|
-
if ("2.0
|
|
5036
|
-
return "2.0
|
|
5041
|
+
if ("2.1.0") {
|
|
5042
|
+
return "2.1.0";
|
|
5037
5043
|
}
|
|
5038
5044
|
} catch {
|
|
5039
5045
|
}
|
|
@@ -5072,7 +5078,8 @@ async function buildRegistration(token, getDeviceId, getDistinctId) {
|
|
|
5072
5078
|
sdk_version: SDK_VERSION,
|
|
5073
5079
|
deviceId: getDeviceId?.() ?? void 0,
|
|
5074
5080
|
locale: getLocale(),
|
|
5075
|
-
timezone: getTimezone2()
|
|
5081
|
+
timezone: getTimezone2(),
|
|
5082
|
+
environment: detectEnvironment()
|
|
5076
5083
|
};
|
|
5077
5084
|
}
|
|
5078
5085
|
async function registerToken(deps, token) {
|
|
@@ -5114,7 +5121,7 @@ var init_TokenRegistration = __esm({
|
|
|
5114
5121
|
init_utils();
|
|
5115
5122
|
init_version();
|
|
5116
5123
|
FCM_TOKEN_KEY = "@panel:push_token";
|
|
5117
|
-
TOKEN_ENDPOINT = "/
|
|
5124
|
+
TOKEN_ENDPOINT = "/push-tokens";
|
|
5118
5125
|
}
|
|
5119
5126
|
});
|
|
5120
5127
|
|
|
@@ -5759,18 +5766,17 @@ function deriveWebUrl(baseUrl) {
|
|
|
5759
5766
|
}
|
|
5760
5767
|
}
|
|
5761
5768
|
function buildConditionalFlagUrl(baseUrl, flagKey, context) {
|
|
5762
|
-
const url = new URL(`${baseUrl}/
|
|
5769
|
+
const url = new URL(`${baseUrl}/sdk/conditional-flags/${flagKey}`);
|
|
5763
5770
|
if (context.platform) url.searchParams.set("platform", context.platform);
|
|
5764
5771
|
if (context.appVersion) url.searchParams.set("appVersion", context.appVersion);
|
|
5765
5772
|
if (context.country) url.searchParams.set("country", context.country);
|
|
5766
5773
|
if (context.distinctId) url.searchParams.set("distinctId", context.distinctId);
|
|
5767
5774
|
return url.toString();
|
|
5768
5775
|
}
|
|
5769
|
-
var DEFAULT_WEB_URL;
|
|
5770
5776
|
var init_apiUrlUtils = __esm({
|
|
5771
5777
|
"src/core/apiUrlUtils.ts"() {
|
|
5772
5778
|
"use strict";
|
|
5773
|
-
|
|
5779
|
+
init_constants();
|
|
5774
5780
|
}
|
|
5775
5781
|
});
|
|
5776
5782
|
|
|
@@ -5815,7 +5821,7 @@ async function getVariant(deps, flagKey, distinctId) {
|
|
|
5815
5821
|
return persisted;
|
|
5816
5822
|
}
|
|
5817
5823
|
try {
|
|
5818
|
-
const res = await deps.get(`/
|
|
5824
|
+
const res = await deps.get(`/sdk/flags/${flagKey}?distinctId=${encodeURIComponent(distinctId)}`);
|
|
5819
5825
|
if (res.status === 404) {
|
|
5820
5826
|
const v = { variant: null };
|
|
5821
5827
|
deps.cache.setVariant(key, v, deps.cache.nullTTL);
|
|
@@ -5836,7 +5842,7 @@ async function getVariant(deps, flagKey, distinctId) {
|
|
|
5836
5842
|
async function evaluateFlags(deps, keys, distinctId) {
|
|
5837
5843
|
const query = keys.map(encodeURIComponent).join(",");
|
|
5838
5844
|
try {
|
|
5839
|
-
const res = await deps.httpClient.get(`/
|
|
5845
|
+
const res = await deps.httpClient.get(`/sdk/flags/evaluate?keys=${query}`, {
|
|
5840
5846
|
headers: { "X-App-Key": deps.appKey, "x-distinct-id": distinctId }
|
|
5841
5847
|
});
|
|
5842
5848
|
if (!res.ok || typeof res.data !== "object" || res.data === null || Array.isArray(res.data)) return {};
|
|
@@ -5887,7 +5893,7 @@ var init_ApiClientFlags = __esm({
|
|
|
5887
5893
|
// src/domains/iap/apiPurchaseMethods.ts
|
|
5888
5894
|
async function validatePurchase(client, appKey, platform, receipt, productId, transactionId, priceLocal, currency, country, distinctId, paywallPlacement, variantKey) {
|
|
5889
5895
|
const response = await client.post(
|
|
5890
|
-
`/purchases/validate`,
|
|
5896
|
+
`/sdk/purchases/validate`,
|
|
5891
5897
|
{
|
|
5892
5898
|
platform,
|
|
5893
5899
|
receipt,
|
|
@@ -5913,7 +5919,7 @@ async function validatePurchase(client, appKey, platform, receipt, productId, tr
|
|
|
5913
5919
|
return response.data;
|
|
5914
5920
|
}
|
|
5915
5921
|
async function getSubscriptionStatus(client, baseUrl, appKey, distinctId) {
|
|
5916
|
-
const url = new URL(`${baseUrl}/purchases/status`);
|
|
5922
|
+
const url = new URL(`${baseUrl}/sdk/purchases/status`);
|
|
5917
5923
|
url.searchParams.set("distinctId", distinctId);
|
|
5918
5924
|
const response = await client.get(url.toString());
|
|
5919
5925
|
if (!response.ok) {
|
|
@@ -5923,7 +5929,7 @@ async function getSubscriptionStatus(client, baseUrl, appKey, distinctId) {
|
|
|
5923
5929
|
}
|
|
5924
5930
|
async function getEmergencyPaywall(client) {
|
|
5925
5931
|
try {
|
|
5926
|
-
const response = await client.get("/
|
|
5932
|
+
const response = await client.get("/emergency-paywall");
|
|
5927
5933
|
if (response.status === 404) return { enabled: false };
|
|
5928
5934
|
return response.data;
|
|
5929
5935
|
} catch {
|
|
@@ -5931,7 +5937,7 @@ async function getEmergencyPaywall(client) {
|
|
|
5931
5937
|
}
|
|
5932
5938
|
}
|
|
5933
5939
|
async function getCampaignData(client, baseUrl, placement, distinctId, context) {
|
|
5934
|
-
const url = new URL(`${baseUrl}/
|
|
5940
|
+
const url = new URL(`${baseUrl}/sdk/campaigns/${placement}`);
|
|
5935
5941
|
url.searchParams.set("distinctId", distinctId);
|
|
5936
5942
|
if (context) url.searchParams.set("context", JSON.stringify(context));
|
|
5937
5943
|
const response = await client.get(url.toString());
|
|
@@ -6442,7 +6448,7 @@ function buildV2Envelope(events, providerContext) {
|
|
|
6442
6448
|
};
|
|
6443
6449
|
});
|
|
6444
6450
|
if (context.sdk_version === void 0) context.sdk_version = SDK_VERSION;
|
|
6445
|
-
if (context.platform === void 0) context.platform =
|
|
6451
|
+
if (context.platform === void 0) context.platform = import_react_native21.Platform.OS;
|
|
6446
6452
|
if (context.distinct_id === void 0 && events.length > 0) {
|
|
6447
6453
|
context.distinct_id = events[0].distinctId;
|
|
6448
6454
|
}
|
|
@@ -6479,12 +6485,12 @@ function splitPayloadAndContext(properties) {
|
|
|
6479
6485
|
}
|
|
6480
6486
|
return { payload, promoted };
|
|
6481
6487
|
}
|
|
6482
|
-
var import_zod2,
|
|
6488
|
+
var import_zod2, import_react_native21, v2EventSchema, v2ContextSchema, v2EnvelopeSchema, CONTEXT_KEY_ALIASES;
|
|
6483
6489
|
var init_eventEnvelopeV2 = __esm({
|
|
6484
6490
|
"src/core/eventEnvelopeV2.ts"() {
|
|
6485
6491
|
"use strict";
|
|
6486
6492
|
import_zod2 = require("zod");
|
|
6487
|
-
|
|
6493
|
+
import_react_native21 = require("react-native");
|
|
6488
6494
|
init_version();
|
|
6489
6495
|
init_uuid();
|
|
6490
6496
|
init_eventFamilies();
|
|
@@ -6530,19 +6536,19 @@ var init_eventEnvelopeV2 = __esm({
|
|
|
6530
6536
|
});
|
|
6531
6537
|
|
|
6532
6538
|
// src/core/EventBatcher.ts
|
|
6533
|
-
var
|
|
6539
|
+
var import_react_native22, BATCH_MAX_SIZE, BATCH_FLUSH_MS, EVENT_NAME_REGEX, V2_BATCH_ENDPOINT, V1_BATCH_ENDPOINT, V1_SINGLE_ENDPOINT, EventBatcher;
|
|
6534
6540
|
var init_EventBatcher = __esm({
|
|
6535
6541
|
"src/core/EventBatcher.ts"() {
|
|
6536
6542
|
"use strict";
|
|
6537
|
-
|
|
6543
|
+
import_react_native22 = require("react-native");
|
|
6538
6544
|
init_events();
|
|
6539
6545
|
init_eventEnvelopeV2();
|
|
6540
6546
|
BATCH_MAX_SIZE = 25;
|
|
6541
6547
|
BATCH_FLUSH_MS = 1e4;
|
|
6542
6548
|
EVENT_NAME_REGEX = /^(\$[a-zA-Z0-9_]+|[a-z][a-z0-9_]*)$/;
|
|
6543
|
-
V2_BATCH_ENDPOINT = "/
|
|
6544
|
-
V1_BATCH_ENDPOINT = "/
|
|
6545
|
-
V1_SINGLE_ENDPOINT = "/
|
|
6549
|
+
V2_BATCH_ENDPOINT = "/ingest/batch";
|
|
6550
|
+
V1_BATCH_ENDPOINT = "/sdk/events/batch";
|
|
6551
|
+
V1_SINGLE_ENDPOINT = "/sdk/events";
|
|
6546
6552
|
EventBatcher = class {
|
|
6547
6553
|
constructor(post, debug = false, contextProvider = null) {
|
|
6548
6554
|
this.criticalQueue = [];
|
|
@@ -6586,7 +6592,7 @@ var init_EventBatcher = __esm({
|
|
|
6586
6592
|
const event = {
|
|
6587
6593
|
eventName,
|
|
6588
6594
|
distinctId,
|
|
6589
|
-
properties: { ...properties, platform:
|
|
6595
|
+
properties: { ...properties, platform: import_react_native22.Platform.OS },
|
|
6590
6596
|
timestamp: timestamp ?? Date.now(),
|
|
6591
6597
|
environment: environment.toLowerCase()
|
|
6592
6598
|
};
|
|
@@ -6669,8 +6675,8 @@ var init_EventBatcher = __esm({
|
|
|
6669
6675
|
}
|
|
6670
6676
|
}
|
|
6671
6677
|
/**
|
|
6672
|
-
* POST the batch with V2 envelope semantics. Tries `/
|
|
6673
|
-
* first; on failure (404/network) falls back to `/
|
|
6678
|
+
* POST the batch with V2 envelope semantics. Tries `/ingest/batch`
|
|
6679
|
+
* first; on failure (404/network) falls back to `/events/batch`
|
|
6674
6680
|
* with the legacy per-event shape for retrocompat.
|
|
6675
6681
|
*
|
|
6676
6682
|
* After a single V2 failure we flip `v2Disabled` and stop trying V2 for
|
|
@@ -6700,7 +6706,7 @@ var init_EventBatcher = __esm({
|
|
|
6700
6706
|
this.v2Disabled = true;
|
|
6701
6707
|
if (this.debug) {
|
|
6702
6708
|
console.log(
|
|
6703
|
-
`[Paywallo EVENTS] V2 ingest unavailable, falling back to /
|
|
6709
|
+
`[Paywallo EVENTS] V2 ingest unavailable, falling back to /events/batch:`,
|
|
6704
6710
|
error
|
|
6705
6711
|
);
|
|
6706
6712
|
}
|
|
@@ -6753,11 +6759,11 @@ var init_ApiClientQueue = __esm({
|
|
|
6753
6759
|
});
|
|
6754
6760
|
|
|
6755
6761
|
// src/core/ApiClient.ts
|
|
6756
|
-
var
|
|
6762
|
+
var import_react_native23, ApiClient;
|
|
6757
6763
|
var init_ApiClient = __esm({
|
|
6758
6764
|
"src/core/ApiClient.ts"() {
|
|
6759
6765
|
"use strict";
|
|
6760
|
-
|
|
6766
|
+
import_react_native23 = require("react-native");
|
|
6761
6767
|
init_version();
|
|
6762
6768
|
init_apiUrlUtils();
|
|
6763
6769
|
init_ApiClientFlags();
|
|
@@ -6859,7 +6865,7 @@ var init_ApiClient = __esm({
|
|
|
6859
6865
|
buildSdkHeaders() {
|
|
6860
6866
|
return {
|
|
6861
6867
|
"x-sdk-version": SDK_VERSION,
|
|
6862
|
-
"x-sdk-platform":
|
|
6868
|
+
"x-sdk-platform": import_react_native23.Platform.OS,
|
|
6863
6869
|
"x-sdk-environment": this.environment
|
|
6864
6870
|
};
|
|
6865
6871
|
}
|
|
@@ -6884,12 +6890,12 @@ var init_ApiClient = __esm({
|
|
|
6884
6890
|
}
|
|
6885
6891
|
async reportError(errorType, message, context) {
|
|
6886
6892
|
try {
|
|
6887
|
-
await this.post("/
|
|
6893
|
+
await this.post("/sdk/errors", {
|
|
6888
6894
|
errorType,
|
|
6889
6895
|
message,
|
|
6890
6896
|
context,
|
|
6891
6897
|
sdkVersion: SDK_VERSION,
|
|
6892
|
-
platform:
|
|
6898
|
+
platform: import_react_native23.Platform.OS
|
|
6893
6899
|
}, true);
|
|
6894
6900
|
} catch (err) {
|
|
6895
6901
|
if (this.debug) console.log("[Paywallo:ApiClient] reportError failed", err);
|
|
@@ -6912,8 +6918,8 @@ var init_ApiClient = __esm({
|
|
|
6912
6918
|
isDebug: () => this.debug,
|
|
6913
6919
|
post: (path, body, skipRetry) => this.post(path, body, skipRetry)
|
|
6914
6920
|
},
|
|
6915
|
-
"/
|
|
6916
|
-
{ distinctId, properties: properties ?? {}, email, platform:
|
|
6921
|
+
"/identify",
|
|
6922
|
+
{ distinctId, properties: properties ?? {}, email, platform: import_react_native23.Platform.OS, ...deviceId && { deviceId } },
|
|
6917
6923
|
"identify"
|
|
6918
6924
|
);
|
|
6919
6925
|
}
|
|
@@ -6928,7 +6934,7 @@ var init_ApiClient = __esm({
|
|
|
6928
6934
|
const hit = this.cache.getPaywall(placement);
|
|
6929
6935
|
if (hit !== void 0) return hit;
|
|
6930
6936
|
try {
|
|
6931
|
-
const res = await this.get(`/
|
|
6937
|
+
const res = await this.get(`/sdk/paywalls/${placement}`);
|
|
6932
6938
|
if (res.status === 404) {
|
|
6933
6939
|
this.cache.setPaywall(placement, null, this.cache.nullTTL);
|
|
6934
6940
|
return null;
|
|
@@ -7264,7 +7270,6 @@ function setupAutoPreload(state, apiClient, config, distinctId) {
|
|
|
7264
7270
|
return null;
|
|
7265
7271
|
}).catch(() => null);
|
|
7266
7272
|
}
|
|
7267
|
-
var DEFAULT_API_URL;
|
|
7268
7273
|
var init_PaywalloInitHelpers = __esm({
|
|
7269
7274
|
"src/core/PaywalloInitHelpers.ts"() {
|
|
7270
7275
|
"use strict";
|
|
@@ -7272,7 +7277,7 @@ var init_PaywalloInitHelpers = __esm({
|
|
|
7272
7277
|
init_identity();
|
|
7273
7278
|
init_notifications();
|
|
7274
7279
|
init_SecureStorage();
|
|
7275
|
-
|
|
7280
|
+
init_constants();
|
|
7276
7281
|
}
|
|
7277
7282
|
});
|
|
7278
7283
|
|
|
@@ -7321,7 +7326,7 @@ function reportInitFailure(state, config, error, reason) {
|
|
|
7321
7326
|
try {
|
|
7322
7327
|
const tempClient = new ApiClient(
|
|
7323
7328
|
config.appKey,
|
|
7324
|
-
config.apiUrl ??
|
|
7329
|
+
config.apiUrl ?? DEFAULT_API_URL,
|
|
7325
7330
|
config.debug
|
|
7326
7331
|
);
|
|
7327
7332
|
void tempClient.reportError("INIT_FAILED", reason, {
|
|
@@ -7365,7 +7370,7 @@ async function doInit(state, config) {
|
|
|
7365
7370
|
]);
|
|
7366
7371
|
const apiClient = new ApiClient(
|
|
7367
7372
|
config.appKey,
|
|
7368
|
-
config.apiUrl ??
|
|
7373
|
+
config.apiUrl ?? DEFAULT_API_URL,
|
|
7369
7374
|
config.debug,
|
|
7370
7375
|
environment,
|
|
7371
7376
|
offlineQueueEnabled,
|
|
@@ -7471,7 +7476,6 @@ async function doInit(state, config) {
|
|
|
7471
7476
|
}
|
|
7472
7477
|
setupAutoPreload(state, apiClient, config, distinctId);
|
|
7473
7478
|
}
|
|
7474
|
-
var DEFAULT_API_URL2;
|
|
7475
7479
|
var init_PaywalloInitializer = __esm({
|
|
7476
7480
|
"src/core/PaywalloInitializer.ts"() {
|
|
7477
7481
|
"use strict";
|
|
@@ -7490,7 +7494,7 @@ var init_PaywalloInitializer = __esm({
|
|
|
7490
7494
|
init_eventPipelineBridge();
|
|
7491
7495
|
init_PaywalloState();
|
|
7492
7496
|
init_PaywalloInitHelpers();
|
|
7493
|
-
|
|
7497
|
+
init_constants();
|
|
7494
7498
|
}
|
|
7495
7499
|
});
|
|
7496
7500
|
|
|
@@ -8379,7 +8383,7 @@ function useSubscription() {
|
|
|
8379
8383
|
|
|
8380
8384
|
// src/PaywalloProvider.tsx
|
|
8381
8385
|
var import_react21 = require("react");
|
|
8382
|
-
var
|
|
8386
|
+
var import_react_native24 = require("react-native");
|
|
8383
8387
|
init_paywall();
|
|
8384
8388
|
init_paywall();
|
|
8385
8389
|
init_paywall();
|
|
@@ -8898,8 +8902,8 @@ function PaywalloProvider({ children, config }) {
|
|
|
8898
8902
|
});
|
|
8899
8903
|
}, []);
|
|
8900
8904
|
const { showingPreloadedWebView, presentPreloadedWebView, resolvePreloadedPaywall, handlePreloadedWebViewReady: baseHandlePreloadedWebViewReady, handlePreloadedClose: baseHandlePreloadedClose, setShowingPreloadedWebView, presentedAtRef } = usePaywallPresenter(preloadedWebView, setPreloadedWebView);
|
|
8901
|
-
const SCREEN_HEIGHT = (0, import_react21.useMemo)(() =>
|
|
8902
|
-
const slideAnim = (0, import_react21.useRef)(new
|
|
8905
|
+
const SCREEN_HEIGHT = (0, import_react21.useMemo)(() => import_react_native24.Dimensions.get("window").height, []);
|
|
8906
|
+
const slideAnim = (0, import_react21.useRef)(new import_react_native24.Animated.Value(SCREEN_HEIGHT)).current;
|
|
8903
8907
|
const handlePreloadedWebViewReady = (0, import_react21.useCallback)(() => {
|
|
8904
8908
|
if (PaywalloClient.getConfig()?.debug) {
|
|
8905
8909
|
console.log(`[Paywallo WEBVIEW] loaded \u2014 placement: ${preloadedWebView?.placement}`);
|
|
@@ -8908,7 +8912,7 @@ function PaywalloProvider({ children, config }) {
|
|
|
8908
8912
|
}, [preloadedWebView?.placement, baseHandlePreloadedWebViewReady]);
|
|
8909
8913
|
const handlePreloadedClose = (0, import_react21.useCallback)(() => {
|
|
8910
8914
|
const placement = preloadedWebView?.placement;
|
|
8911
|
-
|
|
8915
|
+
import_react_native24.Animated.timing(slideAnim, { toValue: SCREEN_HEIGHT, duration: 200, easing: import_react_native24.Easing.in(import_react_native24.Easing.cubic), useNativeDriver: true }).start(() => {
|
|
8912
8916
|
baseHandlePreloadedClose();
|
|
8913
8917
|
if (placement) triggerRepreload(placement);
|
|
8914
8918
|
});
|
|
@@ -9157,7 +9161,7 @@ function PaywalloProvider({ children, config }) {
|
|
|
9157
9161
|
(0, import_react21.useLayoutEffect)(() => {
|
|
9158
9162
|
if (showingPreloadedWebView) {
|
|
9159
9163
|
slideAnim.setValue(SCREEN_HEIGHT);
|
|
9160
|
-
|
|
9164
|
+
import_react_native24.Animated.timing(slideAnim, { toValue: 0, duration: 200, easing: import_react_native24.Easing.out(import_react_native24.Easing.cubic), useNativeDriver: true }).start();
|
|
9161
9165
|
}
|
|
9162
9166
|
}, [showingPreloadedWebView, slideAnim, SCREEN_HEIGHT]);
|
|
9163
9167
|
const preloadStyle = [
|
|
@@ -9167,7 +9171,7 @@ function PaywalloProvider({ children, config }) {
|
|
|
9167
9171
|
];
|
|
9168
9172
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PaywalloContext.Provider, { value: contextValue, children: [
|
|
9169
9173
|
children,
|
|
9170
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PaywallErrorBoundary, { children: !!preloadedWebView?.craftData && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
9174
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PaywallErrorBoundary, { children: !!preloadedWebView?.craftData && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native24.Animated.View, { style: preloadStyle, pointerEvents: showingPreloadedWebView ? "auto" : "none", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
9171
9175
|
PaywallWebView,
|
|
9172
9176
|
{
|
|
9173
9177
|
paywallId: preloadedWebView.paywallId,
|
|
@@ -9198,7 +9202,7 @@ function PaywalloProvider({ children, config }) {
|
|
|
9198
9202
|
) })
|
|
9199
9203
|
] });
|
|
9200
9204
|
}
|
|
9201
|
-
var styles3 =
|
|
9205
|
+
var styles3 = import_react_native24.StyleSheet.create({
|
|
9202
9206
|
preloadOverlay: { position: "absolute", top: 0, left: 0, right: 0, bottom: 0, backgroundColor: "#ffffff" },
|
|
9203
9207
|
hidden: { zIndex: -1, opacity: 0, width: 1, height: 1, overflow: "hidden" },
|
|
9204
9208
|
visible: { zIndex: 9999, opacity: 1 }
|