@remkoj/optimizely-one-nextjs 6.0.0-pre8 → 6.0.0-rc.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.
Files changed (96) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +168 -164
  3. package/dist/api/index.js +5 -3
  4. package/dist/api/index.js.map +1 -1
  5. package/dist/client-types.d.ts +74 -3
  6. package/dist/client-types.js +5 -1
  7. package/dist/client-types.js.map +1 -1
  8. package/dist/components/context.d.ts +218 -64
  9. package/dist/components/context.js +159 -67
  10. package/dist/components/context.js.map +1 -1
  11. package/dist/components/index.d.ts +1 -0
  12. package/dist/components/optimizely-one-gadget/_notice.js +1 -0
  13. package/dist/components/optimizely-one-gadget/_notice.js.map +1 -1
  14. package/dist/components/optimizely-one-gadget/audiences-panel.js +1 -0
  15. package/dist/components/optimizely-one-gadget/audiences-panel.js.map +1 -1
  16. package/dist/components/optimizely-one-gadget/exp-panel.js +1 -0
  17. package/dist/components/optimizely-one-gadget/exp-panel.js.map +1 -1
  18. package/dist/components/optimizely-one-gadget/gadget.js +24 -16
  19. package/dist/components/optimizely-one-gadget/gadget.js.map +1 -1
  20. package/dist/components/optimizely-one-gadget/goals-panel.js +1 -0
  21. package/dist/components/optimizely-one-gadget/goals-panel.js.map +1 -1
  22. package/dist/components/optimizely-one-gadget/graph-panel.js +1 -0
  23. package/dist/components/optimizely-one-gadget/graph-panel.js.map +1 -1
  24. package/dist/components/optimizely-one-gadget/interests-panel.js +1 -0
  25. package/dist/components/optimizely-one-gadget/interests-panel.js.map +1 -1
  26. package/dist/components/optimizely-one-gadget/logo.js +1 -0
  27. package/dist/components/optimizely-one-gadget/logo.js.map +1 -1
  28. package/dist/components/optimizely-one-gadget/profile-panel.js +1 -0
  29. package/dist/components/optimizely-one-gadget/profile-panel.js.map +1 -1
  30. package/dist/components/page-activator.js +12 -31
  31. package/dist/components/page-activator.js.map +1 -1
  32. package/dist/components/service-filters.d.ts +46 -0
  33. package/dist/components/service-filters.js +56 -0
  34. package/dist/components/service-filters.js.map +1 -0
  35. package/dist/components/types.d.ts +2 -0
  36. package/dist/components/types.js +2 -0
  37. package/dist/components/types.js.map +1 -0
  38. package/dist/components/use-local-state.d.ts +24 -0
  39. package/dist/components/use-local-state.js +55 -0
  40. package/dist/components/use-local-state.js.map +1 -0
  41. package/dist/config.d.ts +119 -0
  42. package/dist/config.js +101 -2
  43. package/dist/config.js.map +1 -1
  44. package/dist/env-vars.d.ts +3 -0
  45. package/dist/env-vars.js +3 -0
  46. package/dist/env-vars.js.map +1 -1
  47. package/dist/products/content-recs/client.d.ts +10 -3
  48. package/dist/products/content-recs/client.js +38 -2
  49. package/dist/products/content-recs/client.js.map +1 -1
  50. package/dist/products/content-recs/snippet.js +16 -16
  51. package/dist/{api/content-goals.d.ts → products/content-recs/webservice-goals.d.ts} +1 -1
  52. package/dist/{api/content-goals.js → products/content-recs/webservice-goals.js} +4 -4
  53. package/dist/products/content-recs/webservice-goals.js.map +1 -0
  54. package/dist/{api/content-recs.d.ts → products/content-recs/webservice.d.ts} +1 -1
  55. package/dist/{api/content-recs.js → products/content-recs/webservice.js} +13 -12
  56. package/dist/products/content-recs/webservice.js.map +1 -0
  57. package/dist/products/data-platform/client.d.ts +11 -2
  58. package/dist/products/data-platform/client.js +52 -9
  59. package/dist/products/data-platform/client.js.map +1 -1
  60. package/dist/products/data-platform/snippet.js +3 -3
  61. package/dist/products/data-platform/snippet.js.map +1 -1
  62. package/dist/products/feature-experimentation/provider.d.ts +7 -0
  63. package/dist/products/feature-experimentation/provider.js +32 -0
  64. package/dist/products/feature-experimentation/provider.js.map +1 -0
  65. package/dist/products/web-experimentation/client.d.ts +5 -2
  66. package/dist/products/web-experimentation/client.js +21 -7
  67. package/dist/products/web-experimentation/client.js.map +1 -1
  68. package/dist/products/web-experimentation/snippet.js +17 -17
  69. package/dist/products/web-experimentation/snippet.js.map +1 -1
  70. package/dist/{api/experimentation-api.d.ts → products/web-experimentation/webservice.d.ts} +1 -1
  71. package/dist/{api/experimentation-api.js → products/web-experimentation/webservice.js} +2 -2
  72. package/dist/products/web-experimentation/webservice.js.map +1 -0
  73. package/dist/server-components/index.d.ts +3 -0
  74. package/dist/server-components/index.js +3 -0
  75. package/dist/server-components/index.js.map +1 -1
  76. package/dist/{components/optimizely-one-gadget/index.d.ts → server-components/optimizely-one-gadget.d.ts} +1 -1
  77. package/dist/{components/optimizely-one-gadget/index.js → server-components/optimizely-one-gadget.js} +4 -5
  78. package/dist/server-components/optimizely-one-gadget.js.map +1 -0
  79. package/dist/server-components/optimizely-one.d.ts +219 -0
  80. package/dist/server-components/optimizely-one.js +112 -0
  81. package/dist/server-components/optimizely-one.js.map +1 -0
  82. package/dist/server.d.ts +1 -2
  83. package/dist/server.js +1 -6
  84. package/dist/server.js.map +1 -1
  85. package/dist/styles.css +2 -2
  86. package/dist/utils/products.d.ts +92 -0
  87. package/dist/utils/products.js +84 -0
  88. package/dist/utils/products.js.map +1 -0
  89. package/package.json +25 -30
  90. package/dist/api/content-goals.js.map +0 -1
  91. package/dist/api/content-recs.js.map +0 -1
  92. package/dist/api/experimentation-api.js.map +0 -1
  93. package/dist/components/optimizely-one-gadget/index.js.map +0 -1
  94. package/dist/components/rsc.d.ts +0 -2
  95. package/dist/components/rsc.js +0 -3
  96. package/dist/components/rsc.js.map +0 -1
