@formo/analytics 1.35.1 → 1.35.2

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 (62) hide show
  1. package/dist/cjs/src/FormoAnalytics.d.ts +134 -0
  2. package/dist/cjs/src/FormoAnalytics.js +636 -178
  3. package/dist/cjs/src/constants/base.d.ts +0 -1
  4. package/dist/cjs/src/constants/base.js +1 -3
  5. package/dist/cjs/src/event/EventFactory.js +1 -1
  6. package/dist/cjs/src/utils/mergeDeepRight.d.ts +22 -0
  7. package/dist/cjs/src/utils/mergeDeepRight.js +54 -0
  8. package/dist/cjs/src/version.d.ts +1 -1
  9. package/dist/cjs/src/version.js +1 -1
  10. package/dist/cjs/src/wagmi/WagmiEventHandler.d.ts +193 -1
  11. package/dist/cjs/src/wagmi/WagmiEventHandler.js +1317 -77
  12. package/dist/cjs/src/wagmi/types.d.ts +6 -0
  13. package/dist/esm/src/FormoAnalytics.d.ts +134 -0
  14. package/dist/esm/src/FormoAnalytics.js +636 -178
  15. package/dist/esm/src/constants/base.d.ts +0 -1
  16. package/dist/esm/src/constants/base.js +0 -2
  17. package/dist/esm/src/event/EventFactory.js +1 -1
  18. package/dist/esm/src/utils/mergeDeepRight.d.ts +22 -0
  19. package/dist/esm/src/utils/mergeDeepRight.js +51 -0
  20. package/dist/esm/src/version.d.ts +1 -1
  21. package/dist/esm/src/version.js +1 -1
  22. package/dist/esm/src/wagmi/WagmiEventHandler.d.ts +193 -1
  23. package/dist/esm/src/wagmi/WagmiEventHandler.js +1315 -76
  24. package/dist/esm/src/wagmi/types.d.ts +6 -0
  25. package/dist/index.umd.min.js +1 -1
  26. package/package.json +1 -10
  27. package/dist/cjs/src/ramda/internal/_curry1.d.ts +0 -10
  28. package/dist/cjs/src/ramda/internal/_curry1.js +0 -26
  29. package/dist/cjs/src/ramda/internal/_curry2.d.ts +0 -10
  30. package/dist/cjs/src/ramda/internal/_curry2.js +0 -43
  31. package/dist/cjs/src/ramda/internal/_curry3.d.ts +0 -10
  32. package/dist/cjs/src/ramda/internal/_curry3.js +0 -74
  33. package/dist/cjs/src/ramda/internal/_has.d.ts +0 -2
  34. package/dist/cjs/src/ramda/internal/_has.js +0 -7
  35. package/dist/cjs/src/ramda/internal/_isObject.d.ts +0 -2
  36. package/dist/cjs/src/ramda/internal/_isObject.js +0 -7
  37. package/dist/cjs/src/ramda/internal/_isPlaceholder.d.ts +0 -2
  38. package/dist/cjs/src/ramda/internal/_isPlaceholder.js +0 -7
  39. package/dist/cjs/src/ramda/mergeDeepRight.d.ts +0 -3
  40. package/dist/cjs/src/ramda/mergeDeepRight.js +0 -14
  41. package/dist/cjs/src/ramda/mergeDeepWithKey.d.ts +0 -3
  42. package/dist/cjs/src/ramda/mergeDeepWithKey.js +0 -20
  43. package/dist/cjs/src/ramda/mergeWithKey.d.ts +0 -3
  44. package/dist/cjs/src/ramda/mergeWithKey.js +0 -26
  45. package/dist/esm/src/ramda/internal/_curry1.d.ts +0 -10
  46. package/dist/esm/src/ramda/internal/_curry1.js +0 -20
  47. package/dist/esm/src/ramda/internal/_curry2.d.ts +0 -10
  48. package/dist/esm/src/ramda/internal/_curry2.js +0 -37
  49. package/dist/esm/src/ramda/internal/_curry3.d.ts +0 -10
  50. package/dist/esm/src/ramda/internal/_curry3.js +0 -68
  51. package/dist/esm/src/ramda/internal/_has.d.ts +0 -2
  52. package/dist/esm/src/ramda/internal/_has.js +0 -4
  53. package/dist/esm/src/ramda/internal/_isObject.d.ts +0 -2
  54. package/dist/esm/src/ramda/internal/_isObject.js +0 -4
  55. package/dist/esm/src/ramda/internal/_isPlaceholder.d.ts +0 -2
  56. package/dist/esm/src/ramda/internal/_isPlaceholder.js +0 -4
  57. package/dist/esm/src/ramda/mergeDeepRight.d.ts +0 -3
  58. package/dist/esm/src/ramda/mergeDeepRight.js +0 -9
  59. package/dist/esm/src/ramda/mergeDeepWithKey.d.ts +0 -3
  60. package/dist/esm/src/ramda/mergeDeepWithKey.js +0 -15
  61. package/dist/esm/src/ramda/mergeWithKey.d.ts +0 -3
  62. package/dist/esm/src/ramda/mergeWithKey.js +0 -21
