@contentful/optimization-core 0.1.0-alpha → 0.1.0-alpha10
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 +221 -31
- package/dist/260.mjs +14 -0
- package/dist/260.mjs.map +1 -0
- package/dist/499.mjs +4 -0
- package/dist/632.mjs +5 -0
- package/dist/632.mjs.map +1 -0
- package/dist/808.mjs +2 -0
- package/dist/942.mjs +2 -0
- package/dist/api-client.cjs +60 -0
- package/dist/api-client.cjs.map +1 -0
- package/dist/api-client.d.cts +4 -0
- package/dist/api-client.d.mts +4 -0
- package/dist/api-client.d.ts +4 -0
- package/dist/api-client.mjs +2 -0
- package/dist/api-schemas.cjs +60 -0
- package/dist/api-schemas.cjs.map +1 -0
- package/dist/api-schemas.d.cts +4 -0
- package/dist/api-schemas.d.mts +4 -0
- package/dist/api-schemas.d.ts +4 -0
- package/dist/api-schemas.mjs +2 -0
- package/dist/constants.cjs +78 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/constants.d.cts +88 -0
- package/dist/constants.d.mts +88 -0
- package/dist/constants.d.ts +88 -0
- package/dist/constants.mjs +1 -0
- package/dist/index.cjs +1853 -1665
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2432 -0
- package/dist/index.d.mts +2432 -0
- package/dist/index.d.ts +2432 -15
- package/dist/index.mjs +625 -327
- package/dist/index.mjs.map +1 -1
- package/dist/logger.cjs +67 -0
- package/dist/logger.cjs.map +1 -0
- package/dist/logger.d.cts +8 -0
- package/dist/logger.d.mts +8 -0
- package/dist/logger.d.ts +8 -0
- package/dist/logger.mjs +2 -0
- package/dist/symbols.cjs +42 -0
- package/dist/symbols.cjs.map +1 -0
- package/dist/symbols.d.cts +10 -0
- package/dist/symbols.d.mts +10 -0
- package/dist/symbols.d.ts +10 -0
- package/dist/symbols.mjs +1 -0
- package/package.json +65 -12
- package/dist/Consent.d.ts +0 -44
- package/dist/Consent.d.ts.map +0 -1
- package/dist/Consent.js +0 -2
- package/dist/Consent.js.map +0 -1
- package/dist/CoreBase.d.ts +0 -161
- package/dist/CoreBase.d.ts.map +0 -1
- package/dist/CoreBase.js +0 -151
- package/dist/CoreBase.js.map +0 -1
- package/dist/CoreStateful.d.ts +0 -142
- package/dist/CoreStateful.d.ts.map +0 -1
- package/dist/CoreStateful.js +0 -137
- package/dist/CoreStateful.js.map +0 -1
- package/dist/CoreStateless.d.ts +0 -53
- package/dist/CoreStateless.d.ts.map +0 -1
- package/dist/CoreStateless.js +0 -43
- package/dist/CoreStateless.js.map +0 -1
- package/dist/ProductBase.d.ts +0 -83
- package/dist/ProductBase.d.ts.map +0 -1
- package/dist/ProductBase.js +0 -50
- package/dist/ProductBase.js.map +0 -1
- package/dist/analytics/AnalyticsBase.d.ts +0 -35
- package/dist/analytics/AnalyticsBase.d.ts.map +0 -1
- package/dist/analytics/AnalyticsBase.js +0 -13
- package/dist/analytics/AnalyticsBase.js.map +0 -1
- package/dist/analytics/AnalyticsStateful.d.ts +0 -138
- package/dist/analytics/AnalyticsStateful.d.ts.map +0 -1
- package/dist/analytics/AnalyticsStateful.js +0 -179
- package/dist/analytics/AnalyticsStateful.js.map +0 -1
- package/dist/analytics/AnalyticsStateless.d.ts +0 -48
- package/dist/analytics/AnalyticsStateless.d.ts.map +0 -1
- package/dist/analytics/AnalyticsStateless.js +0 -61
- package/dist/analytics/AnalyticsStateless.js.map +0 -1
- package/dist/analytics/index.d.ts +0 -5
- package/dist/analytics/index.d.ts.map +0 -1
- package/dist/analytics/index.js +0 -5
- package/dist/analytics/index.js.map +0 -1
- package/dist/global-constants.d.ts +0 -18
- package/dist/global-constants.d.ts.map +0 -1
- package/dist/global-constants.js +0 -18
- package/dist/global-constants.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +0 -1
- package/dist/lib/decorators/guardedBy.d.ts +0 -113
- package/dist/lib/decorators/guardedBy.d.ts.map +0 -1
- package/dist/lib/decorators/guardedBy.js +0 -143
- package/dist/lib/decorators/guardedBy.js.map +0 -1
- package/dist/lib/decorators/index.d.ts +0 -2
- package/dist/lib/decorators/index.d.ts.map +0 -1
- package/dist/lib/decorators/index.js +0 -2
- package/dist/lib/decorators/index.js.map +0 -1
- package/dist/lib/interceptor/InterceptorManager.d.ts +0 -127
- package/dist/lib/interceptor/InterceptorManager.d.ts.map +0 -1
- package/dist/lib/interceptor/InterceptorManager.js +0 -125
- package/dist/lib/interceptor/InterceptorManager.js.map +0 -1
- package/dist/lib/interceptor/index.d.ts +0 -2
- package/dist/lib/interceptor/index.d.ts.map +0 -1
- package/dist/lib/interceptor/index.js +0 -2
- package/dist/lib/interceptor/index.js.map +0 -1
- package/dist/lib/value-presence/ValuePresence.d.ts +0 -123
- package/dist/lib/value-presence/ValuePresence.d.ts.map +0 -1
- package/dist/lib/value-presence/ValuePresence.js +0 -141
- package/dist/lib/value-presence/ValuePresence.js.map +0 -1
- package/dist/lib/value-presence/index.d.ts +0 -2
- package/dist/lib/value-presence/index.d.ts.map +0 -1
- package/dist/lib/value-presence/index.js +0 -2
- package/dist/lib/value-presence/index.js.map +0 -1
- package/dist/personalization/PersonalizationBase.d.ts +0 -184
- package/dist/personalization/PersonalizationBase.d.ts.map +0 -1
- package/dist/personalization/PersonalizationBase.js +0 -76
- package/dist/personalization/PersonalizationBase.js.map +0 -1
- package/dist/personalization/PersonalizationStateful.d.ts +0 -226
- package/dist/personalization/PersonalizationStateful.d.ts.map +0 -1
- package/dist/personalization/PersonalizationStateful.js +0 -297
- package/dist/personalization/PersonalizationStateful.js.map +0 -1
- package/dist/personalization/PersonalizationStateless.d.ts +0 -74
- package/dist/personalization/PersonalizationStateless.d.ts.map +0 -1
- package/dist/personalization/PersonalizationStateless.js +0 -98
- package/dist/personalization/PersonalizationStateless.js.map +0 -1
- package/dist/personalization/index.d.ts +0 -6
- package/dist/personalization/index.d.ts.map +0 -1
- package/dist/personalization/index.js +0 -6
- package/dist/personalization/index.js.map +0 -1
- package/dist/personalization/resolvers/FlagsResolver.d.ts +0 -35
- package/dist/personalization/resolvers/FlagsResolver.d.ts.map +0 -1
- package/dist/personalization/resolvers/FlagsResolver.js +0 -47
- package/dist/personalization/resolvers/FlagsResolver.js.map +0 -1
- package/dist/personalization/resolvers/MergeTagValueResolver.d.ts +0 -74
- package/dist/personalization/resolvers/MergeTagValueResolver.d.ts.map +0 -1
- package/dist/personalization/resolvers/MergeTagValueResolver.js +0 -109
- package/dist/personalization/resolvers/MergeTagValueResolver.js.map +0 -1
- package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts +0 -142
- package/dist/personalization/resolvers/PersonalizedEntryResolver.d.ts.map +0 -1
- package/dist/personalization/resolvers/PersonalizedEntryResolver.js +0 -196
- package/dist/personalization/resolvers/PersonalizedEntryResolver.js.map +0 -1
- package/dist/personalization/resolvers/index.d.ts +0 -7
- package/dist/personalization/resolvers/index.d.ts.map +0 -1
- package/dist/personalization/resolvers/index.js +0 -7
- package/dist/personalization/resolvers/index.js.map +0 -1
- package/dist/signals.d.ts +0 -35
- package/dist/signals.d.ts.map +0 -1
- package/dist/signals.js +0 -30
- package/dist/signals.js.map +0 -1
package/dist/CoreBase.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreBase.js","sourceRoot":"","sources":["../src/CoreBase.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,GAoBb,MAAM,qCAAqC,CAAA;AAG5C,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/C,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAA;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAyCtD;;;;GAIG;AACH,MAAe,QAAQ;IAMrB,+CAA+C;IACtC,GAAG,CAAW;IACvB,qCAAqC;IAC5B,YAAY,CAAc;IACnC,6DAA6D;IACpD,MAAM,CAA0B;IAEhC,YAAY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;QAE3D,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;IACrD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CACR,OAA2D;QAE3D,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACjD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CACV,OAA6D;QAE7D,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACnD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK,CACT,OAAwD;QAExD,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;IAClD,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,kBAAkB,CACtB,OAAgE,EAChE,gBAAyB;QAEzB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;QACjF,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;IACpE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,aAAa,CAAC,OAAiC,EAAE,gBAAyB;QAC9E,MAAM,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;IAC/D,CAAC;CACF;AAED,eAAe,QAAQ,CAAA"}
|
package/dist/CoreStateful.d.ts
DELETED
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import type { InsightsEvent as AnalyticsEvent, ChangeArray, ExperienceEvent as PersonalizationEvent, Profile, SelectedPersonalizationArray } from '@contentful/optimization-api-client';
|
|
2
|
-
import { AnalyticsStateful, type AnalyticsStates } from './analytics';
|
|
3
|
-
import type { ConsentController } from './Consent';
|
|
4
|
-
import CoreBase, { type CoreConfig } from './CoreBase';
|
|
5
|
-
import { PersonalizationStateful, type PersonalizationProductConfig, type PersonalizationStates } from './personalization';
|
|
6
|
-
import type { ProductConfig } from './ProductBase';
|
|
7
|
-
import { type Observable, type Signals } from './signals';
|
|
8
|
-
/**
|
|
9
|
-
* Interface for objects that can be registered with the preview panel system.
|
|
10
|
-
* When registered, the object receives direct access to SDK signals for state manipulation.
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export interface PreviewPanelSignalObject {
|
|
15
|
-
/** Signals instance that will be populated by registerPreviewPanel */
|
|
16
|
-
signals: Signals | null;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Combined observable state exposed by the stateful core.
|
|
20
|
-
*
|
|
21
|
-
* @public
|
|
22
|
-
* @see {@link AnalyticsStates}
|
|
23
|
-
* @see {@link PersonalizationStates}
|
|
24
|
-
*/
|
|
25
|
-
export interface CoreStates extends AnalyticsStates, PersonalizationStates {
|
|
26
|
-
/** Current consent value (if any). */
|
|
27
|
-
consent: Observable<boolean | undefined>;
|
|
28
|
-
/** Stream of the most recent event emitted (analytics or personalization). */
|
|
29
|
-
eventStream: Observable<AnalyticsEvent | PersonalizationEvent | undefined>;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Default values used to preconfigure the stateful core and products.
|
|
33
|
-
*
|
|
34
|
-
* @public
|
|
35
|
-
*/
|
|
36
|
-
export interface CoreConfigDefaults {
|
|
37
|
-
/** Global consent default applied at construction time. */
|
|
38
|
-
consent?: boolean;
|
|
39
|
-
/** Default active profile used for personalization and analytics. */
|
|
40
|
-
profile?: Profile;
|
|
41
|
-
/** Initial diff of changes produced by the service. */
|
|
42
|
-
changes?: ChangeArray;
|
|
43
|
-
/** Preselected personalization variants (e.g., winning treatments). */
|
|
44
|
-
personalizations?: SelectedPersonalizationArray;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Configuration for {@link CoreStateful}.
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
|
-
* @see {@link CoreConfig}
|
|
51
|
-
*/
|
|
52
|
-
export interface CoreStatefulConfig extends CoreConfig {
|
|
53
|
-
/**
|
|
54
|
-
* Allow-listed event type strings permitted when consent is not set.
|
|
55
|
-
*
|
|
56
|
-
* @see {@link ProductConfig.allowedEventTypes}
|
|
57
|
-
*/
|
|
58
|
-
allowedEventTypes?: ProductConfig['allowedEventTypes'];
|
|
59
|
-
/** Optional set of default values applied on initialization. */
|
|
60
|
-
defaults?: CoreConfigDefaults;
|
|
61
|
-
/** Function used to obtain an anonymous user identifier. */
|
|
62
|
-
getAnonymousId?: PersonalizationProductConfig['getAnonymousId'];
|
|
63
|
-
/**
|
|
64
|
-
* Initial duplication prevention configuration for component events.
|
|
65
|
-
*
|
|
66
|
-
* @see {@link ProductConfig.preventedComponentEvents}
|
|
67
|
-
*/
|
|
68
|
-
preventedComponentEvents?: ProductConfig['preventedComponentEvents'];
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Core runtime that constructs stateful product instances and exposes shared
|
|
72
|
-
* states, including consent and the event stream.
|
|
73
|
-
*
|
|
74
|
-
* @public
|
|
75
|
-
* @remarks
|
|
76
|
-
* @see {@link CoreBase}
|
|
77
|
-
* @see {@link ConsentController}
|
|
78
|
-
*/
|
|
79
|
-
declare class CoreStateful extends CoreBase implements ConsentController {
|
|
80
|
-
/** Stateful analytics product. */
|
|
81
|
-
readonly analytics: AnalyticsStateful;
|
|
82
|
-
/** Stateful personalization product. */
|
|
83
|
-
readonly personalization: PersonalizationStateful;
|
|
84
|
-
/**
|
|
85
|
-
* Create a stateful core with optional default consent and product defaults.
|
|
86
|
-
*
|
|
87
|
-
* @param config - Core and defaults configuration.
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* const core = new CoreStateful({
|
|
91
|
-
* clientId: 'app',
|
|
92
|
-
* environment: 'prod',
|
|
93
|
-
* defaults: { consent: true }
|
|
94
|
-
* })
|
|
95
|
-
* core.consent(true)
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
constructor(config: CoreStatefulConfig);
|
|
99
|
-
/**
|
|
100
|
-
* Expose merged observable state for consumers.
|
|
101
|
-
*/
|
|
102
|
-
get states(): CoreStates;
|
|
103
|
-
/**
|
|
104
|
-
* Reset internal state. Consent is intentionally preserved.
|
|
105
|
-
*
|
|
106
|
-
* @remarks
|
|
107
|
-
* Resetting personalization also resets analytics dependencies as a
|
|
108
|
-
* consequence of the current shared-state design.
|
|
109
|
-
*/
|
|
110
|
-
reset(): void;
|
|
111
|
-
/**
|
|
112
|
-
* Flush the queues for both the analytics and personalization products.
|
|
113
|
-
* @remarks
|
|
114
|
-
* The personalization queue is only populated if events have been triggered
|
|
115
|
-
* while a device is offline.
|
|
116
|
-
*/
|
|
117
|
-
flush(): Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* Update consent state
|
|
120
|
-
*
|
|
121
|
-
* @param accept - `true` if the user has granted consent; `false` otherwise.
|
|
122
|
-
*/
|
|
123
|
-
consent(accept: boolean): void;
|
|
124
|
-
/**
|
|
125
|
-
* Update online state
|
|
126
|
-
*
|
|
127
|
-
* @param isOnline - `true` if the browser is online; `false` otherwise.
|
|
128
|
-
*/
|
|
129
|
-
protected online(isOnline: boolean): void;
|
|
130
|
-
/**
|
|
131
|
-
* Register a preview panel compatible object to receive direct signal access.
|
|
132
|
-
* This enables the preview panel to modify SDK state for testing and simulation.
|
|
133
|
-
*
|
|
134
|
-
* @param previewPanel - An object implementing PreviewPanelSignalObject
|
|
135
|
-
* @remarks
|
|
136
|
-
* This method is intended for use by the Preview Panel component.
|
|
137
|
-
* Direct signal access allows immediate state updates without API calls.
|
|
138
|
-
*/
|
|
139
|
-
registerPreviewPanel(previewPanel: PreviewPanelSignalObject): void;
|
|
140
|
-
}
|
|
141
|
-
export default CoreStateful;
|
|
142
|
-
//# sourceMappingURL=Core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CAAC,EAAE,4BAA4B,CAAA;CAChD;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAmB,SAAQ,UAAU;IACpD;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAA;IAEtD,gEAAgE;IAChE,QAAQ,CAAC,EAAE,kBAAkB,CAAA;IAE7B,4DAA4D;IAC5D,cAAc,CAAC,EAAE,4BAA4B,CAAC,gBAAgB,CAAC,CAAA;IAE/D;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAAA;CACrE;AAED;;;;;;;;GAQG;AACH,cAAM,YAAa,SAAQ,QAAS,YAAW,iBAAiB;IAC9D,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAA;IACrC,wCAAwC;IACxC,QAAQ,CAAC,eAAe,EAAE,uBAAuB,CAAA;IAEjD;;;;;;;;;;;;;OAaG;gBACS,MAAM,EAAE,kBAAkB;IA0CtC;;OAEG;IACH,IAAI,MAAM,IAAI,UAAU,CAQvB;IAED;;;;;;OAMG;IACH,KAAK,IAAI,IAAI;IASb;;;;;OAKG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAI9B;;;;OAIG;IACH,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAIzC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,YAAY,EAAE,wBAAwB,GAAG,IAAI;CAGnE;AAED,eAAe,YAAY,CAAA"}
|
package/dist/CoreStateful.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { AnalyticsStateful } from './analytics';
|
|
2
|
-
import CoreBase from './CoreBase';
|
|
3
|
-
import { PersonalizationStateful, } from './personalization';
|
|
4
|
-
import { batch, changes, consent, event, flags, online, personalizations, profile, signals, toObservable, } from './signals';
|
|
5
|
-
/**
|
|
6
|
-
* Core runtime that constructs stateful product instances and exposes shared
|
|
7
|
-
* states, including consent and the event stream.
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
* @remarks
|
|
11
|
-
* @see {@link CoreBase}
|
|
12
|
-
* @see {@link ConsentController}
|
|
13
|
-
*/
|
|
14
|
-
class CoreStateful extends CoreBase {
|
|
15
|
-
/** Stateful analytics product. */
|
|
16
|
-
analytics;
|
|
17
|
-
/** Stateful personalization product. */
|
|
18
|
-
personalization;
|
|
19
|
-
/**
|
|
20
|
-
* Create a stateful core with optional default consent and product defaults.
|
|
21
|
-
*
|
|
22
|
-
* @param config - Core and defaults configuration.
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* const core = new CoreStateful({
|
|
26
|
-
* clientId: 'app',
|
|
27
|
-
* environment: 'prod',
|
|
28
|
-
* defaults: { consent: true }
|
|
29
|
-
* })
|
|
30
|
-
* core.consent(true)
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
constructor(config) {
|
|
34
|
-
super(config);
|
|
35
|
-
const { allowedEventTypes, defaults, getAnonymousId, preventedComponentEvents } = config;
|
|
36
|
-
if (defaults?.consent !== undefined) {
|
|
37
|
-
const { consent: defaultConsent } = defaults;
|
|
38
|
-
consent.value = defaultConsent;
|
|
39
|
-
}
|
|
40
|
-
this.analytics = new AnalyticsStateful({
|
|
41
|
-
api: this.api,
|
|
42
|
-
builder: this.eventBuilder,
|
|
43
|
-
config: {
|
|
44
|
-
allowedEventTypes,
|
|
45
|
-
preventedComponentEvents,
|
|
46
|
-
defaults: {
|
|
47
|
-
consent: defaults?.consent,
|
|
48
|
-
profile: defaults?.profile,
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
interceptors: this.interceptors,
|
|
52
|
-
});
|
|
53
|
-
this.personalization = new PersonalizationStateful({
|
|
54
|
-
api: this.api,
|
|
55
|
-
builder: this.eventBuilder,
|
|
56
|
-
config: {
|
|
57
|
-
allowedEventTypes,
|
|
58
|
-
getAnonymousId,
|
|
59
|
-
preventedComponentEvents,
|
|
60
|
-
defaults: {
|
|
61
|
-
consent: defaults?.consent,
|
|
62
|
-
changes: defaults?.changes,
|
|
63
|
-
profile: defaults?.profile,
|
|
64
|
-
personalizations: defaults?.personalizations,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
interceptors: this.interceptors,
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Expose merged observable state for consumers.
|
|
72
|
-
*/
|
|
73
|
-
get states() {
|
|
74
|
-
return {
|
|
75
|
-
consent: toObservable(consent),
|
|
76
|
-
eventStream: toObservable(event),
|
|
77
|
-
flags: toObservable(flags),
|
|
78
|
-
personalizations: toObservable(personalizations),
|
|
79
|
-
profile: toObservable(profile),
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Reset internal state. Consent is intentionally preserved.
|
|
84
|
-
*
|
|
85
|
-
* @remarks
|
|
86
|
-
* Resetting personalization also resets analytics dependencies as a
|
|
87
|
-
* consequence of the current shared-state design.
|
|
88
|
-
*/
|
|
89
|
-
reset() {
|
|
90
|
-
batch(() => {
|
|
91
|
-
event.value = undefined;
|
|
92
|
-
changes.value = undefined;
|
|
93
|
-
profile.value = undefined;
|
|
94
|
-
personalizations.value = undefined;
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Flush the queues for both the analytics and personalization products.
|
|
99
|
-
* @remarks
|
|
100
|
-
* The personalization queue is only populated if events have been triggered
|
|
101
|
-
* while a device is offline.
|
|
102
|
-
*/
|
|
103
|
-
async flush() {
|
|
104
|
-
await this.analytics.flush();
|
|
105
|
-
await this.personalization.flush();
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Update consent state
|
|
109
|
-
*
|
|
110
|
-
* @param accept - `true` if the user has granted consent; `false` otherwise.
|
|
111
|
-
*/
|
|
112
|
-
consent(accept) {
|
|
113
|
-
consent.value = accept;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Update online state
|
|
117
|
-
*
|
|
118
|
-
* @param isOnline - `true` if the browser is online; `false` otherwise.
|
|
119
|
-
*/
|
|
120
|
-
online(isOnline) {
|
|
121
|
-
online.value = isOnline;
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Register a preview panel compatible object to receive direct signal access.
|
|
125
|
-
* This enables the preview panel to modify SDK state for testing and simulation.
|
|
126
|
-
*
|
|
127
|
-
* @param previewPanel - An object implementing PreviewPanelSignalObject
|
|
128
|
-
* @remarks
|
|
129
|
-
* This method is intended for use by the Preview Panel component.
|
|
130
|
-
* Direct signal access allows immediate state updates without API calls.
|
|
131
|
-
*/
|
|
132
|
-
registerPreviewPanel(previewPanel) {
|
|
133
|
-
previewPanel.signals = signals;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
export default CoreStateful;
|
|
137
|
-
//# sourceMappingURL=CoreStateful.js.map
|
package/dist/CoreStateful.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreStateful.js","sourceRoot":"","sources":["../src/CoreStateful.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,aAAa,CAAA;AAErE,OAAO,QAA6B,MAAM,YAAY,CAAA;AACtD,OAAO,EACL,uBAAuB,GAGxB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,KAAK,EACL,OAAO,EACP,OAAO,EACP,KAAK,EACL,KAAK,EACL,MAAM,EACN,gBAAgB,EAChB,OAAO,EACP,OAAO,EACP,YAAY,GAGb,MAAM,WAAW,CAAA;AAuElB;;;;;;;;GAQG;AACH,MAAM,YAAa,SAAQ,QAAQ;IACjC,kCAAkC;IACzB,SAAS,CAAmB;IACrC,wCAAwC;IAC/B,eAAe,CAAyB;IAEjD;;;;;;;;;;;;;OAaG;IACH,YAAY,MAA0B;QACpC,KAAK,CAAC,MAAM,C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AAE,YAAY,CAAC,gBAAgB,CAAC;YAChD,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC;SAC/B,CAAA;IACH,CAAC;IAED;;;;;;OAMG;IACH,KAAK;QACH,KAAK,CAAC,GAAG,EAAE;YACT,KAAK,CAAC,KAAK,GAAG,SAAS,CAAA;YACvB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAA;YACzB,OAAO,CAAC,KAAK,GAAG,SAAS,CAAA;YACzB,gBAAgB,CAAC,KAAK,GAAG,SAAS,CAAA;QACpC,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QAC5B,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAA;IACpC,CAAC;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAe;QACrB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAA;IACxB,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAiB;QAChC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAA;IACzB,CAAC;IAED;;;;;;;;OAQG;IACH,oBAAoB,CAAC,YAAsC;QACzD,YAAY,CAAC,OAAO,GAAG,OAAO,CAAA;IAChC,CAAC;CACF;AAED,eAAe,YAAY,CAAA"}
|
package/dist/CoreStateless.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { EventBuilderConfig } from '@contentful/optimization-api-client';
|
|
2
|
-
import { AnalyticsStateless } from './analytics';
|
|
3
|
-
import CoreBase, { type CoreConfig } from './CoreBase';
|
|
4
|
-
import { PersonalizationStateless } from './personalization';
|
|
5
|
-
/**
|
|
6
|
-
* Configuration for the Node-specific Optimization SDK.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
* @remarks
|
|
10
|
-
* This configuration extends {@link CoreConfig} but allows partial overrides
|
|
11
|
-
* of the event-builder configuration. SDKs commonly inject their own library
|
|
12
|
-
* metadata or channel definitions.
|
|
13
|
-
*/
|
|
14
|
-
export interface CoreStatelessConfig extends CoreConfig {
|
|
15
|
-
/**
|
|
16
|
-
* Override configuration for the analytics (Insights) API client. Omits
|
|
17
|
-
* `beaconHandler`.
|
|
18
|
-
*/
|
|
19
|
-
analytics?: Omit<CoreConfig['analytics'], 'beaconHandler'>;
|
|
20
|
-
/**
|
|
21
|
-
* Overrides for the event builder configuration. Omits methods that are only
|
|
22
|
-
* useful in stateful environments.
|
|
23
|
-
*/
|
|
24
|
-
eventBuilder?: Omit<EventBuilderConfig, 'getLocale' | 'getPageProperties' | 'getUserAgent'>;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Core runtime that constructs product instances for stateless environments.
|
|
28
|
-
*
|
|
29
|
-
* @public
|
|
30
|
-
* @see {@link CoreBase}
|
|
31
|
-
*/
|
|
32
|
-
declare class CoreStateless extends CoreBase {
|
|
33
|
-
/** Stateless analytics product. */
|
|
34
|
-
readonly analytics: AnalyticsStateless;
|
|
35
|
-
/** Stateless personalization product. */
|
|
36
|
-
readonly personalization: PersonalizationStateless;
|
|
37
|
-
/**
|
|
38
|
-
* Create a stateless core. Product instances share the same API client and
|
|
39
|
-
* event builder configured in {@link CoreBase}.
|
|
40
|
-
*
|
|
41
|
-
* @param config - Stateless Core configuration.
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* const sdk = new CoreStateless({ clientId: 'app', environment: 'prod' })
|
|
45
|
-
* core.analytics.trackFlagView({ componentId: 'hero' })
|
|
46
|
-
* // or
|
|
47
|
-
* core.trackFlagView({ componentId: 'hero' })
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
constructor(config: CoreStatelessConfig);
|
|
51
|
-
}
|
|
52
|
-
export default CoreStateless;
|
|
53
|
-
//# sourceMappingURL=CoreStateless.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreStateless.d.ts","sourceRoot":"","sources":["../src/CoreStateless.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAA;AAC7E,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,QAAQ,EAAE,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAE5D;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAoB,SAAQ,UAAU;IACrD;;;OAGG;IACH,SAAS,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,CAAA;IAE1D;;;OAGG;IACH,YAAY,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,WAAW,GAAG,mBAAmB,GAAG,cAAc,CAAC,CAAA;CAC5F;AAED;;;;;GAKG;AACH,cAAM,aAAc,SAAQ,QAAQ;IAClC,mCAAmC;IACnC,QAAQ,CAAC,SAAS,EAAE,kBAAkB,CAAA;IACtC,yCAAyC;IACzC,QAAQ,CAAC,eAAe,EAAE,wBAAwB,CAAA;IAElD;;;;;;;;;;;;OAYG;gBACS,MAAM,EAAE,mBAAmB;CAexC;AAED,eAAe,aAAa,CAAA"}
|
package/dist/CoreStateless.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AnalyticsStateless } from './analytics';
|
|
2
|
-
import CoreBase from './CoreBase';
|
|
3
|
-
import { PersonalizationStateless } from './personalization';
|
|
4
|
-
/**
|
|
5
|
-
* Core runtime that constructs product instances for stateless environments.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
* @see {@link CoreBase}
|
|
9
|
-
*/
|
|
10
|
-
class CoreStateless extends CoreBase {
|
|
11
|
-
/** Stateless analytics product. */
|
|
12
|
-
analytics;
|
|
13
|
-
/** Stateless personalization product. */
|
|
14
|
-
personalization;
|
|
15
|
-
/**
|
|
16
|
-
* Create a stateless core. Product instances share the same API client and
|
|
17
|
-
* event builder configured in {@link CoreBase}.
|
|
18
|
-
*
|
|
19
|
-
* @param config - Stateless Core configuration.
|
|
20
|
-
* @example
|
|
21
|
-
* ```ts
|
|
22
|
-
* const sdk = new CoreStateless({ clientId: 'app', environment: 'prod' })
|
|
23
|
-
* core.analytics.trackFlagView({ componentId: 'hero' })
|
|
24
|
-
* // or
|
|
25
|
-
* core.trackFlagView({ componentId: 'hero' })
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
constructor(config) {
|
|
29
|
-
super(config);
|
|
30
|
-
this.analytics = new AnalyticsStateless({
|
|
31
|
-
api: this.api,
|
|
32
|
-
builder: this.eventBuilder,
|
|
33
|
-
interceptors: this.interceptors,
|
|
34
|
-
});
|
|
35
|
-
this.personalization = new PersonalizationStateless({
|
|
36
|
-
api: this.api,
|
|
37
|
-
builder: this.eventBuilder,
|
|
38
|
-
interceptors: this.interceptors,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export default CoreStateless;
|
|
43
|
-
//# sourceMappingURL=CoreStateless.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreStateless.js","sourceRoot":"","sources":["../src/CoreStateless.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,QAA6B,MAAM,YAAY,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAyB5D;;;;;GAKG;AACH,MAAM,aAAc,SAAQ,QAAQ;IAClC,mCAAmC;IAC1B,SAAS,CAAoB;IACtC,yCAAyC;IAChC,eAAe,CAA0B;IAElD;;;;;;;;;;;;OAYG;IACH,YAAY,MAA2B;QACrC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEb,IAAI,CAAC,SAAS,GAAG,IAAI,kBAAkB,CAAC;YACtC,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,OAAO,EAAE,IAAI,CAAC,YAAY;YAC1B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAA;QAEF,IAAI,CAAC,eAAe,GAAG,IAAI,wBAAwB,CAAC;YAClD,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,OAAO,EAAE,IAAI,CAAC,YAAY;YAC1B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAA;IACJ,CAAC;CACF;AAED,eAAe,aAAa,CAAA"}
|
package/dist/ProductBase.d.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import type { InsightsEventType as AnalyticsEventType, ApiClient, EventBuilder, ExperienceEventType as PersonalizationEventType } from '@contentful/optimization-api-client';
|
|
2
|
-
import type { LifecycleInterceptors } from './CoreBase';
|
|
3
|
-
import ValuePresence from './lib/value-presence/ValuePresence';
|
|
4
|
-
/**
|
|
5
|
-
* Union of all event {@link AnalyticsEventType | type keys} that this package may emit.
|
|
6
|
-
*
|
|
7
|
-
* @public
|
|
8
|
-
*/
|
|
9
|
-
export type EventType = AnalyticsEventType | PersonalizationEventType;
|
|
10
|
-
/**
|
|
11
|
-
* Common configuration for all product implementations.
|
|
12
|
-
*
|
|
13
|
-
* @public
|
|
14
|
-
*/
|
|
15
|
-
export interface ProductConfig {
|
|
16
|
-
/**
|
|
17
|
-
* The set of event type strings that are allowed to be sent even if consent is
|
|
18
|
-
* not granted.
|
|
19
|
-
*
|
|
20
|
-
* @defaultValue `['page', 'identify']`
|
|
21
|
-
* @remarks These types are compared against the `type` property of events.
|
|
22
|
-
*/
|
|
23
|
-
allowedEventTypes?: EventType[];
|
|
24
|
-
/**
|
|
25
|
-
* A map of duplication keys to a list of component IDs that should be
|
|
26
|
-
* considered duplicates and therefore suppressed.
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* The actual duplication check is performed by {@link ValuePresence}. The
|
|
30
|
-
* keys of this record are used as duplication scopes. An empty string `''`
|
|
31
|
-
* is converted to an `indefined` scope when specific scopes are not required.
|
|
32
|
-
*/
|
|
33
|
-
preventedComponentEvents?: Record<string, string[]>;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Options for configuring the common functionality of {@link ProductBase} descendents.
|
|
37
|
-
*
|
|
38
|
-
* @public
|
|
39
|
-
*/
|
|
40
|
-
export interface ProductBaseOptions {
|
|
41
|
-
/** Optimization API client. */
|
|
42
|
-
api: ApiClient;
|
|
43
|
-
/** Event builder for constructing events. */
|
|
44
|
-
builder: EventBuilder;
|
|
45
|
-
/** Optional configuration for allow‑lists and duplication prevention. */
|
|
46
|
-
config?: ProductConfig;
|
|
47
|
-
/** Lifecycle container for event and state interceptors. */
|
|
48
|
-
interceptors: LifecycleInterceptors;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Shared base for all product implementations.
|
|
52
|
-
*
|
|
53
|
-
* @internal
|
|
54
|
-
* @remarks
|
|
55
|
-
* This abstract class is not exported as part of the public API surface.
|
|
56
|
-
* Concrete implementations (e.g., analytics) should extend this class and
|
|
57
|
-
* expose their own public methods.
|
|
58
|
-
*/
|
|
59
|
-
declare abstract class ProductBase {
|
|
60
|
-
/**
|
|
61
|
-
* Allow‑list of event {@link AnalyticsEventType | type keys} permitted when consent is not present.
|
|
62
|
-
*/
|
|
63
|
-
protected readonly allowedEventTypes?: string[];
|
|
64
|
-
/** Event builder used to construct strongly‑typed events. */
|
|
65
|
-
protected readonly builder: EventBuilder;
|
|
66
|
-
/** Optimization API client used to send events to the Experience and Insights APIs. */
|
|
67
|
-
protected readonly api: ApiClient;
|
|
68
|
-
/**
|
|
69
|
-
* Deduplication helper used to track previously seen values within optional
|
|
70
|
-
* scopes
|
|
71
|
-
*/
|
|
72
|
-
readonly duplicationDetector: ValuePresence;
|
|
73
|
-
/** Interceptors that can mutate/augment outgoing events or optimization state. */
|
|
74
|
-
readonly interceptors: LifecycleInterceptors;
|
|
75
|
-
/**
|
|
76
|
-
* Creates a new product base instance.
|
|
77
|
-
*
|
|
78
|
-
* @param options - Options for configuring the functionality common among products.
|
|
79
|
-
*/
|
|
80
|
-
constructor(options: ProductBaseOptions);
|
|
81
|
-
}
|
|
82
|
-
export default ProductBase;
|
|
83
|
-
//# sourceMappingURL=ProductBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProductBase.d.ts","sourceRoot":"","sources":["../src/ProductBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,IAAI,kBAAkB,EACvC,SAAS,EACT,YAAY,EACZ,mBAAmB,IAAI,wBAAwB,EAChD,MAAM,qCAAqC,CAAA;AAC5C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AACvD,OAAO,aAAa,MAAM,oCAAoC,CAAA;AAE9D;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,wBAAwB,CAAA;AAWrE;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAA;IAE/B;;;;;;;;OAQG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;CACpD;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,+BAA+B;IAC/B,GAAG,EAAE,SAAS,CAAA;IACd,6CAA6C;IAC7C,OAAO,EAAE,YAAY,CAAA;IACrB,yEAAyE;IACzE,MAAM,CAAC,EAAE,aAAa,CAAA;IACtB,4DAA4D;IAC5D,YAAY,EAAE,qBAAqB,CAAA;CACpC;AAED;;;;;;;;GAQG;AACH,uBAAe,WAAW;IACxB;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAE/C,6DAA6D;IAC7D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAA;IAExC,uFAAuF;IACvF,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAA;IAEjC;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAA;IAE3C,kFAAkF;IAClF,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAA;IAE5C;;;;OAIG;gBACS,OAAO,EAAE,kBAAkB;CAQxC;AAED,eAAe,WAAW,CAAA"}
|
package/dist/ProductBase.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import ValuePresence from './lib/value-presence/ValuePresence';
|
|
2
|
-
/**
|
|
3
|
-
* Default allow‑list of event types that can be emitted without explicit consent.
|
|
4
|
-
*
|
|
5
|
-
* @internal
|
|
6
|
-
* @privateRemarks These defaults are only applied when a consumer does not provide
|
|
7
|
-
* {@link ProductConfig.allowedEventTypes}.
|
|
8
|
-
*/
|
|
9
|
-
const defaultAllowedEvents = ['page', 'identify'];
|
|
10
|
-
/**
|
|
11
|
-
* Shared base for all product implementations.
|
|
12
|
-
*
|
|
13
|
-
* @internal
|
|
14
|
-
* @remarks
|
|
15
|
-
* This abstract class is not exported as part of the public API surface.
|
|
16
|
-
* Concrete implementations (e.g., analytics) should extend this class and
|
|
17
|
-
* expose their own public methods.
|
|
18
|
-
*/
|
|
19
|
-
class ProductBase {
|
|
20
|
-
/**
|
|
21
|
-
* Allow‑list of event {@link AnalyticsEventType | type keys} permitted when consent is not present.
|
|
22
|
-
*/
|
|
23
|
-
allowedEventTypes;
|
|
24
|
-
/** Event builder used to construct strongly‑typed events. */
|
|
25
|
-
builder;
|
|
26
|
-
/** Optimization API client used to send events to the Experience and Insights APIs. */
|
|
27
|
-
api;
|
|
28
|
-
/**
|
|
29
|
-
* Deduplication helper used to track previously seen values within optional
|
|
30
|
-
* scopes
|
|
31
|
-
*/
|
|
32
|
-
duplicationDetector;
|
|
33
|
-
/** Interceptors that can mutate/augment outgoing events or optimization state. */
|
|
34
|
-
interceptors;
|
|
35
|
-
/**
|
|
36
|
-
* Creates a new product base instance.
|
|
37
|
-
*
|
|
38
|
-
* @param options - Options for configuring the functionality common among products.
|
|
39
|
-
*/
|
|
40
|
-
constructor(options) {
|
|
41
|
-
const { api, builder, config, interceptors } = options;
|
|
42
|
-
this.allowedEventTypes = config?.allowedEventTypes ?? defaultAllowedEvents;
|
|
43
|
-
this.api = api;
|
|
44
|
-
this.builder = builder;
|
|
45
|
-
this.duplicationDetector = new ValuePresence(config?.preventedComponentEvents);
|
|
46
|
-
this.interceptors = interceptors;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export default ProductBase;
|
|
50
|
-
//# sourceMappingURL=ProductBase.js.map
|
package/dist/ProductBase.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProductBase.js","sourceRoot":"","sources":["../src/ProductBase.ts"],"names":[],"mappings":"AAOA,OAAO,aAAa,MAAM,oCAAoC,CAAA;AAS9D;;;;;;GAMG;AACH,MAAM,oBAAoB,GAAgB,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;AA6C9D;;;;;;;;GAQG;AACH,MAAe,WAAW;IACxB;;OAEG;IACgB,iBAAiB,CAAW;IAE/C,6DAA6D;IAC1C,OAAO,CAAc;IAExC,uFAAuF;IACpE,GAAG,CAAW;IAEjC;;;OAGG;IACM,mBAAmB,CAAe;IAE3C,kFAAkF;IACzE,YAAY,CAAuB;IAE5C;;;;OAIG;IACH,YAAY,OAA2B;QACrC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAA;QACtD,IAAI,CAAC,iBAAiB,GAAG,MAAM,EAAE,iBAAiB,IAAI,oBAAoB,CAAA;QAC1E,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,mBAAmB,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAA;QAC9E,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IAClC,CAAC;CACF;AAED,eAAe,WAAW,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ComponentViewBuilderArgs } from '@contentful/optimization-api-client';
|
|
2
|
-
import ProductBase from '../ProductBase';
|
|
3
|
-
/**
|
|
4
|
-
* Base class for analytics implementations (internal).
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
* @remarks
|
|
8
|
-
* Concrete analytics classes should implement the component/flag view tracking
|
|
9
|
-
* methods below. This base is not part of the public API.
|
|
10
|
-
*/
|
|
11
|
-
declare abstract class AnalyticsBase extends ProductBase {
|
|
12
|
-
/**
|
|
13
|
-
* Track a UI component view event.
|
|
14
|
-
*
|
|
15
|
-
* @param payload - Component view builder arguments.
|
|
16
|
-
* @param duplicationScope - Optional string used to scope duplication used in Stateful
|
|
17
|
-
* implementations.
|
|
18
|
-
* @privateRemarks
|
|
19
|
-
* Duplication prevention should be handled in Stateful implementations
|
|
20
|
-
*/
|
|
21
|
-
abstract trackComponentView(payload: ComponentViewBuilderArgs, duplicationScope?: string): Promise<void> | void;
|
|
22
|
-
/**
|
|
23
|
-
* Track a flag (feature) view event.
|
|
24
|
-
*
|
|
25
|
-
* @param payload - Flag view builder arguments.
|
|
26
|
-
* @param duplicationScope - Optional string used to scope duplication used in Stateful
|
|
27
|
-
* implementations.
|
|
28
|
-
* @returns A promise that resolves when processing is complete (or `void`).
|
|
29
|
-
* @privateRemarks
|
|
30
|
-
* Duplication prevention should be handled in Stateful implementations
|
|
31
|
-
*/
|
|
32
|
-
abstract trackFlagView(payload: ComponentViewBuilderArgs, duplicationScope?: string): Promise<void> | void;
|
|
33
|
-
}
|
|
34
|
-
export default AnalyticsBase;
|
|
35
|
-
//# sourceMappingURL=AnalyticsBase.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsBase.d.ts","sourceRoot":"","sources":["../../src/analytics/AnalyticsBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AACnF,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC;;;;;;;GAOG;AACH,uBAAe,aAAc,SAAQ,WAAW;IAC9C;;;;;;;;OAQG;IACH,QAAQ,CAAC,kBAAkB,CACzB,OAAO,EAAE,wBAAwB,EACjC,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAEvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,aAAa,CACpB,OAAO,EAAE,wBAAwB,EACjC,gBAAgB,CAAC,EAAE,MAAM,GACxB,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;CACxB;AAED,eAAe,aAAa,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import ProductBase from '../ProductBase';
|
|
2
|
-
/**
|
|
3
|
-
* Base class for analytics implementations (internal).
|
|
4
|
-
*
|
|
5
|
-
* @internal
|
|
6
|
-
* @remarks
|
|
7
|
-
* Concrete analytics classes should implement the component/flag view tracking
|
|
8
|
-
* methods below. This base is not part of the public API.
|
|
9
|
-
*/
|
|
10
|
-
class AnalyticsBase extends ProductBase {
|
|
11
|
-
}
|
|
12
|
-
export default AnalyticsBase;
|
|
13
|
-
//# sourceMappingURL=AnalyticsBase.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsBase.js","sourceRoot":"","sources":["../../src/analytics/AnalyticsBase.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC;;;;;;;GAOG;AACH,MAAe,aAAc,SAAQ,WAAW;CA6B/C;AAED,eAAe,aAAa,CAAA"}
|