@remkoj/optimizely-one-nextjs 6.0.0-pre9 → 6.0.0-rc.3

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 (128) hide show
  1. package/AGENTS.md +130 -0
  2. package/README.md +5 -1
  3. package/dist/api/graph-info-service.js +1 -1
  4. package/dist/api/graph-info-service.js.map +1 -1
  5. package/dist/api/index.js +5 -3
  6. package/dist/api/index.js.map +1 -1
  7. package/dist/api/profile-api-service.js +4 -2
  8. package/dist/api/profile-api-service.js.map +1 -1
  9. package/dist/api/types.d.ts +2 -2
  10. package/dist/client-types.d.ts +94 -23
  11. package/dist/client-types.js +5 -1
  12. package/dist/client-types.js.map +1 -1
  13. package/dist/components/context.d.ts +223 -60
  14. package/dist/components/context.js +159 -67
  15. package/dist/components/context.js.map +1 -1
  16. package/dist/components/index.d.ts +1 -0
  17. package/dist/components/optimizely-one-gadget/_notice.js +1 -0
  18. package/dist/components/optimizely-one-gadget/_notice.js.map +1 -1
  19. package/dist/components/optimizely-one-gadget/_types.d.ts +13 -13
  20. package/dist/components/optimizely-one-gadget/audiences-panel.js +2 -1
  21. package/dist/components/optimizely-one-gadget/audiences-panel.js.map +1 -1
  22. package/dist/components/optimizely-one-gadget/exp-panel.d.ts +1 -1
  23. package/dist/components/optimizely-one-gadget/exp-panel.js +1 -0
  24. package/dist/components/optimizely-one-gadget/exp-panel.js.map +1 -1
  25. package/dist/components/optimizely-one-gadget/gadget.js +25 -17
  26. package/dist/components/optimizely-one-gadget/gadget.js.map +1 -1
  27. package/dist/components/optimizely-one-gadget/goals-panel.js +1 -0
  28. package/dist/components/optimizely-one-gadget/goals-panel.js.map +1 -1
  29. package/dist/components/optimizely-one-gadget/graph-panel.js +1 -0
  30. package/dist/components/optimizely-one-gadget/graph-panel.js.map +1 -1
  31. package/dist/components/optimizely-one-gadget/interests-panel.js +1 -0
  32. package/dist/components/optimizely-one-gadget/interests-panel.js.map +1 -1
  33. package/dist/components/optimizely-one-gadget/logo.js +1 -0
  34. package/dist/components/optimizely-one-gadget/logo.js.map +1 -1
  35. package/dist/components/optimizely-one-gadget/profile-panel.js +3 -2
  36. package/dist/components/optimizely-one-gadget/profile-panel.js.map +1 -1
  37. package/dist/components/page-activator.d.ts +1 -1
  38. package/dist/components/page-activator.js +12 -31
  39. package/dist/components/page-activator.js.map +1 -1
  40. package/dist/components/service-filters.d.ts +46 -0
  41. package/dist/components/service-filters.js +56 -0
  42. package/dist/components/service-filters.js.map +1 -0
  43. package/dist/components/types.d.ts +2 -0
  44. package/dist/components/types.js +2 -0
  45. package/dist/components/types.js.map +1 -0
  46. package/dist/components/use-cookie.js.map +1 -1
  47. package/dist/components/use-local-state.d.ts +24 -0
  48. package/dist/components/use-local-state.js +55 -0
  49. package/dist/components/use-local-state.js.map +1 -0
  50. package/dist/components/use-test-mode.js +2 -2
  51. package/dist/components/use-test-mode.js.map +1 -1
  52. package/dist/config.d.ts +119 -0
  53. package/dist/config.js +101 -2
  54. package/dist/config.js.map +1 -1
  55. package/dist/env-vars.d.ts +3 -0
  56. package/dist/env-vars.js +3 -0
  57. package/dist/env-vars.js.map +1 -1
  58. package/dist/products/content-recs/api.js.map +1 -1
  59. package/dist/products/content-recs/client.d.ts +10 -3
  60. package/dist/products/content-recs/client.js +38 -2
  61. package/dist/products/content-recs/client.js.map +1 -1
  62. package/dist/products/content-recs/delivery.d.ts +18 -18
  63. package/dist/products/content-recs/delivery.js.map +1 -1
  64. package/dist/products/content-recs/snippet.d.ts +1 -1
  65. package/dist/products/content-recs/snippet.js +0 -1
  66. package/dist/products/content-recs/snippet.js.map +1 -1
  67. package/dist/{api/content-goals.d.ts → products/content-recs/webservice-goals.d.ts} +1 -1
  68. package/dist/{api/content-goals.js → products/content-recs/webservice-goals.js} +4 -4
  69. package/dist/products/content-recs/webservice-goals.js.map +1 -0
  70. package/dist/products/content-recs/webservice.d.ts +3 -0
  71. package/dist/{api/content-recs.js → products/content-recs/webservice.js} +13 -12
  72. package/dist/products/content-recs/webservice.js.map +1 -0
  73. package/dist/products/data-platform/api.d.ts +9 -9
  74. package/dist/products/data-platform/api.js +9 -9
  75. package/dist/products/data-platform/api.js.map +1 -1
  76. package/dist/products/data-platform/client.d.ts +11 -2
  77. package/dist/products/data-platform/client.js +52 -9
  78. package/dist/products/data-platform/client.js.map +1 -1
  79. package/dist/products/data-platform/index.js.map +1 -1
  80. package/dist/products/data-platform/snippet.d.ts +1 -1
  81. package/dist/products/data-platform/snippet.js +3 -4
  82. package/dist/products/data-platform/snippet.js.map +1 -1
  83. package/dist/products/feature-experimentation/provider.d.ts +7 -0
  84. package/dist/products/feature-experimentation/provider.js +38 -0
  85. package/dist/products/feature-experimentation/provider.js.map +1 -0
  86. package/dist/products/web-experimentation/client.d.ts +5 -2
  87. package/dist/products/web-experimentation/client.js +21 -7
  88. package/dist/products/web-experimentation/client.js.map +1 -1
  89. package/dist/products/web-experimentation/snippet.d.ts +1 -1
  90. package/dist/products/web-experimentation/snippet.js +2 -3
  91. package/dist/products/web-experimentation/snippet.js.map +1 -1
  92. package/dist/products/web-experimentation/webservice.d.ts +3 -0
  93. package/dist/{api/experimentation-api.js → products/web-experimentation/webservice.js} +2 -2
  94. package/dist/products/web-experimentation/webservice.js.map +1 -0
  95. package/dist/server-components/index.d.ts +3 -0
  96. package/dist/server-components/index.js +3 -0
  97. package/dist/server-components/index.js.map +1 -1
  98. package/dist/{components/optimizely-one-gadget/index.d.ts → server-components/optimizely-one-gadget.d.ts} +2 -2
  99. package/dist/{components/optimizely-one-gadget/index.js → server-components/optimizely-one-gadget.js} +4 -5
  100. package/dist/server-components/optimizely-one-gadget.js.map +1 -0
  101. package/dist/server-components/optimizely-one.d.ts +219 -0
  102. package/dist/server-components/optimizely-one.js +112 -0
  103. package/dist/server-components/optimizely-one.js.map +1 -0
  104. package/dist/server-components/scripts/footer.d.ts +1 -1
  105. package/dist/server-components/scripts/footer.js.map +1 -1
  106. package/dist/server-components/scripts/header.d.ts +29 -29
  107. package/dist/server-components/scripts/header.js.map +1 -1
  108. package/dist/server-components/scripts/index.d.ts +6 -6
  109. package/dist/server-components/scripts/index.js +6 -6
  110. package/dist/server-components/scripts/index.js.map +1 -1
  111. package/dist/server.d.ts +1 -2
  112. package/dist/server.js +1 -6
  113. package/dist/server.js.map +1 -1
  114. package/dist/styles.css +2 -2
  115. package/dist/utils/env.js.map +1 -1
  116. package/dist/utils/products.d.ts +92 -0
  117. package/dist/utils/products.js +84 -0
  118. package/dist/utils/products.js.map +1 -0
  119. package/package.json +35 -30
  120. package/dist/api/content-goals.js.map +0 -1
  121. package/dist/api/content-recs.d.ts +0 -3
  122. package/dist/api/content-recs.js.map +0 -1
  123. package/dist/api/experimentation-api.d.ts +0 -3
  124. package/dist/api/experimentation-api.js.map +0 -1
  125. package/dist/components/optimizely-one-gadget/index.js.map +0 -1
  126. package/dist/components/rsc.d.ts +0 -2
  127. package/dist/components/rsc.js +0 -3
  128. package/dist/components/rsc.js.map +0 -1
