@sendoracloud/sdk-react-native 0.18.6 → 0.18.8

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
@@ -1646,6 +1646,13 @@ var SendoraSDK = class {
1646
1646
  this.debug = false;
1647
1647
  this.sessionId = "";
1648
1648
  this.autoTrackCleanup = null;
1649
+ /**
1650
+ * Lazy-allocated stable session id for chatbot conversations.
1651
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1652
+ * server-side keyed on this id, so an app restart starts a fresh
1653
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1654
+ */
1655
+ this._chatbotSessionId = null;
1649
1656
  }
1650
1657
  /** Initialize the SDK. Must be awaited at app startup before identify/track. */
1651
1658
  async init(config) {
@@ -2141,6 +2148,103 @@ var SendoraSDK = class {
2141
2148
  }
2142
2149
  };
2143
2150
  }
2151
+ /**
2152
+ * Feature-flags namespace — per-user evaluation against percentage
2153
+ * rollouts + audience targeting. Mirrors backend
2154
+ * `/feature-flags/{evaluate,evaluate-all}` SDK routes and the web
2155
+ * SDK's `FeatureFlags` class.
2156
+ *
2157
+ * `evaluate(key)` returns the resolved value (boolean / string /
2158
+ * number / variant payload) for a single flag — use when you only
2159
+ * need one specific flag in a code path.
2160
+ *
2161
+ * `evaluateAll()` returns the full flag map in one round-trip —
2162
+ * call once on app startup or screen mount, then read from the
2163
+ * map locally. Avoids N+1.
2164
+ *
2165
+ * Both methods auto-thread `userId` (from `identify()`) when not
2166
+ * passed. `entityId` is for entity-scoped flags (org / team /
2167
+ * device-cohort); typically omitted in mobile apps.
2168
+ */
2169
+ get flags() {
2170
+ const self = this;
2171
+ return {
2172
+ evaluate: async (input) => {
2173
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before flags.evaluate().");
2174
+ const body = {
2175
+ key: input.key,
2176
+ userId: input.userId ?? self.userId ?? void 0,
2177
+ entityId: input.entityId,
2178
+ environment: input.environment
2179
+ };
2180
+ const res = await post(
2181
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2182
+ "/feature-flags/evaluate",
2183
+ body
2184
+ );
2185
+ if (!res || !res.ok) throw new Error(`[sendoracloud] flags.evaluate failed (${res?.status ?? "network"})`);
2186
+ const parsed = await res.json();
2187
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] flags.evaluate: bad response");
2188
+ return parsed.data;
2189
+ },
2190
+ evaluateAll: async (input) => {
2191
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before flags.evaluateAll().");
2192
+ const body = {
2193
+ userId: input?.userId ?? self.userId ?? void 0,
2194
+ entityId: input?.entityId,
2195
+ environment: input?.environment
2196
+ };
2197
+ const res = await post(
2198
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2199
+ "/feature-flags/evaluate-all",
2200
+ body
2201
+ );
2202
+ if (!res || !res.ok) throw new Error(`[sendoracloud] flags.evaluateAll failed (${res?.status ?? "network"})`);
2203
+ const parsed = await res.json();
2204
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] flags.evaluateAll: bad response");
2205
+ return parsed.data;
2206
+ }
2207
+ };
2208
+ }
2209
+ /**
2210
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
2211
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
2212
+ * `Chatbot` class.
2213
+ *
2214
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
2215
+ * plus citations (KB article IDs the answer was grounded in) and
2216
+ * mode (`ai` when AI is enabled for the org, `canned` when the
2217
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
2218
+ * context across calls; SDK auto-generates one per app session if
2219
+ * omitted.
2220
+ */
2221
+ get chatbot() {
2222
+ const self = this;
2223
+ return {
2224
+ sendMessage: async (input) => {
2225
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before chatbot.sendMessage().");
2226
+ const body = {
2227
+ chatbotId: input.chatbotId,
2228
+ sessionId: input.sessionId ?? self.chatbotSessionId(),
2229
+ message: input.message,
2230
+ userId: input.userId ?? self.userId ?? void 0
2231
+ };
2232
+ const res = await post(
2233
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2234
+ "/chatbot/message",
2235
+ body
2236
+ );
2237
+ if (!res || !res.ok) throw new Error(`[sendoracloud] chatbot.sendMessage failed (${res?.status ?? "network"})`);
2238
+ const parsed = await res.json();
2239
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] chatbot.sendMessage: bad response");
2240
+ return parsed.data;
2241
+ }
2242
+ };
2243
+ }
2244
+ chatbotSessionId() {
2245
+ if (!this._chatbotSessionId) this._chatbotSessionId = `chat_${uuid().replace(/-/g, "").slice(0, 24)}`;
2246
+ return this._chatbotSessionId;
2247
+ }
2144
2248
  /**
2145
2249
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
2146
2250
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.cts CHANGED
@@ -1035,6 +1035,82 @@ declare class SendoraSDK {
1035
1035
  entityId?: string;
1036
1036
  }) => Promise<void>;
1037
1037
  };
1038
+ /**
1039
+ * Feature-flags namespace — per-user evaluation against percentage
1040
+ * rollouts + audience targeting. Mirrors backend
1041
+ * `/feature-flags/{evaluate,evaluate-all}` SDK routes and the web
1042
+ * SDK's `FeatureFlags` class.
1043
+ *
1044
+ * `evaluate(key)` returns the resolved value (boolean / string /
1045
+ * number / variant payload) for a single flag — use when you only
1046
+ * need one specific flag in a code path.
1047
+ *
1048
+ * `evaluateAll()` returns the full flag map in one round-trip —
1049
+ * call once on app startup or screen mount, then read from the
1050
+ * map locally. Avoids N+1.
1051
+ *
1052
+ * Both methods auto-thread `userId` (from `identify()`) when not
1053
+ * passed. `entityId` is for entity-scoped flags (org / team /
1054
+ * device-cohort); typically omitted in mobile apps.
1055
+ */
1056
+ get flags(): {
1057
+ evaluate: (input: {
1058
+ key: string;
1059
+ entityId?: string;
1060
+ userId?: string;
1061
+ environment?: string;
1062
+ }) => Promise<{
1063
+ key: string;
1064
+ value: unknown;
1065
+ variant: string | null;
1066
+ reason: string;
1067
+ }>;
1068
+ evaluateAll: (input?: {
1069
+ entityId?: string;
1070
+ userId?: string;
1071
+ environment?: string;
1072
+ }) => Promise<Record<string, {
1073
+ value: unknown;
1074
+ variant: string | null;
1075
+ reason: string;
1076
+ }>>;
1077
+ };
1078
+ /**
1079
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
1080
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
1081
+ * `Chatbot` class.
1082
+ *
1083
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
1084
+ * plus citations (KB article IDs the answer was grounded in) and
1085
+ * mode (`ai` when AI is enabled for the org, `canned` when the
1086
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
1087
+ * context across calls; SDK auto-generates one per app session if
1088
+ * omitted.
1089
+ */
1090
+ get chatbot(): {
1091
+ sendMessage: (input: {
1092
+ chatbotId: string;
1093
+ message: string;
1094
+ sessionId?: string;
1095
+ userId?: string;
1096
+ }) => Promise<{
1097
+ reply: string;
1098
+ mode: "ai" | "canned" | string;
1099
+ citations: Array<{
1100
+ id: string;
1101
+ title: string;
1102
+ slug?: string;
1103
+ }> | null;
1104
+ }>;
1105
+ };
1106
+ /**
1107
+ * Lazy-allocated stable session id for chatbot conversations.
1108
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1109
+ * server-side keyed on this id, so an app restart starts a fresh
1110
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1111
+ */
1112
+ private _chatbotSessionId;
1113
+ private chatbotSessionId;
1038
1114
  /**
1039
1115
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1040
1116
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.d.ts CHANGED
@@ -1035,6 +1035,82 @@ declare class SendoraSDK {
1035
1035
  entityId?: string;
1036
1036
  }) => Promise<void>;
1037
1037
  };
1038
+ /**
1039
+ * Feature-flags namespace — per-user evaluation against percentage
1040
+ * rollouts + audience targeting. Mirrors backend
1041
+ * `/feature-flags/{evaluate,evaluate-all}` SDK routes and the web
1042
+ * SDK's `FeatureFlags` class.
1043
+ *
1044
+ * `evaluate(key)` returns the resolved value (boolean / string /
1045
+ * number / variant payload) for a single flag — use when you only
1046
+ * need one specific flag in a code path.
1047
+ *
1048
+ * `evaluateAll()` returns the full flag map in one round-trip —
1049
+ * call once on app startup or screen mount, then read from the
1050
+ * map locally. Avoids N+1.
1051
+ *
1052
+ * Both methods auto-thread `userId` (from `identify()`) when not
1053
+ * passed. `entityId` is for entity-scoped flags (org / team /
1054
+ * device-cohort); typically omitted in mobile apps.
1055
+ */
1056
+ get flags(): {
1057
+ evaluate: (input: {
1058
+ key: string;
1059
+ entityId?: string;
1060
+ userId?: string;
1061
+ environment?: string;
1062
+ }) => Promise<{
1063
+ key: string;
1064
+ value: unknown;
1065
+ variant: string | null;
1066
+ reason: string;
1067
+ }>;
1068
+ evaluateAll: (input?: {
1069
+ entityId?: string;
1070
+ userId?: string;
1071
+ environment?: string;
1072
+ }) => Promise<Record<string, {
1073
+ value: unknown;
1074
+ variant: string | null;
1075
+ reason: string;
1076
+ }>>;
1077
+ };
1078
+ /**
1079
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
1080
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
1081
+ * `Chatbot` class.
1082
+ *
1083
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
1084
+ * plus citations (KB article IDs the answer was grounded in) and
1085
+ * mode (`ai` when AI is enabled for the org, `canned` when the
1086
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
1087
+ * context across calls; SDK auto-generates one per app session if
1088
+ * omitted.
1089
+ */
1090
+ get chatbot(): {
1091
+ sendMessage: (input: {
1092
+ chatbotId: string;
1093
+ message: string;
1094
+ sessionId?: string;
1095
+ userId?: string;
1096
+ }) => Promise<{
1097
+ reply: string;
1098
+ mode: "ai" | "canned" | string;
1099
+ citations: Array<{
1100
+ id: string;
1101
+ title: string;
1102
+ slug?: string;
1103
+ }> | null;
1104
+ }>;
1105
+ };
1106
+ /**
1107
+ * Lazy-allocated stable session id for chatbot conversations.
1108
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1109
+ * server-side keyed on this id, so an app restart starts a fresh
1110
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1111
+ */
1112
+ private _chatbotSessionId;
1113
+ private chatbotSessionId;
1038
1114
  /**
1039
1115
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
1040
1116
  * the AsyncStorage writes so a caller who kills the app immediately
package/dist/index.js CHANGED
@@ -1608,6 +1608,13 @@ var SendoraSDK = class {
1608
1608
  this.debug = false;
1609
1609
  this.sessionId = "";
1610
1610
  this.autoTrackCleanup = null;
1611
+ /**
1612
+ * Lazy-allocated stable session id for chatbot conversations.
1613
+ * Survives only the JS lifetime — chatbot multi-turn context lives
1614
+ * server-side keyed on this id, so an app restart starts a fresh
1615
+ * thread (matches web SDK's `chatbot.sessionId` cache).
1616
+ */
1617
+ this._chatbotSessionId = null;
1611
1618
  }
