@remkoj/optimizely-one-nextjs 6.0.0-pre9 → 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 (94) hide show
  1. package/README.md +5 -1
  2. package/dist/api/index.js +5 -3
  3. package/dist/api/index.js.map +1 -1
  4. package/dist/client-types.d.ts +74 -3
  5. package/dist/client-types.js +5 -1
  6. package/dist/client-types.js.map +1 -1
  7. package/dist/components/context.d.ts +218 -64
  8. package/dist/components/context.js +159 -67
  9. package/dist/components/context.js.map +1 -1
  10. package/dist/components/index.d.ts +1 -0
  11. package/dist/components/optimizely-one-gadget/_notice.js +1 -0
  12. package/dist/components/optimizely-one-gadget/_notice.js.map +1 -1
  13. package/dist/components/optimizely-one-gadget/audiences-panel.js +1 -0
  14. package/dist/components/optimizely-one-gadget/audiences-panel.js.map +1 -1
  15. package/dist/components/optimizely-one-gadget/exp-panel.js +1 -0
  16. package/dist/components/optimizely-one-gadget/exp-panel.js.map +1 -1
  17. package/dist/components/optimizely-one-gadget/gadget.js +24 -16
  18. package/dist/components/optimizely-one-gadget/gadget.js.map +1 -1
  19. package/dist/components/optimizely-one-gadget/goals-panel.js +1 -0
  20. package/dist/components/optimizely-one-gadget/goals-panel.js.map +1 -1
  21. package/dist/components/optimizely-one-gadget/graph-panel.js +1 -0
  22. package/dist/components/optimizely-one-gadget/graph-panel.js.map +1 -1
  23. package/dist/components/optimizely-one-gadget/interests-panel.js +1 -0
  24. package/dist/components/optimizely-one-gadget/interests-panel.js.map +1 -1
  25. package/dist/components/optimizely-one-gadget/logo.js +1 -0
  26. package/dist/components/optimizely-one-gadget/logo.js.map +1 -1
  27. package/dist/components/optimizely-one-gadget/profile-panel.js +1 -0
  28. package/dist/components/optimizely-one-gadget/profile-panel.js.map +1 -1
  29. package/dist/components/page-activator.js +12 -31
  30. package/dist/components/page-activator.js.map +1 -1
  31. package/dist/components/service-filters.d.ts +46 -0
  32. package/dist/components/service-filters.js +56 -0
  33. package/dist/components/service-filters.js.map +1 -0
  34. package/dist/components/types.d.ts +2 -0
  35. package/dist/components/types.js +2 -0
  36. package/dist/components/types.js.map +1 -0
  37. package/dist/components/use-local-state.d.ts +24 -0
  38. package/dist/components/use-local-state.js +55 -0
  39. package/dist/components/use-local-state.js.map +1 -0
  40. package/dist/config.d.ts +119 -0
  41. package/dist/config.js +101 -2
  42. package/dist/config.js.map +1 -1
  43. package/dist/env-vars.d.ts +3 -0
  44. package/dist/env-vars.js +3 -0
  45. package/dist/env-vars.js.map +1 -1
  46. package/dist/products/content-recs/client.d.ts +10 -3
  47. package/dist/products/content-recs/client.js +38 -2
  48. package/dist/products/content-recs/client.js.map +1 -1
  49. package/dist/{api/content-goals.d.ts → products/content-recs/webservice-goals.d.ts} +1 -1
  50. package/dist/{api/content-goals.js → products/content-recs/webservice-goals.js} +4 -4
  51. package/dist/products/content-recs/webservice-goals.js.map +1 -0
  52. package/dist/{api/content-recs.d.ts → products/content-recs/webservice.d.ts} +1 -1
  53. package/dist/{api/content-recs.js → products/content-recs/webservice.js} +13 -12
  54. package/dist/products/content-recs/webservice.js.map +1 -0
  55. package/dist/products/data-platform/client.d.ts +11 -2
  56. package/dist/products/data-platform/client.js +52 -9
  57. package/dist/products/data-platform/client.js.map +1 -1
  58. package/dist/products/data-platform/snippet.js +3 -3
  59. package/dist/products/data-platform/snippet.js.map +1 -1
  60. package/dist/products/feature-experimentation/provider.d.ts +7 -0
  61. package/dist/products/feature-experimentation/provider.js +32 -0
  62. package/dist/products/feature-experimentation/provider.js.map +1 -0
  63. package/dist/products/web-experimentation/client.d.ts +5 -2
  64. package/dist/products/web-experimentation/client.js +21 -7
  65. package/dist/products/web-experimentation/client.js.map +1 -1
  66. package/dist/products/web-experimentation/snippet.js +2 -2
  67. package/dist/products/web-experimentation/snippet.js.map +1 -1
  68. package/dist/{api/experimentation-api.d.ts → products/web-experimentation/webservice.d.ts} +1 -1
  69. package/dist/{api/experimentation-api.js → products/web-experimentation/webservice.js} +2 -2
  70. package/dist/products/web-experimentation/webservice.js.map +1 -0
  71. package/dist/server-components/index.d.ts +3 -0
  72. package/dist/server-components/index.js +3 -0
  73. package/dist/server-components/index.js.map +1 -1
  74. package/dist/{components/optimizely-one-gadget/index.d.ts → server-components/optimizely-one-gadget.d.ts} +1 -1
  75. package/dist/{components/optimizely-one-gadget/index.js → server-components/optimizely-one-gadget.js} +4 -5
  76. package/dist/server-components/optimizely-one-gadget.js.map +1 -0
  77. package/dist/server-components/optimizely-one.d.ts +219 -0
  78. package/dist/server-components/optimizely-one.js +112 -0
  79. package/dist/server-components/optimizely-one.js.map +1 -0
  80. package/dist/server.d.ts +1 -2
  81. package/dist/server.js +1 -6
  82. package/dist/server.js.map +1 -1
  83. package/dist/styles.css +2 -2
  84. package/dist/utils/products.d.ts +92 -0
  85. package/dist/utils/products.js +84 -0
  86. package/dist/utils/products.js.map +1 -0
  87. package/package.json +20 -25
  88. package/dist/api/content-goals.js.map +0 -1
  89. package/dist/api/content-recs.js.map +0 -1
  90. package/dist/api/experimentation-api.js.map +0 -1
  91. package/dist/components/optimizely-one-gadget/index.js.map +0 -1
  92. package/dist/components/rsc.d.ts +0 -2
  93. package/dist/components/rsc.js +0 -3
  94. package/dist/components/rsc.js.map +0 -1
