@scalebun/react-native 1.4.0 → 1.5.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 (48) hide show
  1. package/android/src/main/java/com/scalebun/rn/ota/BsPatch.kt +182 -0
  2. package/android/src/main/java/com/scalebun/rn/ota/ScaleBunOtaModule.kt +88 -13
  3. package/android/src/oldarch/java/com/scalebun/rn/crash/ScaleBunCrashSpec.kt +16 -0
  4. package/bin/scalebun.js +55 -3
  5. package/dist/scalebun.full.js +129 -97
  6. package/dist/scalebun.full.js.map +1 -1
  7. package/dist/scalebun.slim.js +129 -97
  8. package/dist/scalebun.slim.js.map +1 -1
  9. package/ios/Ota/BsPatch.swift +180 -0
  10. package/ios/Ota/OtaSlotManager.swift +59 -2
  11. package/ios/Ota/ScaleBunOtaModule.swift +89 -10
  12. package/lib/commonjs/analytics/EventTracker.js +21 -1
  13. package/lib/commonjs/analytics/EventTracker.js.map +1 -1
  14. package/lib/commonjs/core/constants/version.js +1 -1
  15. package/lib/commonjs/core/id/installationId.js +55 -0
  16. package/lib/commonjs/core/id/installationId.js.map +1 -0
  17. package/lib/commonjs/debug/bootstrap.js +12 -0
  18. package/lib/commonjs/debug/bootstrap.js.map +1 -1
  19. package/lib/commonjs/features/ota/OtaOrchestrator.js +2 -30
  20. package/lib/commonjs/features/ota/OtaOrchestrator.js.map +1 -1
  21. package/lib/commonjs/features/session/BackendSessionAdapter.js +8 -0
  22. package/lib/commonjs/features/session/BackendSessionAdapter.js.map +1 -1
  23. package/lib/module/analytics/EventTracker.js +21 -1
  24. package/lib/module/analytics/EventTracker.js.map +1 -1
  25. package/lib/module/core/constants/version.js +1 -1
  26. package/lib/module/core/id/installationId.js +50 -0
  27. package/lib/module/core/id/installationId.js.map +1 -0
  28. package/lib/module/debug/bootstrap.js +12 -0
  29. package/lib/module/debug/bootstrap.js.map +1 -1
  30. package/lib/module/features/ota/OtaOrchestrator.js +1 -29
  31. package/lib/module/features/ota/OtaOrchestrator.js.map +1 -1
  32. package/lib/module/features/session/BackendSessionAdapter.js +8 -0
  33. package/lib/module/features/session/BackendSessionAdapter.js.map +1 -1
  34. package/lib/typescript/analytics/EventTracker.d.ts.map +1 -1
  35. package/lib/typescript/core/constants/version.d.ts +1 -1
  36. package/lib/typescript/core/id/installationId.d.ts +20 -0
  37. package/lib/typescript/core/id/installationId.d.ts.map +1 -0
  38. package/lib/typescript/debug/bootstrap.d.ts +18 -0
  39. package/lib/typescript/debug/bootstrap.d.ts.map +1 -1
  40. package/lib/typescript/features/ota/OtaOrchestrator.d.ts.map +1 -1
  41. package/lib/typescript/features/session/BackendSessionAdapter.d.ts.map +1 -1
  42. package/package.json +3 -2
  43. package/src/analytics/EventTracker.ts +21 -1
  44. package/src/core/constants/version.ts +1 -1
  45. package/src/core/id/installationId.ts +52 -0
  46. package/src/debug/bootstrap.ts +36 -0
  47. package/src/features/ota/OtaOrchestrator.ts +1 -30
  48. package/src/features/session/BackendSessionAdapter.ts +8 -0
@@ -492,7 +492,7 @@ var SDK_VERSION;
492
492
  var init_version = __esm({
493
493
  "lib/module/core/constants/version.js"() {
494
494
  "use strict";
495
- SDK_VERSION = "1.4.0";
495
+ SDK_VERSION = "1.5.0";
496
496
  }
497
497
  });
498
498
 
