@formo/analytics-react-native 1.0.1 → 1.1.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 (96) hide show
  1. package/lib/commonjs/FormoAnalytics.js +15 -3
  2. package/lib/commonjs/FormoAnalytics.js.map +1 -1
  3. package/lib/commonjs/lib/crash/index.js +23 -7
  4. package/lib/commonjs/lib/crash/index.js.map +1 -1
  5. package/lib/commonjs/lib/event/EventFactory.js +11 -1
  6. package/lib/commonjs/lib/event/EventFactory.js.map +1 -1
  7. package/lib/commonjs/lib/event/EventQueue.js +367 -57
  8. package/lib/commonjs/lib/event/EventQueue.js.map +1 -1
  9. package/lib/commonjs/utils/sanitize.js +260 -0
  10. package/lib/commonjs/utils/sanitize.js.map +1 -0
  11. package/lib/commonjs/utils/trafficSource.js +10 -1
  12. package/lib/commonjs/utils/trafficSource.js.map +1 -1
  13. package/lib/commonjs/version.js +1 -1
  14. package/lib/module/FormoAnalytics.js +15 -3
  15. package/lib/module/FormoAnalytics.js.map +1 -1
  16. package/lib/module/lib/crash/index.js +23 -7
  17. package/lib/module/lib/crash/index.js.map +1 -1
  18. package/lib/module/lib/event/EventFactory.js +11 -1
  19. package/lib/module/lib/event/EventFactory.js.map +1 -1
  20. package/lib/module/lib/event/EventQueue.js +368 -57
  21. package/lib/module/lib/event/EventQueue.js.map +1 -1
  22. package/lib/module/utils/sanitize.js +253 -0
  23. package/lib/module/utils/sanitize.js.map +1 -0
  24. package/lib/module/utils/trafficSource.js +10 -1
  25. package/lib/module/utils/trafficSource.js.map +1 -1
  26. package/lib/module/version.js +1 -1
  27. package/lib/typescript/commonjs/FormoAnalytics.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/lib/crash/index.d.ts.map +1 -1
  29. package/lib/typescript/commonjs/lib/event/EventFactory.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/lib/event/EventQueue.d.ts +55 -0
  31. package/lib/typescript/commonjs/lib/event/EventQueue.d.ts.map +1 -1
  32. package/lib/typescript/commonjs/utils/sanitize.d.ts +31 -0
  33. package/lib/typescript/commonjs/utils/sanitize.d.ts.map +1 -0
  34. package/lib/typescript/commonjs/utils/trafficSource.d.ts +3 -0
  35. package/lib/typescript/commonjs/utils/trafficSource.d.ts.map +1 -1
  36. package/lib/typescript/commonjs/version.d.ts +1 -1
  37. package/lib/typescript/module/FormoAnalytics.d.ts +2 -2
  38. package/lib/typescript/module/FormoAnalytics.d.ts.map +1 -1
  39. package/lib/typescript/module/FormoAnalyticsProvider.d.ts +1 -1
  40. package/lib/typescript/module/FormoAnalyticsProvider.d.ts.map +1 -1
  41. package/lib/typescript/module/constants/index.d.ts +3 -3
  42. package/lib/typescript/module/constants/index.d.ts.map +1 -1
  43. package/lib/typescript/module/index.d.ts +5 -5
  44. package/lib/typescript/module/index.d.ts.map +1 -1
  45. package/lib/typescript/module/lib/crash/index.d.ts.map +1 -1
  46. package/lib/typescript/module/lib/event/EventFactory.d.ts +2 -2
  47. package/lib/typescript/module/lib/event/EventFactory.d.ts.map +1 -1
  48. package/lib/typescript/module/lib/event/EventManager.d.ts +2 -2
  49. package/lib/typescript/module/lib/event/EventManager.d.ts.map +1 -1
  50. package/lib/typescript/module/lib/event/EventQueue.d.ts +57 -2
  51. package/lib/typescript/module/lib/event/EventQueue.d.ts.map +1 -1
  52. package/lib/typescript/module/lib/event/index.d.ts +4 -4
  53. package/lib/typescript/module/lib/event/index.d.ts.map +1 -1
  54. package/lib/typescript/module/lib/event/types.d.ts +1 -1
  55. package/lib/typescript/module/lib/event/types.d.ts.map +1 -1
  56. package/lib/typescript/module/lib/session/index.d.ts +1 -1
  57. package/lib/typescript/module/lib/session/index.d.ts.map +1 -1
  58. package/lib/typescript/module/lib/storage/AsyncStorageAdapter.d.ts +2 -2
  59. package/lib/typescript/module/lib/storage/AsyncStorageAdapter.d.ts.map +1 -1
  60. package/lib/typescript/module/lib/storage/MemoryStorage.d.ts +1 -1
  61. package/lib/typescript/module/lib/storage/MemoryStorage.d.ts.map +1 -1
  62. package/lib/typescript/module/lib/storage/StorageBlueprint.d.ts +1 -1
  63. package/lib/typescript/module/lib/storage/StorageBlueprint.d.ts.map +1 -1
  64. package/lib/typescript/module/lib/storage/StorageManager.d.ts +1 -1
  65. package/lib/typescript/module/lib/storage/StorageManager.d.ts.map +1 -1
  66. package/lib/typescript/module/lib/storage/index.d.ts +4 -4
  67. package/lib/typescript/module/lib/storage/index.d.ts.map +1 -1
  68. package/lib/typescript/module/lib/wagmi/WagmiEventHandler.d.ts +2 -2
  69. package/lib/typescript/module/lib/wagmi/WagmiEventHandler.d.ts.map +1 -1
  70. package/lib/typescript/module/lib/wagmi/index.d.ts +2 -2
  71. package/lib/typescript/module/lib/wagmi/index.d.ts.map +1 -1
  72. package/lib/typescript/module/solana/address.d.ts +1 -1
  73. package/lib/typescript/module/solana/address.d.ts.map +1 -1
  74. package/lib/typescript/module/solana/index.d.ts +2 -2
  75. package/lib/typescript/module/solana/index.d.ts.map +1 -1
  76. package/lib/typescript/module/types/base.d.ts +3 -3
  77. package/lib/typescript/module/types/base.d.ts.map +1 -1
  78. package/lib/typescript/module/types/events.d.ts +2 -2
  79. package/lib/typescript/module/types/events.d.ts.map +1 -1
  80. package/lib/typescript/module/types/index.d.ts +2 -2
  81. package/lib/typescript/module/types/index.d.ts.map +1 -1
  82. package/lib/typescript/module/utils/index.d.ts +5 -5
  83. package/lib/typescript/module/utils/index.d.ts.map +1 -1
  84. package/lib/typescript/module/utils/sanitize.d.ts +31 -0
  85. package/lib/typescript/module/utils/sanitize.d.ts.map +1 -0
  86. package/lib/typescript/module/utils/trafficSource.d.ts +4 -1
  87. package/lib/typescript/module/utils/trafficSource.d.ts.map +1 -1
  88. package/lib/typescript/module/version.d.ts +1 -1
  89. package/package.json +2 -2
  90. package/src/FormoAnalytics.ts +18 -3
  91. package/src/lib/crash/index.ts +21 -7
  92. package/src/lib/event/EventFactory.ts +14 -1
  93. package/src/lib/event/EventQueue.ts +402 -61
  94. package/src/utils/sanitize.ts +274 -0
  95. package/src/utils/trafficSource.ts +19 -1
  96. package/src/version.ts +1 -1
