@sendoracloud/sdk-react-native 1.12.0 → 1.14.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 +120 -83
  2. package/dist/index.js +120 -83
  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.14.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.12.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",
@@ -2045,27 +2055,46 @@ function buildDeviceContext(appVersion) {
2045
2055
  type: isPad ? "tablet" : "mobile",
2046
2056
  os: os === "ios" ? "iOS" : "Android",
2047
2057
  osVersion: String(import_react_native4.Platform.Version ?? ""),
2048
- model: "",
2058
+ model: expoDeviceModel(),
2049
2059
  appVersion: resolveAppVersion(appVersion)
2050
2060
  };
2051
2061
  } catch {
2052
2062
  return void 0;
2053
2063
  }
2054
2064
  }
2055
- function expoNativeAppVersion() {
2065
+ function expoModule(name) {
2066
+ try {
2067
+ const g = globalThis;
2068
+ const m = g?.expo?.modules?.[name];
2069
+ if (m && typeof m === "object") return m;
2070
+ } catch {
2071
+ }
2056
2072
  try {
2057
2073
  const nm = import_react_native4.NativeModules;
2058
- const c = nm?.ExponentConstants ?? nm?.ExpoConstants;
2059
- if (!c) return "";
2060
- if (typeof c.nativeAppVersion === "string" && c.nativeAppVersion) return c.nativeAppVersion;
2074
+ const m = nm?.[name];
2075
+ if (m && typeof m === "object") return m;
2076
+ } catch {
2077
+ }
2078
+ return void 0;
2079
+ }
2080
+ function expoNativeAppVersion() {
2081
+ const c = expoModule("ExponentConstants") ?? expoModule("ExpoConstants");
2082
+ if (!c) return "";
2083
+ if (typeof c.nativeAppVersion === "string" && c.nativeAppVersion) return c.nativeAppVersion;
2084
+ try {
2061
2085
  const raw = c.expoConfig ?? c.manifest ?? c.manifest2;
2062
2086
  const m = typeof raw === "string" ? JSON.parse(raw) : raw;
2063
- const v = m?.version ?? m?.extra?.expoClient?.version;
2087
+ const v = m?.version;
2064
2088
  return typeof v === "string" ? v : "";
2065
2089
  } catch {
2066
2090
  return "";
2067
2091
  }
2068
2092
  }
2093
+ function expoDeviceModel() {
2094
+ const d = expoModule("ExpoDevice");
2095
+ const v = d?.modelName;
2096
+ return typeof v === "string" ? v : "";
2097
+ }
2069
2098
  function resolveAppVersion(configAppVersion) {
2070
2099
  if (configAppVersion) return configAppVersion;
2071
2100
  const native = expoNativeAppVersion();
@@ -2136,7 +2165,15 @@ var SendoraSDK = class {
2136
2165
  `[sendoracloud] apiUrl override active: ${apiUrl} \u2014 confirm this is intentional. Tokens + events will be sent here.`
2137
2166
  );
2138
2167
  }
2139
- await this.storage.hydrate([ANON_KEY, USER_ID_KEY, ...AUTH_HYDRATE_KEYS]);
2168
+ await this.storage.hydrate([
2169
+ ANON_KEY,
2170
+ USER_ID_KEY,
2171
+ SCHEMA_VERSION_KEY,
2172
+ ...AUTH_HYDRATE_KEYS
2173
+ ]);
2174
+ if (!this.storage.get(SCHEMA_VERSION_KEY)) {
2175
+ this.storage.set(SCHEMA_VERSION_KEY, SCHEMA_VERSION);
2176
+ }
2140
2177
  let anon = this.storage.get(ANON_KEY);
2141
2178
  if (!anon) {
2142
2179
  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.14.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.12.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",
@@ -2007,27 +2017,46 @@ function buildDeviceContext(appVersion) {
2007
2017
  type: isPad ? "tablet" : "mobile",
2008
2018
  os: os === "ios" ? "iOS" : "Android",
2009
2019
  osVersion: String(Platform.Version ?? ""),
2010
- model: "",
2020
+ model: expoDeviceModel(),
2011
2021
  appVersion: resolveAppVersion(appVersion)
2012
2022
  };
2013
2023
  } catch {
2014
2024
  return void 0;
2015
2025
  }
2016
2026
  }
2017
- function expoNativeAppVersion() {
2027
+ function expoModule(name) {
2028
+ try {
2029
+ const g = globalThis;
2030
+ const m = g?.expo?.modules?.[name];
2031
+ if (m && typeof m === "object") return m;
2032
+ } catch {
2033
+ }
2018
2034
  try {
2019
2035
  const nm = NativeModules;
2020
- const c = nm?.ExponentConstants ?? nm?.ExpoConstants;
2021
- if (!c) return "";
2022
- if (typeof c.nativeAppVersion === "string" && c.nativeAppVersion) return c.nativeAppVersion;
2036
+ const m = nm?.[name];
2037
+ if (m && typeof m === "object") return m;
2038
+ } catch {
2039
+ }
2040
+ return void 0;
2041
+ }
2042
+ function expoNativeAppVersion() {
2043
+ const c = expoModule("ExponentConstants") ?? expoModule("ExpoConstants");
2044
+ if (!c) return "";
2045
+ if (typeof c.nativeAppVersion === "string" && c.nativeAppVersion) return c.nativeAppVersion;
2046
+ try {
2023
2047
  const raw = c.expoConfig ?? c.manifest ?? c.manifest2;
2024
2048
  const m = typeof raw === "string" ? JSON.parse(raw) : raw;
2025
- const v = m?.version ?? m?.extra?.expoClient?.version;
2049
+ const v = m?.version;
2026
2050
  return typeof v === "string" ? v : "";
2027
2051
  } catch {
2028
2052
  return "";
2029
2053
  }
2030
2054
  }
2055
+ function expoDeviceModel() {
2056
+ const d = expoModule("ExpoDevice");
2057
+ const v = d?.modelName;
2058
+ return typeof v === "string" ? v : "";
2059
+ }
2031
2060
  function resolveAppVersion(configAppVersion) {
2032
2061
  if (configAppVersion) return configAppVersion;
2033
2062
  const native = expoNativeAppVersion();
@@ -2098,7 +2127,15 @@ var SendoraSDK = class {
2098
2127
  `[sendoracloud] apiUrl override active: ${apiUrl} \u2014 confirm this is intentional. Tokens + events will be sent here.`
2099
2128
  );
2100
2129
  }
2101
- await this.storage.hydrate([ANON_KEY, USER_ID_KEY, ...AUTH_HYDRATE_KEYS]);
2130
+ await this.storage.hydrate([
2131
+ ANON_KEY,
2132
+ USER_ID_KEY,
2133
+ SCHEMA_VERSION_KEY,
2134
+ ...AUTH_HYDRATE_KEYS
2135
+ ]);
2136
+ if (!this.storage.get(SCHEMA_VERSION_KEY)) {
2137
+ this.storage.set(SCHEMA_VERSION_KEY, SCHEMA_VERSION);
2138
+ }
2102
2139
  let anon = this.storage.get(ANON_KEY);
2103
2140
  if (!anon) {
2104
2141
  anon = uuid();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendoracloud/sdk-react-native",
3
- "version": "1.12.0",
3
+ "version": "1.14.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",