@@ -5331,6 +5331,10 @@ function enableDebug(config) {
5331
5331
  __DEV__ && logger.debug("Debug already enabled, skipping");
5332
5332
  return;
5333
5333
  }
5334
+ if (!__DEV__ && !config.allowInRelease) {
5335
+ logger.warn("[ScaleBun] Debug connection refused in a release build. The debug transport is unencrypted (ws://) and carries captured traffic and the shared secret in cleartext, so it is development-only by default. If you genuinely need it in a release build, set `allowInRelease: true` \u2014 and do not ship that to users.");
5336
+ return;
5337
+ }
5334
5338
  if (!isDevToolsBundled()) {
5335
5339
  logger.warn("[ScaleBun] debugConnection was configured, but the desktop-debugger tooling is not in this bundle. It is excluded by default (the ScaleBun desktop app is not yet released); opt in with `withScaleBun(config, { features: { devTools: true } })` in metro.config.js. All other SDK behaviour is unaffected.");
5336
5340
  return;
@@ -5854,89 +5858,6 @@ var init_NativeScaleBunPerformance = __esm({
5854
5858
  }
5855
5859
  });
5856
5860
 
5857
- // lib/module/analytics/batching.js
5858
- function chunkEvents(events, size = MAX_BATCH_EVENTS) {
5859
- const cap = Math.max(1, Math.min(size, MAX_BATCH_EVENTS));
5860
- if (events.length <= cap) return events.length ? [events.slice()] : [];
5861
- const out = [];
5862
- for (let i = 0; i < events.length; i += cap) {
5863
- out.push(events.slice(i, i + cap));
5864
- }
5865
- return out;
5866
- }
5867
- function clampBatchSize(configured, fallback) {
5868
- const n = typeof configured === "number" && configured > 0 ? configured : fallback;
5869
- return Math.max(1, Math.min(n, MAX_BATCH_EVENTS));
5870
- }
5871
- function batchIdempotencyKey(eventIds) {
5872
- let h = 2166136261;
5873
- const joined = eventIds.join("");
5874
- for (let i = 0; i < joined.length; i++) {
5875
- h ^= joined.charCodeAt(i);
5876
- h = Math.imul(h, 16777619) >>> 0;
5877
- }
5878
- return `sdk-${eventIds.length}-${h.toString(16).padStart(8, "0")}`;
5879
- }
5880
- var MAX_BATCH_EVENTS;
5881
- var init_batching = __esm({
5882
- "lib/module/analytics/batching.js"() {
5883
- "use strict";
5884
- MAX_BATCH_EVENTS = 500;
5885
- }
5886
- });
5887
-
5888
- // lib/module/analytics/automaticEvents.js
5889
- function compactProperties(properties) {
5890
- const out = {
5891
- capture_source: "automatic"
5892
- };
5893
- for (const [key, value] of Object.entries(properties ?? {})) {
5894
- if (value !== void 0) out[key] = value;
5895
- }
5896
- return out;
5897
- }
5898
- function emitAutomaticEvent(name, properties) {
5899
- const event = {
5900
- name,
5901
- properties: compactProperties(properties)
5902
- };
5903
- if (listeners.size === 0) {
5904
- pending3.push(event);
5905
- if (pending3.length > MAX_PENDING2) pending3.shift();
5906
- return;
5907
- }
5908
- for (const listener of listeners) {
5909
- try {
5910
- listener(event);
5911
- } catch {
5912
- }
5913
- }
5914
- }
5915
- function subscribeAutomaticEvents(listener) {
5916
- listeners.add(listener);
5917
- if (pending3.length > 0) {
5918
- const buffered = pending3.splice(0, pending3.length);
5919
- for (const event of buffered) {
5920
- try {
5921
- listener(event);
5922
- } catch {
5923
- }
5924
- }
5925
- }
5926
- return () => {
5927
- listeners.delete(listener);
5928
- };
5929
- }
5930
- var listeners, pending3, MAX_PENDING2;
5931
- var init_automaticEvents = __esm({
5932
- "lib/module/analytics/automaticEvents.js"() {
5933
- "use strict";
5934
- listeners = /* @__PURE__ */ new Set();
5935
- pending3 = [];
5936
- MAX_PENDING2 = 50;
5937
- }
5938
- });
5939
-
5940
5861
  // lib/module/crypto/hmacSha256.js
