@uxf/analytics 11.54.0 → 11.57.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.54.0",
3
+ "version": "11.57.0",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "build": "tsc -P tsconfig.json",
@@ -31,6 +31,7 @@ export declare function handleABTesting(request: NextRequest, response: NextResp
31
31
  export declare function getExperimentsFromContext(cookies: Partial<{
32
32
  [p: string]: string;
33
33
  }>): [string, string][];
34
+ export declare function getExperimentsFromClient(): [string, string][];
34
35
  export declare function addExperimentsSSR<P>(ctx: GetServerSidePropsContext, pageProps: GetServerSidePropsResult<P>): GetServerSidePropsResult<P>;
35
36
  export declare function sendABTestingEvent(): void;
36
37
  export {};
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getExperimentVariant = getExperimentVariant;
4
4
  exports.handleABTesting = handleABTesting;
5
5
  exports.getExperimentsFromContext = getExperimentsFromContext;
6
+ exports.getExperimentsFromClient = getExperimentsFromClient;
6
7
  exports.addExperimentsSSR = addExperimentsSSR;
7
8
  exports.sendABTestingEvent = sendABTestingEvent;
8
9
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
@@ -48,6 +49,14 @@ function getExperimentsFromContext(cookies) {
48
49
  .filter(([, cookieValue]) => (0, is_not_nil_1.isNotNil)(cookieValue))
49
50
  .map(([cookieName, cookieValue]) => [cookieName.replace(constants_1.EXPERIMENT_COOKIE_PREFIX, ""), cookieValue]);
50
51
  }
52
+ function getExperimentsFromClient() {
53
+ return decodeURIComponent(typeof document !== "undefined" ? document.cookie : "")
54
+ .split(";")
55
+ .map((cookie) => cookie.trim().split("="))
56
+ .filter(([cookieName]) => cookieName.startsWith(constants_1.EXPERIMENT_COOKIE_PREFIX))
57
+ .filter(([, cookieValue]) => (0, is_not_nil_1.isNotNil)(cookieValue))
58
+ .map(([cookieName, cookieValue]) => [cookieName.replace(constants_1.EXPERIMENT_COOKIE_PREFIX, ""), cookieValue]);
59
+ }
51
60
  function addExperimentsSSR(ctx, pageProps) {
52
61
  if (pageProps.props !== undefined) {
53
62
  pageProps.props[constants_1.AB_TESTING_VARIANT_PROP_NAME] = getExperimentsFromContext(ctx.req.cookies);