@@ -8,9 +8,52 @@ export declare class FormoAnalytics implements IFormoAnalytics {
8
8
  private _chainState;
9
9
  private _activeNamespace?;
10
10
  private get _provider();
11
+ /**
12
+ * Drop a provider's reported-connect record when it stops being active.
13
+ *
14
+ * The active provider is displaced from several places, and not all of them
15
+ * go through the `_provider` setter: `setChainState()` writes
16
+ * `_chainState.evm.provider` directly and `clearChainState()` replaces the
17
+ * whole namespace. Guarding only the setter left A's record alive across a
18
+ * real A-to-B switch, so returning to A was suppressed.
19
+ */
20
+ private forgetConnectRecord;
11
21
  private set _provider(value);
12
22
  private get _evmAddress();
13
23
  private get _evmChainId();
24
+ /**
25
+ * Last known chain per tracked provider, fed by `chainChanged` / `connect`
26
+ * and by a one-off probe at tracking time. Read synchronously when labelling
27
+ * an autocaptured event, so the wallet's request transport is never used for
28
+ * analytics. Weak so an untracked provider can be collected.
29
+ */
30
+ /**
31
+ * The connect this SDK has actually REPORTED for a provider.
32
+ *
33
+ * Deduplicating on "is an address known" was wrong in both directions.
34
+ * `onConnected` and `onAccountsChanged` both observe one connection, so
35
+ * something has to stop them double-reporting - but an address can be
36
+ * present without a connect ever having been sent: restored from the
37
+ * active-wallet cookie, or reported with an unresolved chain and then
38
+ * refused by `tracking.excludeChains`. Suppressing on address presence lost
39
+ * the connect entirely in those cases.
40
+ *
41
+ * Records what was reported, so a later event can be recognised as a
42
+ * genuine improvement on it rather than a duplicate.
43
+ */
44
+ private _announcedConnect;
45
+ private _providerChainIds;
46
+ /**
47
+ * Bumped on every chain observation, PER PROVIDER. An `eth_chainId` answer
48
+ * that resolves after a newer observation for the same provider must not
49
+ * overwrite it.
50
+ *
51
+ * Deliberately per provider, not per SDK instance: a global counter meant
52
+ * any activity on wallet B discarded a perfectly valid in-flight answer for
53
+ * wallet A, leaving A at chain 0 - and, since an unresolved chain fails
54
+ * closed, dropping all of A's events whenever `excludeChains` is set.
55
+ */
56
+ private _providerChainGenerations;
14
57
  private _providerListenersMap;
15
58
  private session;
16
59
  private eventManager;
@@ -260,6 +303,16 @@ export declare class FormoAnalytics implements IFormoAnalytics {
260
303
  * Opt out of tracking.
261
304
  * @returns {void}
262
305
  */
306
+ /**
307
+ * Whether an event carrying this chain would currently be sent.
308
+ *
309
+ * Exposed for integrations that keep their own "already reported" state.
310
+ * `syncWalletState()` can accept a wallet that `trackEvent()` then drops -
311
+ * `tracking: false`, or a chain in `excludeChains` - and an integration that
312
+ * marked it as reported would stay silent about that wallet even after the
313
+ * configuration changed to allow it.
314
+ */
315
+ willTrackEvent(chainId?: ChainID): boolean;
263
316
  optOutTracking(): void;
264
317
  /**
265
318
  * Opt back into tracking after previously opting out. This will re-enable analytics tracking
@@ -296,6 +349,37 @@ export declare class FormoAnalytics implements IFormoAnalytics {
296
349
  private _handleAccountsChanged;
297
350
  private registerChainChangedListener;
298
351
  private onChainChanged;
352
+ /**
353
+ * Record a provider's chain from its `connect` event, and nothing else.
354
+ *
355
+ * Used when connect autocapture is off. `connect` carries `chainId` in its
356
+ * payload, so this needs no RPC - unlike the full handler, which resolves
357
+ * the account.
358
+ */
359
+ private registerConnectChainObserver;
360
+ /**
361
+ * Whether a connect for this wallet still needs reporting.
362
+ *
363
+ * True when nothing has been reported for this provider, or when the account
364
+ * changed. A wallet already reported is not reported again.
365
+ *
366
+ * Deliberately does NOT re-report to correct a chain. When `accountsChanged`
367
+ * wins the race on a provider that exposes no synchronous `chainId`, the
368
+ * connect carries 0 - honestly, since the chain is unknown at that instant -
369
+ * and the `connect` payload that follows knows the real one. Emitting again
370
+ * to relabel would mean two connects for one connection, which is the bug
371
+ * this whole path exists to prevent. That payload still corrects
372
+ * `currentChainId`, so everything after it is attributed properly.
373
+ */
374
+ private shouldReportConnect;
375
+ /**
376
+ * Record a connect as reported - but only if it will actually be sent.
377
+ *
378
+ * `connect()` passes through `shouldTrack()`, which refuses an unresolvable
379
+ * chain when `tracking.excludeChains` is configured. Marking a refused event
380
+ * as reported would suppress the authoritative one that follows.
381
+ */
382
+ private markConnectReported;
299
383
  private registerConnectListener;
300
384
  private registerDisconnectListener;
301
385
  private onConnected;
@@ -416,6 +500,56 @@ export declare class FormoAnalytics implements IFormoAnalytics {
416
500
  get solana(): SolanaManager;
417
501
  private getAddress;
418
502
  private getAccounts;
503
+ /**
504
+ * Resolve the chain an autocaptured request actually ran on.
505
+ *
506
+ * `_evmChainId` is maintained by `chainChanged` from whichever provider is
507
+ * currently active. When a request arrives from a *different* tracked
508
+ * provider - which happens whenever a visitor has two wallets installed -
509
+ * that cached value describes the wrong wallet, and tagging the event with
510
+ * it silently mis-attributes the chain.
511
+ *
512
+ * Answered entirely from a per-provider snapshot. This is deliberately
513
+ * SYNCHRONOUS and never issues an RPC.
514
+ *
515
+ * An earlier version called `eth_chainId` on the signing provider and
516
+ * time-boxed it with `Promise.race`. That is not safe: the race abandons the
517
+ * SDK's promise but cannot cancel the provider's request. On a transport
518
+ * that serializes - WalletConnect's relay socket, the very case this path
519
+ * exists to serve - an abandoned lookup stays at the head of the wallet's
520
+ * queue, and every later RPC the dapp makes queues behind it until reload.
521
+ * Mislabelling a chain is a reporting defect; wedging the user's wallet is
522
+ * not acceptable to avoid one.
523
+ *
524
+ * When nothing is known, this reports 0 ("unknown") rather than guessing
525
+ * with the active provider's chain, which is known-wrong for another wallet.
526
+ */
527
+ private resolveChainIdForProvider;
528
+ /**
529
+ * Record a provider's chain. Fed by `chainChanged` and `connect`, and by the
530
+ * one-off probe at tracking time - never from inside a user request.
531
+ */
532
+ private rememberProviderChain;
533
+ /** Advance and return this provider's chain-observation generation. */
534
+ private bumpProviderChainGeneration;
535
+ /**
536
+ * Seed a provider's chain from whatever it already exposes synchronously.
537
+ *
538
+ * Most EIP-1193 implementations carry a `chainId` property (MetaMask,
539
+ * WalletConnect, Coinbase). Reading it costs nothing and cannot block.
540
+ *
541
+ * There is deliberately no RPC fallback. An earlier version probed with
542
+ * `eth_chainId` when a provider was first tracked, on the theory that
543
+ * tracking time is off the user's critical path. It is not: a serialized
544
+ * transport has ONE queue, so a stalled probe sits in front of every later
545
+ * signature and transaction the dapp makes. It could also land out of order
546
+ * - a slow probe response overwriting a newer `chainChanged` - and relabel
547
+ * events onto a chain the wallet had already left.
548
+ *
549
+ * A provider that exposes nothing stays unknown until it emits
550
+ * `chainChanged` or `connect`, and unknown is reported honestly as 0.
551
+ */
552
+ private seedProviderChainFromState;
419
553
  private getCurrentChainId;
420
554
  private buildSignatureEventPayload;
421
555
  private buildTransactionEventPayload;