@@ -1,102 +1,256 @@
1
- import { type FunctionComponent, type PropsWithChildren } from 'react';
2
- import WebExperimenationService from '../products/web-experimentation/client';
3
- import DataPlatformService from '../products/data-platform/client';
4
- import ContentRecsService from '../products/content-recs/client';
5
- import * as ClientApi from '../client-types';
1
+ import { type PropsWithChildren, type Dispatch, type SetStateAction } from "react";
2
+ import type * as ClientApi from '../client-types';
3
+ import type { SupportedProductNames } from './types';
6
4
  /**
7
- * The data stored within the OptimizelyOne context
5
+ * Context contract for Optimizely One integrations.
6
+ *
7
+ * Provides runtime flags, active service management, event dispatching,
8
+ * and capability-specific service selectors used by consumers.
8
9
  */
9
- type OptimizelyOneContextType = {
10
+ export type OptimizelyOneContextType = Readonly<{
10
11
  /**
11
12
  * With tracking completely disabled, all events will be stopped by
12
13
  * the OptimizelyOne hook. The "PageActivator" component will propagate
13
14
  * this instruction to all configured Optimizely One services
14
15
  */
15
- disableTracking?: boolean;
16
+ disableTracking: Readonly<boolean>;
16
17
  /**
17
18
  * With auto-tracking disabled, the "PageActivator" component will not
18
19
  * automatically track a generic pageview for all configured Optimizely
19
20
  * One services.
20
21
  */
21
- disableAutotracking?: boolean;
22
+ disableAutotracking: Readonly<boolean>;
22
23
  /**
23
- * The list of services Optimizely One Services registered with the
24
- * context. When creating the context, you may only add to the existing
25
- * service.
24
+ * The list of the active Optimizely One Services registered with the
25
+ * context. Inactive services are filtered out and will not be part of
26
+ * this collection.
26
27
  */
27
- services?: Readonly<ClientApi.OptimizelyOneService[]>;
28
+ services: ReadonlyArray<ClientApi.OptimizelyOneService>;
28
29
  /**
29
- * Whether or not debug output ging must be enabled
30
+ * Whether debug output is enabled for registered services.
31
+ */
32
+ debug: Readonly<boolean>;
33
+ /**
34
+ * Updates debug mode for the context.
35
+ */
36
+ setDebug: Dispatch<SetStateAction<boolean>>;
37
+ /**
38
+ * Adds a service to the context.
39
+ *
40
+ * This allows dynamic service registration after initialization, but requires
41
+ * the full service definition, including `isActive`.
42
+ *
43
+ * @param service The service instance to add.
30
44
  */
31
- debug?: boolean;
32
- setDebug: (newDebug: boolean) => void;
33
45
  addService: (service: ClientApi.OptimizelyOneService) => void;
46
+ /**
47
+ * Removes a service from the context.
48
+ *
49
+ * The exact same service instance must be passed as was used during add.
50
+ * Built-in default services cannot be removed with this method.
51
+ *
52
+ * @param service The service instance to remove.
53
+ */
34
54
  removeService: (service: ClientApi.OptimizelyOneService) => void;
35
- };
36
- type OptimizelyOneProviderProps = PropsWithChildren<{
37
- value?: Omit<OptimizelyOneContextType, 'setDebug' | 'addService' | 'removeService'>;
55
+ /**
56
+ * Tracks an event through the generic event API.
57
+ *
58
+ * All configured services that support event tracking receive this event.
59
+ *
60
+ * @param event The event payload to send.
61
+ */
62
+ track: (event: ClientApi.OptimizelyOneEvent) => void;
63
+ /**
64
+ * Discovers profile data from active discovery-capable services.
65
+ *
66
+ * @param signal Optional abort signal used to cancel discovery requests.
67
+ * @returns A promise that resolves when profile discovery and merge are complete.
68
+ */
69
+ discoverProfileData: (signal?: AbortSignal | null) => Promise<void>;
70
+ /**
71
+ * Merges the provided profile data into the current profile state.
72
+ *
73
+ * @param profileData Profile data patch to merge.
74
+ */
75
+ updateProfile: (profileData: Partial<ClientApi.OptimizelyOneProfileData>) => void;
76
+ /**
77
+ * Retrieves active services that support the page activation step.
78
+ *
79
+ * @returns A list of active services with `activatePage` capability.
80
+ */
81
+ getActivatePageServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, 'activatePage'>[];
82
+ /**
83
+ * Retrieves active services that support page-view tracking.
84
+ *
85
+ * @returns A list of active services with `trackPage` capability.
86
+ */
87
+ getTrackPageServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, 'trackPage'>[];
88
+ /**
89
+ * Retrieves active services that support profile updates.
90
+ *
91
+ * @returns A list of active services with `updateProfile` capability.
92
+ */
93
+ getProfileServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, 'updateProfile'>[];
94
+ /**
95
+ * Retrieves active services that can discover profile data.
96
+ *
97
+ * @returns A list of active services with `discoverProfileData` capability.
98
+ */
99
+ getProfileDataSources: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, 'discoverProfileData'>[];
100
+ /**
101
+ * Retrieves an individual active service by its code.
102
+ *
103
+ * @param code The service code.
104
+ * @returns The matching service, or `undefined` when not found.
105
+ */
106
+ getService: <SC extends string>(code: SC) => ClientApi.OptimizelyOneService<any, SC> | undefined;
107
+ }>;
108
+ /**
109
+ * Props accepted by `OptimizelyOneProvider`.
110
+ *
111
+ * `value` supplies initial context flags and optional additional services.
112
+ * `enabledOptimizelyServices` controls which built-in product services are enabled.
113
+ */
114
+ export type ProviderProps = PropsWithChildren<{
115
+ /**
116
+ * Initial context values and optional custom services.
117
+ */
118
+ value?: {
119
+ /**
120
+ * Disables all event tracking when `true`.
121
+ */
122
+ disableTracking?: boolean | undefined;
123
+ /**
124
+ * Disables automatic page-view tracking when `true`.
125
+ */
126
+ disableAutotracking?: boolean | undefined;
127
+ /**
128
+ * Additional services to register alongside built-in services.
129
+ */
130
+ services?: readonly ClientApi.OptimizelyOneService[] | undefined;
131
+ /**
132
+ * Enables debug logging for service operations when `true`.
133
+ */
134
+ debug?: boolean;
135
+ };
136
+ /**
137
+ * Optional allow-list for built-in product services.
138
+ */
139
+ enabledOptimizelyServices?: Array<SupportedProductNames>;
38
140
  }>;
39
- type OptimizelyOneServiceMap = Record<string, ClientApi.OptimizelyOneService>;
40
- interface DefaultServiceMap extends OptimizelyOneServiceMap {
41
- webex: InstanceType<typeof WebExperimenationService>;
42
- odp: InstanceType<typeof DataPlatformService>;
43
- crecs: InstanceType<typeof ContentRecsService>;
141
+ /**
142
+ * Provides Optimizely One context values to descendant components.
143
+ *
144
+ * It composes built-in product services with optional additional services,
145
+ * filters active capabilities, and exposes tracking and service access APIs.
146
+ *
147
+ * @param props Provider configuration and children.
148
+ * @returns The Optimizely One context provider element.
149
+ */
150
+ export declare function OptimizelyOneProvider({ value: { disableTracking, disableAutotracking, services, debug }, children, enabledOptimizelyServices }: ProviderProps): import("react/jsx-runtime").JSX.Element;
151
+ export declare namespace OptimizelyOneProvider {
152
+ var displayName: string;
44
153
  }
45
154
  /**
46
- * The results of the invokation of the useOptimizelyOne
47
- * hook
155
+ * Retrieves the current Optimizely One context value.
156
+ *
157
+ * @returns The active `OptimizelyOneContextType` instance.
48
158
  */
49
- type OptimizelyOneHookResult<TM extends DefaultServiceMap = DefaultServiceMap> = OptimizelyOneContextType & {
159
+ export declare function useOptimizelyOne(): Readonly<{
160
+ /**
161
+ * With tracking completely disabled, all events will be stopped by
162
+ * the OptimizelyOne hook. The "PageActivator" component will propagate
163
+ * this instruction to all configured Optimizely One services
164
+ */
165
+ disableTracking: Readonly<boolean>;
166
+ /**
167
+ * With auto-tracking disabled, the "PageActivator" component will not
168
+ * automatically track a generic pageview for all configured Optimizely
169
+ * One services.
170
+ */
171
+ disableAutotracking: Readonly<boolean>;
172
+ /**
173
+ * The list of the active Optimizely One Services registered with the
174
+ * context. Inactive services are filtered out and will not be part of
175
+ * this collection.
176
+ */
177
+ services: ReadonlyArray<ClientApi.OptimizelyOneService>;
178
+ /**
179
+ * Whether debug output is enabled for registered services.
180
+ */
181
+ debug: Readonly<boolean>;
182
+ /**
183
+ * Updates debug mode for the context.
184
+ */
185
+ setDebug: Dispatch<SetStateAction<boolean>>;
50
186
  /**
51
- * Track an event using the generic events api, which allows all configured
52
- * Optimizely One services to receive this event
187
+ * Adds a service to the context.
53
188
  *
54
- * @param event The event data to send
55
- * @returns
189
+ * This allows dynamic service registration after initialization, but requires
190
+ * the full service definition, including `isActive`.
191
+ *
192
+ * @param service The service instance to add.
193
+ */
194
+ addService: (service: ClientApi.OptimizelyOneService) => void;
195
+ /**
196
+ * Removes a service from the context.
197
+ *
198
+ * The exact same service instance must be passed as was used during add.
199
+ * Built-in default services cannot be removed with this method.
200
+ *
201
+ * @param service The service instance to remove.
202
+ */
203
+ removeService: (service: ClientApi.OptimizelyOneService) => void;
204
+ /**
205
+ * Tracks an event through the generic event API.
206
+ *
207
+ * All configured services that support event tracking receive this event.
208
+ *
209
+ * @param event The event payload to send.
56
210
  */
57
211
  track: (event: ClientApi.OptimizelyOneEvent) => void;
58
212
  /**
59
- * Retrieve all services that must be invoked on the "activate page" step of
60
- * the execution cycle
213
+ * Discovers profile data from active discovery-capable services.
214
+ *
215
+ * @param signal Optional abort signal used to cancel discovery requests.
216
+ * @returns A promise that resolves when profile discovery and merge are complete.
217
+ */
218
+ discoverProfileData: (signal?: AbortSignal | null) => Promise<void>;
219
+ /**
220
+ * Merges the provided profile data into the current profile state.
221
+ *
222
+ * @param profileData Profile data patch to merge.
223
+ */
224
+ updateProfile: (profileData: Partial<ClientApi.OptimizelyOneProfileData>) => void;
225
+ /**
226
+ * Retrieves active services that support the page activation step.
61
227
  *
62
- * @returns A list of active services
228
+ * @returns A list of active services with `activatePage` capability.
63
229
  */
64
- getActivatePageServices: () => (Omit<ClientApi.OptimizelyOneService, 'activatePage' | 'isActive'> & {
65
- activatePage: NonNullable<ClientApi.OptimizelyOneService['activatePage']>;
66
- isActive: true;
67
- })[];
230
+ getActivatePageServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, "activatePage">[];
68
231
  /**
69
- * Retrieve all services that must be invoked on the "track page view" step of
70
- * the execution cycle
232
+ * Retrieves active services that support page-view tracking.
71
233
  *
72
- * @returns A list of active services
234
+ * @returns A list of active services with `trackPage` capability.
73
235
  */
74
- getTrackPageServices: () => (Omit<ClientApi.OptimizelyOneService, 'trackPage' | 'isActive'> & {
75
- trackPage: NonNullable<ClientApi.OptimizelyOneService['trackPage']>;
76
- isActive: true;
77
- })[];
236
+ getTrackPageServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, "trackPage">[];
78
237
  /**
79
- * Retrieve all services that must be invoked when new profile information has
80
- * been discovered
238
+ * Retrieves active services that support profile updates.
81
239
  *
82
- * @returns A list of active services
240
+ * @returns A list of active services with `updateProfile` capability.
83
241
  */
84
- getProfileServices: () => (Omit<ClientApi.OptimizelyOneService, 'updateProfile' | 'isActive'> & {
85
- updateProfile: NonNullable<ClientApi.OptimizelyOneService['updateProfile']>;
86
- isActive: true;
87
- })[];
88
- getProfileDataSources: () => (Omit<ClientApi.OptimizelyOneService, 'discoverProfileData' | 'isActive'> & {
89
- discoverProfileData: NonNullable<ClientApi.OptimizelyOneService['discoverProfileData']>;
90
- isActive: true;
91
- })[];
242
+ getProfileServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, "updateProfile">[];
92
243
  /**
93
- * Retrieve an individual service by its code from the collection of services
244
+ * Retrieves active services that can discover profile data.
94
245
  *
95
- * @param code The service code
96
- * @returns The service, or undefined if it's not part of the collection
246
+ * @returns A list of active services with `discoverProfileData` capability.
97
247
  */
98
- getService: <SC extends keyof TM>(code: SC) => TM[SC] | undefined;
99
- };
100
- declare function useOptimizelyOne(): OptimizelyOneHookResult;
101
- declare const OptimizelyOneProvider: FunctionComponent<OptimizelyOneProviderProps>;
102
- export { OptimizelyOneProvider, useOptimizelyOne };
248
+ getProfileDataSources: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, "discoverProfileData">[];
249
+ /**
250
+ * Retrieves an individual active service by its code.
251
+ *
252
+ * @param code The service code.
253
+ * @returns The matching service, or `undefined` when not found.
254
+ */
255
+ getService: <SC extends string>(code: SC) => ClientApi.OptimizelyOneService<any, SC> | undefined;
256
+ }>;
@@ -1,79 +1,171 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { createContext, useContext, useState, useMemo } from 'react';
3
+ import { createContext, useContext, useCallback, useMemo, useState, useEffect } from "react";
4
+ import { deepmerge as createDeepmerge } from "@fastify/deepmerge";
5
+ import { diff } from "deep-object-diff";
6
+ import { DefaultProfileData } from "../client-types";
7
+ import * as Filters from './service-filters';
8
+ // Default services to be always included in the context, but can be toggled on/off based on the enabledOptimizelyServices
4
9
  import WebExperimenationService from '../products/web-experimentation/client';
5
10
  import DataPlatformService from '../products/data-platform/client';
6
11
  import ContentRecsService from '../products/content-recs/client';
7
- function isActiveWithActivatePage(toTest) {
8
- return (toTest.isActive && toTest.activatePage && typeof (toTest.activatePage) == 'function') ?? false;
9
- }
10
- function isActiveWithTrackPage(toTest) {
11
- return (toTest.isActive && toTest.trackPage && typeof (toTest.trackPage) == 'function') ?? false;
12
- }
13
- function isActiveWithUpdateProfile(toTest) {
14
- return (toTest.isActive && toTest.updateProfile && typeof (toTest.updateProfile) == 'function') ?? false;
15
- }
16
- function isActiveWithProfileDiscovery(toTest) {
17
- return (toTest.isActive && toTest.discoverProfileData && typeof (toTest.discoverProfileData) == 'function') ?? false;
18
- }
19
- function isActiveWithEventTracker(toTest) {
20
- return (toTest.isActive && toTest.trackEvent && typeof (toTest.trackEvent) == 'function') ?? false;
21
- }
22
- const OptimizelyOneContext = createContext({ services: [], setDebug: () => { }, addService: () => { }, removeService: () => { } });
12
+ import { useLocalState } from "./use-local-state";
13
+ // Create a deepmerge instance for merging profile data from multiple sources
14
+ const deepmerge = createDeepmerge({
15
+ onlyDefinedProperties: true
16
+ });
17
+ const throwNoContextDefined = () => {
18
+ throw new Error("No context defined");
19
+ };
20
+ const DefaultOptimizelyOneContextValues = {
21
+ disableTracking: false,
22
+ disableAutotracking: false,
23
+ services: [],
24
+ debug: false,
25
+ setDebug: throwNoContextDefined,
26
+ addService: throwNoContextDefined,
27
+ removeService: throwNoContextDefined,
28
+ track: throwNoContextDefined,
29
+ getActivatePageServices: throwNoContextDefined,
30
+ getTrackPageServices: throwNoContextDefined,
31
+ getProfileServices: throwNoContextDefined,
32
+ getProfileDataSources: throwNoContextDefined,
33
+ getService: throwNoContextDefined,
34
+ discoverProfileData: throwNoContextDefined,
35
+ updateProfile: throwNoContextDefined
36
+ };
37
+ const OptimizelyOneContext = createContext(DefaultOptimizelyOneContextValues);
23
38
  OptimizelyOneContext.displayName = "Optimizely One: Context";
24
- function useOptimizelyOne() {
25
- const ctx = useContext(OptimizelyOneContext);
26
- const result = useMemo(() => {
27
- return {
28
- ...ctx,
29
- getActivatePageServices: () => (ctx.services || []).filter(isActiveWithActivatePage),
30
- getTrackPageServices: () => (ctx.services || []).filter(isActiveWithTrackPage),
31
- getProfileServices: () => (ctx.services || []).filter(isActiveWithUpdateProfile),
32
- getProfileDataSources: () => (ctx.services || []).filter(isActiveWithProfileDiscovery),
33
- getService: (code) => (ctx.services || []).filter(s => s.code == code)[0],
34
- track: (event) => {
35
- if (ctx.disableTracking) {
36
- if (ctx.debug)
37
- console.log('🔐 [Optimizely One] Tracking disabled, ignored event');
38
- return;
39
- }
40
- if (ctx.debug) {
41
- console.groupCollapsed(`📢 [Optimizely One] Tracking ${event.event} event`);
42
- console.log('Event:', event);
43
- }
44
- (ctx.services || []).filter(isActiveWithEventTracker).forEach(service => service.trackEvent(event));
45
- if (ctx.debug) {
46
- console.groupEnd();
39
+ /**
40
+ * Provides Optimizely One context values to descendant components.
41
+ *
42
+ * It composes built-in product services with optional additional services,
43
+ * filters active capabilities, and exposes tracking and service access APIs.
44
+ *
45
+ * @param props Provider configuration and children.
46
+ * @returns The Optimizely One context provider element.
47
+ */
48
+ export function OptimizelyOneProvider({ value: { disableTracking = false, disableAutotracking = false, services = [], debug = false } = {}, children, enabledOptimizelyServices }) {
49
+ // Local state to hold the current profile data, allowing it to be updated and
50
+ // accessed across the context
51
+ const [currentProfileData, setCurrentProfileData] = useLocalState('profileData', DefaultProfileData);
52
+ // Track the debug state in the context, to allow dynamic enabling/disabling
53
+ // of debug mode after initialization.
54
+ const [ctxDebug, setCtxDebug] = useState(debug);
55
+ // Track the additional services through state, to allow dynamic
56
+ // adding/removing of services after initialization.
57
+ const [additionalServices, setAdditionalServices] = useState(services);
58
+ // Memoize the active services to avoid unnecessary re-renders and
59
+ // computations in the context consumers.
60
+ const activeServices = useMemo(() => {
61
+ const defaultServices = [
62
+ new WebExperimenationService(enabledOptimizelyServices),
63
+ new DataPlatformService(enabledOptimizelyServices),
64
+ new ContentRecsService(enabledOptimizelyServices)
65
+ ];
66
+ const allServices = [...defaultServices, ...additionalServices];
67
+ allServices.forEach(s => s.debug = ctxDebug);
68
+ return allServices.filter(s => s.isActive).sort((a, b) => a.order - b.order);
69
+ }, [additionalServices, enabledOptimizelyServices, ctxDebug]);
70
+ // Use memoized event tracking function to ensure stable reference for
71
+ // context consumers
72
+ const track = useCallback((event) => {
73
+ if (!disableTracking) {
74
+ if (ctxDebug) {
75
+ console.groupCollapsed(`📢 [Optimizely One] Tracking event: ${event.event}`);
76
+ console.log('Event data:', event);
77
+ }
78
+ activeServices.forEach(service => {
79
+ if (Filters.isActiveWithEventTracker(service)) {
80
+ service.trackEvent(event);
47
81
  }
82
+ });
83
+ if (ctxDebug)
84
+ console.groupEnd();
85
+ }
86
+ else if (ctxDebug)
87
+ console.log('🔐 [Optimizely One] Tracking disabled, ignored event');
88
+ }, [activeServices, ctxDebug]);
89
+ // Use memoized profile discovery function to ensure stable reference for
90
+ // context consumers and to allow triggering profile refresh from multiple
91
+ // places (e.g. page activator effect and manual trigger) without causing
92
+ // unnecessary re-renders.
93
+ const discoverProfileData = useCallback(async (signal) => {
94
+ if (ctxDebug)
95
+ console.log('📢 [Optimizely One] Updating profile data from sources...');
96
+ const discoveryServices = activeServices.filter(Filters.isActiveWithProfileDiscovery);
97
+ const results = await Promise.allSettled(discoveryServices.map(service => service.discoverProfileData(signal ?? undefined)));
98
+ const mergedProfileData = results.reduce((merged, current) => current.status === 'fulfilled'
99
+ ? deepmerge(merged, current.value)
100
+ : merged, currentProfileData);
101
+ const profileDataDiff = diff(currentProfileData, mergedProfileData);
102
+ if (Object.keys(profileDataDiff).length > 0) {
103
+ if (ctxDebug)
104
+ console.log(' - Profile data changes detected:', profileDataDiff);
105
+ setCurrentProfileData(mergedProfileData);
106
+ }
107
+ else if (ctxDebug) {
108
+ console.log(' - No changes in profile data detected.');
109
+ }
110
+ }, [currentProfileData, activeServices, ctxDebug]);
111
+ // Callback to update profile data, which can be passed to services that support
112
+ // profile updates. This allows those services to trigger profile data changes
113
+ // that are then propagated to all other services and context consumers.
114
+ const updateProfile = useCallback((profileData) => {
115
+ if (ctxDebug)
116
+ console.log('📢 [Optimizely One] Updating profile data with:', profileData);
117
+ const mergedProfileData = deepmerge(currentProfileData, profileData);
118
+ const profileDataDiff = diff(currentProfileData, mergedProfileData);
119
+ if (Object.keys(profileDataDiff).length > 0) {
120
+ if (ctxDebug)
121
+ console.log(' - Profile data changes detected:', profileDataDiff);
122
+ setCurrentProfileData(mergedProfileData);
123
+ }
124
+ else if (ctxDebug) {
125
+ console.log(' - No changes in profile data detected.');
126
+ }
127
+ }, [currentProfileData, ctxDebug]);
128
+ // Effect to update profile data across all services whenever it changes
129
+ useEffect(() => {
130
+ if (ctxDebug)
131
+ console.log('📢 [Optimizely One] Profile data updated:', currentProfileData);
132
+ activeServices.forEach(service => {
133
+ if (Filters.isActiveWithUpdateProfile(service)) {
134
+ service.updateProfile(currentProfileData);
48
135
  }
136
+ });
137
+ }, [currentProfileData, activeServices, ctxDebug]);
138
+ // Memoize the entire context value to avoid unnecessary re-renders in context consumers
139
+ // when any of the context values change. This ensures that consumers only re-render
140
+ // when the specific context values they use actually change.
141
+ const contextValue = useMemo(() => {
142
+ return {
143
+ disableTracking,
144
+ disableAutotracking,
145
+ services: activeServices,
146
+ debug: ctxDebug,
147
+ setDebug: setCtxDebug,
148
+ addService: (service) => setAdditionalServices(prev => [...prev, service]),
149
+ removeService: (service) => setAdditionalServices(prev => prev.filter(s => s !== service)),
150
+ track,
151
+ getActivatePageServices: () => activeServices.filter(Filters.isActiveWithActivatePage),
152
+ getTrackPageServices: () => activeServices.filter(Filters.isActiveWithTrackPage),
153
+ getProfileServices: () => activeServices.filter(Filters.isActiveWithUpdateProfile),
154
+ getProfileDataSources: () => activeServices.filter(Filters.isActiveWithProfileDiscovery),
155
+ getService: (code) => activeServices.find(s => s.code === code),
156
+ discoverProfileData,
157
+ updateProfile
49
158
  };
50
- }, [ctx]);
51
- return result;
159
+ }, [disableTracking, disableAutotracking, activeServices, ctxDebug, track, discoverProfileData, updateProfile]);
160
+ return _jsx(OptimizelyOneContext.Provider, { value: contextValue, children: children });
52
161
  }
53
- const OptimizelyOneProvider = ({ value, children }) => {
54
- const [ctxDebug, setCtxDebug] = useState(value?.debug ?? false);
55
- const [services, setServices] = useState([
56
- new WebExperimenationService(),
57
- new DataPlatformService(),
58
- new ContentRecsService(),
59
- ...(value?.services || [])
60
- ].sort((a, b) => a.order - b.order));
61
- services.forEach(service => service.debug = ctxDebug);
62
- return _jsx(OptimizelyOneContext.Provider, { value: {
63
- disableAutotracking: value?.disableAutotracking,
64
- disableTracking: value?.disableTracking,
65
- services,
66
- debug: ctxDebug,
67
- setDebug: debugEnabled => { services.forEach(service => service.debug = debugEnabled); setCtxDebug(debugEnabled); },
68
- addService: service => setServices(list => list.concat([service]).sort((a, b) => a.order - b.order)),
69
- removeService: service => {
70
- const idx = services.indexOf(service);
71
- if (idx == -1)
72
- return;
73
- setServices(list => list.slice(0, idx).concat(list.slice(idx + 1)));
74
- },
75
- }, children: children });
76
- };
77
162
  OptimizelyOneProvider.displayName = "Optimizely One: State & Context provider";
78
- export { OptimizelyOneProvider, useOptimizelyOne };
163
+ /**
164
+ * Retrieves the current Optimizely One context value.
165
+ *
166
+ * @returns The active `OptimizelyOneContextType` instance.
167
+ */
168
+ export function useOptimizelyOne() {
169
+ return useContext(OptimizelyOneContext);
170
+ }
79
171
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/components/context.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAkD,MAAM,OAAO,CAAA;AACpH,OAAO,wBAAwB,MAAM,wCAAwC,CAAA;AAC7E,OAAO,mBAAmB,MAAM,kCAAkC,CAAA;AAClE,OAAO,kBAAkB,MAAM,iCAAiC,CAAA;AAkGhE,SAAS,wBAAwB,CAAC,MAAsC;IAEpE,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,YAAY,IAAI,OAAM,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,CAAA;AACzG,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAsC;IAEjE,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS,IAAI,OAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,CAAA;AACnG,CAAC;AAED,SAAS,yBAAyB,CAAC,MAAsC;IAErE,OAA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2,4 @@ export { OptimizelyOneGadget } from './optimizely-one-gadget/gadget';
2
2
  export { OptimizelyOneProvider, useOptimizelyOne } from './context';
3
3
  export { PageActivator } from './page-activator';
4
4
  export { useIsInTestMode } from './use-test-mode';
5
+ export type { SupportedProductNames } from './types';
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { ArrowPathIcon } from '@heroicons/react/20/solid';
3
4
  export const Notice = ({ prefix, message, isLoading = false, children }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"_notice.js","sourceRoot":"","sources":["../../../src/components/optimizely-one-gadget/_notice.tsx"],"names":[],"mappings":";AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,CAAC,MAAM,MAAM,GAMf,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvD,MAAM,eAAe,GAAG,MAAM,IAAI,CAChC,eAAM,SAAS,EAAC,cAAc,YAAE,MAAM,GAAQ,CAC/C,CAAA;IACD,MAAM,OAAO,GAAG,SAAS,IAAI,CAC3B,KAAC,aAAa,IAAC,SAAS,EAAC,uDAAuD,GAAG,CACpF,CAAA;IACD,OAAO,CACL,aAAG,SAAS,EAAC,8HAA8H,aACxI,OAAO,EACP,eAAe,EACf,OAAO,EACP,QAAQ,IACP,CACL,CAAA;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
1
+ {"version":3,"file":"_notice.js","sourceRoot":"","sources":["../../../src/components/optimizely-one-gadget/_notice.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAOZ,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAEzD,MAAM,CAAC,MAAM,MAAM,GAMf,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IACvD,MAAM,eAAe,GAAG,MAAM,IAAI,CAChC,eAAM,SAAS,EAAC,cAAc,YAAE,MAAM,GAAQ,CAC/C,CAAA;IACD,MAAM,OAAO,GAAG,SAAS,IAAI,CAC3B,KAAC,aAAa,IAAC,SAAS,EAAC,uDAAuD,GAAG,CACpF,CAAA;IACD,OAAO,CACL,aAAG,SAAS,EAAC,8HAA8H,aACxI,OAAO,EACP,eAAe,EACf,OAAO,EACP,QAAQ,IACP,CACL,CAAA;AACH,CAAC,CAAA;AAED,eAAe,MAAM,CAAA"}
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
3
  import { useEffect } from 'react';
3
4
  import { UserGroupIcon } from '@heroicons/react/20/solid';