@formo/analytics 1.30.0 → 1.31.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.
@@ -1,5 +1,11 @@
1
- import { FC } from "react";
2
- import { FormoAnalyticsProviderProps, IFormoAnalytics } from "./types";
1
+ import { FC, ReactNode } from "react";
2
+ import { IFormoAnalytics, Options } from "./types";
3
+ export interface FormoAnalyticsProviderProps {
4
+ writeKey: string;
5
+ options?: Options;
6
+ disabled?: boolean;
7
+ children: ReactNode;
8
+ }
3
9
  export declare const FormoAnalyticsContext: import("react").Context<IFormoAnalytics>;
4
10
  export declare const FormoAnalyticsProvider: FC<FormoAnalyticsProviderProps>;
5
11
  export declare const useFormo: () => IFormoAnalytics;
@@ -0,0 +1,10 @@
1
+ export * from "./FormoAnalytics";
2
+ export * from "./types";
3
+ export { formofy } from "./initialization";
4
+ export { parsePrivyProperties } from "./privy";
5
+ export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./privy";
6
+ export { SolanaManager } from "./solana";
7
+ export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId, } from "./solana";
8
+ export type { SolanaOptions, SolanaCluster } from "./solana";
9
+ export type { SolanaClientStore, SolanaClientState } from "./solana";
10
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ // React-free entry point.
3
+ // Use this from non-React frameworks (Angular, Vue, Svelte, vanilla JS) to
4
+ // avoid pulling the React provider into the dependency graph.
5
+ //
6
+ // Equivalent to the package root entry minus FormoAnalyticsProvider/useFormo
7
+ // and the `window.formofy = formofy` side effect.
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.isSolanaChainId = exports.DEFAULT_SOLANA_CHAIN_ID = exports.SOLANA_CHAIN_IDS = exports.SolanaManager = exports.parsePrivyProperties = exports.formofy = void 0;
24
+ __exportStar(require("./FormoAnalytics"), exports);
25
+ __exportStar(require("./types"), exports);
26
+ var initialization_1 = require("./initialization");
27
+ Object.defineProperty(exports, "formofy", { enumerable: true, get: function () { return initialization_1.formofy; } });
28
+ var privy_1 = require("./privy");
29
+ Object.defineProperty(exports, "parsePrivyProperties", { enumerable: true, get: function () { return privy_1.parsePrivyProperties; } });
30
+ var solana_1 = require("./solana");
31
+ Object.defineProperty(exports, "SolanaManager", { enumerable: true, get: function () { return solana_1.SolanaManager; } });
32
+ var solana_2 = require("./solana");
33
+ Object.defineProperty(exports, "SOLANA_CHAIN_IDS", { enumerable: true, get: function () { return solana_2.SOLANA_CHAIN_IDS; } });
34
+ Object.defineProperty(exports, "DEFAULT_SOLANA_CHAIN_ID", { enumerable: true, get: function () { return solana_2.DEFAULT_SOLANA_CHAIN_ID; } });
35
+ Object.defineProperty(exports, "isSolanaChainId", { enumerable: true, get: function () { return solana_2.isSolanaChainId; } });
36
+ //# sourceMappingURL=core.js.map
@@ -19,6 +19,14 @@ declare class EventFactory implements IEventFactory {
19
19
  private extractUTMParameters;
20
20
  private extractClickIdParameters;
21
21
  private extractReferralParameter;
22
+ /**
23
+ * Returns the document referrer with same-host referrers filtered out.
24
+ * Internal navigation populates `document.referrer` with the previous page
25
+ * on the same site, which is not an attribution signal — treating it as
26
+ * "external" would otherwise let an internal URL become the session's
27
+ * first-touch referrer after a direct landing.
28
+ */
29
+ private getExternalReferrer;
22
30
  private getTrafficSources;
23
31
  private getScreen;
24
32
  private generateContext;
@@ -127,9 +127,29 @@ var EventFactory = /** @class */ (function () {
127
127
  }
128
128
  return "";
129
129
  };
130
+ /**
131
+ * Returns the document referrer with same-host referrers filtered out.
132
+ * Internal navigation populates `document.referrer` with the previous page
133
+ * on the same site, which is not an attribution signal — treating it as
134
+ * "external" would otherwise let an internal URL become the session's
135
+ * first-touch referrer after a direct landing.
136
+ */
137
+ this.getExternalReferrer = function () {
138
+ var _a;
139
+ var ref = document.referrer;
140
+ if (!ref)
141
+ return "";
142
+ try {
143
+ var currentHost = (_a = globalThis.location) === null || _a === void 0 ? void 0 : _a.hostname;
144
+ if (currentHost && new URL(ref).hostname === currentHost)
145
+ return "";
146
+ }
147
+ catch (_b) { }
148
+ return ref;
149
+ };
130
150
  this.getTrafficSources = function (url) {
131
151
  var urlObj = new URL(url);
132
- var contextTrafficSources = __assign(__assign(__assign({}, _this.extractUTMParameters(url)), _this.extractClickIdParameters(urlObj)), { ref: _this.extractReferralParameter(urlObj), referrer: document.referrer });
152
+ var contextTrafficSources = __assign(__assign(__assign({}, _this.extractUTMParameters(url)), _this.extractClickIdParameters(urlObj)), { ref: _this.extractReferralParameter(urlObj), referrer: _this.getExternalReferrer() });
133
153
  var storedTrafficSources = (0, storage_1.session)().get(constants_1.SESSION_TRAFFIC_SOURCE_KEY) || {};
134
154
  var mergedClickIds = {};
135
155
  for (var _i = 0, CLICK_ID_PARAMS_2 = constants_2.CLICK_ID_PARAMS; _i < CLICK_ID_PARAMS_2.length; _i++) {
@@ -137,7 +157,12 @@ var EventFactory = /** @class */ (function () {
137
157
  mergedClickIds[p] =
138
158
  contextTrafficSources[p] || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources[p]) || "";
139
159
  }
140
- var finalTrafficSources = __assign({ ref: contextTrafficSources.ref || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.ref) || "", referrer: contextTrafficSources.referrer || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer) || "", utm_campaign: contextTrafficSources.utm_campaign ||
160
+ var finalTrafficSources = __assign({ ref: contextTrafficSources.ref || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.ref) || "",
161
+ // Referrer is sticky (first-touch wins). Same-host referrers are already
162
+ // stripped by getExternalReferrer; the stored-first OR keeps the entry
163
+ // referrer pinned even if a later pageview reports a different external
164
+ // referrer (e.g. cross-domain return from an outbound click).
165
+ referrer: (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer) || contextTrafficSources.referrer || "", utm_campaign: contextTrafficSources.utm_campaign ||
141
166
  (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_campaign) ||
142
167
  "", utm_content: contextTrafficSources.utm_content ||
143
168
  (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_content) ||
@@ -1,10 +1,3 @@
1
+ export * from "./core";
1
2
  export * from "./FormoAnalyticsProvider";
2
- export * from "./FormoAnalytics";
3
- export * from "./types";
4
- export { parsePrivyProperties } from "./privy";
5
- export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo } from "./privy";
6
- export { SolanaManager } from "./solana";
7
- export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId } from "./solana";
8
- export type { SolanaOptions, SolanaCluster, } from "./solana";
9
- export type { SolanaClientStore, SolanaClientState, } from "./solana";
10
3
  //# sourceMappingURL=index.d.ts.map
@@ -14,20 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.isSolanaChainId = exports.DEFAULT_SOLANA_CHAIN_ID = exports.SOLANA_CHAIN_IDS = exports.SolanaManager = exports.parsePrivyProperties = void 0;
18
17
  var initialization_1 = require("./initialization");
18
+ __exportStar(require("./core"), exports);
19
19
  __exportStar(require("./FormoAnalyticsProvider"), exports);
20
- __exportStar(require("./FormoAnalytics"), exports);
21
- __exportStar(require("./types"), exports);
22
- var privy_1 = require("./privy");
23
- Object.defineProperty(exports, "parsePrivyProperties", { enumerable: true, get: function () { return privy_1.parsePrivyProperties; } });
24
- // Solana integration exports
25
- var solana_1 = require("./solana");
26
- Object.defineProperty(exports, "SolanaManager", { enumerable: true, get: function () { return solana_1.SolanaManager; } });
27
- var solana_2 = require("./solana");
28
- Object.defineProperty(exports, "SOLANA_CHAIN_IDS", { enumerable: true, get: function () { return solana_2.SOLANA_CHAIN_IDS; } });
29
- Object.defineProperty(exports, "DEFAULT_SOLANA_CHAIN_ID", { enumerable: true, get: function () { return solana_2.DEFAULT_SOLANA_CHAIN_ID; } });
30
- Object.defineProperty(exports, "isSolanaChainId", { enumerable: true, get: function () { return solana_2.isSolanaChainId; } });
31
20
  if (typeof window !== "undefined")
32
21
  window.formofy = initialization_1.formofy;
33
22
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
1
  import { LogLevel } from "../logger";
2
2
  import { IFormoEventContext, IFormoEventProperties, SignatureStatus, TransactionStatus } from "./events";
3
3
  import { EIP1193Provider } from "./provider";
4
- import { ReactNode } from "react";
5
4
  import { SolanaOptions } from "../solana/types";
6
5
  export type Nullable<T> = T | null;
7
6
  export type ChainID = number;
@@ -221,10 +220,4 @@ export interface Options {
221
220
  errorHandler?: (err: Error) => void;
222
221
  ready?: (formo: IFormoAnalytics) => void;
223
222
  }
224
- export interface FormoAnalyticsProviderProps {
225
- writeKey: string;
226
- options?: Options;
227
- disabled?: boolean;
228
- children: ReactNode;
229
- }
230
223
  //# sourceMappingURL=base.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const version = "1.30.0";
1
+ export declare const version = "1.30.1";
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.30.0';
6
+ exports.version = '1.30.1';
7
7
  //# sourceMappingURL=version.js.map
@@ -1,5 +1,11 @@
1
- import { FC } from "react";
2
- import { FormoAnalyticsProviderProps, IFormoAnalytics } from "./types";
1
+ import { FC, ReactNode } from "react";
2
+ import { IFormoAnalytics, Options } from "./types";
3
+ export interface FormoAnalyticsProviderProps {
4
+ writeKey: string;
5
+ options?: Options;
6
+ disabled?: boolean;
7
+ children: ReactNode;
8
+ }
3
9
  export declare const FormoAnalyticsContext: import("react").Context<IFormoAnalytics>;
4
10
  export declare const FormoAnalyticsProvider: FC<FormoAnalyticsProviderProps>;
5
11
  export declare const useFormo: () => IFormoAnalytics;
@@ -0,0 +1,10 @@
1
+ export * from "./FormoAnalytics";
2
+ export * from "./types";
3
+ export { formofy } from "./initialization";
4
+ export { parsePrivyProperties } from "./privy";
5
+ export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo, } from "./privy";
6
+ export { SolanaManager } from "./solana";
7
+ export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId, } from "./solana";
8
+ export type { SolanaOptions, SolanaCluster } from "./solana";
9
+ export type { SolanaClientStore, SolanaClientState } from "./solana";
10
+ //# sourceMappingURL=core.d.ts.map
@@ -0,0 +1,13 @@
1
+ // React-free entry point.
2
+ // Use this from non-React frameworks (Angular, Vue, Svelte, vanilla JS) to
3
+ // avoid pulling the React provider into the dependency graph.
4
+ //
5
+ // Equivalent to the package root entry minus FormoAnalyticsProvider/useFormo
6
+ // and the `window.formofy = formofy` side effect.
7
+ export * from "./FormoAnalytics";
8
+ export * from "./types";
9
+ export { formofy } from "./initialization";
10
+ export { parsePrivyProperties } from "./privy";
11
+ export { SolanaManager } from "./solana";
12
+ export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId, } from "./solana";
13
+ //# sourceMappingURL=core.js.map
@@ -19,6 +19,14 @@ declare class EventFactory implements IEventFactory {
19
19
  private extractUTMParameters;
20
20
  private extractClickIdParameters;
21
21
  private extractReferralParameter;
22
+ /**
23
+ * Returns the document referrer with same-host referrers filtered out.
24
+ * Internal navigation populates `document.referrer` with the previous page
25
+ * on the same site, which is not an attribution signal — treating it as
26
+ * "external" would otherwise let an internal URL become the session's
27
+ * first-touch referrer after a direct landing.
28
+ */
29
+ private getExternalReferrer;
22
30
  private getTrafficSources;
23
31
  private getScreen;
24
32
  private generateContext;
@@ -121,9 +121,29 @@ var EventFactory = /** @class */ (function () {
121
121
  }
122
122
  return "";
123
123
  };
124
+ /**
125
+ * Returns the document referrer with same-host referrers filtered out.
126
+ * Internal navigation populates `document.referrer` with the previous page
127
+ * on the same site, which is not an attribution signal — treating it as
128
+ * "external" would otherwise let an internal URL become the session's
129
+ * first-touch referrer after a direct landing.
130
+ */
131
+ this.getExternalReferrer = function () {
132
+ var _a;
133
+ var ref = document.referrer;
134
+ if (!ref)
135
+ return "";
136
+ try {
137
+ var currentHost = (_a = globalThis.location) === null || _a === void 0 ? void 0 : _a.hostname;
138
+ if (currentHost && new URL(ref).hostname === currentHost)
139
+ return "";
140
+ }
141
+ catch (_b) { }
142
+ return ref;
143
+ };
124
144
  this.getTrafficSources = function (url) {
125
145
  var urlObj = new URL(url);
126
- var contextTrafficSources = __assign(__assign(__assign({}, _this.extractUTMParameters(url)), _this.extractClickIdParameters(urlObj)), { ref: _this.extractReferralParameter(urlObj), referrer: document.referrer });
146
+ var contextTrafficSources = __assign(__assign(__assign({}, _this.extractUTMParameters(url)), _this.extractClickIdParameters(urlObj)), { ref: _this.extractReferralParameter(urlObj), referrer: _this.getExternalReferrer() });
127
147
  var storedTrafficSources = session().get(SESSION_TRAFFIC_SOURCE_KEY) || {};
128
148
  var mergedClickIds = {};
129
149
  for (var _i = 0, CLICK_ID_PARAMS_2 = CLICK_ID_PARAMS; _i < CLICK_ID_PARAMS_2.length; _i++) {
@@ -131,7 +151,12 @@ var EventFactory = /** @class */ (function () {
131
151
  mergedClickIds[p] =
132
152
  contextTrafficSources[p] || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources[p]) || "";
133
153
  }
134
- var finalTrafficSources = __assign({ ref: contextTrafficSources.ref || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.ref) || "", referrer: contextTrafficSources.referrer || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer) || "", utm_campaign: contextTrafficSources.utm_campaign ||
154
+ var finalTrafficSources = __assign({ ref: contextTrafficSources.ref || (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.ref) || "",
155
+ // Referrer is sticky (first-touch wins). Same-host referrers are already
156
+ // stripped by getExternalReferrer; the stored-first OR keeps the entry
157
+ // referrer pinned even if a later pageview reports a different external
158
+ // referrer (e.g. cross-domain return from an outbound click).
159
+ referrer: (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.referrer) || contextTrafficSources.referrer || "", utm_campaign: contextTrafficSources.utm_campaign ||
135
160
  (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_campaign) ||
136
161
  "", utm_content: contextTrafficSources.utm_content ||
137
162
  (storedTrafficSources === null || storedTrafficSources === void 0 ? void 0 : storedTrafficSources.utm_content) ||
@@ -1,10 +1,3 @@
1
+ export * from "./core";
1
2
  export * from "./FormoAnalyticsProvider";
2
- export * from "./FormoAnalytics";
3
- export * from "./types";
4
- export { parsePrivyProperties } from "./privy";
5
- export type { PrivyUser, PrivyLinkedAccount, PrivyAccountType, PrivyProfileProperties, PrivyWalletInfo } from "./privy";
6
- export { SolanaManager } from "./solana";
7
- export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId } from "./solana";
8
- export type { SolanaOptions, SolanaCluster, } from "./solana";
9
- export type { SolanaClientStore, SolanaClientState, } from "./solana";
10
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,6 @@
1
1
  import { formofy } from "./initialization";
2
+ export * from "./core";
2
3
  export * from "./FormoAnalyticsProvider";
3
- export * from "./FormoAnalytics";
4
- export * from "./types";
5
- export { parsePrivyProperties } from "./privy";
6
- // Solana integration exports
7
- export { SolanaManager } from "./solana";
8
- export { SOLANA_CHAIN_IDS, DEFAULT_SOLANA_CHAIN_ID, isSolanaChainId } from "./solana";
9
4
  if (typeof window !== "undefined")
10
5
  window.formofy = formofy;
11
6
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,6 @@
1
1
  import { LogLevel } from "../logger";
2
2
  import { IFormoEventContext, IFormoEventProperties, SignatureStatus, TransactionStatus } from "./events";
3
3
  import { EIP1193Provider } from "./provider";
4
- import { ReactNode } from "react";
5
4
  import { SolanaOptions } from "../solana/types";
6
5
  export type Nullable<T> = T | null;
7
6
  export type ChainID = number;
@@ -221,10 +220,4 @@ export interface Options {
221
220
  errorHandler?: (err: Error) => void;
222
221
  ready?: (formo: IFormoAnalytics) => void;
223
222
  }
224
- export interface FormoAnalyticsProviderProps {
225
- writeKey: string;
226
- options?: Options;
227
- disabled?: boolean;
228
- children: ReactNode;
229
- }
230
223
  //# sourceMappingURL=base.d.ts.map
@@ -1,2 +1,2 @@
1
- export declare const version = "1.30.0";
1
+ export declare const version = "1.30.1";
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.30.0';
3
+ export var version = '1.30.1';
4
4
  //# sourceMappingURL=version.js.map