@sendoracloud/sdk-react-native 0.11.0 → 0.12.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.cjs CHANGED
@@ -845,7 +845,9 @@ function installAutoTrack(args) {
845
845
  if (flags.appBackground) {
846
846
  let AppState = null;
847
847
  try {
848
- AppState = require("react-native").AppState;
848
+ const dyn = globalThis.require;
849
+ const mod = dyn ? dyn("react-native") : null;
850
+ AppState = mod?.AppState ?? null;
849
851
  } catch {
850
852
  AppState = null;
851
853
  }
@@ -1133,6 +1135,28 @@ var SendoraSDK = class {
1133
1135
  }
1134
1136
  return { tokenId: data.tokenId, created: data.created === true };
1135
1137
  }
1138
+ /**
1139
+ * Push namespace — mirrors the iOS / Android / Web SDK shape so
1140
+ * `sendora.push.registerToken(...)` works consistently across all 5 SDKs.
1141
+ * Backed by the same registerPushToken() implementation; kept top-level
1142
+ * too for backwards compatibility with the s47 release.
1143
+ */
1144
+ get push() {
1145
+ const self = this;
1146
+ return {
1147
+ registerToken: (reg) => self.registerPushToken(reg),
1148
+ trackOpen: async (sendId, clickAction) => {
1149
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before push.trackOpen().");
1150
+ const body = { sendId };
1151
+ if (clickAction !== void 0) body.clickAction = clickAction;
1152
+ await post(
1153
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
1154
+ "/push/track-open",
1155
+ body
1156
+ );
1157
+ }
1158
+ };
1159
+ }
1136
1160
  /**
1137
1161
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1138
1162
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.cts CHANGED
@@ -425,6 +425,16 @@ declare class SendoraSDK {
425
425
  * `@react-native-firebase/messaging`.
426
426
  */
427
427
  registerPushToken(reg: PushTokenRegistration): Promise<PushTokenReceipt>;
428
+ /**
429
+ * Push namespace — mirrors the iOS / Android / Web SDK shape so
430
+ * `sendora.push.registerToken(...)` works consistently across all 5 SDKs.
431
+ * Backed by the same registerPushToken() implementation; kept top-level
432
+ * too for backwards compatibility with the s47 release.
433
+ */
434
+ get push(): {
435
+ registerToken: (reg: PushTokenRegistration) => Promise<PushTokenReceipt>;
436
+ trackOpen: (sendId: string, clickAction?: string) => Promise<void>;
437
+ };
428
438
  /**
429
439
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
430
440
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.ts CHANGED
@@ -425,6 +425,16 @@ declare class SendoraSDK {
425
425
  * `@react-native-firebase/messaging`.
426
426
  */
427
427
  registerPushToken(reg: PushTokenRegistration): Promise<PushTokenReceipt>;
428
+ /**
429
+ * Push namespace — mirrors the iOS / Android / Web SDK shape so
430
+ * `sendora.push.registerToken(...)` works consistently across all 5 SDKs.
431
+ * Backed by the same registerPushToken() implementation; kept top-level
432
+ * too for backwards compatibility with the s47 release.
433
+ */
434
+ get push(): {
435
+ registerToken: (reg: PushTokenRegistration) => Promise<PushTokenReceipt>;
436
+ trackOpen: (sendId: string, clickAction?: string) => Promise<void>;
437
+ };
428
438
  /**
429
439
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
430
440
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.js CHANGED
@@ -1,10 +1,3 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined") return require.apply(this, arguments);
5
- throw Error('Dynamic require of "' + x + '" is not supported');
6
- });
7
-
8
1
  // src/storage.ts
9
2
  var PREFIX = "sendora_";
10
3
  var asyncStoragePromise = null;
@@ -812,7 +805,9 @@ function installAutoTrack(args) {
812
805
  if (flags.appBackground) {
813
806
  let AppState = null;
814
807
  try {
815
- AppState = __require("react-native").AppState;
808
+ const dyn = globalThis.require;
809
+ const mod = dyn ? dyn("react-native") : null;
810
+ AppState = mod?.AppState ?? null;
816
811
  } catch {
817
812
  AppState = null;
818
813
  }
@@ -1100,6 +1095,28 @@ var SendoraSDK = class {
1100
1095
  }
1101
1096
  return { tokenId: data.tokenId, created: data.created === true };
1102
1097
  }
1098
+ /**
1099
+ * Push namespace — mirrors the iOS / Android / Web SDK shape so
1100
+ * `sendora.push.registerToken(...)` works consistently across all 5 SDKs.
1101
+ * Backed by the same registerPushToken() implementation; kept top-level
1102
+ * too for backwards compatibility with the s47 release.
1103
+ */
1104
+ get push() {
1105
+ const self = this;
1106
+ return {
1107
+ registerToken: (reg) => self.registerPushToken(reg),
1108
+ trackOpen: async (sendId, clickAction) => {
1109
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before push.trackOpen().");
1110
+ const body = { sendId };
1111
+ if (clickAction !== void 0) body.clickAction = clickAction;
1112
+ await post(
1113
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
1114
+ "/push/track-open",
1115
+ body
1116
+ );
1117
+ }
1118
+ };
1119
+ }
1103
1120
  /**
1104
1121
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1105
1122
  * the AsyncStorage writes so a caller who kills the app immediately
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth. Expo Go compatible, no native modules beyond AsyncStorage.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",