@@ -1,16 +1,18 @@
1
1
  'use client';
2
2
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
- import { useEffect, useLayoutEffect } from 'react';
3
+ import { useEffect, useLayoutEffect, } from 'react';
4
4
  import { usePathname } from 'next/navigation';
5
5
  import { useOptimizelyOne } from './context';
6
- export const PageActivator = props => {
6
+ export const PageActivator = (props) => {
7
7
  const path = usePathname();
8
8
  const opti = useOptimizelyOne();
9
9
  // Page activation effect
10
10
  useLayoutEffect(() => {
11
11
  if (opti.debug)
12
12
  console.groupCollapsed(`📑 [Optimizely One] Applying layout effects for: ${path}`);
13
- opti.getActivatePageServices().forEach(service => service.activatePage(path));
13
+ opti
14
+ .getActivatePageServices()
15
+ .forEach((service) => service.activatePage(path));
14
16
  if (opti.debug)
15
17
  console.groupEnd();
16
18
  }, [path, opti]);
@@ -18,41 +20,20 @@ export const PageActivator = props => {
18
20
  useEffect(() => {
19
21
  if (opti.disableAutotracking) {
20
22
  if (opti.debug)
21
- console.log('🔐 [Optimizely One] Automatic page tracking disabled');
23
+ console.log('🔐 [Optimizely One] Automatic page tracking and profile data updates disabled');
22
24
  return;
23
25
  }
24
26
  if (opti.debug)
25
- console.groupCollapsed(`📢 [Optimizely One] Tracking page view for: ${path}`);
26
- opti.getTrackPageServices().forEach(service => service.trackPage(path));
27
+ console.groupCollapsed(`📢 [Optimizely One] Path update detected, tracking page view and updating profile data for: ${path}`);
28
+ const abort = new AbortController();
29
+ opti.getTrackPageServices().forEach((service) => service.trackPage(path));
30
+ opti.discoverProfileData(abort.signal);
27
31
  if (opti.debug)
28
32
  console.groupEnd();
29
- }, [path, opti]);
30
- // Profile data effect
31
- useEffect(() => {
32
- if (opti.debug)
33
- console.log(`📢 [Optimizely One] Refreshing profile data for: ${path}`);
34
- const abort = new AbortController();
35
- Promise.allSettled(opti.getProfileDataSources().map(pds => pds.discoverProfileData(abort.signal))).then(results => {
36
- const mergedProfileData = { custom: {} };
37
- results.forEach(result => {
38
- if (result.status == "fulfilled") {
39
- if (result.value.content_intelligence_id)
40
- mergedProfileData.content_intelligence_id = result.value.content_intelligence_id;
41
- mergedProfileData.custom = { ...mergedProfileData.custom, ...result.value.custom };
42
- }
43
- });
44
- if (mergedProfileData.content_intelligence_id || Object.getOwnPropertyNames(mergedProfileData.custom).length > 0) {
45
- if (opti.debug)
46
- console.log(`📢 [Optimizely One] Discovered profile data: ${JSON.stringify(mergedProfileData)}`);
47
- opti.getProfileServices().forEach(service => service.updateProfile(mergedProfileData));
48
- }
49
- });
50
- return () => {
51
- abort.abort(`[Optimizely One] Profile data refresh cancelled`);
52
- };
33
+ return () => abort.abort(`[Optimizely One] Page tracking cancelled for: ${path}`);
53
34
  }, [path, opti]);
54
35
  return _jsx(_Fragment, { children: props.children });
55
36
  };
56
- PageActivator.displayName = "Optimizely One: (Layout) Effect processor";
37
+ PageActivator.displayName = 'Optimizely One: (Layout) Effect processor';
57
38
  export default PageActivator;
58
39
  //# sourceMappingURL=page-activator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-activator.js","sourceRoot":"","sources":["../../src/components/page-activator.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AACZ,OAAO,EAAE,SAAS,EAAE,eAAe,EAAkD,MAAM,OAAO,CAAA;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAK5C,MAAM,CAAC,MAAM,aAAa,GAA2C,KAAK,CAAC,EAAE;IAEzE,MAAM,IAAI,GAAG,WAAW,EAAE,CAAA;IAC1B,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAA;IAE/B,yBAAyB;IACzB,eAAe,CAAC,GAAG,EAAE;QACjB,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,cAAc,CAAC,oDAAqD,IAAK,EAAE,CAAC,CAAA;QAEpG,IAAI,CAAC,uBAAuB,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAA;QAE7E,IAAI,IAAI,CAAC,KAAK;YACV,OAAO,CAAC,QAAQ,EAAE,CAAA;IAC1B,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAEhB,uBAAuB;IACvB,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC3B,IAAI,IAAI,CAAC,KAAK;gBAAE,OAAO,CAAC,GAAG,CAAC,sDAAsD,CAAC,CAAA;YACnF,OAAM;QACV,CAAC;QAED,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,cAAc,C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Y,CAAC,IAAI,CAAC,CAAC,CAAA;QAEnD,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,QAAQ,EAAE,CAAA;IACpC,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAEhB,uBAAuB;IACvB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,IAAI,IAAI,CAAC,KAAK;gBACZ,OAAO,CAAC,GAAG,CAAC,+EAA+E,CAAC,CAAA;YAC9F,OAAM;QACR,CAAC;QAED,IAAI,IAAI,CAAC,KAAK;YACZ,OAAO,CAAC,cAAc,CACpB,+FAA+F,IAAI,EAAE,CACtG,CAAA;QACH,MAAM,KAAK,GAAG,IAAI,eAAe,EAAE,CAAA;QACnC,IAAI,CAAC,oBAAoB,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1E,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;QACnC,OAAO,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,iDAAiD,IAAI,EAAE,CAAC,CAAC;IACpF,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IAEhB,OAAO,4BAAG,KAAK,CAAC,QAAQ,GAAI,CAAA;AAC9B,CAAC,CAAA;AACD,aAAa,CAAC,WAAW,GAAG,2CAA2C,CAAA;AACvE,eAAe,aAAa,CAAA"}
@@ -0,0 +1,46 @@
1
+ import * as ClientApi from '../client-types';
2
+ /**
3
+ * Checks whether a service is active and supports page activation.
4
+ *
5
+ * @typeParam T The service context payload type.
6
+ * @typeParam SC The service channel identifier type.
7
+ * @param toTest The service instance to validate.
8
+ * @returns `true` when the service is active and exposes `activatePage`.
9
+ */
10
+ export declare function isActiveWithActivatePage<T = any, SC extends string = string>(toTest: ClientApi.OptimizelyOneService<T, SC>): toTest is ClientApi.OptimizelyOneServiceWithCapability<T, SC, 'activatePage'>;
11
+ /**
12
+ * Checks whether a service is active and supports page tracking.
13
+ *
14
+ * @typeParam T The service context payload type.
15
+ * @typeParam SC The service channel identifier type.
16
+ * @param toTest The service instance to validate.
17
+ * @returns `true` when the service is active and exposes `trackPage`.
18
+ */
19
+ export declare function isActiveWithTrackPage<T = any, SC extends string = string>(toTest: ClientApi.OptimizelyOneService<T, SC>): toTest is ClientApi.OptimizelyOneServiceWithCapability<T, SC, 'trackPage'>;
20
+ /**
21
+ * Checks whether a service is active and supports profile updates.
22
+ *
23
+ * @typeParam T The service context payload type.
24
+ * @typeParam SC The service channel identifier type.
25
+ * @param toTest The service instance to validate.
26
+ * @returns `true` when the service is active and exposes `updateProfile`.
27
+ */
28
+ export declare function isActiveWithUpdateProfile<T = any, SC extends string = string>(toTest: ClientApi.OptimizelyOneService<T, SC>): toTest is ClientApi.OptimizelyOneServiceWithCapability<T, SC, 'updateProfile'>;
29
+ /**
30
+ * Checks whether a service is active and supports profile discovery.
31
+ *
32
+ * @typeParam T The service context payload type.
33
+ * @typeParam SC The service channel identifier type.
34
+ * @param toTest The service instance to validate.
35
+ * @returns `true` when the service is active and exposes `discoverProfileData`.
36
+ */
37
+ export declare function isActiveWithProfileDiscovery<T = any, SC extends string = string>(toTest: ClientApi.OptimizelyOneService<T, SC>): toTest is ClientApi.OptimizelyOneServiceWithCapability<T, SC, 'discoverProfileData'>;
38
+ /**
39
+ * Checks whether a service is active and supports event tracking.
40
+ *
41
+ * @typeParam T The service context payload type.
42
+ * @typeParam SC The service channel identifier type.
43
+ * @param toTest The service instance to validate.
44
+ * @returns `true` when the service is active and exposes `trackEvent`.
45
+ */
46
+ export declare function isActiveWithEventTracker<T = any, SC extends string = string>(toTest: ClientApi.OptimizelyOneService<T, SC>): toTest is ClientApi.OptimizelyOneServiceWithCapability<T, SC, 'trackEvent'>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Checks whether a service is active and supports page activation.
3
+ *
4
+ * @typeParam T The service context payload type.
5
+ * @typeParam SC The service channel identifier type.
6
+ * @param toTest The service instance to validate.
7
+ * @returns `true` when the service is active and exposes `activatePage`.
8
+ */
9
+ export function isActiveWithActivatePage(toTest) {
10
+ return (toTest.isActive && toTest.activatePage && typeof toTest.activatePage === 'function') ?? false;
11
+ }
12
+ /**
13
+ * Checks whether a service is active and supports page tracking.
14
+ *
15
+ * @typeParam T The service context payload type.
16
+ * @typeParam SC The service channel identifier type.
17
+ * @param toTest The service instance to validate.
18
+ * @returns `true` when the service is active and exposes `trackPage`.
19
+ */
20
+ export function isActiveWithTrackPage(toTest) {
21
+ return (toTest.isActive && toTest.trackPage && typeof toTest.trackPage === 'function') ?? false;
22
+ }
23
+ /**
24
+ * Checks whether a service is active and supports profile updates.
25
+ *
26
+ * @typeParam T The service context payload type.
27
+ * @typeParam SC The service channel identifier type.
28
+ * @param toTest The service instance to validate.
29
+ * @returns `true` when the service is active and exposes `updateProfile`.
30
+ */
31
+ export function isActiveWithUpdateProfile(toTest) {
32
+ return (toTest.isActive && toTest.updateProfile && typeof toTest.updateProfile === 'function') ?? false;
33
+ }
34
+ /**
35
+ * Checks whether a service is active and supports profile discovery.
36
+ *
37
+ * @typeParam T The service context payload type.
38
+ * @typeParam SC The service channel identifier type.
39
+ * @param toTest The service instance to validate.
40
+ * @returns `true` when the service is active and exposes `discoverProfileData`.
41
+ */
42
+ export function isActiveWithProfileDiscovery(toTest) {
43
+ return (toTest.isActive && toTest.discoverProfileData && typeof toTest.discoverProfileData === 'function') ?? false;
44
+ }
45
+ /**
46
+ * Checks whether a service is active and supports event tracking.
47
+ *
48
+ * @typeParam T The service context payload type.
49
+ * @typeParam SC The service channel identifier type.
50
+ * @param toTest The service instance to validate.
51
+ * @returns `true` when the service is active and exposes `trackEvent`.
52
+ */
53
+ export function isActiveWithEventTracker(toTest) {
54
+ return (toTest.isActive && toTest.trackEvent && typeof toTest.trackEvent === 'function') ?? false;
55
+ }
56
+ //# sourceMappingURL=service-filters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-filters.js","sourceRoot":"","sources":["../../src/components/service-filters.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAsC,MAA6C;IACvH,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,YAAY,IAAI,OAAO,MAAM,CAAC,YAAY,KAAK,UAAU,CAAC,IAAI,KAAK,CAAA;AACzG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAsC,MAA6C;IACpH,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,SAAS,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,UAAU,CAAC,IAAI,KAAK,CAAA;AACnG,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAsC,MAA6C;IACxH,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,aAAa,IAAI,OAAO,MAAM,CAAC,aAAa,KAAK,UAAU,CAAC,IAAI,KAAK,CAAA;AAC3G,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,4BAA4B,CAAsC,MAA6C;IAC3H,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,mBAAmB,IAAI,OAAO,MAAM,CAAC,mBAAmB,KAAK,UAAU,CAAC,IAAI,KAAK,CAAA;AACvH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAsC,MAA6C;IACvH,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,UAAU,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,CAAC,IAAI,KAAK,CAAA;AACrG,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { checkProductStatus } from '../config';
2
+ export type SupportedProductNames = keyof ReturnType<typeof checkProductStatus>;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/components/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { type Dispatch, type SetStateAction } from 'react';
2
+ /**
3
+ * Reads and persists component state in `window.localStorage` under the provided key.
4
+ *
5
+ * The hook keeps the in-memory value synchronized with `localStorage` updates from
6
+ * other browser tabs by listening to the `storage` event.
7
+ *
8
+ * @typeParam S The state value type.
9
+ * @param localStorageKey The `localStorage` key used to read and write the state.
10
+ * @returns The current state value and a React state setter.
11
+ */
12
+ export declare function useLocalState<S>(localStorageKey: string): [S | undefined, Dispatch<SetStateAction<S | undefined>>];
13
+ export declare function useLocalState<S>(localStorageKey: string, initialState: S | (() => S)): [S, Dispatch<SetStateAction<S>>];
14
+ /**
15
+ * Parses a JSON string and returns the decoded value.
16
+ *
17
+ * If the input is already a non-string value, it is returned as-is.
18
+ *
19
+ * @typeParam R The expected return type.
20
+ * @param input The value to parse.
21
+ * @param reviver The reviver passed to `JSON.parse()`.
22
+ * @returns The parsed value, the original non-string input, or `undefined` when parsing fails.
23
+ */
24
+ export declare function tryParseJson<R = any>(input?: R | string | null, reviver?: (this: any, key: string, value: any) => any): R | undefined;
@@ -0,0 +1,55 @@
1
+ 'use client';
2
+ import { useState, useEffect } from 'react';
3
+ export function useLocalState(localStorageKey, initialState) {
4
+ const [internalState, setInternalState] = useState(initialState);
5
+ // Everytime the localstoragekey changes, we'll update the
6
+ // state from local storage. Also we'll register event handlers
7
+ // to ensure state consistency across windows
8
+ useEffect(() => {
9
+ function updateFromLocalStorage() {
10
+ const localStorageValue = window.localStorage.getItem(localStorageKey);
11
+ if (!localStorageValue)
12
+ return;
13
+ const parsedValue = tryParseJson(localStorageValue);
14
+ setInternalState(parsedValue);
15
+ }
16
+ function eventHandler(e) {
17
+ if (e.storageArea === window.localStorage && e.key === localStorageKey) {
18
+ updateFromLocalStorage();
19
+ }
20
+ }
21
+ updateFromLocalStorage();
22
+ window.addEventListener('storage', eventHandler);
23
+ return () => {
24
+ window.removeEventListener('storage', eventHandler);
25
+ };
26
+ }, [localStorageKey]);
27
+ // Every time the internal state, or storage key changes, we'll
28
+ // write to localstorage
29
+ useEffect(() => {
30
+ window.localStorage.setItem(localStorageKey, JSON.stringify(internalState));
31
+ }, [internalState, localStorageKey]);
32
+ return [internalState, setInternalState];
33
+ }
34
+ /**
35
+ * Parses a JSON string and returns the decoded value.
36
+ *
37
+ * If the input is already a non-string value, it is returned as-is.
38
+ *
39
+ * @typeParam R The expected return type.
40
+ * @param input The value to parse.
41
+ * @param reviver The reviver passed to `JSON.parse()`.
42
+ * @returns The parsed value, the original non-string input, or `undefined` when parsing fails.
43
+ */
44
+ export function tryParseJson(input, reviver) {
45
+ try {
46
+ if (input && typeof (input) === "string")
47
+ return JSON.parse(input, reviver);
48
+ return input;
49
+ }
50
+ catch {
51
+ // Ignored on purpose
52
+ }
53
+ return undefined;
54
+ }
55
+ //# sourceMappingURL=use-local-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-local-state.js","sourceRoot":"","sources":["../../src/components/use-local-state.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAsC,MAAM,OAAO,CAAA;AAc/E,MAAM,UAAU,aAAa,CAAI,eAAuB,EAAE,YAA4B;IAElF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAgB,YAAY,CAAC,CAAC;IAEhF,2DAA2D;IAC3D,+DAA+D;IAC/D,6CAA6C;IAC7C,SAAS,CAAC,GAAG,EAAE;QACX,SAAS,sBAAsB;YAC3B,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YACvE,IAAI,CAAC,iBAAiB;gBA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
+ *
4
+ * Reads environment variables using the `EnvVars` map and returns a typed
5
+ * configuration object containing all Optimizely One service parameters.
6
+ *
7
+ * This function is called automatically by `getEnabledProducts()` if a custom
8
+ * config is not provided.
9
+ *
10
+ * **Configuration properties:**
11
+ *
12
+ * - `RuntimeEnv`: Node runtime environment (defaults to `'production'`)
13
+ * - `OdpApiKey`: API key for Optimizely Data Platform
14
+ * - `OdpService`: ODP service endpoint URL (defaults to `https://api.zaius.com/`)
15
+ * - `OdpAudienceBatchSize`: Batch size for ODP audience queries (defaults to `25`)
16
+ * - `HelperEnabled`: Enable/disable Optimizely One integration (defaults to `false`)
17
+ * - `ContentRecsClient`: Content Recommendations client identifier
18
+ * - `ContentRecsDelivery`: Content Recommendations delivery method (defaults to `0`)
19
+ * - `ContentRecsDeliveryKey`: API key for Content Recommendations
20
+ * - `ContentRecsHost`: Content Recommendations host (defaults to `"idio.co"`)
21
+ * - `FrontendCookie`: Cookie name for visitor ID (defaults to `"visitorId"`)
22
+ * - `WebExperimentationProject`: Project ID for Web Experimentation
23
+ * - `OptimizelyDebug`: Enable debug logging for Optimizely (defaults to `false`)
24
+ *
25
+ * @returns Configuration object with type `OptiOneConfig`.
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * import { readConfigFromEnv } from '@remkoj/optimizely-one-nextjs'
30
+ *
31
+ * const config = readConfigFromEnv()
32
+ * console.log('ODP API Key:', config.OdpApiKey)
33
+ * console.log('Runtime Environment:', config.RuntimeEnv)
34
+ * ```
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * // Use for conditional initialization
39
+ * import { readConfigFromEnv, checkProductStatus } from '@remkoj/optimizely-one-nextjs'
40
+ *
41
+ * const config = readConfigFromEnv()
42
+ * const productStatus = checkProductStatus(config)
43
+ * if (productStatus.dataPlatform) {
44
+ * initializeODP(config.OdpApiKey, config.OdpService)
45
+ * }
46
+ * ```
47
+ */
1
48
  export declare function readConfigFromEnv(): {
2
49
  RuntimeEnv: string;
3
50
  OdpApiKey: string | undefined;
@@ -11,12 +58,84 @@ export declare function readConfigFromEnv(): {
11
58
  FrontendCookie: string;
12
59
  WebExperimentationProject: string | undefined;
13
60
  OptimizelyDebug: boolean;
61
+ FeatureExperimentationProject: string | undefined;
62
+ FeatureExperimentationSdkKey: string | undefined;
63
+ FeatureExperimentationToken: string | undefined;
14
64
  };
65
+ /**
66
+ * Evaluate product enablement status based on configuration.
67
+ *
68
+ * Checks the provided configuration object to determine which Optimizely One
69
+ * products are properly configured and available for use. Each product has
70
+ * specific configuration requirements:
71
+ *
72
+ * **Activation criteria:**
73
+ *
74
+ * - `dataPlatform`: `OdpApiKey` must be a string with >8 characters
75
+ * - `contentRecsClient`: Both `ContentRecsClient` AND `ContentRecsDelivery` must be set
76
+ * - `contentRecsApi`: Both `ContentRecsClient` AND `ContentRecsDeliveryKey` must be set
77
+ * - `webExperimentation`: `WebExperimentationProject` must be a string with >5 characters
78
+ *
79
+ * @param config - Optional partial configuration object.
80
+ * If not provided, configuration is read from environment variables.
81
+ * @returns An object with boolean status for each product:
82
+ * - `dataPlatform: boolean`
83
+ * - `contentRecsClient: boolean`
84
+ * - `contentRecsApi: boolean`
85
+ * - `webExperimentation: boolean`
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * import { checkProductStatus, readConfigFromEnv } from '@remkoj/optimizely-one-nextjs'
90
+ *
91
+ * const config = readConfigFromEnv()
92
+ * const status = checkProductStatus(config)
93
+ *
94
+ * Object.entries(status).forEach(([product, isEnabled]) => {
95
+ * console.log(`${product}: ${isEnabled ? 'enabled' : 'disabled'}`)
96
+ * })
97
+ * ```
98
+ *
99
+ * @example
100
+ * ```tsx
101
+ * import { checkProductStatus } from '@remkoj/optimizely-one-nextjs'
102
+ *
103
+ * // Check with custom configuration
104
+ * const customConfig = {
105
+ * OdpApiKey: 'my-api-key-12345678',
106
+ * WebExperimentationProject: 'campaign-123456',
107
+ * ContentRecsClient: 'my-client',
108
+ * ContentRecsDeliveryKey: 'content-key'
109
+ * }
110
+ * const productStatus = checkProductStatus(customConfig)
111
+ * ```
112
+ */
15
113
  export declare function checkProductStatus(config?: Partial<OptiOneConfig>): {
16
114
  dataPlatform: boolean;
17
115
  contentRecsClient: boolean;
18
116
  contentRecsApi: boolean;
19
117
  webExperimentation: boolean;
118
+ featureExperimentation: boolean;
20
119
  };
120
+ /**
121
+ * Complete Optimizely One configuration object.
122
+ *
123
+ * This is the return type of `readConfigFromEnv()` and represents all
124
+ * configuration parameters available for Optimizely One services.
125
+ *
126
+ * Contains settings for:
127
+ * - ODP (Data Platform)
128
+ * - Content Recommendations
129
+ * - Web Experimentation
130
+ * - General platform options
131
+ *
132
+ * @example
133
+ * ```tsx
134
+ * import type { OptiOneConfig } from '@remkoj/optimizely-one-nextjs'
135
+ * import { readConfigFromEnv } from '@remkoj/optimizely-one-nextjs'
136
+ *
137
+ * const config: OptiOneConfig = readConfigFromEnv()
138
+ * ```
139
+ */
21
140
  export type OptiOneConfig = ReturnType<typeof readConfigFromEnv>;
22
141
  export default readConfigFromEnv;
package/dist/config.js CHANGED
@@ -1,5 +1,52 @@
1
1
  import { readValue, readValueAsBoolean, readValueAsInt } from "./utils/env";
2
2
  import EnvVars from "./env-vars";
3
+ /**
4
+ * Load Optimizely One configuration from environment variables.
5
+ *
6
+ * Reads environment variables using the `EnvVars` map and returns a typed
7
+ * configuration object containing all Optimizely One service parameters.
8
+ *
9
+ * This function is called automatically by `getEnabledProducts()` if a custom
10
+ * config is not provided.
11
+ *
12
+ * **Configuration properties:**
13
+ *
14
+ * - `RuntimeEnv`: Node runtime environment (defaults to `'production'`)
15
+ * - `OdpApiKey`: API key for Optimizely Data Platform
16
+ * - `OdpService`: ODP service endpoint URL (defaults to `https://api.zaius.com/`)
17
+ * - `OdpAudienceBatchSize`: Batch size for ODP audience queries (defaults to `25`)
18
+ * - `HelperEnabled`: Enable/disable Optimizely One integration (defaults to `false`)
19
+ * - `ContentRecsClient`: Content Recommendations client identifier
20
+ * - `ContentRecsDelivery`: Content Recommendations delivery method (defaults to `0`)
21
+ * - `ContentRecsDeliveryKey`: API key for Content Recommendations
22
+ * - `ContentRecsHost`: Content Recommendations host (defaults to `"idio.co"`)
23
+ * - `FrontendCookie`: Cookie name for visitor ID (defaults to `"visitorId"`)
24
+ * - `WebExperimentationProject`: Project ID for Web Experimentation
25
+ * - `OptimizelyDebug`: Enable debug logging for Optimizely (defaults to `false`)
26
+ *
27
+ * @returns Configuration object with type `OptiOneConfig`.
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * import { readConfigFromEnv } from '@remkoj/optimizely-one-nextjs'
32
+ *
33
+ * const config = readConfigFromEnv()
34
+ * console.log('ODP API Key:', config.OdpApiKey)
35
+ * console.log('Runtime Environment:', config.RuntimeEnv)
36
+ * ```
37
+ *
38
+ * @example
39
+ * ```tsx
40
+ * // Use for conditional initialization
41
+ * import { readConfigFromEnv, checkProductStatus } from '@remkoj/optimizely-one-nextjs'
42
+ *
43
+ * const config = readConfigFromEnv()
44
+ * const productStatus = checkProductStatus(config)
45
+ * if (productStatus.dataPlatform) {
46
+ * initializeODP(config.OdpApiKey, config.OdpService)
47
+ * }
48
+ * ```
49
+ */
3
50
  export function readConfigFromEnv() {
4
51
  return {
5
52
  RuntimeEnv: readValue('NODE_ENV', 'production'),
@@ -13,16 +60,68 @@ export function readConfigFromEnv() {
13
60
  ContentRecsHost: readValue(EnvVars.ContentRecsHost, "idio.co"),
14
61
  FrontendCookie: readValue(EnvVars.FrontendCookie, "visitorId"),
15
62
  WebExperimentationProject: readValue(EnvVars.WebExperimentationProject),
16
- OptimizelyDebug: readValueAsBoolean(EnvVars.OptimizelyDebug, false)
63
+ OptimizelyDebug: readValueAsBoolean(EnvVars.OptimizelyDebug, false),
64
+ FeatureExperimentationProject: readValue(EnvVars.FeatureExperimentationProject),
65
+ FeatureExperimentationSdkKey: readValue(EnvVars.FeatureExperimentationSdkKey),
66
+ FeatureExperimentationToken: readValue(EnvVars.FeatureExperimentationPat)
17
67
  };
18
68
  }
69
+ /**
70
+ * Evaluate product enablement status based on configuration.
71
+ *
72
+ * Checks the provided configuration object to determine which Optimizely One
73
+ * products are properly configured and available for use. Each product has
74
+ * specific configuration requirements:
75
+ *
76
+ * **Activation criteria:**
77
+ *
78
+ * - `dataPlatform`: `OdpApiKey` must be a string with >8 characters
79
+ * - `contentRecsClient`: Both `ContentRecsClient` AND `ContentRecsDelivery` must be set
80
+ * - `contentRecsApi`: Both `ContentRecsClient` AND `ContentRecsDeliveryKey` must be set
81
+ * - `webExperimentation`: `WebExperimentationProject` must be a string with >5 characters
82
+ *
83
+ * @param config - Optional partial configuration object.
84
+ * If not provided, configuration is read from environment variables.
85
+ * @returns An object with boolean status for each product:
86
+ * - `dataPlatform: boolean`
87
+ * - `contentRecsClient: boolean`
88
+ * - `contentRecsApi: boolean`
89
+ * - `webExperimentation: boolean`
90
+ *
91
+ * @example
92
+ * ```tsx
93
+ * import { checkProductStatus, readConfigFromEnv } from '@remkoj/optimizely-one-nextjs'
94
+ *
95
+ * const config = readConfigFromEnv()
96
+ * const status = checkProductStatus(config)
97
+ *
98
+ * Object.entries(status).forEach(([product, isEnabled]) => {
99
+ * console.log(`${product}: ${isEnabled ? 'enabled' : 'disabled'}`)
100
+ * })
101
+ * ```
102
+ *
103
+ * @example
104
+ * ```tsx
105
+ * import { checkProductStatus } from '@remkoj/optimizely-one-nextjs'
106
+ *
107
+ * // Check with custom configuration
108
+ * const customConfig = {
109
+ * OdpApiKey: 'my-api-key-12345678',
110
+ * WebExperimentationProject: 'campaign-123456',
111
+ * ContentRecsClient: 'my-client',
112
+ * ContentRecsDeliveryKey: 'content-key'
113
+ * }
114
+ * const productStatus = checkProductStatus(customConfig)
115
+ * ```
116
+ */
19
117
  export function checkProductStatus(config) {
20
118
  const appConfig = config ?? readConfigFromEnv();
21
119
  return {
22
120
  dataPlatform: typeof (appConfig.OdpApiKey) == 'string' && appConfig.OdpApiKey.length > 8,
23
121
  contentRecsClient: appConfig.ContentRecsClient && appConfig.ContentRecsDelivery ? true : false,
24
122
  contentRecsApi: appConfig.ContentRecsClient && appConfig.ContentRecsDeliveryKey ? true : false,
25
- webExperimentation: typeof (appConfig.WebExperimentationProject) == 'string' && appConfig.WebExperimentationProject.length > 5
123
+ webExperimentation: typeof (appConfig.WebExperimentationProject) == 'string' && appConfig.WebExperimentationProject.length > 5,
124
+ featureExperimentation: typeof (appConfig.FeatureExperimentationSdkKey) == 'string' && appConfig.FeatureExperimentationSdkKey.length > 5
26
125
  };
27
126
  }
28
127
  export default readConfigFromEnv;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC3E,OAAO,OAAO,MAAM,YAAY,CAAA;AAEhC,MAAM,UAAU,iBAAiB;IAC/B,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;QAC/C,SAAS,EAAE,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;QACvC,UAAU,EAAE,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,wBAAwB,CAAC;QACnE,oBAAoB,EAAE,cAAc,CAAC,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC;QACtE,aAAa,EAAE,kBAAkB,CAAC,OAAO,CAAC,aAAa,EAAE,KAAK,CAAC;QAC/D,iBAAiB,EAAE,SAAS,CAAC,OAAO,CAAC,iBAAiB,CAAC;QACvD,mBAAmB,EAAE,cAAc,CAAC,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;QACnE,sBAAsB,EAAE,SAAS,CAAC,OAAO,CAAC,sBAAsB,CAAC;QACjE,eAAe,EAAE,SAAS,CAAC,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC;QAC9D,cAAc,EAAE,SAAS,CAAC,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC;QAC9D,yBAAyB,EAAE,SAAS,CAAC,OAA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AsB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK;QAC9F,kBAAkB,EAAE,OAAO,CAAC,SAAS,CAAC,yBAAyB,CAAC,IAAI,QAAQ,IAAI,SAAS,CAAC,yBAAyB,CAAC,MAAM,GAAG,CAAC;QAC9H,sBAAsB,EAAE,OAAO,CAAC,SAAS,CAAC,4BAA4B,CAAC,IAAI,QAAQ,IAAI,SAAS,CAAC,4BAA4B,CAAC,MAAM,GAAG,CAAC;KACzI,CAAA;AACH,CAAC;AAwBD,eAAe,iBAAiB,CAAA"}
@@ -9,6 +9,9 @@ export declare const enum EnvVars {
9
9
  ContentRecsHost = "OPTIMIZELY_CONTENTRECS_DOMAIN",
10
10
  FrontendCookie = "OPTIMIZELY_FRONTEND_COOKIE",
11
11
  WebExperimentationProject = "OPTIMIZELY_WEB_EXPERIMENTATION_PROJECT",
12
+ FeatureExperimentationSdkKey = "OPTIMIZELY_FX_SDKKEY",
13
+ FeatureExperimentationProject = "OPTIMIZELY_FX_PROJECT",
14
+ FeatureExperimentationPat = "OPTIMIZELY_FX_PAT",
12
15
  OptimizelyDebug = "OPTIMIZELY_DEBUG"
13
16
  }
14
17
  export default EnvVars;
package/dist/env-vars.js CHANGED
@@ -10,6 +10,9 @@ export var EnvVars;
10
10
  EnvVars["ContentRecsHost"] = "OPTIMIZELY_CONTENTRECS_DOMAIN";
11
11
  EnvVars["FrontendCookie"] = "OPTIMIZELY_FRONTEND_COOKIE";
12
12
  EnvVars["WebExperimentationProject"] = "OPTIMIZELY_WEB_EXPERIMENTATION_PROJECT";
13
+ EnvVars["FeatureExperimentationSdkKey"] = "OPTIMIZELY_FX_SDKKEY";
14
+ EnvVars["FeatureExperimentationProject"] = "OPTIMIZELY_FX_PROJECT";
15
+ EnvVars["FeatureExperimentationPat"] = "OPTIMIZELY_FX_PAT";
13
16
  EnvVars["OptimizelyDebug"] = "OPTIMIZELY_DEBUG";
14
17
  })(EnvVars || (EnvVars = {}));
15
18
  export default EnvVars;
@@ -1 +1 @@
1
- {"version":3,"file":"env-vars.js","sourceRoot":"","sources":["../src/env-vars.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAkB,OAYjB;AAZD,WAAkB,OAAO;IACvB,mDAAwC,CAAA;IACxC,0DAA+C,CAAA;IAC/C,sEAA2D,CAAA;IAC3D,kDAAuC,CAAA;IACvC,8DAAmD,CAAA;IACnD,kEAAuD,CAAA;IACvD,yEAA8D,CAAA;IAC9D,4DAAiD,CAAA;IACjD,wDAA6C,CAAA;IAC7C,+EAAoE,CAAA;IACpE,+CAAoC,CAAA;AACtC,CAAC,EAZiB,OAAO,KAAP,OAAO,QAYxB;AAED,eAAe,OAAO,CAAA"}
1
+ {"version":3,"file":"env-vars.js","sourceRoot":"","sources":["../src/env-vars.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAkB,OAejB;AAfD,WAAkB,OAAO;IACvB,mDAAwC,CAAA;IACxC,0DAA+C,CAAA;IAC/C,sEAA2D,CAAA;IAC3D,kDAAuC,CAAA;IACvC,8DAAmD,CAAA;IACnD,kEAAuD,CAAA;IACvD,yEAA8D,CAAA;IAC9D,4DAAiD,CAAA;IACjD,wDAA6C,CAAA;IAC7C,+EAAoE,CAAA;IACpE,gEAAqD,CAAA;IACrD,kEAAuD,CAAA;IACvD,0DAA+C,CAAA;IAC/C,+CAAoC,CAAA;AACtC,CAAC,EAfiB,OAAO,KAAP,OAAO,QAexB;AAED,eAAe,OAAO,CAAA"}
@@ -1,12 +1,19 @@
1
1
  import * as ClientApi from '../../client-types';
2
- export declare class ContentRecsService implements ClientApi.OptimizelyOneService<ClientApi.OptimizelyContentRecsApi> {
2
+ import * as GlobalClientTypes from '../../components/types';
3
+ export declare class ContentRecsService implements ClientApi.OptimizelyOneService<ClientApi.OptimizelyContentRecsApi, 'crecs'> {
4
+ private _apiEnabled;
5
+ private _clientEnabled;
6
+ constructor(enabledServices?: Array<GlobalClientTypes.SupportedProductNames>);
7
+ get isApiEnabled(): boolean;
8
+ get isClientEnabled(): boolean;
3
9
  order: Readonly<number>;
4
- code: Readonly<string>;
10
+ code: Readonly<'crecs'>;
5
11
  debug: boolean;
6
12
  endpoint: string;
7
13
  get isActive(): boolean;
8
14
  trackPage(): void;
15
+ trackEvent(event: ClientApi.OptimizelyOneEvent): void;
9
16
  getBrowserApi(): ClientApi.OptimizelyContentRecsApi | undefined;
10
- discoverProfileData(signal?: AbortSignal | null): Promise<ClientApi.OptimizelyOneProfileData>;
17
+ discoverProfileData(signal?: AbortSignal | null): Promise<Partial<ClientApi.OptimizelyOneProfileData>>;
11
18
  }
12
19
  export default ContentRecsService;