5941
5862
  function utf8(str3) {
5942
5863
  const out = [];
@@ -6053,6 +5974,89 @@ var init_hmacSha256 = __esm({
6053
5974
  }
6054
5975
  });
6055
5976
 
5977
+ // lib/module/analytics/batching.js
5978
+ function chunkEvents(events, size = MAX_BATCH_EVENTS) {
5979
+ const cap = Math.max(1, Math.min(size, MAX_BATCH_EVENTS));
5980
+ if (events.length <= cap) return events.length ? [events.slice()] : [];
5981
+ const out = [];
5982
+ for (let i = 0; i < events.length; i += cap) {
5983
+ out.push(events.slice(i, i + cap));
5984
+ }
5985
+ return out;
5986
+ }
5987
+ function clampBatchSize(configured, fallback) {
5988
+ const n = typeof configured === "number" && configured > 0 ? configured : fallback;
5989
+ return Math.max(1, Math.min(n, MAX_BATCH_EVENTS));
5990
+ }
5991
+ function batchIdempotencyKey(eventIds) {
5992
+ let h = 2166136261;
5993
+ const joined = eventIds.join("");
5994
+ for (let i = 0; i < joined.length; i++) {
5995
+ h ^= joined.charCodeAt(i);
5996
+ h = Math.imul(h, 16777619) >>> 0;
5997
+ }
5998
+ return `sdk-${eventIds.length}-${h.toString(16).padStart(8, "0")}`;
5999
+ }
6000
+ var MAX_BATCH_EVENTS;
6001
+ var init_batching = __esm({
6002
+ "lib/module/analytics/batching.js"() {
6003
+ "use strict";
6004
+ MAX_BATCH_EVENTS = 500;
6005
+ }
6006
+ });
6007
+
6008
+ // lib/module/analytics/automaticEvents.js
6009
+ function compactProperties(properties) {
6010
+ const out = {
6011
+ capture_source: "automatic"
6012
+ };
6013
+ for (const [key, value] of Object.entries(properties ?? {})) {
6014
+ if (value !== void 0) out[key] = value;
6015
+ }
6016
+ return out;
6017
+ }
6018
+ function emitAutomaticEvent(name, properties) {
6019
+ const event = {
6020
+ name,
6021
+ properties: compactProperties(properties)
6022
+ };
6023
+ if (listeners.size === 0) {
6024
+ pending3.push(event);
6025
+ if (pending3.length > MAX_PENDING2) pending3.shift();
6026
+ return;
6027
+ }
6028
+ for (const listener of listeners) {
6029
+ try {
6030
+ listener(event);
6031
+ } catch {
6032
+ }
6033
+ }
6034
+ }
6035
+ function subscribeAutomaticEvents(listener) {
6036
+ listeners.add(listener);
6037
+ if (pending3.length > 0) {
6038
+ const buffered = pending3.splice(0, pending3.length);
6039
+ for (const event of buffered) {
6040
+ try {
6041
+ listener(event);
6042
+ } catch {
6043
+ }
6044
+ }
6045
+ }
6046
+ return () => {
6047
+ listeners.delete(listener);
6048
+ };
6049
+ }
6050
+ var listeners, pending3, MAX_PENDING2;
6051
+ var init_automaticEvents = __esm({
6052
+ "lib/module/analytics/automaticEvents.js"() {
6053
+ "use strict";
6054
+ listeners = /* @__PURE__ */ new Set();
6055
+ pending3 = [];
6056
+ MAX_PENDING2 = 50;
6057
+ }
6058
+ });
6059
+
6056
6060
  // lib/module/analytics/EventTracker.js
6057
6061
  function uuid() {
6058
6062
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
@@ -6418,6 +6422,38 @@ var init_EventTracker = __esm({
6418
6422
  }
6419
6423
  });
