@walkeros/web-destination-optimizely 3.4.0-next-1776749829492
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/README.md +121 -0
- package/dist/dev.d.mts +193 -0
- package/dist/dev.d.ts +193 -0
- package/dist/dev.js +1 -0
- package/dist/dev.js.map +1 -0
- package/dist/dev.mjs +1 -0
- package/dist/dev.mjs.map +1 -0
- package/dist/examples/index.d.mts +152 -0
- package/dist/examples/index.d.ts +152 -0
- package/dist/examples/index.js +228 -0
- package/dist/examples/index.mjs +206 -0
- package/dist/index.browser.js +1 -0
- package/dist/index.d.mts +111 -0
- package/dist/index.d.ts +111 -0
- package/dist/index.es5.js +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +1 -0
- package/dist/index.mjs.map +1 -0
- package/dist/walkerOS.json +641 -0
- package/package.json +78 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
+
import { DestinationWeb } from '@walkeros/web-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Destination-level settings.
|
|
6
|
+
*/
|
|
7
|
+
interface Settings {
|
|
8
|
+
/** Optimizely Feature Experimentation SDK key. Required. */
|
|
9
|
+
sdkKey: string;
|
|
10
|
+
/** walkerOS mapping value to resolve userId for experiment bucketing. */
|
|
11
|
+
userId?: Mapping$1.Value;
|
|
12
|
+
/** User attributes for audience targeting, applied to every event. */
|
|
13
|
+
attributes?: Mapping$1.Value;
|
|
14
|
+
/** Polling interval for datafile updates in ms. Default: 60000. */
|
|
15
|
+
updateInterval?: number;
|
|
16
|
+
/** Auto-update datafile via polling. Default: true. */
|
|
17
|
+
autoUpdate?: boolean;
|
|
18
|
+
/** Batch event processor: events per batch. Default: 10. */
|
|
19
|
+
batchSize?: number;
|
|
20
|
+
/** Batch event processor: flush interval in ms. Default: 1000. */
|
|
21
|
+
flushInterval?: number;
|
|
22
|
+
/** Skip ODP manager initialization. Default: true. */
|
|
23
|
+
skipOdp?: boolean;
|
|
24
|
+
/** Runtime state -- not user-facing. Mutated by init/push. */
|
|
25
|
+
_state?: RuntimeState;
|
|
26
|
+
}
|
|
27
|
+
interface RuntimeState {
|
|
28
|
+
/** The Optimizely client instance (typed as OptimizelyClient). */
|
|
29
|
+
client?: OptimizelyClient;
|
|
30
|
+
/** Cached user context. Recreated when userId changes. */
|
|
31
|
+
userContext?: OptimizelyUserContext;
|
|
32
|
+
/** Last resolved userId to detect identity changes. */
|
|
33
|
+
lastUserId?: string;
|
|
34
|
+
}
|
|
35
|
+
type InitSettings = Partial<Settings>;
|
|
36
|
+
/**
|
|
37
|
+
* Per-rule mapping settings.
|
|
38
|
+
*/
|
|
39
|
+
interface Mapping {
|
|
40
|
+
/** Override event key sent to Optimizely. If omitted, event.name is used. */
|
|
41
|
+
eventKey?: string;
|
|
42
|
+
/** Revenue mapping. Resolves to integer (cents). Passed as eventTags.revenue. */
|
|
43
|
+
revenue?: Mapping$1.Value;
|
|
44
|
+
/** Numeric value mapping. Resolves to float. Passed as eventTags.value. */
|
|
45
|
+
value?: Mapping$1.Value;
|
|
46
|
+
/** Additional event tags. Resolves to Record<string, unknown>. */
|
|
47
|
+
eventTags?: Mapping$1.Value;
|
|
48
|
+
/** Per-event user attributes override. Merged onto user context for this event. */
|
|
49
|
+
attributes?: Mapping$1.Value;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* OptimizelyClient -- the subset of the Optimizely SDK client the destination
|
|
53
|
+
* actually uses. Tests provide a mock via env.optimizely.
|
|
54
|
+
*/
|
|
55
|
+
interface OptimizelyClient {
|
|
56
|
+
onReady: () => Promise<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
createUserContext: (userId: string, attributes?: Record<string, unknown>) => OptimizelyUserContext | null;
|
|
60
|
+
close: () => void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* OptimizelyUserContext -- user context methods the destination calls.
|
|
64
|
+
*/
|
|
65
|
+
interface OptimizelyUserContext {
|
|
66
|
+
trackEvent: (eventKey: string, eventTags?: Record<string, unknown>) => void;
|
|
67
|
+
setAttribute: (key: string, value: unknown) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* OptimizelySDK -- factory functions the destination imports from the SDK.
|
|
71
|
+
* Tests provide this via env.optimizely to avoid importing the real SDK.
|
|
72
|
+
*/
|
|
73
|
+
interface OptimizelySDK {
|
|
74
|
+
createInstance: (config: Record<string, unknown>) => OptimizelyClient;
|
|
75
|
+
createPollingProjectConfigManager: (config: Record<string, unknown>) => unknown;
|
|
76
|
+
createBatchEventProcessor: (config: Record<string, unknown>) => unknown;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Env -- optional SDK override. Production leaves env.optimizely undefined
|
|
80
|
+
* and the destination falls back to the real @optimizely/optimizely-sdk
|
|
81
|
+
* import. Tests provide a mock via env.optimizely.
|
|
82
|
+
*/
|
|
83
|
+
interface Env extends DestinationWeb.Env {
|
|
84
|
+
optimizely?: OptimizelySDK;
|
|
85
|
+
}
|
|
86
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
87
|
+
type Destination = DestinationWeb.Destination<Types>;
|
|
88
|
+
type Config = DestinationWeb.Config<Types>;
|
|
89
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
90
|
+
type Rules = Mapping$1.Rules<Rule>;
|
|
91
|
+
|
|
92
|
+
type index_Config = Config;
|
|
93
|
+
type index_Destination = Destination;
|
|
94
|
+
type index_Env = Env;
|
|
95
|
+
type index_InitSettings = InitSettings;
|
|
96
|
+
type index_Mapping = Mapping;
|
|
97
|
+
type index_OptimizelyClient = OptimizelyClient;
|
|
98
|
+
type index_OptimizelySDK = OptimizelySDK;
|
|
99
|
+
type index_OptimizelyUserContext = OptimizelyUserContext;
|
|
100
|
+
type index_Rule = Rule;
|
|
101
|
+
type index_Rules = Rules;
|
|
102
|
+
type index_RuntimeState = RuntimeState;
|
|
103
|
+
type index_Settings = Settings;
|
|
104
|
+
type index_Types = Types;
|
|
105
|
+
declare namespace index {
|
|
106
|
+
export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_OptimizelyClient as OptimizelyClient, index_OptimizelySDK as OptimizelySDK, index_OptimizelyUserContext as OptimizelyUserContext, index_Rule as Rule, index_Rules as Rules, index_RuntimeState as RuntimeState, index_Settings as Settings, index_Types as Types };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare const destinationOptimizely: Destination;
|
|
110
|
+
|
|
111
|
+
export { index as DestinationOptimizely, destinationOptimizely as default, destinationOptimizely };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Destination as Destination$1, Mapping as Mapping$1 } from '@walkeros/core';
|
|
2
|
+
import { DestinationWeb } from '@walkeros/web-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Destination-level settings.
|
|
6
|
+
*/
|
|
7
|
+
interface Settings {
|
|
8
|
+
/** Optimizely Feature Experimentation SDK key. Required. */
|
|
9
|
+
sdkKey: string;
|
|
10
|
+
/** walkerOS mapping value to resolve userId for experiment bucketing. */
|
|
11
|
+
userId?: Mapping$1.Value;
|
|
12
|
+
/** User attributes for audience targeting, applied to every event. */
|
|
13
|
+
attributes?: Mapping$1.Value;
|
|
14
|
+
/** Polling interval for datafile updates in ms. Default: 60000. */
|
|
15
|
+
updateInterval?: number;
|
|
16
|
+
/** Auto-update datafile via polling. Default: true. */
|
|
17
|
+
autoUpdate?: boolean;
|
|
18
|
+
/** Batch event processor: events per batch. Default: 10. */
|
|
19
|
+
batchSize?: number;
|
|
20
|
+
/** Batch event processor: flush interval in ms. Default: 1000. */
|
|
21
|
+
flushInterval?: number;
|
|
22
|
+
/** Skip ODP manager initialization. Default: true. */
|
|
23
|
+
skipOdp?: boolean;
|
|
24
|
+
/** Runtime state -- not user-facing. Mutated by init/push. */
|
|
25
|
+
_state?: RuntimeState;
|
|
26
|
+
}
|
|
27
|
+
interface RuntimeState {
|
|
28
|
+
/** The Optimizely client instance (typed as OptimizelyClient). */
|
|
29
|
+
client?: OptimizelyClient;
|
|
30
|
+
/** Cached user context. Recreated when userId changes. */
|
|
31
|
+
userContext?: OptimizelyUserContext;
|
|
32
|
+
/** Last resolved userId to detect identity changes. */
|
|
33
|
+
lastUserId?: string;
|
|
34
|
+
}
|
|
35
|
+
type InitSettings = Partial<Settings>;
|
|
36
|
+
/**
|
|
37
|
+
* Per-rule mapping settings.
|
|
38
|
+
*/
|
|
39
|
+
interface Mapping {
|
|
40
|
+
/** Override event key sent to Optimizely. If omitted, event.name is used. */
|
|
41
|
+
eventKey?: string;
|
|
42
|
+
/** Revenue mapping. Resolves to integer (cents). Passed as eventTags.revenue. */
|
|
43
|
+
revenue?: Mapping$1.Value;
|
|
44
|
+
/** Numeric value mapping. Resolves to float. Passed as eventTags.value. */
|
|
45
|
+
value?: Mapping$1.Value;
|
|
46
|
+
/** Additional event tags. Resolves to Record<string, unknown>. */
|
|
47
|
+
eventTags?: Mapping$1.Value;
|
|
48
|
+
/** Per-event user attributes override. Merged onto user context for this event. */
|
|
49
|
+
attributes?: Mapping$1.Value;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* OptimizelyClient -- the subset of the Optimizely SDK client the destination
|
|
53
|
+
* actually uses. Tests provide a mock via env.optimizely.
|
|
54
|
+
*/
|
|
55
|
+
interface OptimizelyClient {
|
|
56
|
+
onReady: () => Promise<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
}>;
|
|
59
|
+
createUserContext: (userId: string, attributes?: Record<string, unknown>) => OptimizelyUserContext | null;
|
|
60
|
+
close: () => void;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* OptimizelyUserContext -- user context methods the destination calls.
|
|
64
|
+
*/
|
|
65
|
+
interface OptimizelyUserContext {
|
|
66
|
+
trackEvent: (eventKey: string, eventTags?: Record<string, unknown>) => void;
|
|
67
|
+
setAttribute: (key: string, value: unknown) => void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* OptimizelySDK -- factory functions the destination imports from the SDK.
|
|
71
|
+
* Tests provide this via env.optimizely to avoid importing the real SDK.
|
|
72
|
+
*/
|
|
73
|
+
interface OptimizelySDK {
|
|
74
|
+
createInstance: (config: Record<string, unknown>) => OptimizelyClient;
|
|
75
|
+
createPollingProjectConfigManager: (config: Record<string, unknown>) => unknown;
|
|
76
|
+
createBatchEventProcessor: (config: Record<string, unknown>) => unknown;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Env -- optional SDK override. Production leaves env.optimizely undefined
|
|
80
|
+
* and the destination falls back to the real @optimizely/optimizely-sdk
|
|
81
|
+
* import. Tests provide a mock via env.optimizely.
|
|
82
|
+
*/
|
|
83
|
+
interface Env extends DestinationWeb.Env {
|
|
84
|
+
optimizely?: OptimizelySDK;
|
|
85
|
+
}
|
|
86
|
+
type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
|
|
87
|
+
type Destination = DestinationWeb.Destination<Types>;
|
|
88
|
+
type Config = DestinationWeb.Config<Types>;
|
|
89
|
+
type Rule = Mapping$1.Rule<Mapping>;
|
|
90
|
+
type Rules = Mapping$1.Rules<Rule>;
|
|
91
|
+
|
|
92
|
+
type index_Config = Config;
|
|
93
|
+
type index_Destination = Destination;
|
|
94
|
+
type index_Env = Env;
|
|
95
|
+
type index_InitSettings = InitSettings;
|
|
96
|
+
type index_Mapping = Mapping;
|
|
97
|
+
type index_OptimizelyClient = OptimizelyClient;
|
|
98
|
+
type index_OptimizelySDK = OptimizelySDK;
|
|
99
|
+
type index_OptimizelyUserContext = OptimizelyUserContext;
|
|
100
|
+
type index_Rule = Rule;
|
|
101
|
+
type index_Rules = Rules;
|
|
102
|
+
type index_RuntimeState = RuntimeState;
|
|
103
|
+
type index_Settings = Settings;
|
|
104
|
+
type index_Types = Types;
|
|
105
|
+
declare namespace index {
|
|
106
|
+
export type { index_Config as Config, index_Destination as Destination, index_Env as Env, index_InitSettings as InitSettings, index_Mapping as Mapping, index_OptimizelyClient as OptimizelyClient, index_OptimizelySDK as OptimizelySDK, index_OptimizelyUserContext as OptimizelyUserContext, index_Rule as Rule, index_Rules as Rules, index_RuntimeState as RuntimeState, index_Settings as Settings, index_Types as Types };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare const destinationOptimizely: Destination;
|
|
110
|
+
|
|
111
|
+
export { index as DestinationOptimizely, destinationOptimizely as default, destinationOptimizely };
|