@@ -1,102 +1,265 @@
1
- import { type FunctionComponent, type PropsWithChildren } from 'react';
1
+ import { type PropsWithChildren, type Dispatch, type SetStateAction } from "react";
2
+ import type * as ClientApi from '../client-types';
3
+ import type { SupportedProductNames } from './types';
2
4
  import WebExperimenationService from '../products/web-experimentation/client';
3
5
  import DataPlatformService from '../products/data-platform/client';
4
6
  import ContentRecsService from '../products/content-recs/client';
5
- import * as ClientApi from '../client-types';
6
7
  /**
7
- * The data stored within the OptimizelyOne context
8
+ * Context contract for Optimizely One integrations.
9
+ *
10
+ * Provides runtime flags, active service management, event dispatching,
11
+ * and capability-specific service selectors used by consumers.
8
12
  */
9
- type OptimizelyOneContextType = {
13
+ export type OptimizelyOneContextType = Readonly<{
10
14
  /**
11
15
  * With tracking completely disabled, all events will be stopped by
12
16
  * the OptimizelyOne hook. The "PageActivator" component will propagate
13
17
  * this instruction to all configured Optimizely One services
14
18
  */
15
- disableTracking?: boolean;
19
+ disableTracking: Readonly<boolean>;
16
20
  /**
17
21
  * With auto-tracking disabled, the "PageActivator" component will not
18
22
  * automatically track a generic pageview for all configured Optimizely
19
23
  * One services.
20
24
  */
21
- disableAutotracking?: boolean;
25
+ disableAutotracking: Readonly<boolean>;
22
26
  /**
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.
27
+ * The list of the active Optimizely One Services registered with the
28
+ * context. Inactive services are filtered out and will not be part of
29
+ * this collection.
26
30
  */
27
- services?: Readonly<ClientApi.OptimizelyOneService[]>;
31
+ services: ReadonlyArray<ClientApi.OptimizelyOneService>;
28
32
  /**
29
- * Whether or not debug output ging must be enabled
33
+ * Whether debug output is enabled for registered services.
34
+ */
35
+ debug: Readonly<boolean>;
36
+ /**
37
+ * Updates debug mode for the context.
38
+ */
39
+ setDebug: Dispatch<SetStateAction<boolean>>;
40
+ /**
41
+ * Adds a service to the context.
42
+ *
43
+ * This allows dynamic service registration after initialization, but requires
44
+ * the full service definition, including `isActive`.
45
+ *
46
+ * @param service The service instance to add.
30
47
  */
31
- debug?: boolean;
32
- setDebug: (newDebug: boolean) => void;
33
48
  addService: (service: ClientApi.OptimizelyOneService) => void;
49
+ /**
50
+ * Removes a service from the context.
51
+ *
52
+ * The exact same service instance must be passed as was used during add.
53
+ * Built-in default services cannot be removed with this method.
54
+ *
55
+ * @param service The service instance to remove.
56
+ */
34
57
  removeService: (service: ClientApi.OptimizelyOneService) => void;
58
+ /**
59
+ * Tracks an event through the generic event API.
60
+ *
61
+ * All configured services that support event tracking receive this event.
62
+ *
63
+ * @param event The event payload to send.
64
+ */
65
+ track: (event: ClientApi.OptimizelyOneEvent) => void;
66
+ /**
67
+ * Discovers profile data from active discovery-capable services.
68
+ *
69
+ * @param signal Optional abort signal used to cancel discovery requests.
70
+ * @returns A promise that resolves when profile discovery and merge are complete.
71
+ */
72
+ discoverProfileData: (signal?: AbortSignal | null) => Promise<void>;
73
+ /**
74
+ * Merges the provided profile data into the current profile state.
75
+ *
76
+ * @param profileData Profile data patch to merge.
77
+ */
78
+ updateProfile: (profileData: Partial<ClientApi.OptimizelyOneProfileData>) => void;
79
+ /**
80
+ * Retrieves active services that support the page activation step.
81
+ *
82
+ * @returns A list of active services with `activatePage` capability.
83
+ */
84
+ getActivatePageServices: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, 'activatePage'>[];
85
+ /**
86
+ * Retrieves active services that support page-view tracking.
87
+ *
88
+ * @returns A list of active services with `trackPage` capability.
89
+ */
90
+ getTrackPageServices: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, 'trackPage'>[];
91
+ /**
92
+ * Retrieves active services that support profile updates.
93
+ *
94
+ * @returns A list of active services with `updateProfile` capability.
95
+ */
96
+ getProfileServices: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, 'updateProfile'>[];
97
+ /**
98
+ * Retrieves active services that can discover profile data.
99
+ *
100
+ * @returns A list of active services with `discoverProfileData` capability.
101
+ */
102
+ getProfileDataSources: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, 'discoverProfileData'>[];
103
+ /**
104
+ * Retrieves an individual active service by its code.
105
+ *
106
+ * @param code The service code.
107
+ * @returns The matching service, or `undefined` when not found.
108
+ */
109
+ getService: <SC extends string>(code: SC) => SC extends keyof CoreServices ? CoreServices[SC] : (ClientApi.OptimizelyOneService<unknown, SC> | undefined);
110
+ }>;
111
+ type CoreServices = {
112
+ webex: WebExperimenationService;
113
+ dataPlatform: DataPlatformService;
114
+ contentRecs: ContentRecsService;
35
115
  };
36
- type OptimizelyOneProviderProps = PropsWithChildren<{
37
- value?: Omit<OptimizelyOneContextType, 'setDebug' | 'addService' | 'removeService'>;
116
+ /**
117
+ * Props accepted by `OptimizelyOneProvider`.
118
+ *
119
+ * `value` supplies initial context flags and optional additional services.
120
+ * `enabledOptimizelyServices` controls which built-in product services are enabled.
121
+ */
122
+ export type ProviderProps = PropsWithChildren<{
123
+ /**
124
+ * Initial context values and optional custom services.
125
+ */
126
+ value?: {
127
+ /**
128
+ * Disables all event tracking when `true`.
129
+ */
130
+ disableTracking?: boolean | undefined;
131
+ /**
132
+ * Disables automatic page-view tracking when `true`.
133
+ */
134
+ disableAutotracking?: boolean | undefined;
135
+ /**
136
+ * Additional services to register alongside built-in services.
137
+ */
138
+ services?: readonly ClientApi.OptimizelyOneService[] | undefined;
139
+ /**
140
+ * Enables debug logging for service operations when `true`.
141
+ */
142
+ debug?: boolean;
143
+ };
144
+ /**
145
+ * Optional allow-list for built-in product services.
146
+ */
147
+ enabledOptimizelyServices?: Array<SupportedProductNames>;
38
148
  }>;
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>;
149
+ /**
150
+ * Provides Optimizely One context values to descendant components.
151
+ *
152
+ * It composes built-in product services with optional additional services,
153
+ * filters active capabilities, and exposes tracking and service access APIs.
154
+ *
155
+ * @param props Provider configuration and children.
156
+ * @returns The Optimizely One context provider element.
157
+ */
158
+ export declare function OptimizelyOneProvider({ value: { disableTracking, disableAutotracking, services, debug }, children, enabledOptimizelyServices }: ProviderProps): import("react").JSX.Element;
159
+ export declare namespace OptimizelyOneProvider {
160
+ var displayName: string;
44
161
  }
45
162
  /**
46
- * The results of the invokation of the useOptimizelyOne
47
- * hook
163
+ * Retrieves the current Optimizely One context value.
164
+ *
165
+ * @returns The active `OptimizelyOneContextType` instance.
48
166
  */
49
- type OptimizelyOneHookResult<TM extends DefaultServiceMap = DefaultServiceMap> = OptimizelyOneContextType & {
167
+ export declare function useOptimizelyOne(): Readonly<{
168
+ /**
169
+ * With tracking completely disabled, all events will be stopped by
170
+ * the OptimizelyOne hook. The "PageActivator" component will propagate
171
+ * this instruction to all configured Optimizely One services
172
+ */
173
+ disableTracking: Readonly<boolean>;
174
+ /**
175
+ * With auto-tracking disabled, the "PageActivator" component will not
176
+ * automatically track a generic pageview for all configured Optimizely
177
+ * One services.
178
+ */
179
+ disableAutotracking: Readonly<boolean>;
180
+ /**
181
+ * The list of the active Optimizely One Services registered with the
182
+ * context. Inactive services are filtered out and will not be part of
183
+ * this collection.
184
+ */
185
+ services: ReadonlyArray<ClientApi.OptimizelyOneService>;
50
186
  /**
51
- * Track an event using the generic events api, which allows all configured
52
- * Optimizely One services to receive this event
187
+ * Whether debug output is enabled for registered services.
188
+ */
189
+ debug: Readonly<boolean>;
190
+ /**
191
+ * Updates debug mode for the context.
192
+ */
193
+ setDebug: Dispatch<SetStateAction<boolean>>;
194
+ /**
195
+ * Adds a service to the context.
196
+ *
197
+ * This allows dynamic service registration after initialization, but requires
198
+ * the full service definition, including `isActive`.
53
199
  *
54
- * @param event The event data to send
55
- * @returns
200
+ * @param service The service instance to add.
201
+ */
202
+ addService: (service: ClientApi.OptimizelyOneService) => void;
203
+ /**
204
+ * Removes a service from the context.
205
+ *
206
+ * The exact same service instance must be passed as was used during add.
207
+ * Built-in default services cannot be removed with this method.
208
+ *
209
+ * @param service The service instance to remove.
210
+ */
211
+ removeService: (service: ClientApi.OptimizelyOneService) => void;
212
+ /**
213
+ * Tracks an event through the generic event API.
214
+ *
215
+ * All configured services that support event tracking receive this event.
216
+ *
217
+ * @param event The event payload to send.
56
218
  */
57
219
  track: (event: ClientApi.OptimizelyOneEvent) => void;
58
220
  /**
59
- * Retrieve all services that must be invoked on the "activate page" step of
60
- * the execution cycle
221
+ * Discovers profile data from active discovery-capable services.
222
+ *
223
+ * @param signal Optional abort signal used to cancel discovery requests.
224
+ * @returns A promise that resolves when profile discovery and merge are complete.
225
+ */
226
+ discoverProfileData: (signal?: AbortSignal | null) => Promise<void>;
227
+ /**
228
+ * Merges the provided profile data into the current profile state.
229
+ *
230
+ * @param profileData Profile data patch to merge.
231
+ */
232
+ updateProfile: (profileData: Partial<ClientApi.OptimizelyOneProfileData>) => void;
233
+ /**
234
+ * Retrieves active services that support the page activation step.
61
235
  *
62
- * @returns A list of active services
236
+ * @returns A list of active services with `activatePage` capability.
63
237
  */
64
- getActivatePageServices: () => (Omit<ClientApi.OptimizelyOneService, 'activatePage' | 'isActive'> & {
65
- activatePage: NonNullable<ClientApi.OptimizelyOneService['activatePage']>;
66
- isActive: true;
67
- })[];
238
+ getActivatePageServices: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, "activatePage">[];
68
239
  /**
69
- * Retrieve all services that must be invoked on the "track page view" step of
70
- * the execution cycle
240
+ * Retrieves active services that support page-view tracking.
71
241
  *
72
- * @returns A list of active services
242
+ * @returns A list of active services with `trackPage` capability.
73
243
  */
74
- getTrackPageServices: () => (Omit<ClientApi.OptimizelyOneService, 'trackPage' | 'isActive'> & {
75
- trackPage: NonNullable<ClientApi.OptimizelyOneService['trackPage']>;
76
- isActive: true;
77
- })[];
244
+ getTrackPageServices: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, "trackPage">[];
78
245
  /**
79
- * Retrieve all services that must be invoked when new profile information has
80
- * been discovered
246
+ * Retrieves active services that support profile updates.
81
247
  *
82
- * @returns A list of active services
248
+ * @returns A list of active services with `updateProfile` capability.
83
249
  */
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
- })[];
250
+ getProfileServices: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, "updateProfile">[];
92
251
  /**
93
- * Retrieve an individual service by its code from the collection of services
252
+ * Retrieves active services that can discover profile data.
94
253
  *
95
- * @param code The service code
96
- * @returns The service, or undefined if it's not part of the collection
254
+ * @returns A list of active services with `discoverProfileData` capability.
97
255
  */
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 };
256
+ getProfileDataSources: () => ClientApi.OptimizelyOneServiceWithCapability<unknown, string, "discoverProfileData">[];
257
+ /**
258
+ * Retrieves an individual active service by its code.
259
+ *
260
+ * @param code The service code.
261
+ * @returns The matching service, or `undefined` when not found.
262
+ */
263
+ getService: <SC extends string>(code: SC) => SC extends keyof CoreServices ? CoreServices[SC] : (ClientApi.OptimizelyOneService<unknown, SC> | undefined);
264
+ }>;
265
+ export {};
@@ -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,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,aAAa,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  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"}