@se-studio/ab-testing 1.0.60 → 1.0.62
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/CHANGELOG.md +6 -0
- package/dist/components/AbTestReporter.d.ts.map +1 -1
- package/dist/components/AbTestReporter.js +0 -8
- package/dist/components/AbTestReporter.js.map +1 -1
- package/dist/components/AbTestUtmScript.d.ts +13 -0
- package/dist/components/AbTestUtmScript.d.ts.map +1 -0
- package/dist/components/AbTestUtmScript.js +34 -0
- package/dist/components/AbTestUtmScript.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbTestReporter.d.ts","sourceRoot":"","sources":["../../src/components/AbTestReporter.tsx"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,
|
|
1
|
+
{"version":3,"file":"AbTestReporter.d.ts","sourceRoot":"","sources":["../../src/components/AbTestReporter.tsx"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,SAgC7B"}
|
|
@@ -13,14 +13,6 @@ export function AbTestReporter() {
|
|
|
13
13
|
console.log('[A/B reporter] No active tests on this page');
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
// Update browser URL with utm_content so third-party scripts can read it
|
|
17
|
-
const url = new URL(window.location.href);
|
|
18
|
-
const firstAssignment = assignments[0];
|
|
19
|
-
if (firstAssignment) {
|
|
20
|
-
const utmContent = `${firstAssignment.test_label}:${firstAssignment.test_path}`;
|
|
21
|
-
url.searchParams.set('utm_content', utmContent);
|
|
22
|
-
history.replaceState(null, '', url.toString());
|
|
23
|
-
}
|
|
24
16
|
for (const assignment of assignments) {
|
|
25
17
|
console.log(`[A/B reporter] Test "${assignment.test_label}" (${assignment.testId})`, {
|
|
26
18
|
variant: assignment.test_path,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbTestReporter.js","sourceRoot":"","sources":["../../src/components/AbTestReporter.tsx"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,UAAU,cAAc;IAC5B,MAAM,WAAW,GAAG,oBAAoB,EAAE,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,yDAAyD;QACzD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO;QACT,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAC3D,OAAO;QACT,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"AbTestReporter.js","sourceRoot":"","sources":["../../src/components/AbTestReporter.tsx"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,YAAY,CAAC;AAEb,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,UAAU,cAAc;IAC5B,MAAM,WAAW,GAAG,oBAAoB,EAAE,CAAC;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,yDAAyD;QACzD,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACzB,OAAO;QACT,CAAC;QAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAC3D,OAAO;QACT,CAAC;QAED,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;YACrC,OAAO,CAAC,GAAG,CAAC,wBAAwB,UAAU,CAAC,UAAU,MAAM,UAAU,CAAC,MAAM,GAAG,EAAE;gBACnF,OAAO,EAAE,UAAU,CAAC,SAAS;gBAC7B,IAAI,EAAE,UAAU,CAAC,aAAa;aAC/B,CAAC,CAAC;YAEH,wBAAwB;YACtB,MAA6C,CAAC,SAAmC,EAAE,IAAI,CAAC;gBACxF,KAAK,EAAE,uBAAuB;gBAC9B,aAAa,EAAE,UAAU,CAAC,MAAM;gBAChC,eAAe,EAAE,UAAU,CAAC,UAAU;gBACtC,UAAU,EAAE,UAAU,CAAC,SAAS;gBAChC,WAAW,EAAE,GAAG,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,SAAS,EAAE;aAChE,CAAC,CAAC;QACL,CAAC;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface AbTestUtmScriptProps {
|
|
2
|
+
cookieName?: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Inline script that sets utm_content on the browser URL as early as possible
|
|
6
|
+
* (before React hydration) so GTM scripts can read it on initial page load.
|
|
7
|
+
*
|
|
8
|
+
* Must be rendered in the root layout only — Next.js requires
|
|
9
|
+
* `strategy="beforeInteractive"` scripts to live in the root layout.
|
|
10
|
+
*/
|
|
11
|
+
export declare function AbTestUtmScript({ cookieName }: AbTestUtmScriptProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=AbTestUtmScript.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbTestUtmScript.d.ts","sourceRoot":"","sources":["../../src/components/AbTestUtmScript.tsx"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAAE,UAA2B,EAAE,EAAE,oBAAoB,2CAyBpF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Script from 'next/script';
|
|
3
|
+
/**
|
|
4
|
+
* Inline script that sets utm_content on the browser URL as early as possible
|
|
5
|
+
* (before React hydration) so GTM scripts can read it on initial page load.
|
|
6
|
+
*
|
|
7
|
+
* Must be rendered in the root layout only — Next.js requires
|
|
8
|
+
* `strategy="beforeInteractive"` scripts to live in the root layout.
|
|
9
|
+
*/
|
|
10
|
+
export function AbTestUtmScript({ cookieName = 'ab-test-info' }) {
|
|
11
|
+
return (_jsx(Script, { id: "ab-test-utm", strategy: "beforeInteractive", children: `
|
|
12
|
+
(function() {
|
|
13
|
+
try {
|
|
14
|
+
if (window.location.search.indexOf('utm_content=') !== -1) return;
|
|
15
|
+
var m = document.cookie.match(new RegExp('(^| )${cookieName}=([^;]+)'));
|
|
16
|
+
if (!m) return;
|
|
17
|
+
var a = JSON.parse(decodeURIComponent(m[2]));
|
|
18
|
+
var p = window.location.pathname.replace(/\\/$/, '') || '/';
|
|
19
|
+
var parts = [];
|
|
20
|
+
for (var id in a) {
|
|
21
|
+
var t = a[id];
|
|
22
|
+
var op = (t.original_path || '').replace(/\\/$/, '') || '/';
|
|
23
|
+
if (op === p) parts.push(t.test_label + ':' + t.test_path);
|
|
24
|
+
}
|
|
25
|
+
if (parts.length > 0) {
|
|
26
|
+
var url = new URL(window.location.href);
|
|
27
|
+
url.searchParams.set('utm_content', parts.join(','));
|
|
28
|
+
window.history.replaceState(window.history.state, '', url.toString());
|
|
29
|
+
}
|
|
30
|
+
} catch(e) {}
|
|
31
|
+
})();
|
|
32
|
+
` }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=AbTestUtmScript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbTestUtmScript.js","sourceRoot":"","sources":["../../src/components/AbTestUtmScript.tsx"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AAMjC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,UAAU,GAAG,cAAc,EAAwB;IACnF,OAAO,CACL,KAAC,MAAM,IAAC,EAAE,EAAC,aAAa,EAAC,QAAQ,EAAC,mBAAmB,YAAE;;;;qDAIN,UAAU;;;;;;;;;;;;;;;;;KAiB1D,GAAU,CACZ,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@se-studio/ab-testing",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.62",
|
|
4
4
|
"description": "Server-side A/B testing framework for Next.js applications with Contentful CMS",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"react": "^19.0.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@biomejs/biome": "^2.4.
|
|
67
|
-
"@types/node": "^22.19.
|
|
66
|
+
"@biomejs/biome": "^2.4.12",
|
|
67
|
+
"@types/node": "^22.19.17",
|
|
68
68
|
"@types/react": "^19.2.14",
|
|
69
|
-
"next": "^15.5.
|
|
69
|
+
"next": "^15.5.15",
|
|
70
70
|
"typescript": "^6.0.2"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|