@@ -64,18 +64,31 @@ export class CrashReporter {
64
64
  return;
65
65
  }
66
66
 
67
- this.previousHandler = errorUtils.getGlobalHandler();
67
+ // Captured in the closure, NOT read from `this` at crash time. If another
68
+ // reporter wraps us afterwards our handler stays reachable through its
69
+ // chain, and cleanup() clearing the field would otherwise sever the chain
70
+ // at the moment it matters: A.start, B.start, A.cleanup, crash — B calls
71
+ // our handler, which would then forward to `undefined` and the real
72
+ // RN/default handler would never run.
73
+ const previousHandler = errorUtils.getGlobalHandler();
74
+ this.previousHandler = previousHandler;
68
75
 
69
76
  const handler: ErrorHandler = (error, isFatal) => {
70
77
  // Nothing in here may throw: this runs while the app is already failing,
71
78
  // and an exception would replace the real crash with ours.
72
- try {
73
- this.report(error, isFatal);
74
- } catch (reportingError) {
75
- logger.debug("CrashReporter: failed to report crash", reportingError);
79
+ //
80
+ // `started` is checked so a cleaned-up reporter still FORWARDS (keeping
81
+ // the chain intact) but no longer reports — otherwise the sequence above
82
+ // would emit a duplicate Application Crashed from the stopped instance.
83
+ if (this.started) {
84
+ try {
85
+ this.report(error, isFatal);
86
+ } catch (reportingError) {
87
+ logger.debug("CrashReporter: failed to report crash", reportingError);
88
+ }
76
89
  }
77
90
 
78
- this.previousHandler?.(error, isFatal);
91
+ previousHandler?.(error, isFatal);
79
92
  };
80
93
 
81
94
  this.installedHandler = handler;
@@ -123,9 +136,10 @@ export class CrashReporter {
123
136
  errorUtils.setGlobalHandler(this.previousHandler);
124
137
  }
125
138
 
139
+ // previousHandler is deliberately NOT cleared: if another reporter wrapped
140
+ // us, our installed handler is still in its chain and must keep forwarding.
126
141
  this.started = false;
127
142
  this.installedHandler = undefined;
128
- this.previousHandler = undefined;
129
143
  logger.info("CrashReporter: Cleaned up");
130
144
  }
131
145
  }
@@ -156,7 +156,20 @@ interface DeviceInfoResult {
156
156
  * ("/tabs/leaderboard") does not produce a doubled separator.
157
157
  */
158
158
  export function buildScreenUrl(bundleId: string, name: string): string {
159
- const screen = (name ?? "").replace(/^\/+/, "");
159
+ const screen = (name ?? "")
160
+ .replace(/^\/+/, "")
161
+ // Percent-encode the characters that would otherwise change the URL's
162
+ // STRUCTURE rather than its path. '?' starts a query and '#' a fragment, so
163
+ // screen("Checkout?coupon=X") would parse with pathname "/Checkout" and the
164
+ // rest silently dropped from the screen name. '/' is deliberately NOT
165
+ // encoded — router-style names like "/tabs/leaderboard" are meant to be
166
+ // path segments.
167
+ // '%' FIRST, so the transform stays injective. Without it a screen literally
168
+ // named "Checkout%3Fx" and one named "Checkout?x" both produce
169
+ // ".../Checkout%3Fx" and two distinct screens merge in the analytics.
170
+ .replace(/%/g, "%25")
171
+ .replace(/\?/g, "%3F")
172
+ .replace(/#/g, "%23");
160
173
  return `app://${bundleId ?? ""}/${screen}`;
161
174
  }
162
175