@sendoracloud/sdk-react-native 1.13.0 → 1.15.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.
Files changed (3) hide show
  1. package/dist/index.cjs +114 -81
  2. package/dist/index.js +114 -81
  3. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -136,7 +136,84 @@ var Storage = class {
136
136
  }
137
137
  };
138
138
 
139
+ // package.json
140
+ var package_default = {
141
+ name: "@sendoracloud/sdk-react-native",
142
+ version: "1.15.0",
143
+ description: "Sendora Cloud React Native + Expo SDK \u2014 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`).",
144
+ type: "module",
145
+ main: "./dist/index.cjs",
146
+ module: "./dist/index.js",
147
+ types: "./dist/index.d.ts",
148
+ exports: {
149
+ ".": {
150
+ types: "./dist/index.d.ts",
151
+ import: "./dist/index.js",
152
+ require: "./dist/index.cjs"
153
+ },
154
+ "./contact-widget": {
155
+ types: "./dist/contact-widget.d.ts",
156
+ import: "./dist/contact-widget.js",
157
+ require: "./dist/contact-widget.cjs"
158
+ }
159
+ },
160
+ files: [
161
+ "dist",
162
+ "examples",
163
+ "README.md",
164
+ "LICENSE"
165
+ ],
166
+ keywords: [
167
+ "sendora",
168
+ "react-native",
169
+ "expo",
170
+ "analytics",
171
+ "tracking",
172
+ "customer-engagement"
173
+ ],
174
+ dependencies: {
175
+ "react-native-get-random-values": "^1.11.0"
176
+ },
177
+ peerDependencies: {
178
+ "@react-native-async-storage/async-storage": ">=1.17.0",
179
+ "react-native": ">=0.70.0",
180
+ "react-native-webview": ">=13.0.0"
181
+ },
182
+ peerDependenciesMeta: {
183
+ "@react-native-async-storage/async-storage": {
184
+ optional: false
185
+ },
186
+ "react-native": {
187
+ optional: false
188
+ },
189
+ "react-native-webview": {
190
+ optional: true
191
+ }
192
+ },
193
+ scripts: {
194
+ build: "tsup src/index.ts src/contact-widget.tsx --format esm,cjs --dts --clean --external react --external react-native --external react-native-webview",
195
+ typecheck: "tsc --noEmit"
196
+ },
197
+ devDependencies: {
198
+ "@types/react": "^19.2.16",
199
+ "react-native": "^0.85.3",
200
+ "react-native-webview": "^13.16.1",
201
+ tsup: "^8.0.0",
202
+ typescript: "^5.0.0"
203
+ },
204
+ license: "MIT",
205
+ repository: {
206
+ type: "git",
207
+ url: "https://github.com/sendoracloud/sdk-react-native"
208
+ },
209
+ homepage: "https://sendoracloud.com/sdks"
210
+ };
211
+
212
+ // src/version.ts
213
+ var SDK_VERSION = package_default.version;
214
+
139
215
  // src/http.ts
