@intlayer/analytics 9.7.0 → 9.7.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.
- package/dist/cjs/core/AnalyticsClient.cjs +9 -10
- package/dist/cjs/core/abTesting.cjs +2 -3
- package/dist/cjs/core/eventBuffer.cjs +1 -2
- package/dist/cjs/core/globalManager.cjs +1 -2
- package/dist/cjs/core/index.cjs +8 -8
- package/dist/cjs/core/initAnalyticsClient.cjs +3 -4
- package/dist/cjs/core/publicToken.cjs +1 -2
- package/dist/cjs/core/sampling.cjs +2 -3
- package/dist/cjs/core/session.cjs +1 -2
- package/dist/cjs/core/transport.cjs +1 -2
- package/dist/cjs/events/contentExposure.cjs +1 -2
- package/dist/cjs/index.cjs +10 -10
- package/dist/cjs/isEnabled.cjs +2 -3
- package/dist/cjs/utils/hash.cjs +1 -2
- package/dist/cjs/utils/idle.cjs +1 -2
- package/dist/cjs/utils/isBot.cjs +1 -2
- package/dist/esm/core/AnalyticsClient.mjs +2 -3
- package/dist/esm/core/abTesting.mjs +1 -2
- package/dist/esm/core/eventBuffer.mjs +1 -2
- package/dist/esm/core/globalManager.mjs +1 -2
- package/dist/esm/core/index.mjs +3 -3
- package/dist/esm/core/initAnalyticsClient.mjs +1 -2
- package/dist/esm/core/publicToken.mjs +1 -2
- package/dist/esm/core/sampling.mjs +1 -2
- package/dist/esm/core/session.mjs +1 -2
- package/dist/esm/core/transport.mjs +1 -2
- package/dist/esm/events/contentExposure.mjs +1 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/isEnabled.mjs +1 -2
- package/dist/esm/utils/hash.mjs +1 -2
- package/dist/esm/utils/idle.mjs +1 -2
- package/dist/esm/utils/isBot.mjs +1 -2
- package/dist/types/core/AnalyticsClient.d.ts +0 -2
- package/dist/types/core/AnalyticsClient.d.ts.map +1 -1
- package/dist/types/core/abTesting.d.ts +0 -2
- package/dist/types/core/abTesting.d.ts.map +1 -1
- package/dist/types/core/eventBuffer.d.ts +0 -2
- package/dist/types/core/eventBuffer.d.ts.map +1 -1
- package/dist/types/core/globalManager.d.ts +0 -2
- package/dist/types/core/globalManager.d.ts.map +1 -1
- package/dist/types/core/index.d.ts +1 -1
- package/dist/types/core/initAnalyticsClient.d.ts +0 -2
- package/dist/types/core/initAnalyticsClient.d.ts.map +1 -1
- package/dist/types/core/publicToken.d.ts +0 -2
- package/dist/types/core/publicToken.d.ts.map +1 -1
- package/dist/types/core/sampling.d.ts +0 -2
- package/dist/types/core/sampling.d.ts.map +1 -1
- package/dist/types/core/session.d.ts +0 -2
- package/dist/types/core/session.d.ts.map +1 -1
- package/dist/types/core/transport.d.ts +0 -2
- package/dist/types/core/transport.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +0 -2
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/events/contentExposure.d.ts +0 -2
- package/dist/types/events/contentExposure.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/isEnabled.d.ts +0 -2
- package/dist/types/isEnabled.d.ts.map +1 -1
- package/dist/types/utils/hash.d.ts +0 -2
- package/dist/types/utils/hash.d.ts.map +1 -1
- package/dist/types/utils/idle.d.ts +0 -2
- package/dist/types/utils/idle.d.ts.map +1 -1
- package/dist/types/utils/isBot.d.ts +0 -2
- package/dist/types/utils/isBot.d.ts.map +1 -1
- package/package.json +32 -32
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_core_abTesting = require(
|
|
5
|
-
const require_core_eventBuffer = require(
|
|
6
|
-
const require_core_publicToken = require(
|
|
7
|
-
const require_core_sampling = require(
|
|
8
|
-
const require_core_session = require(
|
|
9
|
-
const require_core_transport = require(
|
|
2
|
+
const require_utils_idle = require("../utils/idle.cjs");
|
|
3
|
+
const require_utils_isBot = require("../utils/isBot.cjs");
|
|
4
|
+
const require_core_abTesting = require("./abTesting.cjs");
|
|
5
|
+
const require_core_eventBuffer = require("./eventBuffer.cjs");
|
|
6
|
+
const require_core_publicToken = require("./publicToken.cjs");
|
|
7
|
+
const require_core_sampling = require("./sampling.cjs");
|
|
8
|
+
const require_core_session = require("./session.cjs");
|
|
9
|
+
const require_core_transport = require("./transport.cjs");
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
// src/core/AnalyticsClient.ts
|
|
12
12
|
/** Default flush cadence — one network request per 20 seconds. */
|
|
13
13
|
const DEFAULT_FLUSH_INTERVAL = 2e4;
|
|
14
14
|
/** Default cap on distinct buffered events before an early flush. */
|
|
@@ -192,7 +192,6 @@ const createAnalyticsClient = (config) => {
|
|
|
192
192
|
};
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
-
//#endregion
|
|
196
195
|
exports.DEFAULT_FLUSH_INTERVAL = DEFAULT_FLUSH_INTERVAL;
|
|
197
196
|
exports.DEFAULT_MAX_BUFFER_SIZE = DEFAULT_MAX_BUFFER_SIZE;
|
|
198
197
|
exports.DEFAULT_SAMPLE_RATE = DEFAULT_SAMPLE_RATE;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_hash = require(
|
|
2
|
+
const require_utils_hash = require("../utils/hash.cjs");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/core/abTesting.ts
|
|
5
5
|
/**
|
|
6
6
|
* Deterministically assigns a variant to a session for a given experiment.
|
|
7
7
|
*
|
|
@@ -39,6 +39,5 @@ const assignVariant = (sessionId, experimentKey, variants, weights) => {
|
|
|
39
39
|
return variants[variants.length - 1];
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
//#endregion
|
|
43
42
|
exports.assignVariant = assignVariant;
|
|
44
43
|
//# sourceMappingURL=abTesting.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/core/eventBuffer.ts
|
|
3
3
|
/** Field separator for coalescing keys — never present in content keys. */
|
|
4
4
|
const KEY_SEPARATOR = "";
|
|
5
5
|
/**
|
|
@@ -62,6 +62,5 @@ const createEventBuffer = ({ max }) => {
|
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
//#endregion
|
|
66
65
|
exports.createEventBuffer = createEventBuffer;
|
|
67
66
|
//# sourceMappingURL=eventBuffer.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/core/globalManager.ts
|
|
3
3
|
/**
|
|
4
4
|
* Key on `window` used to share the client singleton across multiple module
|
|
5
5
|
* instances. When bundlers include `@intlayer/analytics` more than once (e.g.
|
|
@@ -54,7 +54,6 @@ const decrementAnalyticsClientRefCount = () => {
|
|
|
54
54
|
return globals[REF_COUNT_KEY];
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
-
//#endregion
|
|
58
57
|
exports.decrementAnalyticsClientRefCount = decrementAnalyticsClientRefCount;
|
|
59
58
|
exports.getGlobalAnalyticsClient = getGlobalAnalyticsClient;
|
|
60
59
|
exports.incrementAnalyticsClientRefCount = incrementAnalyticsClientRefCount;
|
package/dist/cjs/core/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
2
|
+
const require_core_AnalyticsClient = require("./AnalyticsClient.cjs");
|
|
3
|
+
const require_core_abTesting = require("./abTesting.cjs");
|
|
4
|
+
const require_core_eventBuffer = require("./eventBuffer.cjs");
|
|
5
|
+
const require_core_globalManager = require("./globalManager.cjs");
|
|
6
|
+
const require_core_initAnalyticsClient = require("./initAnalyticsClient.cjs");
|
|
7
|
+
const require_core_sampling = require("./sampling.cjs");
|
|
8
|
+
const require_core_session = require("./session.cjs");
|
|
9
|
+
const require_core_transport = require("./transport.cjs");
|
|
10
10
|
|
|
11
11
|
exports.DEFAULT_FLUSH_INTERVAL = require_core_AnalyticsClient.DEFAULT_FLUSH_INTERVAL;
|
|
12
12
|
exports.DEFAULT_MAX_BUFFER_SIZE = require_core_AnalyticsClient.DEFAULT_MAX_BUFFER_SIZE;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_core_AnalyticsClient = require(
|
|
3
|
-
const require_core_globalManager = require(
|
|
2
|
+
const require_core_AnalyticsClient = require("./AnalyticsClient.cjs");
|
|
3
|
+
const require_core_globalManager = require("./globalManager.cjs");
|
|
4
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// src/core/initAnalyticsClient.ts
|
|
7
7
|
/**
|
|
8
8
|
* Initializes the Intlayer analytics client singleton.
|
|
9
9
|
*
|
|
@@ -45,7 +45,6 @@ const stopAnalyticsClient = () => {
|
|
|
45
45
|
require_core_globalManager.setGlobalAnalyticsClient(null);
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
//#endregion
|
|
49
48
|
exports.initAnalyticsClient = initAnalyticsClient;
|
|
50
49
|
exports.stopAnalyticsClient = stopAnalyticsClient;
|
|
51
50
|
//# sourceMappingURL=initAnalyticsClient.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/core/publicToken.ts
|
|
3
3
|
/**
|
|
4
4
|
* Short-lived ingest token used to authorise analytics batches.
|
|
5
5
|
*
|
|
@@ -99,6 +99,5 @@ const createPublicTokenManager = ({ backendURL, clientId }) => {
|
|
|
99
99
|
};
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
//#endregion
|
|
103
102
|
exports.createPublicTokenManager = createPublicTokenManager;
|
|
104
103
|
//# sourceMappingURL=publicToken.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_hash = require(
|
|
2
|
+
const require_utils_hash = require("../utils/hash.cjs");
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/core/sampling.ts
|
|
5
5
|
/**
|
|
6
6
|
* Deterministic per-session sampling gate. Using the session id (rather than a
|
|
7
7
|
* fresh random draw per event) means a sampled-in session reports *all* of its
|
|
@@ -23,6 +23,5 @@ const isSampledIn = (sessionId, sampleRate) => {
|
|
|
23
23
|
return require_utils_hash.hashString(sessionId) / 4294967295 < sampleRate;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
-
//#endregion
|
|
27
26
|
exports.isSampledIn = isSampledIn;
|
|
28
27
|
//# sourceMappingURL=sampling.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/core/session.ts
|
|
3
3
|
/**
|
|
4
4
|
* Anonymous, per-tab session identity. Stored in `sessionStorage` so it is
|
|
5
5
|
* cleared when the tab closes and is never shared across sites — no durable
|
|
@@ -36,6 +36,5 @@ const getSessionId = () => {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
|
|
39
|
-
//#endregion
|
|
40
39
|
exports.getSessionId = getSessionId;
|
|
41
40
|
//# sourceMappingURL=session.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/core/transport.ts
|
|
3
3
|
/**
|
|
4
4
|
* Sends a batch of events to the backend. Every path is non-blocking and
|
|
5
5
|
* no-throw — analytics must never break, slow, or delay the host application.
|
|
@@ -47,6 +47,5 @@ const sendEvents = (endpoint, body, { useBeacon = false, token } = {}) => {
|
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
//#endregion
|
|
51
50
|
exports.sendEvents = sendEvents;
|
|
52
51
|
//# sourceMappingURL=transport.cjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/events/contentExposure.ts
|
|
3
3
|
/**
|
|
4
4
|
* Serializes a `KeyPath[]` into a compact, stable string used both as the
|
|
5
5
|
* coalescing key in the buffer and as the stored `keyPath` on the wire.
|
|
@@ -32,7 +32,6 @@ const buildContentExposure = (params) => ({
|
|
|
32
32
|
variant: params.variant
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
//#endregion
|
|
36
35
|
exports.buildContentExposure = buildContentExposure;
|
|
37
36
|
exports.serializeKeyPath = serializeKeyPath;
|
|
38
37
|
//# sourceMappingURL=contentExposure.cjs.map
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
3
|
-
const require_core_abTesting = require(
|
|
4
|
-
const require_core_eventBuffer = require(
|
|
5
|
-
const require_core_sampling = require(
|
|
6
|
-
const require_core_session = require(
|
|
7
|
-
const require_core_transport = require(
|
|
8
|
-
const require_core_AnalyticsClient = require(
|
|
9
|
-
const require_core_globalManager = require(
|
|
10
|
-
const require_core_initAnalyticsClient = require(
|
|
11
|
-
const
|
|
2
|
+
const require_events_contentExposure = require("./events/contentExposure.cjs");
|
|
3
|
+
const require_core_abTesting = require("./core/abTesting.cjs");
|
|
4
|
+
const require_core_eventBuffer = require("./core/eventBuffer.cjs");
|
|
5
|
+
const require_core_sampling = require("./core/sampling.cjs");
|
|
6
|
+
const require_core_session = require("./core/session.cjs");
|
|
7
|
+
const require_core_transport = require("./core/transport.cjs");
|
|
8
|
+
const require_core_AnalyticsClient = require("./core/AnalyticsClient.cjs");
|
|
9
|
+
const require_core_globalManager = require("./core/globalManager.cjs");
|
|
10
|
+
const require_core_initAnalyticsClient = require("./core/initAnalyticsClient.cjs");
|
|
11
|
+
const require_utils_isBot = require("./utils/isBot.cjs");
|
|
12
12
|
|
|
13
13
|
exports.BOT_USER_AGENT_PATTERN = require_utils_isBot.BOT_USER_AGENT_PATTERN;
|
|
14
14
|
exports.DEFAULT_FLUSH_INTERVAL = require_core_AnalyticsClient.DEFAULT_FLUSH_INTERVAL;
|
package/dist/cjs/isEnabled.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_utils_isBot = require(
|
|
2
|
+
const require_utils_isBot = require("./utils/isBot.cjs");
|
|
3
3
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/isEnabled.ts
|
|
6
6
|
/**
|
|
7
7
|
* Compile-time kill switch. Bundlers replace `process.env.INTLAYER_ANALYTICS_ENABLED`
|
|
8
8
|
* (set to `'false'` by `@intlayer/config` unless `analytics.enabled` is `true`
|
|
@@ -27,6 +27,5 @@ const TREE_SHAKE_ANALYTICS = process.env.INTLAYER_ANALYTICS_ENABLED === "false";
|
|
|
27
27
|
*/
|
|
28
28
|
const isEnabled = !TREE_SHAKE_ANALYTICS && _intlayer_config_built.analytics?.enabled === true && Boolean(_intlayer_config_built.editor?.clientId) && typeof window !== "undefined" && window.self === window.top && !require_utils_isBot.isBotEnvironment();
|
|
29
29
|
|
|
30
|
-
//#endregion
|
|
31
30
|
exports.isEnabled = isEnabled;
|
|
32
31
|
//# sourceMappingURL=isEnabled.cjs.map
|
package/dist/cjs/utils/hash.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/hash.ts
|
|
3
3
|
/**
|
|
4
4
|
* FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across
|
|
5
5
|
* runtimes — good enough for deterministic A/B bucketing and session seeding
|
|
@@ -20,6 +20,5 @@ const hashString = (input) => {
|
|
|
20
20
|
return hash >>> 0;
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
//#endregion
|
|
24
23
|
exports.hashString = hashString;
|
|
25
24
|
//# sourceMappingURL=hash.cjs.map
|
package/dist/cjs/utils/idle.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/idle.ts
|
|
3
3
|
/**
|
|
4
4
|
* Runs a callback when the browser is idle, without blocking first render.
|
|
5
5
|
* Falls back to a short `setTimeout` where `requestIdleCallback` is unavailable
|
|
@@ -20,6 +20,5 @@ const onIdle = (callback) => {
|
|
|
20
20
|
setTimeout(callback, 1);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
//#endregion
|
|
24
23
|
exports.onIdle = onIdle;
|
|
25
24
|
//# sourceMappingURL=idle.cjs.map
|
package/dist/cjs/utils/isBot.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// src/utils/isBot.ts
|
|
3
3
|
/**
|
|
4
4
|
* Bot / automation detection.
|
|
5
5
|
*
|
|
@@ -82,7 +82,6 @@ const isBotEnvironment = () => {
|
|
|
82
82
|
return isBotUserAgent(navigator.userAgent);
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
//#endregion
|
|
86
85
|
exports.BOT_USER_AGENT_PATTERN = BOT_USER_AGENT_PATTERN;
|
|
87
86
|
exports.isBotEnvironment = isBotEnvironment;
|
|
88
87
|
exports.isBotUserAgent = isBotUserAgent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBotEnvironment } from "../utils/isBot.mjs";
|
|
2
1
|
import { onIdle } from "../utils/idle.mjs";
|
|
2
|
+
import { isBotEnvironment } from "../utils/isBot.mjs";
|
|
3
3
|
import { assignVariant } from "./abTesting.mjs";
|
|
4
4
|
import { createEventBuffer } from "./eventBuffer.mjs";
|
|
5
5
|
import { createPublicTokenManager } from "./publicToken.mjs";
|
|
@@ -7,7 +7,7 @@ import { isSampledIn } from "./sampling.mjs";
|
|
|
7
7
|
import { getSessionId } from "./session.mjs";
|
|
8
8
|
import { sendEvents } from "./transport.mjs";
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// src/core/AnalyticsClient.ts
|
|
11
11
|
/** Default flush cadence — one network request per 20 seconds. */
|
|
12
12
|
const DEFAULT_FLUSH_INTERVAL = 2e4;
|
|
13
13
|
/** Default cap on distinct buffered events before an early flush. */
|
|
@@ -191,6 +191,5 @@ const createAnalyticsClient = (config) => {
|
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
193
|
|
|
194
|
-
//#endregion
|
|
195
194
|
export { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, createAnalyticsClient };
|
|
196
195
|
//# sourceMappingURL=AnalyticsClient.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hashString } from "../utils/hash.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/core/abTesting.ts
|
|
4
4
|
/**
|
|
5
5
|
* Deterministically assigns a variant to a session for a given experiment.
|
|
6
6
|
*
|
|
@@ -38,6 +38,5 @@ const assignVariant = (sessionId, experimentKey, variants, weights) => {
|
|
|
38
38
|
return variants[variants.length - 1];
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
-
//#endregion
|
|
42
41
|
export { assignVariant };
|
|
43
42
|
//# sourceMappingURL=abTesting.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/eventBuffer.ts
|
|
2
2
|
/** Field separator for coalescing keys — never present in content keys. */
|
|
3
3
|
const KEY_SEPARATOR = "";
|
|
4
4
|
/**
|
|
@@ -61,6 +61,5 @@ const createEventBuffer = ({ max }) => {
|
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
//#endregion
|
|
65
64
|
export { createEventBuffer };
|
|
66
65
|
//# sourceMappingURL=eventBuffer.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/globalManager.ts
|
|
2
2
|
/**
|
|
3
3
|
* Key on `window` used to share the client singleton across multiple module
|
|
4
4
|
* instances. When bundlers include `@intlayer/analytics` more than once (e.g.
|
|
@@ -53,6 +53,5 @@ const decrementAnalyticsClientRefCount = () => {
|
|
|
53
53
|
return globals[REF_COUNT_KEY];
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
//#endregion
|
|
57
56
|
export { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient };
|
|
58
57
|
//# sourceMappingURL=globalManager.mjs.map
|
package/dist/esm/core/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, createAnalyticsClient } from "./AnalyticsClient.mjs";
|
|
1
2
|
import { assignVariant } from "./abTesting.mjs";
|
|
2
3
|
import { createEventBuffer } from "./eventBuffer.mjs";
|
|
4
|
+
import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./globalManager.mjs";
|
|
5
|
+
import { initAnalyticsClient, stopAnalyticsClient } from "./initAnalyticsClient.mjs";
|
|
3
6
|
import { isSampledIn } from "./sampling.mjs";
|
|
4
7
|
import { getSessionId } from "./session.mjs";
|
|
5
8
|
import { sendEvents } from "./transport.mjs";
|
|
6
|
-
import { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, createAnalyticsClient } from "./AnalyticsClient.mjs";
|
|
7
|
-
import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./globalManager.mjs";
|
|
8
|
-
import { initAnalyticsClient, stopAnalyticsClient } from "./initAnalyticsClient.mjs";
|
|
9
9
|
|
|
10
10
|
export { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, assignVariant, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isSampledIn, sendEvents, setGlobalAnalyticsClient, stopAnalyticsClient };
|
|
@@ -2,7 +2,7 @@ import { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, c
|
|
|
2
2
|
import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./globalManager.mjs";
|
|
3
3
|
import { analytics, editor } from "@intlayer/config/built";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
// src/core/initAnalyticsClient.ts
|
|
6
6
|
/**
|
|
7
7
|
* Initializes the Intlayer analytics client singleton.
|
|
8
8
|
*
|
|
@@ -44,6 +44,5 @@ const stopAnalyticsClient = () => {
|
|
|
44
44
|
setGlobalAnalyticsClient(null);
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
-
//#endregion
|
|
48
47
|
export { initAnalyticsClient, stopAnalyticsClient };
|
|
49
48
|
//# sourceMappingURL=initAnalyticsClient.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/publicToken.ts
|
|
2
2
|
/**
|
|
3
3
|
* Short-lived ingest token used to authorise analytics batches.
|
|
4
4
|
*
|
|
@@ -98,6 +98,5 @@ const createPublicTokenManager = ({ backendURL, clientId }) => {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
//#endregion
|
|
102
101
|
export { createPublicTokenManager };
|
|
103
102
|
//# sourceMappingURL=publicToken.mjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hashString } from "../utils/hash.mjs";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// src/core/sampling.ts
|
|
4
4
|
/**
|
|
5
5
|
* Deterministic per-session sampling gate. Using the session id (rather than a
|
|
6
6
|
* fresh random draw per event) means a sampled-in session reports *all* of its
|
|
@@ -22,6 +22,5 @@ const isSampledIn = (sessionId, sampleRate) => {
|
|
|
22
22
|
return hashString(sessionId) / 4294967295 < sampleRate;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
//#endregion
|
|
26
25
|
export { isSampledIn };
|
|
27
26
|
//# sourceMappingURL=sampling.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/session.ts
|
|
2
2
|
/**
|
|
3
3
|
* Anonymous, per-tab session identity. Stored in `sessionStorage` so it is
|
|
4
4
|
* cleared when the tab closes and is never shared across sites — no durable
|
|
@@ -35,6 +35,5 @@ const getSessionId = () => {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
//#endregion
|
|
39
38
|
export { getSessionId };
|
|
40
39
|
//# sourceMappingURL=session.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/core/transport.ts
|
|
2
2
|
/**
|
|
3
3
|
* Sends a batch of events to the backend. Every path is non-blocking and
|
|
4
4
|
* no-throw — analytics must never break, slow, or delay the host application.
|
|
@@ -46,6 +46,5 @@ const sendEvents = (endpoint, body, { useBeacon = false, token } = {}) => {
|
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
-
//#endregion
|
|
50
49
|
export { sendEvents };
|
|
51
50
|
//# sourceMappingURL=transport.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/events/contentExposure.ts
|
|
2
2
|
/**
|
|
3
3
|
* Serializes a `KeyPath[]` into a compact, stable string used both as the
|
|
4
4
|
* coalescing key in the buffer and as the stored `keyPath` on the wire.
|
|
@@ -31,6 +31,5 @@ const buildContentExposure = (params) => ({
|
|
|
31
31
|
variant: params.variant
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
//#endregion
|
|
35
34
|
export { buildContentExposure, serializeKeyPath };
|
|
36
35
|
//# sourceMappingURL=contentExposure.mjs.map
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildContentExposure, serializeKeyPath } from "./events/contentExposure.mjs";
|
|
2
2
|
import { assignVariant } from "./core/abTesting.mjs";
|
|
3
3
|
import { createEventBuffer } from "./core/eventBuffer.mjs";
|
|
4
4
|
import { isSampledIn } from "./core/sampling.mjs";
|
|
@@ -7,6 +7,6 @@ import { sendEvents } from "./core/transport.mjs";
|
|
|
7
7
|
import { DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, createAnalyticsClient } from "./core/AnalyticsClient.mjs";
|
|
8
8
|
import { decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, incrementAnalyticsClientRefCount, setGlobalAnalyticsClient } from "./core/globalManager.mjs";
|
|
9
9
|
import { initAnalyticsClient, stopAnalyticsClient } from "./core/initAnalyticsClient.mjs";
|
|
10
|
-
import {
|
|
10
|
+
import { BOT_USER_AGENT_PATTERN, isBotEnvironment, isBotUserAgent } from "./utils/isBot.mjs";
|
|
11
11
|
|
|
12
12
|
export { BOT_USER_AGENT_PATTERN, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, assignVariant, buildContentExposure, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isBotEnvironment, isBotUserAgent, isSampledIn, sendEvents, serializeKeyPath, setGlobalAnalyticsClient, stopAnalyticsClient };
|
package/dist/esm/isEnabled.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isBotEnvironment } from "./utils/isBot.mjs";
|
|
2
2
|
import { analytics, editor } from "@intlayer/config/built";
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// src/isEnabled.ts
|
|
5
5
|
/**
|
|
6
6
|
* Compile-time kill switch. Bundlers replace `process.env.INTLAYER_ANALYTICS_ENABLED`
|
|
7
7
|
* (set to `'false'` by `@intlayer/config` unless `analytics.enabled` is `true`
|
|
@@ -26,6 +26,5 @@ const TREE_SHAKE_ANALYTICS = process.env.INTLAYER_ANALYTICS_ENABLED === "false";
|
|
|
26
26
|
*/
|
|
27
27
|
const isEnabled = !TREE_SHAKE_ANALYTICS && analytics?.enabled === true && Boolean(editor?.clientId) && typeof window !== "undefined" && window.self === window.top && !isBotEnvironment();
|
|
28
28
|
|
|
29
|
-
//#endregion
|
|
30
29
|
export { isEnabled };
|
|
31
30
|
//# sourceMappingURL=isEnabled.mjs.map
|
package/dist/esm/utils/hash.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/utils/hash.ts
|
|
2
2
|
/**
|
|
3
3
|
* FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across
|
|
4
4
|
* runtimes — good enough for deterministic A/B bucketing and session seeding
|
|
@@ -19,6 +19,5 @@ const hashString = (input) => {
|
|
|
19
19
|
return hash >>> 0;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
export { hashString };
|
|
24
23
|
//# sourceMappingURL=hash.mjs.map
|
package/dist/esm/utils/idle.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/utils/idle.ts
|
|
2
2
|
/**
|
|
3
3
|
* Runs a callback when the browser is idle, without blocking first render.
|
|
4
4
|
* Falls back to a short `setTimeout` where `requestIdleCallback` is unavailable
|
|
@@ -19,6 +19,5 @@ const onIdle = (callback) => {
|
|
|
19
19
|
setTimeout(callback, 1);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
//#endregion
|
|
23
22
|
export { onIdle };
|
|
24
23
|
//# sourceMappingURL=idle.mjs.map
|
package/dist/esm/utils/isBot.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/utils/isBot.ts
|
|
2
2
|
/**
|
|
3
3
|
* Bot / automation detection.
|
|
4
4
|
*
|
|
@@ -81,6 +81,5 @@ const isBotEnvironment = () => {
|
|
|
81
81
|
return isBotUserAgent(navigator.userAgent);
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
//#endregion
|
|
85
84
|
export { BOT_USER_AGENT_PATTERN, isBotEnvironment, isBotUserAgent };
|
|
86
85
|
//# sourceMappingURL=isBot.mjs.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnalyticsClientConfig, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent } from "./types.js";
|
|
2
|
-
//#region src/core/AnalyticsClient.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Caller-supplied fields for a page view. Everything is optional — the client
|
|
5
4
|
* fills `url`, `locale`, viewport, and referrer from the environment when omitted.
|
|
@@ -59,5 +58,4 @@ export type AnalyticsClient = {
|
|
|
59
58
|
* @returns A started-on-demand {@link AnalyticsClient}.
|
|
60
59
|
*/
|
|
61
60
|
export declare const createAnalyticsClient: (config: AnalyticsClientConfig) => AnalyticsClient;
|
|
62
|
-
//#endregion
|
|
63
61
|
//# sourceMappingURL=AnalyticsClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsClient.d.ts","names":[],"sources":["../../../src/core/AnalyticsClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AnalyticsClient.d.ts","names":[],"sources":["../../../src/core/AnalyticsClient.ts"],"mappings":";;;;;YAqBY;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA,SAAS;;;qBAIE;;qBAEA;;qBAEA;;;;;qBAKA;;;;;YAQD;;EAEV,YAAY;;EAEZ,gBAAgB,QAAQ;;EAExB,uBACE,OAAO,KAAK,eAAe;;EAG7B,kBACE,OAAO,KAAK,eAAe;;EAG7B,aACE,uBACA,oBACA;;EAGF,QAAQ;;EAER;;EAEA;;;;;;;;;qBA+BW,wBAAqB,QACxB,0BACP"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/abTesting.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Deterministically assigns a variant to a session for a given experiment.
|
|
4
3
|
*
|
|
@@ -18,5 +17,4 @@
|
|
|
18
17
|
* assignVariant('sid-1', 'homepage-hero', ['a', 'b'], [9, 1]); // ~90% 'a'
|
|
19
18
|
*/
|
|
20
19
|
export declare const assignVariant: (sessionId: string, experimentKey: string, variants: string[], weights?: number[]) => string;
|
|
21
|
-
//#endregion
|
|
22
20
|
//# sourceMappingURL=abTesting.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abTesting.d.ts","names":[],"sources":["../../../src/core/abTesting.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"abTesting.d.ts","names":[],"sources":["../../../src/core/abTesting.ts"],"mappings":";;;;;;;;;;;;;;;;;;qBAoBa,gBAAa,mBACP,uBACI,oBACH"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnalyticsEvent } from "./types.js";
|
|
2
|
-
//#region src/core/eventBuffer.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* A bounded, coalescing in-memory buffer for analytics events.
|
|
5
4
|
*
|
|
@@ -30,5 +29,4 @@ export type EventBuffer = {
|
|
|
30
29
|
export declare const createEventBuffer: ({ max }: {
|
|
31
30
|
max: number;
|
|
32
31
|
}) => EventBuffer;
|
|
33
|
-
//#endregion
|
|
34
32
|
//# sourceMappingURL=eventBuffer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventBuffer.d.ts","names":[],"sources":["../../../src/core/eventBuffer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"eventBuffer.d.ts","names":[],"sources":["../../../src/core/eventBuffer.ts"],"mappings":";;;;;;;;;;;;;YAgCY;;EAEV,OAAO,OAAO;;EAEd,aAAa;;EAEb;;;;;;;;;qBAUW,sBAAiB;EAAe;MAAgB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnalyticsClient } from "./AnalyticsClient.js";
|
|
2
|
-
//#region src/core/globalManager.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Returns the global analytics client, or `null` in SSR or before init.
|
|
5
4
|
*/
|
|
@@ -22,5 +21,4 @@ export declare const incrementAnalyticsClientRefCount: () => number;
|
|
|
22
21
|
* @returns The count after decrementing (`0` in SSR, where nothing is stored).
|
|
23
22
|
*/
|
|
24
23
|
export declare const decrementAnalyticsClientRefCount: () => number;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# sourceMappingURL=globalManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalManager.d.ts","names":[],"sources":["../../../src/core/globalManager.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"globalManager.d.ts","names":[],"sources":["../../../src/core/globalManager.ts"],"mappings":";;;;qBA2Ba,gCAA+B;;;;;;qBAU/B,2BAAwB,QAC3B;;;;;;qBAWG;;;;;;qBAYA"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent } from "./types.js";
|
|
2
1
|
import { AnalyticsClient, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, MAX_EVENTS_PER_SEND, PageViewInput, createAnalyticsClient } from "./AnalyticsClient.js";
|
|
3
2
|
import { assignVariant } from "./abTesting.js";
|
|
4
3
|
import { EventBuffer, createEventBuffer } from "./eventBuffer.js";
|
|
@@ -7,4 +6,5 @@ import { initAnalyticsClient, stopAnalyticsClient } from "./initAnalyticsClient.
|
|
|
7
6
|
import { isSampledIn } from "./sampling.js";
|
|
8
7
|
import { getSessionId } from "./session.js";
|
|
9
8
|
import { sendEvents } from "./transport.js";
|
|
9
|
+
import { AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, PageViewEvent, TrackableEvent } from "./types.js";
|
|
10
10
|
export { AnalyticsClient, AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, EventBuffer, MAX_EVENTS_PER_SEND, PageViewEvent, PageViewInput, TrackableEvent, assignVariant, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isSampledIn, sendEvents, setGlobalAnalyticsClient, stopAnalyticsClient };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnalyticsClient } from "./AnalyticsClient.js";
|
|
2
|
-
//#region src/core/initAnalyticsClient.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Initializes the Intlayer analytics client singleton.
|
|
5
4
|
*
|
|
@@ -22,5 +21,4 @@ export declare const initAnalyticsClient: () => AnalyticsClient;
|
|
|
22
21
|
* `initAnalyticsClient` — never call it when init was skipped or cancelled.
|
|
23
22
|
*/
|
|
24
23
|
export declare const stopAnalyticsClient: () => void;
|
|
25
|
-
//#endregion
|
|
26
24
|
//# sourceMappingURL=initAnalyticsClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initAnalyticsClient.d.ts","names":[],"sources":["../../../src/core/initAnalyticsClient.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"initAnalyticsClient.d.ts","names":[],"sources":["../../../src/core/initAnalyticsClient.ts"],"mappings":";;;;;;;;;;;;;;qBA4Ba,2BAA0B;;;;;;;;qBA2B1B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/publicToken.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Short-lived ingest token used to authorise analytics batches.
|
|
4
3
|
*
|
|
@@ -43,5 +42,4 @@ export type PublicTokenManager = {
|
|
|
43
42
|
* @returns A manager exposing a synchronous {@link PublicTokenManager.getToken}.
|
|
44
43
|
*/
|
|
45
44
|
export declare const createPublicTokenManager: ({ backendURL, clientId }: PublicTokenManagerOptions) => PublicTokenManager;
|
|
46
|
-
//#endregion
|
|
47
45
|
//# sourceMappingURL=publicToken.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicToken.d.ts","names":[],"sources":["../../../src/core/publicToken.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"publicToken.d.ts","names":[],"sources":["../../../src/core/publicToken.ts"],"mappings":";;;;;;;;;;;;;;YAyDY;;EAEV;;EAEA;;;YAIU;;;;;EAKV;;;;;EAKA;;;;;;;;;;;;qBAaW,6BAAwB,YAAA,YAGlC,8BAA4B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/sampling.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Deterministic per-session sampling gate. Using the session id (rather than a
|
|
4
3
|
* fresh random draw per event) means a sampled-in session reports *all* of its
|
|
@@ -15,5 +14,4 @@
|
|
|
15
14
|
* isSampledIn('abc', 0.5); // stable per session
|
|
16
15
|
*/
|
|
17
16
|
export declare const isSampledIn: (sessionId: string, sampleRate: number) => boolean;
|
|
18
|
-
//#endregion
|
|
19
17
|
//# sourceMappingURL=sampling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sampling.d.ts","names":[],"sources":["../../../src/core/sampling.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sampling.d.ts","names":[],"sources":["../../../src/core/sampling.ts"],"mappings":";;;;;;;;;;;;;;;qBAiBa,cAAW,mBAAqB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/session.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Anonymous, per-tab session identity. Stored in `sessionStorage` so it is
|
|
4
3
|
* cleared when the tab closes and is never shared across sites — no durable
|
|
@@ -12,5 +11,4 @@
|
|
|
12
11
|
* @returns The stable session id for the lifetime of the tab.
|
|
13
12
|
*/
|
|
14
13
|
export declare const getSessionId: () => string;
|
|
15
|
-
//#endregion
|
|
16
14
|
//# sourceMappingURL=session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","names":[],"sources":["../../../src/core/session.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","names":[],"sources":["../../../src/core/session.ts"],"mappings":";;;;;;;;;;;;qBAkCa"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AnalyticsIngestBody } from "./types.js";
|
|
2
|
-
//#region src/core/transport.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Sends a batch of events to the backend. Every path is non-blocking and
|
|
5
4
|
* no-throw — analytics must never break, slow, or delay the host application.
|
|
@@ -27,5 +26,4 @@ export declare const sendEvents: (endpoint: string, body: AnalyticsIngestBody, {
|
|
|
27
26
|
useBeacon?: boolean;
|
|
28
27
|
token?: string;
|
|
29
28
|
}) => boolean;
|
|
30
|
-
//#endregion
|
|
31
29
|
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/core/transport.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","names":[],"sources":["../../../src/core/transport.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;qBAyBa,aAAU,kBACL,MACV,uBAAmB,WAAA;EACO;EAAqB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/core/types.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Wire contract shared between the analytics client, `@intlayer/api`, and the
|
|
4
3
|
* backend ingestion endpoint. Keys are intentionally short to keep the batched
|
|
@@ -120,5 +119,4 @@ export type AnalyticsClientConfig = {
|
|
|
120
119
|
/** Fraction of content-exposure events to keep, 0..1. Defaults to 1. */
|
|
121
120
|
sampleRate: number;
|
|
122
121
|
};
|
|
123
|
-
//#endregion
|
|
124
122
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/core/types.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/core/types.ts"],"mappings":";;;;;;;;YASY;;;;YAQA;;EAEV;;EAEA;;EAEA;;;;;;YAOU,gBAAgB;EAC1B;;EAEA;;EAEA;;EAEA;;EAEA;;;;;;;YAQU,uBAAuB;EACjC;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;YAMU,kBAAkB;EAC5B;;EAEA;;EAEA;;EAEA;;EAEA;;;;;YAMU,iBACR,gBACA,uBACA;;;;;YAMQ,eAAe,UAAU,iBAAiB,kBAAkB,KACtE;;EAIA;;;;;YAMU;;;;;;;EAOV;;;;;;EAMA;;EAEA;;EAEA;;EAEA,QAAQ;;;;;;YAOE;;EAEV;;EAEA;;EAEA;;EAEA;;EAEA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ContentExposureEvent, TrackableEvent } from "../core/types.js";
|
|
2
2
|
import { KeyPath } from "@intlayer/types/keyPath";
|
|
3
|
-
//#region src/events/contentExposure.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Serializes a `KeyPath[]` into a compact, stable string used both as the
|
|
6
5
|
* coalescing key in the buffer and as the stored `keyPath` on the wire.
|
|
@@ -32,5 +31,4 @@ export declare const buildContentExposure: (params: {
|
|
|
32
31
|
experimentKey?: string;
|
|
33
32
|
variant?: string;
|
|
34
33
|
}) => Omit<TrackableEvent<ContentExposureEvent>, 'type'>;
|
|
35
|
-
//#endregion
|
|
36
34
|
//# sourceMappingURL=contentExposure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contentExposure.d.ts","names":[],"sources":["../../../src/events/contentExposure.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"contentExposure.d.ts","names":[],"sources":["../../../src/events/contentExposure.ts"],"mappings":";;;;;;;;;;;;;;;;qBAiBa,mBAAgB,SAAa;;;;;;;;;qBAa7B,uBAAoB;EAC/B;EACA,SAAS;EACT;EACA;EACA;EACA;MACE,KAAK,eAAe"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { initAnalyticsClient, stopAnalyticsClient } from "./core/initAnalyticsCl
|
|
|
7
7
|
import { isSampledIn } from "./core/sampling.js";
|
|
8
8
|
import { getSessionId } from "./core/session.js";
|
|
9
9
|
import { sendEvents } from "./core/transport.js";
|
|
10
|
+
import "./core/index.js";
|
|
10
11
|
import { buildContentExposure, serializeKeyPath } from "./events/contentExposure.js";
|
|
11
12
|
import { BOT_USER_AGENT_PATTERN, isBotEnvironment, isBotUserAgent } from "./utils/isBot.js";
|
|
12
13
|
export { AnalyticsClient, AnalyticsClientConfig, AnalyticsEvent, AnalyticsEventType, AnalyticsIngestBody, BOT_USER_AGENT_PATTERN, BaseAnalyticsEvent, ContentExposureEvent, ConversionEvent, DEFAULT_FLUSH_INTERVAL, DEFAULT_MAX_BUFFER_SIZE, DEFAULT_SAMPLE_RATE, EventBuffer, MAX_EVENTS_PER_SEND, PageViewEvent, PageViewInput, TrackableEvent, assignVariant, buildContentExposure, createAnalyticsClient, createEventBuffer, decrementAnalyticsClientRefCount, getGlobalAnalyticsClient, getSessionId, incrementAnalyticsClientRefCount, initAnalyticsClient, isBotEnvironment, isBotUserAgent, isSampledIn, sendEvents, serializeKeyPath, setGlobalAnalyticsClient, stopAnalyticsClient };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/isEnabled.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Runtime guard mirroring `@intlayer/editor`'s `isEnabled`, but inverted with
|
|
4
3
|
* respect to the iframe: analytics runs for real end users on the **top**
|
|
@@ -14,5 +13,4 @@
|
|
|
14
13
|
* - the visitor is not a bot, crawler or automation runtime.
|
|
15
14
|
*/
|
|
16
15
|
export declare const isEnabled: boolean;
|
|
17
|
-
//#endregion
|
|
18
16
|
//# sourceMappingURL=isEnabled.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isEnabled.d.ts","names":[],"sources":["../../src/isEnabled.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isEnabled.d.ts","names":[],"sources":["../../src/isEnabled.ts"],"mappings":";;;;;;;;;;;;;;qBA0Ba"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/utils/hash.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* FNV-1a 32-bit string hash. Small, fast, dependency-free, and stable across
|
|
4
3
|
* runtimes — good enough for deterministic A/B bucketing and session seeding
|
|
@@ -11,5 +10,4 @@
|
|
|
11
10
|
* hashString('session-1:homepage-hero'); // 3039336720
|
|
12
11
|
*/
|
|
13
12
|
export declare const hashString: (input: string) => number;
|
|
14
|
-
//#endregion
|
|
15
13
|
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","names":[],"sources":["../../../src/utils/hash.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hash.d.ts","names":[],"sources":["../../../src/utils/hash.ts"],"mappings":";;;;;;;;;;;qBAWa,aAAU"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/utils/idle.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Runs a callback when the browser is idle, without blocking first render.
|
|
4
3
|
* Falls back to a short `setTimeout` where `requestIdleCallback` is unavailable
|
|
@@ -10,5 +9,4 @@
|
|
|
10
9
|
* onIdle(() => attachVisibilityListeners());
|
|
11
10
|
*/
|
|
12
11
|
export declare const onIdle: (callback: () => void) => void;
|
|
13
|
-
//#endregion
|
|
14
12
|
//# sourceMappingURL=idle.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"idle.d.ts","names":[],"sources":["../../../src/utils/idle.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"idle.d.ts","names":[],"sources":["../../../src/utils/idle.ts"],"mappings":";;;;;;;;;;qBAUa,SAAM"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/utils/isBot.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Bot / automation detection.
|
|
4
3
|
*
|
|
@@ -49,5 +48,4 @@ export declare const isBotUserAgent: (userAgent?: string | null) => boolean;
|
|
|
49
48
|
* if (isBotEnvironment()) return; // never start the client for a crawler
|
|
50
49
|
*/
|
|
51
50
|
export declare const isBotEnvironment: () => boolean;
|
|
52
|
-
//#endregion
|
|
53
51
|
//# sourceMappingURL=isBot.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isBot.d.ts","names":[],"sources":["../../../src/utils/isBot.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"isBot.d.ts","names":[],"sources":["../../../src/utils/isBot.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;qBA4Ba,wBAAsB;;;;;;;;;;;;;;;qBAiBtB,iBAAc;;;;;;;;;;;;;;qBAmCd"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/analytics",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Collects which Intlayer content is shown (page/locale + node-level) and powers content A/B testing. Optional, lazily-imported companion to @intlayer/editor.",
|
|
6
6
|
"keywords": [
|
|
7
|
-
"intlayer",
|
|
8
|
-
"analytics",
|
|
9
7
|
"ab-testing",
|
|
10
|
-
"
|
|
8
|
+
"analytics",
|
|
9
|
+
"i18n",
|
|
10
|
+
"intlayer"
|
|
11
11
|
],
|
|
12
12
|
"homepage": "https://intlayer.org",
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/aymericzip/intlayer/issues"
|
|
15
15
|
},
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
19
|
-
},
|
|
20
16
|
"license": "Apache-2.0",
|
|
21
17
|
"author": {
|
|
22
18
|
"name": "Aymeric PINEAU",
|
|
@@ -29,7 +25,25 @@
|
|
|
29
25
|
"url": "https://github.com/aymericzip"
|
|
30
26
|
}
|
|
31
27
|
],
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/aymericzip/intlayer.git"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"./dist",
|
|
34
|
+
"./package.json"
|
|
35
|
+
],
|
|
32
36
|
"sideEffects": false,
|
|
37
|
+
"main": "dist/cjs/index.cjs",
|
|
38
|
+
"module": "dist/esm/index.mjs",
|
|
39
|
+
"types": "dist/types/index.d.ts",
|
|
40
|
+
"typesVersions": {
|
|
41
|
+
"*": {
|
|
42
|
+
"package.json": [
|
|
43
|
+
"./package.json"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
},
|
|
33
47
|
"exports": {
|
|
34
48
|
".": {
|
|
35
49
|
"types": "./dist/types/index.d.ts",
|
|
@@ -53,29 +67,15 @@
|
|
|
53
67
|
},
|
|
54
68
|
"./package.json": "./package.json"
|
|
55
69
|
},
|
|
56
|
-
"main": "dist/cjs/index.cjs",
|
|
57
|
-
"module": "dist/esm/index.mjs",
|
|
58
|
-
"types": "dist/types/index.d.ts",
|
|
59
|
-
"typesVersions": {
|
|
60
|
-
"*": {
|
|
61
|
-
"package.json": [
|
|
62
|
-
"./package.json"
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
"files": [
|
|
67
|
-
"./dist",
|
|
68
|
-
"./package.json"
|
|
69
|
-
],
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "bun --bun tsdown --config tsdown.config.ts",
|
|
72
72
|
"build:ci": "bun --bun tsdown --config tsdown.config.ts",
|
|
73
73
|
"clean": "bun --bun rimraf ./dist .turbo",
|
|
74
74
|
"dev": "bun --bun tsdown --config tsdown.config.ts --watch",
|
|
75
|
-
"format": "
|
|
76
|
-
"format:fix": "
|
|
77
|
-
"lint": "
|
|
78
|
-
"lint:fix": "
|
|
75
|
+
"format": "oxfmt --check .",
|
|
76
|
+
"format:fix": "oxfmt .",
|
|
77
|
+
"lint": "oxlint .",
|
|
78
|
+
"lint:fix": "oxlint --fix .",
|
|
79
79
|
"prepublish": "cp -f ../../../README.md ./README.md",
|
|
80
80
|
"publish": "bun publish || true",
|
|
81
81
|
"publish:canary": "bun publish --access public --tag canary || true",
|
|
@@ -86,19 +86,19 @@
|
|
|
86
86
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@intlayer/config": "9.
|
|
90
|
-
"@intlayer/core": "9.7.
|
|
91
|
-
"@intlayer/types": "9.7.
|
|
89
|
+
"@intlayer/config": "9.7.2",
|
|
90
|
+
"@intlayer/core": "9.7.2",
|
|
91
|
+
"@intlayer/types": "9.7.2"
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@types/node": "^26",
|
|
95
95
|
"@utils/ts-config": "1.0.4",
|
|
96
96
|
"@utils/ts-config-types": "1.0.4",
|
|
97
97
|
"@utils/tsdown-config": "1.0.4",
|
|
98
|
-
"rimraf": "6.1.
|
|
99
|
-
"tsdown": "0.23.
|
|
98
|
+
"rimraf": "6.1.4",
|
|
99
|
+
"tsdown": "0.23.7",
|
|
100
100
|
"typescript": "7.0.2",
|
|
101
|
-
"vitest": "5.0
|
|
101
|
+
"vitest": "5.1.0"
|
|
102
102
|
},
|
|
103
103
|
"engines": {
|
|
104
104
|
"node": ">=14.18"
|