@sendoracloud/sdk-react-native 0.18.5 → 0.18.6

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
@@ -2094,6 +2094,53 @@ var SendoraSDK = class {
2094
2094
  }
2095
2095
  };
2096
2096
  }
2097
+ /**
2098
+ * In-app messaging namespace — fetch active messages (modals,
2099
+ * banners, slideouts, tooltips) targeted at this user + record
2100
+ * impressions (shown / clicked / dismissed) so the dashboard's
2101
+ * "shown N times" caps and CTR analytics work. Mirrors backend
2102
+ * `/in-app-messages/{active,impressions}` SDK routes and the web
2103
+ * SDK's `InAppMessaging` class.
2104
+ *
2105
+ * Typical use:
2106
+ * const msgs = await SendoraCloud.messages.fetchActive();
2107
+ * for (const m of msgs) renderMessage(m);
2108
+ * // when user sees it:
2109
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "shown" });
2110
+ * // when user clicks CTA:
2111
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "clicked" });
2112
+ *
2113
+ * `action` is a free-form string; "shown" / "clicked" / "dismissed"
2114
+ * are the canonical set the dashboard graphs from.
2115
+ */
2116
+ get messages() {
2117
+ const self = this;
2118
+ return {
2119
+ fetchActive: async () => {
2120
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before messages.fetchActive().");
2121
+ const url = `${self.config.apiUrl}/api/v1/in-app-messages/active`;
2122
+ const res = await fetch(url, {
2123
+ method: "GET",
2124
+ headers: { "x-api-key": self.config.publicKey }
2125
+ });
2126
+ if (!res.ok) throw new Error(`[sendoracloud] messages.fetchActive failed (${res.status})`);
2127
+ const parsed = await res.json();
2128
+ if (!parsed.success || !Array.isArray(parsed.data)) {
2129
+ throw new Error("[sendoracloud] messages.fetchActive: bad response");
2130
+ }
2131
+ return parsed.data;
2132
+ },
2133
+ recordImpression: async (input) => {
2134
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before messages.recordImpression().");
2135
+ const res = await post(
2136
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2137
+ "/in-app-messages/impressions",
2138
+ input
2139
+ );
2140
+ if (!res || !res.ok) throw new Error(`[sendoracloud] messages.recordImpression failed (${res?.status ?? "network"})`);
2141
+ }
2142
+ };
2143
+ }
2097
2144
  /**
2098
2145
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
2099
2146
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.cts CHANGED
@@ -996,6 +996,45 @@ declare class SendoraSDK {
996
996
  submittedAt: string;
997
997
  }>;
998
998
  };
999
+ /**
1000
+ * In-app messaging namespace — fetch active messages (modals,
1001
+ * banners, slideouts, tooltips) targeted at this user + record
1002
+ * impressions (shown / clicked / dismissed) so the dashboard's
1003
+ * "shown N times" caps and CTR analytics work. Mirrors backend
1004
+ * `/in-app-messages/{active,impressions}` SDK routes and the web
1005
+ * SDK's `InAppMessaging` class.
1006
+ *
1007
+ * Typical use:
1008
+ * const msgs = await SendoraCloud.messages.fetchActive();
1009
+ * for (const m of msgs) renderMessage(m);
1010
+ * // when user sees it:
1011
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "shown" });
1012
+ * // when user clicks CTA:
1013
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "clicked" });
1014
+ *
1015
+ * `action` is a free-form string; "shown" / "clicked" / "dismissed"
1016
+ * are the canonical set the dashboard graphs from.
1017
+ */
1018
+ get messages(): {
1019
+ fetchActive: () => Promise<Array<{
1020
+ id: string;
1021
+ type: string;
1022
+ title: string | null;
1023
+ body: string;
1024
+ ctaText: string | null;
1025
+ ctaUrl: string | null;
1026
+ imageUrl: string | null;
1027
+ theme: string | null;
1028
+ priority: number;
1029
+ isActive: boolean;
1030
+ [key: string]: unknown;
1031
+ }>>;
1032
+ recordImpression: (input: {
1033
+ messageId: string;
1034
+ action: string;
1035
+ entityId?: string;
1036
+ }) => Promise<void>;
1037
+ };
999
1038
  /**
1000
1039
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1001
1040
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.ts CHANGED
@@ -996,6 +996,45 @@ declare class SendoraSDK {
996
996
  submittedAt: string;
997
997
  }>;
998
998
  };
999
+ /**
1000
+ * In-app messaging namespace — fetch active messages (modals,
1001
+ * banners, slideouts, tooltips) targeted at this user + record
1002
+ * impressions (shown / clicked / dismissed) so the dashboard's
1003
+ * "shown N times" caps and CTR analytics work. Mirrors backend
1004
+ * `/in-app-messages/{active,impressions}` SDK routes and the web
1005
+ * SDK's `InAppMessaging` class.
1006
+ *
1007
+ * Typical use:
1008
+ * const msgs = await SendoraCloud.messages.fetchActive();
1009
+ * for (const m of msgs) renderMessage(m);
1010
+ * // when user sees it:
1011
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "shown" });
1012
+ * // when user clicks CTA:
1013
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "clicked" });
1014
+ *
1015
+ * `action` is a free-form string; "shown" / "clicked" / "dismissed"
1016
+ * are the canonical set the dashboard graphs from.
1017
+ */
1018
+ get messages(): {
1019
+ fetchActive: () => Promise<Array<{
1020
+ id: string;
1021
+ type: string;
1022
+ title: string | null;
1023
+ body: string;
1024
+ ctaText: string | null;
1025
+ ctaUrl: string | null;
1026
+ imageUrl: string | null;
1027
+ theme: string | null;
1028
+ priority: number;
1029
+ isActive: boolean;
1030
+ [key: string]: unknown;
1031
+ }>>;
1032
+ recordImpression: (input: {
1033
+ messageId: string;
1034
+ action: string;
1035
+ entityId?: string;
1036
+ }) => Promise<void>;
1037
+ };
999
1038
  /**
1000
1039
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1001
1040
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.js CHANGED
@@ -2056,6 +2056,53 @@ var SendoraSDK = class {
2056
2056
  }
2057
2057
  };
2058
2058
  }
2059
+ /**
2060
+ * In-app messaging namespace — fetch active messages (modals,
2061
+ * banners, slideouts, tooltips) targeted at this user + record
2062
+ * impressions (shown / clicked / dismissed) so the dashboard's
2063
+ * "shown N times" caps and CTR analytics work. Mirrors backend
2064
+ * `/in-app-messages/{active,impressions}` SDK routes and the web
2065
+ * SDK's `InAppMessaging` class.
2066
+ *
2067
+ * Typical use:
2068
+ * const msgs = await SendoraCloud.messages.fetchActive();
2069
+ * for (const m of msgs) renderMessage(m);
2070
+ * // when user sees it:
2071
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "shown" });
2072
+ * // when user clicks CTA:
2073
+ * await SendoraCloud.messages.recordImpression({ messageId: m.id, action: "clicked" });
2074
+ *
2075
+ * `action` is a free-form string; "shown" / "clicked" / "dismissed"
2076
+ * are the canonical set the dashboard graphs from.
2077
+ */
2078
+ get messages() {
2079
+ const self = this;
2080
+ return {
2081
+ fetchActive: async () => {
2082
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before messages.fetchActive().");
2083
+ const url = `${self.config.apiUrl}/api/v1/in-app-messages/active`;
2084
+ const res = await fetch(url, {
2085
+ method: "GET",
2086
+ headers: { "x-api-key": self.config.publicKey }
2087
+ });
2088
+ if (!res.ok) throw new Error(`[sendoracloud] messages.fetchActive failed (${res.status})`);
2089
+ const parsed = await res.json();
2090
+ if (!parsed.success || !Array.isArray(parsed.data)) {
2091
+ throw new Error("[sendoracloud] messages.fetchActive: bad response");
2092
+ }
2093
+ return parsed.data;
2094
+ },
2095
+ recordImpression: async (input) => {
2096
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before messages.recordImpression().");
2097
+ const res = await post(
2098
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2099
+ "/in-app-messages/impressions",
2100
+ input
2101
+ );
2102
+ if (!res || !res.ok) throw new Error(`[sendoracloud] messages.recordImpression failed (${res?.status ?? "network"})`);
2103
+ }
2104
+ };
2105
+ }
2059
2106
  /**
2060
2107
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
2061
2108
  * 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.18.5",
3
+ "version": "0.18.6",
4
4
  "description": "Sendora Cloud React Native + Expo SDK — analytics, identity, push-token registration, auth, deep links (Branch / Firebase Dynamic Links parity). Auth + analytics + deep links work in Expo Go; push token registration requires a Dev Client (EAS Build or `npx expo prebuild`).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",