6420
6424
 
6425
+ // lib/module/core/id/installationId.js
6426
+ function resolveInstallationId() {
6427
+ try {
6428
+ const storage3 = createStorageBackend();
6429
+ const existing = storage3.get(K_INSTALLATION_ID);
6430
+ if (existing) return existing;
6431
+ const id = `inst-${randomSegment()}${randomSegment()}`;
6432
+ storage3.set(K_INSTALLATION_ID, id);
6433
+ return id;
6434
+ } catch {
6435
+ return `inst-ephemeral-${randomSegment()}`;
6436
+ }
6437
+ }
6438
+ function randomSegment() {
6439
+ try {
6440
+ const g = globalThis;
6441
+ if (g.crypto?.getRandomValues) {
6442
+ const bytes = g.crypto.getRandomValues(new Uint8Array(6));
6443
+ return Array.from(bytes).map((b) => b.toString(36).padStart(2, "0")).join("").slice(0, 8);
6444
+ }
6445
+ } catch {
6446
+ }
6447
+ return Math.random().toString(36).slice(2, 10).padEnd(8, "0");
6448
+ }
6449
+ var init_installationId = __esm({
6450
+ "lib/module/core/id/installationId.js"() {
6451
+ "use strict";
6452
+ init_StorageBackend();
6453
+ init_EventTracker();
6454
+ }
6455
+ });
6456
+
6421
6457
  // lib/module/features/engage/engageSignals.js
6422
6458
  var EngageSignalBus, engageSignals;
6423
6459
  var init_engageSignals = __esm({
@@ -6877,18 +6913,6 @@ function subscribeNativeProgress(onTick) {
6877
6913
  };
6878
6914
  }
6879
6915
  }
6880
- function resolveInstallationId() {
6881
- try {
6882
- const storage3 = createStorageBackend();
6883
- const existing = storage3.get(K_INSTALLATION_ID);
6884
- if (existing) return existing;
6885
- const id = `inst-${Math.random().toString(36).slice(2, 10)}${Math.random().toString(36).slice(2, 10)}`;
6886
- storage3.set(K_INSTALLATION_ID, id);
6887
- return id;
6888
- } catch {
6889
- return `inst-ephemeral-${Math.random().toString(36).slice(2, 10)}`;
6890
- }
6891
- }
6892
6916
  async function deliverOtaEvents(params) {
6893
6917
  const events = otaEventEmitter.flush();
6894
6918
  if (!events.length) return;
@@ -6938,7 +6962,7 @@ var init_OtaOrchestrator = __esm({
6938
6962
  init_OtaEventEmitter();
6939
6963
  init_geoCountry();
6940
6964
  init_deviceAttributes();
6941
- init_EventTracker();
6965
+ init_installationId();
6942
6966
  init_signature();
6943
6967
  init_environment();
6944
6968
  init_retry();
@@ -12172,6 +12196,7 @@ function decodeManual(base64) {
12172
12196
  }
12173
12197
 
12174
12198
  // lib/module/features/session/BackendSessionAdapter.js
12199
+ init_installationId();
12175
12200
  init_version();
12176
12201
  init_bridgeAdapter();
12177
12202
  init_nativeModule();
@@ -12307,6 +12332,13 @@ var BackendSessionAdapter = class _BackendSessionAdapter {
12307
12332
  const payload = {
12308
12333
  sessionId: session.sessionId,
12309
12334
  deviceId: session.deviceId,
12335
+ // The canonical per-install id — the SAME value OTA events are
12336
+ // reported under, and a DIFFERENT value from deviceId. The
12337
+ // backend stores it on the Device so release health can join a
12338
+ // bundle's installs to that device's sessions. Without it, crash
12339
+ // impact for a release resolves to "no data" for every device
12340
+ // that never registered for push.
12341
+ installationId: resolveInstallationId(),
12310
12342
  startedAt: session.startedAt,
12311
12343
  // Link the recording row to the always-on analytics row so the
12312
12344
  // dashboard can join them. track() events land on the analytics