@formo/analytics 1.34.0 → 1.35.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.
@@ -190,12 +190,12 @@ export declare class FormoAnalytics implements IFormoAnalytics {
190
190
  * // Basic identify
191
191
  * formo.identify({ address: '0x...', userId: 'user123' });
192
192
  *
193
- * // Privy: pass the usePrivy() user with `{ privy: true }` to identify every
194
- * // linked wallet under the user's DID in one call. Attribution stays on the
195
- * // already-connected wallet when there is one, else Privy's primary
196
- * // (user.wallet); pass `activeAddress` to pin a specific wallet.
193
+ * // Privy: pass the usePrivy() user to identify every linked wallet under
194
+ * // the user's DID in one call. Attribution stays on the already-connected
195
+ * // wallet when there is one, else Privy's primary (user.wallet); pass
196
+ * // `activeAddress` to pin a specific wallet.
197
197
  * const { user } = usePrivy();
198
- * if (user) formo.identify(user, { privy: true });
198
+ * if (user) formo.identify(user);
199
199
  * ```
200
200
  */
201
201
  identify(user: PrivyUser, options?: {
@@ -75,7 +75,8 @@ var chain_1 = require("./utils/chain");
75
75
  var wagmi_1 = require("./wagmi");
76
76
  var solana_1 = require("./solana");
77
77
  var SolanaManager_1 = require("./solana/SolanaManager");
78
- var privy_1 = require("./privy");
78
+ // Internal: the Privy identify is reached through identify(user), not exported.
79
+ var utils_1 = require("./privy/utils");
79
80
  /**
80
81
  * Constants for provider switching reasons
81
82
  */
@@ -573,7 +574,7 @@ var FormoAnalytics = /** @class */ (function () {
573
574
  // namespace before emitting. It reads this.currentAddress itself to
574
575
  // preserve an already-connected wallet, so this dispatch is a thin
575
576
  // pass-through and both entry points behave identically.
576
- return [4 /*yield*/, (0, privy_1.identifyPrivyUser)(this, maybeUser, {
577
+ return [4 /*yield*/, (0, utils_1.identifyPrivyUser)(this, maybeUser, {
577
578
  activeAddress: opts.activeAddress,
578
579
  properties: opts.properties,
579
580
  })];
@@ -1,8 +1,8 @@
1
1
  export * from "./FormoAnalytics";
2
2
  export * from "./types";
3
3
  export { formofy } from "./initialization";
4
- export { parsePrivyProperties, identifyPrivyUser } from "./privy";
5
- export type { IdentifyPrivyUserOptions, PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./privy";
4
+ export { parsePrivyProperties } from "./privy";
5
+ export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./privy";
6
6
  export { SolanaManager } from "./solana";
7
7
  export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId, } from "./solana";
8
8
  export type { SolanaOptions, SolanaCluster } from "./solana";
@@ -20,14 +20,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.isSolanaChainId = exports.DEFAULT_SOLANA_CHAIN_ID = exports.SOLANA_CHAIN_IDS = exports.SolanaManager = exports.identifyPrivyUser = exports.parsePrivyProperties = exports.formofy = void 0;
23
+ exports.isSolanaChainId = exports.DEFAULT_SOLANA_CHAIN_ID = exports.SOLANA_CHAIN_IDS = exports.SolanaManager = exports.parsePrivyProperties = exports.formofy = void 0;
24
24
  __exportStar(require("./FormoAnalytics"), exports);
25
25
  __exportStar(require("./types"), exports);
26
26
  var initialization_1 = require("./initialization");
27
27
  Object.defineProperty(exports, "formofy", { enumerable: true, get: function () { return initialization_1.formofy; } });
28
28
  var privy_1 = require("./privy");
29
29
  Object.defineProperty(exports, "parsePrivyProperties", { enumerable: true, get: function () { return privy_1.parsePrivyProperties; } });
30
- Object.defineProperty(exports, "identifyPrivyUser", { enumerable: true, get: function () { return privy_1.identifyPrivyUser; } });
31
30
  var solana_1 = require("./solana");
32
31
  Object.defineProperty(exports, "SolanaManager", { enumerable: true, get: function () { return solana_1.SolanaManager; } });
33
32
  var solana_2 = require("./solana");
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * Privy integration module
3
3
  *
4
- * Provides utilities for enriching wallet profiles with Privy user data:
5
- * `parsePrivyProperties` (low-level parsing) and `identifyPrivyUser` (identify
6
- * every linked wallet under the user's DID). The same behavior is also
7
- * available as `formo.identify(user, { privy: true })`.
4
+ * Exports `parsePrivyProperties`, which parses a Privy user into a flat
5
+ * properties object and the list of linked wallets without emitting anything -
6
+ * useful for inspecting or displaying what an identify would send.
7
+ *
8
+ * The identify itself is `formo.identify(user)`, which recognises a Privy user
9
+ * by shape. The function behind it lives in ./utils and is internal.
8
10
  *
9
11
  * This module is React-free so it can be used from the `core` entry.
10
12
  */
11
- export { parsePrivyProperties, identifyPrivyUser } from "./utils";
12
- export type { IdentifyPrivyUserOptions } from "./utils";
13
+ export { parsePrivyProperties } from "./utils";
13
14
  export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./types";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -2,16 +2,17 @@
2
2
  /**
3
3
  * Privy integration module
4
4
  *
5
- * Provides utilities for enriching wallet profiles with Privy user data:
6
- * `parsePrivyProperties` (low-level parsing) and `identifyPrivyUser` (identify
7
- * every linked wallet under the user's DID). The same behavior is also
8
- * available as `formo.identify(user, { privy: true })`.
5
+ * Exports `parsePrivyProperties`, which parses a Privy user into a flat
6
+ * properties object and the list of linked wallets without emitting anything -
7
+ * useful for inspecting or displaying what an identify would send.
8
+ *
9
+ * The identify itself is `formo.identify(user)`, which recognises a Privy user
10
+ * by shape. The function behind it lives in ./utils and is internal.
9
11
  *
10
12
  * This module is React-free so it can be used from the `core` entry.
11
13
  */
12
14
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.identifyPrivyUser = exports.parsePrivyProperties = void 0;
15
+ exports.parsePrivyProperties = void 0;
14
16
  var utils_1 = require("./utils");
15
17
  Object.defineProperty(exports, "parsePrivyProperties", { enumerable: true, get: function () { return utils_1.parsePrivyProperties; } });
16
- Object.defineProperty(exports, "identifyPrivyUser", { enumerable: true, get: function () { return utils_1.identifyPrivyUser; } });
17
18
  //# sourceMappingURL=index.js.map
@@ -92,7 +92,7 @@ export interface IdentifyPrivyUserOptions {
92
92
  * chain namespace (clearing a stale EVM chain id when a Solana wallet becomes
93
93
  * active, and vice versa), so identifies aren't dropped by an `excludeChains`
94
94
  * gate and later events aren't paired with the wrong chain. This happens here,
95
- * so the direct helper and the `formo.identify(user, { privy: true })` form
95
+ * so the direct helper and the `formo.identify(user)` form
96
96
  * behave identically.
97
97
  *
98
98
  * Returns the active linked wallet's `{ address, chainType }` (the one now
@@ -421,7 +421,7 @@ function parsePrivyProperties(user) {
421
421
  * chain namespace (clearing a stale EVM chain id when a Solana wallet becomes
422
422
  * active, and vice versa), so identifies aren't dropped by an `excludeChains`
423
423
  * gate and later events aren't paired with the wrong chain. This happens here,
424
- * so the direct helper and the `formo.identify(user, { privy: true })` form
424
+ * so the direct helper and the `formo.identify(user)` form
425
425
  * behave identically.
426
426
  *
427
427
  * Returns the active linked wallet's `{ address, chainType }` (the one now
@@ -80,7 +80,7 @@ var MIN_QUEUE_SIZE = 200; // 200 bytes
80
80
  // keepalive fetch requests. Payloads exceeding this are silently cancelled,
81
81
  // producing a TypeError: Failed to fetch that cannot be resolved by retrying.
82
82
  var KEEPALIVE_PAYLOAD_LIMIT = 64 * 1024; // 64kB
83
- var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 1 MINUTE
83
+ var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 30 SECONDS
84
84
  var MAX_FLUSH_INTERVAL = 1000 * 300; // 5 MINUTES
85
85
  var MIN_FLUSH_INTERVAL = 1000 * 10; // 10 SECONDS
86
86
  var EventQueue = /** @class */ (function () {
@@ -148,7 +148,12 @@ var EventQueue = /** @class */ (function () {
148
148
  this.flushAt = (0, utils_1.clampNumber)(options.flushAt || DEFAULT_FLUSH_AT, MAX_FLUSH_AT, MIN_FLUSH_AT);
149
149
  this.maxQueueSize = (0, utils_1.clampNumber)(options.maxQueueSize || DEFAULT_QUEUE_SIZE, MAX_QUEUE_SIZE, MIN_QUEUE_SIZE);
150
150
  this.flushIntervalMs = (0, utils_1.clampNumber)(options.flushInterval || DEFAULT_FLUSH_INTERVAL, MAX_FLUSH_INTERVAL, MIN_FLUSH_INTERVAL);
151
- this.flushed = true;
151
+ // Start un-flushed so the first event of the page load is sent
152
+ // immediately (see enqueue). Short visits — e.g. ad-click landings in
153
+ // mobile in-app browsers — often end with the webview process killed
154
+ // before any pagehide/visibilitychange fires, so an event that waits
155
+ // for the batch timer or a lifecycle flush is lost with the process.
156
+ this.flushed = false;
152
157
  this.errorHandler = options.errorHandler;
153
158
  this.pendingFlush = null;
154
159
  this.timer = null;
@@ -259,11 +264,11 @@ var EventQueue = /** @class */ (function () {
259
264
  // before opt-out. Drop everything rather than send post-withdrawal.
260
265
  if (this.canSend && !this.canSend()) {
261
266
  this.clear();
262
- callback();
267
+ safeCall(callback);
263
268
  return [2 /*return*/, Promise.resolve()];
264
269
  }
265
270
  if (!this.queue.length) {
266
- callback();
271
+ safeCall(callback);
267
272
  return [2 /*return*/, Promise.resolve()];
268
273
  }
269
274
  if (!this.pendingFlush) return [3 /*break*/, 2];
@@ -1,2 +1,2 @@
1
- export declare const version = "1.34.0";
1
+ export declare const version = "1.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // This file is auto-generated by scripts/update-version.js during npm version
5
5
  // Do not edit manually - it will be overwritten
6
- exports.version = '1.34.0';
6
+ exports.version = '1.35.0';
7
7
  //# sourceMappingURL=version.js.map
@@ -190,12 +190,12 @@ export declare class FormoAnalytics implements IFormoAnalytics {
190
190
  * // Basic identify
191
191
  * formo.identify({ address: '0x...', userId: 'user123' });
192
192
  *
193
- * // Privy: pass the usePrivy() user with `{ privy: true }` to identify every
194
- * // linked wallet under the user's DID in one call. Attribution stays on the
195
- * // already-connected wallet when there is one, else Privy's primary
196
- * // (user.wallet); pass `activeAddress` to pin a specific wallet.
193
+ * // Privy: pass the usePrivy() user to identify every linked wallet under
194
+ * // the user's DID in one call. Attribution stays on the already-connected
195
+ * // wallet when there is one, else Privy's primary (user.wallet); pass
196
+ * // `activeAddress` to pin a specific wallet.
197
197
  * const { user } = usePrivy();
198
- * if (user) formo.identify(user, { privy: true });
198
+ * if (user) formo.identify(user);
199
199
  * ```
200
200
  */
201
201
  identify(user: PrivyUser, options?: {
@@ -72,7 +72,8 @@ import { parseChainId } from "./utils/chain";
72
72
  import { WagmiEventHandler } from "./wagmi";
73
73
  import { isSolanaChainId } from "./solana";
74
74
  import { SolanaManager } from "./solana/SolanaManager";
75
- import { identifyPrivyUser } from "./privy";
75
+ // Internal: the Privy identify is reached through identify(user), not exported.
76
+ import { identifyPrivyUser } from "./privy/utils";
76
77
  /**
77
78
  * Constants for provider switching reasons
78
79
  */
@@ -1,8 +1,8 @@
1
1
  export * from "./FormoAnalytics";
2
2
  export * from "./types";
3
3
  export { formofy } from "./initialization";
4
- export { parsePrivyProperties, identifyPrivyUser } from "./privy";
5
- export type { IdentifyPrivyUserOptions, PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./privy";
4
+ export { parsePrivyProperties } from "./privy";
5
+ export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./privy";
6
6
  export { SolanaManager } from "./solana";
7
7
  export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId, } from "./solana";
8
8
  export type { SolanaOptions, SolanaCluster } from "./solana";
@@ -7,7 +7,7 @@
7
7
  export * from "./FormoAnalytics";
8
8
  export * from "./types";
9
9
  export { formofy } from "./initialization";
10
- export { parsePrivyProperties, identifyPrivyUser } from "./privy";
10
+ export { parsePrivyProperties } from "./privy";
11
11
  export { SolanaManager } from "./solana";
12
12
  export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId, } from "./solana";
13
13
  //# sourceMappingURL=core.js.map
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * Privy integration module
3
3
  *
4
- * Provides utilities for enriching wallet profiles with Privy user data:
5
- * `parsePrivyProperties` (low-level parsing) and `identifyPrivyUser` (identify
6
- * every linked wallet under the user's DID). The same behavior is also
7
- * available as `formo.identify(user, { privy: true })`.
4
+ * Exports `parsePrivyProperties`, which parses a Privy user into a flat
5
+ * properties object and the list of linked wallets without emitting anything -
6
+ * useful for inspecting or displaying what an identify would send.
7
+ *
8
+ * The identify itself is `formo.identify(user)`, which recognises a Privy user
9
+ * by shape. The function behind it lives in ./utils and is internal.
8
10
  *
9
11
  * This module is React-free so it can be used from the `core` entry.
10
12
  */
11
- export { parsePrivyProperties, identifyPrivyUser } from "./utils";
12
- export type { IdentifyPrivyUserOptions } from "./utils";
13
+ export { parsePrivyProperties } from "./utils";
13
14
  export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./types";
14
15
  //# sourceMappingURL=index.d.ts.map
@@ -1,12 +1,14 @@
1
1
  /**
2
2
  * Privy integration module
3
3
  *
4
- * Provides utilities for enriching wallet profiles with Privy user data:
5
- * `parsePrivyProperties` (low-level parsing) and `identifyPrivyUser` (identify
6
- * every linked wallet under the user's DID). The same behavior is also
7
- * available as `formo.identify(user, { privy: true })`.
4
+ * Exports `parsePrivyProperties`, which parses a Privy user into a flat
5
+ * properties object and the list of linked wallets without emitting anything -
6
+ * useful for inspecting or displaying what an identify would send.
7
+ *
8
+ * The identify itself is `formo.identify(user)`, which recognises a Privy user
9
+ * by shape. The function behind it lives in ./utils and is internal.
8
10
  *
9
11
  * This module is React-free so it can be used from the `core` entry.
10
12
  */
11
- export { parsePrivyProperties, identifyPrivyUser } from "./utils";
13
+ export { parsePrivyProperties } from "./utils";
12
14
  //# sourceMappingURL=index.js.map
@@ -92,7 +92,7 @@ export interface IdentifyPrivyUserOptions {
92
92
  * chain namespace (clearing a stale EVM chain id when a Solana wallet becomes
93
93
  * active, and vice versa), so identifies aren't dropped by an `excludeChains`
94
94
  * gate and later events aren't paired with the wrong chain. This happens here,
95
- * so the direct helper and the `formo.identify(user, { privy: true })` form
95
+ * so the direct helper and the `formo.identify(user)` form
96
96
  * behave identically.
97
97
  *
98
98
  * Returns the active linked wallet's `{ address, chainType }` (the one now
@@ -417,7 +417,7 @@ export function parsePrivyProperties(user) {
417
417
  * chain namespace (clearing a stale EVM chain id when a Solana wallet becomes
418
418
  * active, and vice versa), so identifies aren't dropped by an `excludeChains`
419
419
  * gate and later events aren't paired with the wrong chain. This happens here,
420
- * so the direct helper and the `formo.identify(user, { privy: true })` form
420
+ * so the direct helper and the `formo.identify(user)` form
421
421
  * behave identically.
422
422
  *
423
423
  * Returns the active linked wallet's `{ address, chainType }` (the one now
@@ -74,7 +74,7 @@ var MIN_QUEUE_SIZE = 200; // 200 bytes
74
74
  // keepalive fetch requests. Payloads exceeding this are silently cancelled,
75
75
  // producing a TypeError: Failed to fetch that cannot be resolved by retrying.
76
76
  var KEEPALIVE_PAYLOAD_LIMIT = 64 * 1024; // 64kB
77
- var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 1 MINUTE
77
+ var DEFAULT_FLUSH_INTERVAL = 1000 * 30; // 30 SECONDS
78
78
  var MAX_FLUSH_INTERVAL = 1000 * 300; // 5 MINUTES
79
79
  var MIN_FLUSH_INTERVAL = 1000 * 10; // 10 SECONDS
80
80
  var EventQueue = /** @class */ (function () {
@@ -142,7 +142,12 @@ var EventQueue = /** @class */ (function () {
142
142
  this.flushAt = clampNumber(options.flushAt || DEFAULT_FLUSH_AT, MAX_FLUSH_AT, MIN_FLUSH_AT);
143
143
  this.maxQueueSize = clampNumber(options.maxQueueSize || DEFAULT_QUEUE_SIZE, MAX_QUEUE_SIZE, MIN_QUEUE_SIZE);
144
144
  this.flushIntervalMs = clampNumber(options.flushInterval || DEFAULT_FLUSH_INTERVAL, MAX_FLUSH_INTERVAL, MIN_FLUSH_INTERVAL);
145
- this.flushed = true;
145
+ // Start un-flushed so the first event of the page load is sent
146
+ // immediately (see enqueue). Short visits — e.g. ad-click landings in
147
+ // mobile in-app browsers — often end with the webview process killed
148
+ // before any pagehide/visibilitychange fires, so an event that waits
149
+ // for the batch timer or a lifecycle flush is lost with the process.
150
+ this.flushed = false;
146
151
  this.errorHandler = options.errorHandler;
147
152
  this.pendingFlush = null;
148
153
  this.timer = null;
@@ -253,11 +258,11 @@ var EventQueue = /** @class */ (function () {
253
258
  // before opt-out. Drop everything rather than send post-withdrawal.
254
259
  if (this.canSend && !this.canSend()) {
255
260
  this.clear();
256
- callback();
261
+ safeCall(callback);
257
262
  return [2 /*return*/, Promise.resolve()];
258
263
  }
259
264
  if (!this.queue.length) {
260
- callback();
265
+ safeCall(callback);
261
266
  return [2 /*return*/, Promise.resolve()];
262
267
  }
263
268
  if (!this.pendingFlush) return [3 /*break*/, 2];
@@ -1,2 +1,2 @@
1
- export declare const version = "1.34.0";
1
+ export declare const version = "1.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // This file is auto-generated by scripts/update-version.js during npm version
2
2
  // Do not edit manually - it will be overwritten
3
- export var version = '1.34.0';
3
+ export var version = '1.35.0';
4
4
  //# sourceMappingURL=version.js.map