@virex-tech/paywallo-sdk 2.2.4 → 2.2.5

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.mjs CHANGED
@@ -2008,13 +2008,21 @@ var init_NativePushBridge = __esm({
2008
2008
  if (!raw || typeof raw !== "object") return null;
2009
2009
  const r = raw;
2010
2010
  const notification = r["notification"];
2011
+ const asString = (v) => typeof v === "string" ? v : void 0;
2011
2012
  return {
2012
- messageId: typeof r["messageId"] === "string" ? r["messageId"] : void 0,
2013
+ messageId: asString(r["messageId"]),
2013
2014
  data: typeof r["data"] === "object" && r["data"] !== null ? r["data"] : void 0,
2014
2015
  notification: notification && typeof notification === "object" ? {
2015
- title: typeof notification["title"] === "string" ? notification["title"] : void 0,
2016
- body: typeof notification["body"] === "string" ? notification["body"] : void 0
2016
+ title: asString(notification["title"]),
2017
+ body: asString(notification["body"]),
2018
+ imageUrl: asString(notification["imageUrl"])
2017
2019
  } : void 0,
2020
+ // Pass through top-level title/body/imageUrl emitted by the native modules
2021
+ // (both iOS and Android currently emit these at the top level rather than
2022
+ // nested under `notification`).
2023
+ title: asString(r["title"]),
2024
+ body: asString(r["body"]),
2025
+ imageUrl: asString(r["imageUrl"]),
2018
2026
  sentTime: typeof r["sentTime"] === "number" ? r["sentTime"] : void 0
2019
2027
  };
2020
2028
  } catch {
@@ -2153,8 +2161,9 @@ function setupForegroundHandler(deps, onReceive) {
2153
2161
  const data = message.data ?? {};
2154
2162
  const payload = extractPayload({
2155
2163
  ...data,
2156
- title: data["title"] ?? message.notification?.title ?? "",
2157
- body: data["body"] ?? message.notification?.body ?? ""
2164
+ title: data["title"] ?? message.notification?.title ?? message.title ?? "",
2165
+ body: data["body"] ?? message.notification?.body ?? message.body ?? "",
2166
+ imageUrl: data["imageUrl"] ?? message.notification?.imageUrl ?? message.imageUrl
2158
2167
  });
2159
2168
  if (debug) console.log("[Paywallo PUSH] foreground message received:", payload.notificationId);
2160
2169
  onReceive(payload);
@@ -2345,8 +2354,8 @@ async function getInitialNotificationPayload(bridge) {
2345
2354
  notificationId: String(data["notificationId"] ?? data["notification_id"] ?? ""),
2346
2355
  campaignId: String(data["campaignId"] ?? data["campaign_id"] ?? ""),
2347
2356
  variantKey: data["variantKey"] != null ? String(data["variantKey"]) : void 0,
2348
- title: String(data["title"] ?? message.notification?.title ?? ""),
2349
- body: String(data["body"] ?? message.notification?.body ?? ""),
2357
+ title: String(data["title"] ?? message.notification?.title ?? message.title ?? ""),
2358
+ body: String(data["body"] ?? message.notification?.body ?? message.body ?? ""),
2350
2359
  data
2351
2360
  };
2352
2361
  }
@@ -2361,8 +2370,8 @@ var init_NotificationHandlerSetup = __esm({
2361
2370
  // src/core/version.ts
2362
2371
  function resolveVersion() {
2363
2372
  try {
2364
- if ("2.2.4") {
2365
- return "2.2.4";
2373
+ if ("2.2.5") {
2374
+ return "2.2.5";
2366
2375
  }
2367
2376
  } catch {
2368
2377
  }
@@ -4718,12 +4727,24 @@ var init_QueueProcessor = __esm({
4718
4727
  const freshHeaders = this.config.getFreshHeaders?.() ?? {};
4719
4728
  const headers = { ...persistedHeaders, ...freshHeaders };
4720
4729
  this.log("Sending event batch", { size: batch.length, batchIndex: Math.floor(i / BATCH_SIZE) });
4721
- const response = await this.httpClient.request("/sdk/ingest/batch", {
4722
- method: "POST",
4723
- body: { events: bodies },
4724
- headers,
4725
- skipRetry: false
4726
- });
4730
+ let response;
4731
+ try {
4732
+ response = await this.httpClient.request("/sdk/ingest/batch", {
4733
+ method: "POST",
4734
+ body: { events: bodies },
4735
+ headers,
4736
+ skipRetry: false
4737
+ });
4738
+ } catch (error) {
4739
+ for (const item of batch) {
4740
+ retryIds.add(item.id);
4741
+ }
4742
+ this.log("Event batch threw network error - will retry", {
4743
+ size: batch.length,
4744
+ error: error instanceof Error ? error.message : String(error)
4745
+ });
4746
+ continue;
4747
+ }
4727
4748
  if (response.ok) {
4728
4749
  for (const item of batch) {
4729
4750
  await offlineQueue.removeItem(item.id);
@@ -4763,12 +4784,21 @@ var init_QueueProcessor = __esm({
4763
4784
  });
4764
4785
  const persistedHeaders = item.headers ?? {};
4765
4786
  const freshHeaders = this.config.getFreshHeaders?.() ?? {};
4766
- const response = await this.httpClient.request(item.url, {
4767
- method: item.method,
4768
- body: item.body,
4769
- headers: { ...persistedHeaders, ...freshHeaders },
4770
- skipRetry: false
4771
- });
4787
+ let response;
4788
+ try {
4789
+ response = await this.httpClient.request(item.url, {
4790
+ method: item.method,
4791
+ body: item.body,
4792
+ headers: { ...persistedHeaders, ...freshHeaders },
4793
+ skipRetry: false
4794
+ });
4795
+ } catch (error) {
4796
+ this.log("Request threw network error - will retry", {
4797
+ id: item.id,
4798
+ error: error instanceof Error ? error.message : String(error)
4799
+ });
4800
+ return { success: false, permanent: false };
4801
+ }
4772
4802
  if (response.ok) {
4773
4803
  this.log("Queue item processed successfully", { id: item.id });
4774
4804
  return { success: true, permanent: false };