@amplitude/experiment-tag 0.23.4 → 0.25.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.
Binary file
@@ -1,6 +1,6 @@
1
1
  import { Plugin } from '@amplitude/analytics-types';
2
2
  import { ExperimentClient, Variants } from '@amplitude/experiment-js-client';
3
- import { MutationController } from 'dom-mutator';
3
+ import type { MutationController } from 'dom-mutator/dist/types';
4
4
  import { BehavioralTargetingManager } from './behavioral-targeting';
5
5
  import { PageChangeEvent } from './subscriptions/subscriptions';
6
6
  import { InitConfigs, WebExperimentClient, WebExperimentConfig } from './types';
@@ -69,7 +69,7 @@ export declare class DefaultWebExperimentClient implements WebExperimentClient {
69
69
  * Apply evaluated variants to the page.
70
70
  * @param options
71
71
  */
72
- applyVariants(options?: ApplyVariantsOptions): void;
72
+ applyVariants(options?: ApplyVariantsOptions): Promise<void>;
73
73
  /**
74
74
  * Revert variant actions applied by the experiment.
75
75
  * @param options
@@ -79,7 +79,7 @@ export declare class DefaultWebExperimentClient implements WebExperimentClient {
79
79
  * Preview the effect of a variant on the page.
80
80
  * @param options
81
81
  */
82
- previewVariants(options: PreviewVariantsOptions): void;
82
+ previewVariants(options: PreviewVariantsOptions): Promise<void>;
83
83
  /**
84
84
  * Get all variants for the current web experiment user context.
85
85
  */
@@ -79,6 +79,19 @@ export type BehavioralTargetingRules = {
79
79
  [id: string]: BehavioralTargeting;
80
80
  };
81
81
  };
82
+ export interface RedirectConfig {
83
+ /**
84
+ * When true, redirect impression data is stored in a cookie scoped to the root domain,
85
+ * enabling impression tracking across subdomains.
86
+ */
87
+ encodeRedirectInCookie?: boolean;
88
+ /**
89
+ * When true, redirect impression data is base64-encoded as an AMP_REDIRECT query
90
+ * parameter on the destination URL, enabling tracking in cross-domain redirects
91
+ * and cookie-blocked environments.
92
+ */
93
+ encodeRedirectInUrl?: boolean;
94
+ }
82
95
  export interface WebExperimentConfig extends ExperimentConfig {
83
96
  /**
84
97
  * Determines whether the default implementation for handling navigation will be used
@@ -87,6 +100,7 @@ export interface WebExperimentConfig extends ExperimentConfig {
87
100
  * 2. Custom handling of navigation {@link setRedirectHandler} should be implemented such that variant actions applied on the site reflect the latest context
88
101
  */
89
102
  useDefaultNavigationHandler?: boolean;
103
+ redirectConfig?: RedirectConfig;
90
104
  }
91
105
  export declare const Defaults: WebExperimentConfig;
92
106
  /**
@@ -108,6 +122,7 @@ export interface WebExperimentClient {
108
122
  }
109
123
  export type WebExperimentUser = {
110
124
  web_exp_id?: string;
125
+ web_exp_id_v2?: string;
111
126
  } & ExperimentUser;
112
127
  export type InitConfigs = {
113
128
  initialFlags: string;
@@ -6,7 +6,8 @@
6
6
  */
7
7
  export declare const applyAntiFlickerCss: () => void;
8
8
  /**
9
- * Revert the anti-flicker stylesheet immediately. Idempotent safe to call
10
- * even when no sheet is active.
9
+ * Revert the anti-flicker stylesheet immediately. Also removes any
10
+ * <style id="amp-exp-css"> element injected by customer snippets.
11
+ * Idempotent — safe to call even when no sheet is active.
11
12
  */
12
13
  export declare const removeAntiFlickerCss: () => void;
@@ -1,5 +1,11 @@
1
+ import { CookieStorage } from '@amplitude/analytics-core';
2
+ export declare function getTopLevelDomain(hostname: string): Promise<string>;
1
3
  /**
2
- * Utility function to generate and set marketing cookie
3
- * Parses current campaign data from URL and referrer, then stores it in the marketing cookie
4
+ * Resolves a cross-subdomain value using cookie storage as the authoritative
5
+ * source. Falls back to a provided localStorage value (migration path), then
6
+ * generates a new value if neither exists. Attempts to set the cookie when
7
+ * missing; cookie I/O failures fall back to localStorage / generateNew.
8
+ * Callers are responsible for syncing the returned value back to localStorage.
4
9
  */
5
- export declare function setMarketingCookie(apiKey: string): Promise<void>;
10
+ export declare function resolveCrossSubdomainValue(cookieStorage: CookieStorage<string>, cookieKey: string, localStorageValue: string | undefined, generateNew: () => string): Promise<string>;
11
+ export declare function setMarketingCookie(apiKey: string, hostname: string): Promise<void>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Runs `callback` once `document.body` is available.
3
+ *
4
+ * Polls via `requestAnimationFrame` instead of waiting on a
5
+ * `DOMContentLoaded` / `load` listener because third-party scripts that
6
+ * proxy global event listeners can swallow those events — see #299.
7
+ *
8
+ * In the (effectively impossible) case where `requestAnimationFrame` is
9
+ * unavailable, the callback is invoked immediately rather than never —
10
+ * callers that would crash on a null body should guard inside.
11
+ */
12
+ export declare const whenBodyReady: (callback: () => void) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/experiment-tag",
3
- "version": "0.23.4",
3
+ "version": "0.25.0",
4
4
  "description": "Amplitude Experiment Javascript Snippet",
5
5
  "author": "Amplitude",
6
6
  "homepage": "https://github.com/amplitude/experiment-js-client",
@@ -31,7 +31,7 @@
31
31
  "@amplitude/analytics-types": "^2.11.0",
32
32
  "@amplitude/experiment-core": "^0.13.1",
33
33
  "@amplitude/experiment-js-client": "^1.21.1",
34
- "dom-mutator": "git+ssh://git@github.com/amplitude/dom-mutator#07a72dddbc2969ea826bdfe2b55d461d5d340992",
34
+ "dom-mutator": "git+ssh://git@github.com/amplitude/dom-mutator#bb5f4b52273e6a3de39dcf6db6f428d66d988a7b",
35
35
  "rollup-plugin-license": "^3.6.0"
36
36
  },
37
37
  "devDependencies": {
@@ -43,5 +43,5 @@
43
43
  "files": [
44
44
  "dist"
45
45
  ],
46
- "gitHead": "bb39e4125884b7eaab4685d67e8cb719da6d0edf"
46
+ "gitHead": "59c9a47ae78137304e5b56520fd6955a103c2ffc"
47
47
  }