@uxf/analytics 11.70.0 → 11.75.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxf/analytics",
3
- "version": "11.70.0",
3
+ "version": "11.75.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "tsc -P tsconfig.json",
@@ -15,7 +15,7 @@
15
15
  "author": "",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@uxf/core": "11.70.0"
18
+ "@uxf/core": "11.72.3"
19
19
  },
20
20
  "peerDependencies": {
21
21
  "react": ">=18.0.2"
@@ -1,8 +1,9 @@
1
1
  import React, { type ReactNode } from "react";
2
- import type { ExperimentConfig } from "./types";
2
+ import { ExperimentConfig, GetExpVariantString } from "./types";
3
3
  interface Props {
4
- experiments: [string, string][];
5
4
  children: ReactNode;
5
+ experiments: [string, string][];
6
+ getExpVariantString?: GetExpVariantString;
6
7
  }
7
8
  export declare function ABTestingProvider(props: Props): React.JSX.Element;
8
9
  export declare function useABTesting(): [string, string][];
@@ -33,7 +33,7 @@ const ab_testing_1 = require("./ab-testing");
33
33
  const ABTestingContext = (0, react_1.createContext)([]);
34
34
  function ABTestingProvider(props) {
35
35
  (0, use_on_mount_1.useOnMount)(() => {
36
- (0, ab_testing_1.sendABTestingEvent)();
36
+ (0, ab_testing_1.sendABTestingEvent)(props.getExpVariantString);
37
37
  });
38
38
  return react_1.default.createElement(ABTestingContext.Provider, { value: props.experiments }, props.children);
39
39
  }
@@ -1,4 +1,4 @@
1
- import type { ExperimentConfig, ExperimentVariant } from "./types";
1
+ import type { ExperimentConfig, ExperimentVariant, GetExpVariantString } from "./types";
2
2
  type NextRequest = {
3
3
  cookies: {
4
4
  get: (cookieName: string) => {
@@ -33,5 +33,5 @@ export declare function getExperimentsFromContext(cookies: Partial<{
33
33
  }>): [string, string][];
34
34
  export declare function getExperimentsFromClient(): [string, string][];
35
35
  export declare function addExperimentsSSR<P>(ctx: GetServerSidePropsContext, pageProps: GetServerSidePropsResult<P>): GetServerSidePropsResult<P>;
36
- export declare function sendABTestingEvent(): void;
36
+ export declare function sendABTestingEvent(getExpVariantString?: GetExpVariantString): void;
37
37
  export {};
@@ -63,7 +63,7 @@ function addExperimentsSSR(ctx, pageProps) {
63
63
  }
64
64
  return pageProps;
65
65
  }
66
- function sendABTestingEvent() {
66
+ function sendABTestingEvent(getExpVariantString) {
67
67
  if (typeof document === "undefined") {
68
68
  // eslint-disable-next-line no-console
69
69
  console.error("Document is undefined. This method can be called only on client.");
@@ -79,10 +79,11 @@ function sendABTestingEvent() {
79
79
  .map((cookie) => cookie.trim().split("="))
80
80
  .map(([cookieName, cookieValue]) => ({ name: cookieName, value: cookieValue }))
81
81
  .forEach((cookie) => {
82
+ var _a;
82
83
  if (cookie.name.startsWith(constants_1.EXPERIMENT_COOKIE_PREFIX) && typeof window !== "undefined") {
83
84
  (0, gtm_event_1.gtmEvent)({
84
85
  event: "experience_impression",
85
- exp_variant_string: `${cookie.name}-${cookie.value}`,
86
+ exp_variant_string: (_a = getExpVariantString === null || getExpVariantString === void 0 ? void 0 : getExpVariantString(cookie)) !== null && _a !== void 0 ? _a : `${cookie.name}-${cookie.value}`,
86
87
  });
87
88
  }
88
89
  });
@@ -8,3 +8,7 @@ export interface ExperimentConfig {
8
8
  traffic: number;
9
9
  variants: Array<ExperimentVariant>;
10
10
  }
11
+ export type GetExpVariantString = (cookie: {
12
+ name: string;
13
+ value: string;
14
+ }) => string;