@absmartly/sdk-plugins 1.0.1 → 1.1.1
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/absmartly-cookie.min.js +1 -1
- package/dist/absmartly-dom-changes-core.min.js +1 -1
- package/dist/absmartly-dom-changes-lite.min.js +1 -1
- package/dist/absmartly-overrides-full.min.js +1 -1
- package/dist/absmartly-sdk-plugins.min.js +1 -1
- package/dist/absmartly-vitals.min.js +1 -1
- package/es/cookies/CookiePlugin.js +31 -61
- package/es/cookies/CookiePlugin.js.map +1 -1
- package/es/cookies/cookieUtils.js +82 -0
- package/es/cookies/cookieUtils.js.map +1 -0
- package/es/cookies/index.js +1 -0
- package/es/cookies/index.js.map +1 -1
- package/es/core/DOMChangesPluginLite.js +199 -103
- package/es/core/DOMChangesPluginLite.js.map +1 -1
- package/es/core/DOMManipulatorLite.js +64 -9
- package/es/core/DOMManipulatorLite.js.map +1 -1
- package/es/core/ExposureTracker.js +6 -15
- package/es/core/ExposureTracker.js.map +1 -1
- package/es/entries/dom-with-overrides-lite.js +6 -1
- package/es/entries/dom-with-overrides-lite.js.map +1 -1
- package/es/index.js +4 -0
- package/es/index.js.map +1 -1
- package/es/overrides/index.js +1 -0
- package/es/overrides/index.js.map +1 -1
- package/es/overrides/overridesUtils.js +255 -0
- package/es/overrides/overridesUtils.js.map +1 -0
- package/es/utils/debug.js +2 -1
- package/es/utils/debug.js.map +1 -1
- package/es/vitals/WebVitalsPlugin.js +65 -54
- package/es/vitals/WebVitalsPlugin.js.map +1 -1
- package/lib/cookies/CookiePlugin.d.ts +0 -3
- package/lib/cookies/CookiePlugin.js +31 -61
- package/lib/cookies/CookiePlugin.js.map +1 -1
- package/lib/cookies/cookieUtils.d.ts +34 -0
- package/lib/cookies/cookieUtils.js +90 -0
- package/lib/cookies/cookieUtils.js.map +1 -0
- package/lib/cookies/index.d.ts +2 -0
- package/lib/cookies/index.js +8 -1
- package/lib/cookies/index.js.map +1 -1
- package/lib/core/DOMChangesPluginLite.d.ts +1 -1
- package/lib/core/DOMChangesPluginLite.js +199 -103
- package/lib/core/DOMChangesPluginLite.js.map +1 -1
- package/lib/core/DOMManipulatorLite.js +64 -9
- package/lib/core/DOMManipulatorLite.js.map +1 -1
- package/lib/core/ExposureTracker.d.ts +4 -1
- package/lib/core/ExposureTracker.js +6 -15
- package/lib/core/ExposureTracker.js.map +1 -1
- package/lib/entries/dom-with-overrides-lite.d.ts +7 -1
- package/lib/entries/dom-with-overrides-lite.js +19 -1
- package/lib/entries/dom-with-overrides-lite.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.js +17 -1
- package/lib/index.js.map +1 -1
- package/lib/overrides/index.d.ts +2 -0
- package/lib/overrides/index.js +8 -1
- package/lib/overrides/index.js.map +1 -1
- package/lib/overrides/overridesUtils.d.ts +48 -0
- package/lib/overrides/overridesUtils.js +263 -0
- package/lib/overrides/overridesUtils.js.map +1 -0
- package/lib/utils/debug.js +2 -1
- package/lib/utils/debug.js.map +1 -1
- package/lib/vitals/WebVitalsPlugin.d.ts +1 -2
- package/lib/vitals/WebVitalsPlugin.js +98 -54
- package/lib/vitals/WebVitalsPlugin.js.map +1 -1
- package/package.json +4 -1
- package/types/cookies/CookiePlugin.d.ts +0 -3
- package/types/cookies/cookieUtils.d.ts +34 -0
- package/types/cookies/index.d.ts +2 -0
- package/types/core/DOMChangesPluginLite.d.ts +1 -1
- package/types/core/ExposureTracker.d.ts +4 -1
- package/types/entries/dom-with-overrides-lite.d.ts +7 -1
- package/types/index.d.ts +4 -0
- package/types/overrides/index.d.ts +2 -0
- package/types/overrides/overridesUtils.d.ts +48 -0
- package/types/vitals/WebVitalsPlugin.d.ts +1 -2
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie utility functions extracted from CookiePlugin
|
|
3
|
+
* These can be used independently for lightweight cookie operations
|
|
4
|
+
*/
|
|
5
|
+
export interface CookieOptions {
|
|
6
|
+
domain?: string;
|
|
7
|
+
path?: string;
|
|
8
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
9
|
+
secure?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get a cookie value by name
|
|
13
|
+
*/
|
|
14
|
+
export declare function getCookie(name: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Set a cookie with expiry and options
|
|
17
|
+
*/
|
|
18
|
+
export declare function setCookie(name: string, value: string, days: number, options?: CookieOptions): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Delete a cookie by name
|
|
21
|
+
*/
|
|
22
|
+
export declare function deleteCookie(name: string, options?: CookieOptions): void;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a fast unique ID (timestamp + random)
|
|
25
|
+
*/
|
|
26
|
+
export declare function generateUniqueId(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Generate a UUID v4
|
|
29
|
+
*/
|
|
30
|
+
export declare function generateUUID(): string;
|
|
31
|
+
/**
|
|
32
|
+
* Check if localStorage is available
|
|
33
|
+
*/
|
|
34
|
+
export declare function isLocalStorageAvailable(): boolean;
|
package/types/cookies/index.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { CookiePlugin } from './CookiePlugin';
|
|
2
2
|
export type { CookiePluginOptions } from './CookiePlugin';
|
|
3
|
+
export { getCookie, setCookie, deleteCookie, generateUniqueId, generateUUID, isLocalStorageAvailable, } from './cookieUtils';
|
|
4
|
+
export type { CookieOptions } from './cookieUtils';
|
|
@@ -20,7 +20,7 @@ export declare class DOMChangesPluginLite {
|
|
|
20
20
|
protected persistenceObserver: MutationObserver | null;
|
|
21
21
|
protected reapplyingElements: Set<Element>;
|
|
22
22
|
protected reapplyLogThrottle: Map<string, number>;
|
|
23
|
-
protected
|
|
23
|
+
protected appliedChanges: Map<string, DOMChange[]>;
|
|
24
24
|
protected antiFlickerTimeout: number | null;
|
|
25
25
|
protected antiFlickerStyleId: string;
|
|
26
26
|
constructor(config: PluginConfig);
|
|
@@ -10,8 +10,11 @@ export declare class ExposureTracker {
|
|
|
10
10
|
constructor(context: ABsmartlyContext, debug?: boolean);
|
|
11
11
|
/**
|
|
12
12
|
* Register an experiment with all its variants' changes for comprehensive tracking
|
|
13
|
+
*
|
|
14
|
+
* @param hasImmediateTrigger - Whether ANY variant matching URL filter has immediate trigger
|
|
15
|
+
* @param hasViewportTrigger - Whether ANY variant matching URL filter has viewport trigger
|
|
13
16
|
*/
|
|
14
|
-
registerExperiment(experimentName: string, currentVariant: number, currentChanges: DOMChange[], allVariantsChanges: DOMChange[][]): void;
|
|
17
|
+
registerExperiment(experimentName: string, currentVariant: number, currentChanges: DOMChange[], allVariantsChanges: DOMChange[][], hasImmediateTrigger: boolean, hasViewportTrigger: boolean): void;
|
|
15
18
|
/**
|
|
16
19
|
* Create a container-based placeholder at the hypothetical position
|
|
17
20
|
* Uses inline-block with minimal dimensions to be observable but not affect layout
|
|
@@ -4,8 +4,14 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { DOMChangesPluginLite } from '../core/DOMChangesPluginLite';
|
|
6
6
|
import { OverridesPluginLite } from '../overrides/OverridesPluginLite';
|
|
7
|
+
import { CookiePlugin } from '../cookies/CookiePlugin';
|
|
7
8
|
export * from '../types';
|
|
8
9
|
export * from '../overrides/types';
|
|
9
|
-
export {
|
|
10
|
+
export type { CookiePluginOptions } from '../cookies/CookiePlugin';
|
|
11
|
+
export type { CookieOptions } from '../cookies/cookieUtils';
|
|
12
|
+
export { DOMChangesPluginLite, OverridesPluginLite, CookiePlugin };
|
|
10
13
|
export { DOMChangesPluginLite as DOMChangesPlugin };
|
|
14
|
+
export { getCookie, setCookie, deleteCookie, generateUniqueId, generateUUID, isLocalStorageAvailable, } from '../cookies/cookieUtils';
|
|
15
|
+
export { getQueryStringOverrides, parseOverrideCookie, getCookieOverrides as getOverrideCookie, serializeOverrides, persistOverridesToCookie, getOverrides, } from '../overrides/overridesUtils';
|
|
16
|
+
export type { SimpleOverride, OverrideOptions } from '../overrides/overridesUtils';
|
|
11
17
|
export default DOMChangesPluginLite;
|
package/types/index.d.ts
CHANGED
|
@@ -6,8 +6,12 @@ import { WebVitalsPlugin } from './vitals/WebVitalsPlugin';
|
|
|
6
6
|
export * from './types';
|
|
7
7
|
export * from './overrides/types';
|
|
8
8
|
export type { CookiePluginOptions } from './cookies/CookiePlugin';
|
|
9
|
+
export type { CookieOptions } from './cookies/cookieUtils';
|
|
9
10
|
export type { WebVitalsPluginOptions, Metric } from './vitals/WebVitalsPlugin';
|
|
10
11
|
export { DOMChangesPluginLite, DOMChangesPluginLite as DOMChangesPlugin, // Alias for backward compatibility
|
|
11
12
|
OverridesPlugin, // Legacy export - this is the original full-featured version
|
|
12
13
|
BrowserCookieAdapter, CookiePlugin, WebVitalsPlugin, };
|
|
14
|
+
export { getCookie, setCookie, deleteCookie, generateUniqueId, generateUUID, isLocalStorageAvailable, } from './cookies/cookieUtils';
|
|
15
|
+
export { getQueryStringOverrides, parseOverrideCookie, getCookieOverrides, serializeOverrides, persistOverridesToCookie, getOverrides, } from './overrides/overridesUtils';
|
|
16
|
+
export type { SimpleOverride, OverrideOptions } from './overrides/overridesUtils';
|
|
13
17
|
export default DOMChangesPluginLite;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { OverridesPlugin } from './OverridesPlugin';
|
|
2
2
|
export { BrowserCookieAdapter } from './BrowserCookieAdapter';
|
|
3
3
|
export * from './types';
|
|
4
|
+
export { getQueryStringOverrides, parseOverrideCookie, getCookieOverrides, serializeOverrides, persistOverridesToCookie, getOverrides, } from './overridesUtils';
|
|
5
|
+
export type { SimpleOverride, OverrideOptions } from './overridesUtils';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Override utility functions extracted for reusability
|
|
3
|
+
* These can be used independently for lightweight override operations
|
|
4
|
+
* without requiring the full OverridesPlugin class
|
|
5
|
+
*/
|
|
6
|
+
export interface SimpleOverride {
|
|
7
|
+
variant: number;
|
|
8
|
+
env?: number;
|
|
9
|
+
id?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface OverrideOptions {
|
|
12
|
+
cookieName?: string;
|
|
13
|
+
queryPrefix?: string;
|
|
14
|
+
maxAge?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parse query string parameters for experiment overrides
|
|
18
|
+
* @param queryPrefix - Prefix for experiment parameters (e.g., '_exp_')
|
|
19
|
+
* @param searchParams - Optional URLSearchParams instance (defaults to window.location.search)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getQueryStringOverrides(queryPrefix?: string, searchParams?: URLSearchParams): Record<string, number | SimpleOverride>;
|
|
22
|
+
/**
|
|
23
|
+
* Parse cookie value for experiment overrides
|
|
24
|
+
* Format: name:variant.env.id,name2:variant2
|
|
25
|
+
*/
|
|
26
|
+
export declare function parseOverrideCookie(value: string): Record<string, number | SimpleOverride>;
|
|
27
|
+
/**
|
|
28
|
+
* Get experiment overrides from cookie
|
|
29
|
+
*/
|
|
30
|
+
export declare function getCookieOverrides(cookieName?: string): Record<string, number | SimpleOverride>;
|
|
31
|
+
/**
|
|
32
|
+
* Serialize overrides to cookie value format
|
|
33
|
+
*/
|
|
34
|
+
export declare function serializeOverrides(overrides: Record<string, number | SimpleOverride>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Persist experiment overrides to cookie
|
|
37
|
+
*/
|
|
38
|
+
export declare function persistOverridesToCookie(overrides: Record<string, number | SimpleOverride>, options?: OverrideOptions): void;
|
|
39
|
+
/**
|
|
40
|
+
* Get experiment overrides from query string or cookie
|
|
41
|
+
* Returns normalized Record<string, number> for use with SDK createContext
|
|
42
|
+
*
|
|
43
|
+
* @param cookieName - Name of the cookie to read/write (default: 'absmartly_overrides')
|
|
44
|
+
* @param queryPrefix - Prefix for query string parameters (default: '_exp_')
|
|
45
|
+
* @param searchParams - Optional URLSearchParams instance (defaults to window.location.search)
|
|
46
|
+
* @returns Normalized overrides as Record<string, number>
|
|
47
|
+
*/
|
|
48
|
+
export declare function getOverrides(cookieName?: string, queryPrefix?: string, searchParams?: URLSearchParams): Record<string, number>;
|
|
@@ -4,7 +4,6 @@ export interface WebVitalsPluginOptions {
|
|
|
4
4
|
debug?: boolean;
|
|
5
5
|
trackWebVitals?: boolean;
|
|
6
6
|
trackPageMetrics?: boolean;
|
|
7
|
-
webVitalsUrl?: string;
|
|
8
7
|
autoTrack?: boolean;
|
|
9
8
|
}
|
|
10
9
|
export interface Metric {
|
|
@@ -20,10 +19,10 @@ export declare class WebVitalsPlugin {
|
|
|
20
19
|
private debug;
|
|
21
20
|
private trackWebVitals;
|
|
22
21
|
private trackPageMetrics;
|
|
23
|
-
private webVitalsUrl;
|
|
24
22
|
private autoTrack;
|
|
25
23
|
private webVitalsLoaded;
|
|
26
24
|
private metricsTracked;
|
|
25
|
+
private webVitalsPromise?;
|
|
27
26
|
constructor(options?: WebVitalsPluginOptions);
|
|
28
27
|
private debugLog;
|
|
29
28
|
setContext(context: Context): void;
|