216
+ var SDK_NAME = "@sendoracloud/sdk-react-native";
140
217
  var NetworkTimeoutError = class extends Error {
141
218
  constructor(method, path, timeoutMs) {
142
219
  super(`Request timed out: ${method} ${path} (${timeoutMs}ms)`);
@@ -179,6 +256,13 @@ async function request(opts, method, path, body, extraHeaders, reqOpts) {
179
256
  // silently 401'd. Do not change this header without updating
180
257
  // apps/backend/src/middleware/auth.ts in lockstep.
181
258
  "x-api-key": opts.publicKey,
259
+ // ADR-023: identify the SDK + version on every request so the
260
+ // backend can attribute traffic + drive version-adoption /
261
+ // compatibility telemetry. Additive — the server ignores these
262
+ // today. Placed before extraHeaders so a caller could override
263
+ // if ever needed (none do).
264
+ "X-Sendora-SDK-Name": SDK_NAME,
265
+ "X-Sendora-SDK-Version": SDK_VERSION,
182
266
  ...extraHeaders ?? {}
183
267
  },
184
268
  body: body !== void 0 ? JSON.stringify(body) : void 0,
@@ -220,82 +304,6 @@ async function request(opts, method, path, body, extraHeaders, reqOpts) {
220
304
  return res;
221
305
  }
222
306
 
223
- // package.json
224
- var package_default = {
225
- name: "@sendoracloud/sdk-react-native",
226
- version: "1.13.0",
227
- description: "Sendora Cloud React Native + Expo SDK \u2014 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`).",
228
- type: "module",
229
- main: "./dist/index.cjs",
230
- module: "./dist/index.js",
231
- types: "./dist/index.d.ts",
232
- exports: {
233
- ".": {
234
- types: "./dist/index.d.ts",
235
- import: "./dist/index.js",
236
- require: "./dist/index.cjs"
237
- },
238
- "./contact-widget": {
239
- types: "./dist/contact-widget.d.ts",
240
- import: "./dist/contact-widget.js",
241
- require: "./dist/contact-widget.cjs"
242
- }
243
- },
244
- files: [
245
- "dist",
246
- "examples",
247
- "README.md",
248
- "LICENSE"
249
- ],
250
- keywords: [
251
- "sendora",
252
- "react-native",
253
- "expo",
254
- "analytics",
255
- "tracking",
256
- "customer-engagement"
257
- ],
258
- dependencies: {
259
- "react-native-get-random-values": "^1.11.0"
260
- },
261
- peerDependencies: {
262
- "@react-native-async-storage/async-storage": ">=1.17.0",
263
- "react-native": ">=0.70.0",
264
- "react-native-webview": ">=13.0.0"
265
- },
266
- peerDependenciesMeta: {
267
- "@react-native-async-storage/async-storage": {
268
- optional: false
269
- },
270
- "react-native": {
271
- optional: false
272
- },
273
- "react-native-webview": {
274
- optional: true
275
- }
276
- },
277
- scripts: {
278
- build: "tsup src/index.ts src/contact-widget.tsx --format esm,cjs --dts --clean --external react --external react-native --external react-native-webview",
279
- typecheck: "tsc --noEmit"
280
- },
281
- devDependencies: {
282
- "@types/react": "^19.2.16",
283
- "react-native": "^0.85.3",
284
- "react-native-webview": "^13.16.1",
285
- tsup: "^8.0.0",
286
- typescript: "^5.0.0"
287
- },
288
- license: "MIT",
289
- repository: {
290
- type: "git",
291
- url: "https://github.com/sendoracloud/sdk-react-native"
292
- },
293
- homepage: "https://sendoracloud.com/sdks"
294
- };
295
-
296
- // src/version.ts
297
- var SDK_VERSION = package_default.version;
298
-
299
307
  // src/auth.ts
300
308
  var import_react_native = require("react-native");
301
309
  var TOKEN_KEY = "auth_access_token";
@@ -1983,6 +1991,8 @@ function installAutoTrack(args) {
1983
1991
  var DEFAULT_API_URL = "https://api.sendoracloud.com";
1984
1992
  var ANON_KEY = "anon_id";
1985
1993
  var USER_ID_KEY = "user_id";
1994
+ var SCHEMA_VERSION_KEY = "schema_version";
1995
+ var SCHEMA_VERSION = "1";
1986
1996
  var AUTH_HYDRATE_KEYS = [
1987
1997
  "auth_access_token",
1988
1998
  "auth_access_expires",
@@ -2059,6 +2069,14 @@ function expoModule(name) {
2059
2069
  if (m && typeof m === "object") return m;
2060
2070
  } catch {
2061
2071
  }
2072
+ try {
2073
+ const g = globalThis;
2074
+ const nm = import_react_native4.NativeModules;
2075
+ const proxy = g?.expo?.modules?.NativeModulesProxy ?? nm?.NativeUnimoduleProxy;
2076
+ const consts = proxy?.modulesConstants?.[name];
2077
+ if (consts && typeof consts === "object") return consts;
2078
+ } catch {
2079
+ }
2062
2080
  try {
2063
2081
  const nm = import_react_native4.NativeModules;
2064
2082
  const m = nm?.[name];
@@ -2067,12 +2085,17 @@ function expoModule(name) {
2067
2085
  }
2068
2086
  return void 0;
2069
2087
  }
2070
- function expoNativeAppVersion() {
2088
+ function expoApplicationVersion() {
2089
+ const a = expoModule("ExpoApplication");
2090
+ const v = a?.nativeApplicationVersion;
2091
+ return typeof v === "string" && v ? v : "";
2092
+ }
2093
+ function expoConstantsVersion() {
2071
2094
  const c = expoModule("ExponentConstants") ?? expoModule("ExpoConstants");
2072
2095
  if (!c) return "";
2073
2096
  if (typeof c.nativeAppVersion === "string" && c.nativeAppVersion) return c.nativeAppVersion;
2074
2097
  try {
2075
- const raw = c.expoConfig ?? c.manifest ?? c.manifest2;
2098
+ const raw = c.manifest ?? c.expoConfig ?? c.manifest2;
2076
2099
  const m = typeof raw === "string" ? JSON.parse(raw) : raw;
2077
2100
  const v = m?.version;
2078
2101
  return typeof v === "string" ? v : "";
@@ -2087,8 +2110,10 @@ function expoDeviceModel() {
2087
2110
  }
2088
2111
  function resolveAppVersion(configAppVersion) {
2089
2112
  if (configAppVersion) return configAppVersion;
2090
- const native = expoNativeAppVersion();
2091
- if (native) return native;
2113
+ const appMod = expoApplicationVersion();
2114
+ if (appMod) return appMod;
2115
+ const constMod = expoConstantsVersion();
2116
+ if (constMod) return constMod;
2092
2117
  try {
2093
2118
  const env = process.env.EXPO_PUBLIC_APP_VERSION;
2094
2119
  if (env) return env;
@@ -2155,7 +2180,15 @@ var SendoraSDK = class {
2155
2180
  `[sendoracloud] apiUrl override active: ${apiUrl} \u2014 confirm this is intentional. Tokens + events will be sent here.`
2156
2181
  );
2157
2182
  }
2158
- await this.storage.hydrate([ANON_KEY, USER_ID_KEY, ...AUTH_HYDRATE_KEYS]);
2183
+ await this.storage.hydrate([
2184
+ ANON_KEY,
2185
+ USER_ID_KEY,
2186
+ SCHEMA_VERSION_KEY,
2187
+ ...AUTH_HYDRATE_KEYS
2188
+ ]);
2189
+ if (!this.storage.get(SCHEMA_VERSION_KEY)) {
2190
+ this.storage.set(SCHEMA_VERSION_KEY, SCHEMA_VERSION);
2191
+ }
2159
2192
  let anon = this.storage.get(ANON_KEY);
2160
2193
  if (!anon) {
2161
2194
  anon = uuid();
package/dist/index.js CHANGED
@@ -93,7 +93,84 @@ var Storage = class {
93
93
  }
94
94
  };
95
95
 
96
+ // package.json
97
+ var package_default = {
98
+ name: "@sendoracloud/sdk-react-native",
99
+ version: "1.15.0",
100
+ description: "Sendora Cloud React Native + Expo SDK \u2014 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`).",
101
+ type: "module",
102
+ main: "./dist/index.cjs",
103
+ module: "./dist/index.js",
104
+ types: "./dist/index.d.ts",
105
+ exports: {
106
+ ".": {
107
+ types: "./dist/index.d.ts",
108
+ import: "./dist/index.js",
109
+ require: "./dist/index.cjs"
110
+ },
111
+ "./contact-widget": {
112
+ types: "./dist/contact-widget.d.ts",
113
+ import: "./dist/contact-widget.js",
114
+ require: "./dist/contact-widget.cjs"
115
+ }
116
+ },
117
+ files: [
118
+ "dist",
119
+ "examples",
120
+ "README.md",
121
+ "LICENSE"
122
+ ],
123
+ keywords: [
124
+ "sendora",
125
+ "react-native",
126
+ "expo",
127
+ "analytics",
128
+ "tracking",
129
+ "customer-engagement"
130
+ ],
131
+ dependencies: {
132
+ "react-native-get-random-values": "^1.11.0"
133
+ },
134
+ peerDependencies: {
135
+ "@react-native-async-storage/async-storage": ">=1.17.0",
136
+ "react-native": ">=0.70.0",
137
+ "react-native-webview": ">=13.0.0"
138
+ },
139
+ peerDependenciesMeta: {
140
+ "@react-native-async-storage/async-storage": {
141
+ optional: false
142
+ },
143
+ "react-native": {
144
+ optional: false
145
+ },
146
+ "react-native-webview": {
147
+ optional: true
148
+ }
149
+ },
150
+ scripts: {
151
+ build: "tsup src/index.ts src/contact-widget.tsx --format esm,cjs --dts --clean --external react --external react-native --external react-native-webview",
152
+ typecheck: "tsc --noEmit"
153
+ },
154
+ devDependencies: {
155
+ "@types/react": "^19.2.16",
156
+ "react-native": "^0.85.3",
157
+ "react-native-webview": "^13.16.1",
158
+ tsup: "^8.0.0",
159
+ typescript: "^5.0.0"
160
+ },
161
+ license: "MIT",
162
+ repository: {
163
+ type: "git",
164
+ url: "https://github.com/sendoracloud/sdk-react-native"
165
+ },
166
+ homepage: "https://sendoracloud.com/sdks"
167
+ };
168
+
169
+ // src/version.ts
170
+ var SDK_VERSION = package_default.version;
171
+
96
172
  // src/http.ts
173
+ var SDK_NAME = "@sendoracloud/sdk-react-native";
97
174
  var NetworkTimeoutError = class extends Error {
98
175
  constructor(method, path, timeoutMs) {
99
176
  super(`Request timed out: ${method} ${path} (${timeoutMs}ms)`);
@@ -136,6 +213,13 @@ async function request(opts, method, path, body, extraHeaders, reqOpts) {
136
213
  // silently 401'd. Do not change this header without updating
137
214
  // apps/backend/src/middleware/auth.ts in lockstep.
138
215
  "x-api-key": opts.publicKey,
216
+ // ADR-023: identify the SDK + version on every request so the
217
+ // backend can attribute traffic + drive version-adoption /
218
+ // compatibility telemetry. Additive — the server ignores these
219
+ // today. Placed before extraHeaders so a caller could override
220
+ // if ever needed (none do).
221
+ "X-Sendora-SDK-Name": SDK_NAME,
222
+ "X-Sendora-SDK-Version": SDK_VERSION,
139
223
  ...extraHeaders ?? {}
140
224
  },
141
225
  body: body !== void 0 ? JSON.stringify(body) : void 0,
@@ -177,82 +261,6 @@ async function request(opts, method, path, body, extraHeaders, reqOpts) {
177
261
  return res;
178
262
  }
179
263
 
180
- // package.json
181
- var package_default = {
182
- name: "@sendoracloud/sdk-react-native",
183
- version: "1.13.0",
184
- description: "Sendora Cloud React Native + Expo SDK \u2014 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`).",
185
- type: "module",
186
- main: "./dist/index.cjs",
187
- module: "./dist/index.js",
188
- types: "./dist/index.d.ts",
189
- exports: {
190
- ".": {
191
- types: "./dist/index.d.ts",
192
- import: "./dist/index.js",
193
- require: "./dist/index.cjs"
194
- },
195
- "./contact-widget": {
196
- types: "./dist/contact-widget.d.ts",
197
- import: "./dist/contact-widget.js",
198
- require: "./dist/contact-widget.cjs"
199
- }
200
- },
201
- files: [
202
- "dist",
203
- "examples",
204
- "README.md",
205
- "LICENSE"
206
- ],
207
- keywords: [
208
- "sendora",
209
- "react-native",
210
- "expo",
211
- "analytics",
212
- "tracking",
213
- "customer-engagement"
214
- ],
215
- dependencies: {
216
- "react-native-get-random-values": "^1.11.0"
217
- },
218
- peerDependencies: {
219
- "@react-native-async-storage/async-storage": ">=1.17.0",
220
- "react-native": ">=0.70.0",
221
- "react-native-webview": ">=13.0.0"
222
- },
223
- peerDependenciesMeta: {
224
- "@react-native-async-storage/async-storage": {
225
- optional: false
226
- },
227
- "react-native": {
228
- optional: false
229
- },
230
- "react-native-webview": {
231
- optional: true
232
- }
233
- },
234
- scripts: {
235
- build: "tsup src/index.ts src/contact-widget.tsx --format esm,cjs --dts --clean --external react --external react-native --external react-native-webview",
236
- typecheck: "tsc --noEmit"
237
- },
238
- devDependencies: {
239
- "@types/react": "^19.2.16",
240
- "react-native": "^0.85.3",
241
- "react-native-webview": "^13.16.1",
242
- tsup: "^8.0.0",
243
- typescript: "^5.0.0"
244
- },
245
- license: "MIT",
246
- repository: {
247
- type: "git",
248
- url: "https://github.com/sendoracloud/sdk-react-native"
249
- },
250
- homepage: "https://sendoracloud.com/sdks"
251
- };
252
-
253
- // src/version.ts
254
- var SDK_VERSION = package_default.version;
255
-
256
264
  // src/auth.ts
257
265
  import { AppState as RnAppState } from "react-native";
258
266
  var TOKEN_KEY = "auth_access_token";
@@ -1945,6 +1953,8 @@ function installAutoTrack(args) {
1945
1953
  var DEFAULT_API_URL = "https://api.sendoracloud.com";
1946
1954
  var ANON_KEY = "anon_id";
1947
1955
  var USER_ID_KEY = "user_id";
1956
+ var SCHEMA_VERSION_KEY = "schema_version";
1957
+ var SCHEMA_VERSION = "1";
1948
1958
  var AUTH_HYDRATE_KEYS = [
1949
1959
  "auth_access_token",
1950
1960
  "auth_access_expires",
@@ -2021,6 +2031,14 @@ function expoModule(name) {
2021
2031
  if (m && typeof m === "object") return m;
2022
2032
  } catch {
2023
2033
  }
2034
+ try {
2035
+ const g = globalThis;
2036
+ const nm = NativeModules;
2037
+ const proxy = g?.expo?.modules?.NativeModulesProxy ?? nm?.NativeUnimoduleProxy;
2038
+ const consts = proxy?.modulesConstants?.[name];
2039
+ if (consts && typeof consts === "object") return consts;
2040
+ } catch {
2041
+ }
2024
2042
  try {
2025
2043
  const nm = NativeModules;
2026
2044
  const m = nm?.[name];
@@ -2029,12 +2047,17 @@ function expoModule(name) {
2029
2047
  }
2030
2048
  return void 0;
2031
2049
  }
2032
- function expoNativeAppVersion() {
2050
+ function expoApplicationVersion() {
2051
+ const a = expoModule("ExpoApplication");
2052
+ const v = a?.nativeApplicationVersion;
2053
+ return typeof v === "string" && v ? v : "";
2054
+ }
2055
+ function expoConstantsVersion() {
2033
2056
  const c = expoModule("ExponentConstants") ?? expoModule("ExpoConstants");
2034
2057
  if (!c) return "";
2035
2058
  if (typeof c.nativeAppVersion === "string" && c.nativeAppVersion) return c.nativeAppVersion;
2036
2059
  try {
2037
- const raw = c.expoConfig ?? c.manifest ?? c.manifest2;
2060
+ const raw = c.manifest ?? c.expoConfig ?? c.manifest2;
2038
2061
  const m = typeof raw === "string" ? JSON.parse(raw) : raw;
2039
2062
  const v = m?.version;
2040
2063
  return typeof v === "string" ? v : "";
@@ -2049,8 +2072,10 @@ function expoDeviceModel() {
2049
2072
  }
2050
2073
  function resolveAppVersion(configAppVersion) {
2051
2074
  if (configAppVersion) return configAppVersion;
2052
- const native = expoNativeAppVersion();
2053
- if (native) return native;
2075
+ const appMod = expoApplicationVersion();
2076
+ if (appMod) return appMod;
2077
+ const constMod = expoConstantsVersion();
2078
+ if (constMod) return constMod;
2054
2079
  try {
2055
2080
  const env = process.env.EXPO_PUBLIC_APP_VERSION;
2056
2081
  if (env) return env;
@@ -2117,7 +2142,15 @@ var SendoraSDK = class {
2117
2142
  `[sendoracloud] apiUrl override active: ${apiUrl} \u2014 confirm this is intentional. Tokens + events will be sent here.`
2118
2143
  );
2119
2144
  }
2120
- await this.storage.hydrate([ANON_KEY, USER_ID_KEY, ...AUTH_HYDRATE_KEYS]);
2145
+ await this.storage.hydrate([
2146
+ ANON_KEY,
2147
+ USER_ID_KEY,
2148
+ SCHEMA_VERSION_KEY,
2149
+ ...AUTH_HYDRATE_KEYS
2150
+ ]);
2151
+ if (!this.storage.get(SCHEMA_VERSION_KEY)) {
2152
+ this.storage.set(SCHEMA_VERSION_KEY, SCHEMA_VERSION);
2153
+ }
2121
2154
  let anon = this.storage.get(ANON_KEY);
2122
2155
  if (!anon) {
2123
2156
  anon = uuid();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "1.13.0",
3
+ "version": "1.15.0",
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",