1612
1619
  /** Initialize the SDK. Must be awaited at app startup before identify/track. */
1613
1620
  async init(config) {
@@ -2103,6 +2110,103 @@ var SendoraSDK = class {
2103
2110
  }
2104
2111
  };
2105
2112
  }
2113
+ /**
2114
+ * Feature-flags namespace — per-user evaluation against percentage
2115
+ * rollouts + audience targeting. Mirrors backend
2116
+ * `/feature-flags/{evaluate,evaluate-all}` SDK routes and the web
2117
+ * SDK's `FeatureFlags` class.
2118
+ *
2119
+ * `evaluate(key)` returns the resolved value (boolean / string /
2120
+ * number / variant payload) for a single flag — use when you only
2121
+ * need one specific flag in a code path.
2122
+ *
2123
+ * `evaluateAll()` returns the full flag map in one round-trip —
2124
+ * call once on app startup or screen mount, then read from the
2125
+ * map locally. Avoids N+1.
2126
+ *
2127
+ * Both methods auto-thread `userId` (from `identify()`) when not
2128
+ * passed. `entityId` is for entity-scoped flags (org / team /
2129
+ * device-cohort); typically omitted in mobile apps.
2130
+ */
2131
+ get flags() {
2132
+ const self = this;
2133
+ return {
2134
+ evaluate: async (input) => {
2135
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before flags.evaluate().");
2136
+ const body = {
2137
+ key: input.key,
2138
+ userId: input.userId ?? self.userId ?? void 0,
2139
+ entityId: input.entityId,
2140
+ environment: input.environment
2141
+ };
2142
+ const res = await post(
2143
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2144
+ "/feature-flags/evaluate",
2145
+ body
2146
+ );
2147
+ if (!res || !res.ok) throw new Error(`[sendoracloud] flags.evaluate failed (${res?.status ?? "network"})`);
2148
+ const parsed = await res.json();
2149
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] flags.evaluate: bad response");
2150
+ return parsed.data;
2151
+ },
2152
+ evaluateAll: async (input) => {
2153
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before flags.evaluateAll().");
2154
+ const body = {
2155
+ userId: input?.userId ?? self.userId ?? void 0,
2156
+ entityId: input?.entityId,
2157
+ environment: input?.environment
2158
+ };
2159
+ const res = await post(
2160
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2161
+ "/feature-flags/evaluate-all",
2162
+ body
2163
+ );
2164
+ if (!res || !res.ok) throw new Error(`[sendoracloud] flags.evaluateAll failed (${res?.status ?? "network"})`);
2165
+ const parsed = await res.json();
2166
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] flags.evaluateAll: bad response");
2167
+ return parsed.data;
2168
+ }
2169
+ };
2170
+ }
2171
+ /**
2172
+ * Chatbot namespace — RAG-backed AI chat over the org's knowledge
2173
+ * base. Mirrors backend `/chatbot/message` SDK route + web SDK's
2174
+ * `Chatbot` class.
2175
+ *
2176
+ * `sendMessage({ chatbotId, message })` returns the bot's reply
2177
+ * plus citations (KB article IDs the answer was grounded in) and
2178
+ * mode (`ai` when AI is enabled for the org, `canned` when the
2179
+ * fallback fires). Pass a stable `sessionId` to preserve multi-turn
2180
+ * context across calls; SDK auto-generates one per app session if
2181
+ * omitted.
2182
+ */
2183
+ get chatbot() {
2184
+ const self = this;
2185
+ return {
2186
+ sendMessage: async (input) => {
2187
+ if (!self.config) throw new Error("[sendoracloud] init() must complete before chatbot.sendMessage().");
2188
+ const body = {
2189
+ chatbotId: input.chatbotId,
2190
+ sessionId: input.sessionId ?? self.chatbotSessionId(),
2191
+ message: input.message,
2192
+ userId: input.userId ?? self.userId ?? void 0
2193
+ };
2194
+ const res = await post(
2195
+ { apiUrl: self.config.apiUrl, publicKey: self.config.publicKey, debug: self.debug },
2196
+ "/chatbot/message",
2197
+ body
2198
+ );
2199
+ if (!res || !res.ok) throw new Error(`[sendoracloud] chatbot.sendMessage failed (${res?.status ?? "network"})`);
2200
+ const parsed = await res.json();
2201
+ if (!parsed.success || !parsed.data) throw new Error("[sendoracloud] chatbot.sendMessage: bad response");
2202
+ return parsed.data;
2203
+ }
2204
+ };
2205
+ }
2206
+ chatbotSessionId() {
2207
+ if (!this._chatbotSessionId) this._chatbotSessionId = `chat_${uuid().replace(/-/g, "").slice(0, 24)}`;
2208
+ return this._chatbotSessionId;
2209
+ }
2106
2210
  /**
2107
2211
  * Clear identity + rotate the anonymous id. Call on logout. Awaits
2108
2212
  * 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.6",
3
+ "version": "0.18.8",
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",