@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.
- package/README.md +5 -1
- package/dist/api/index.js +5 -3
- package/dist/api/index.js.map +1 -1
- package/dist/client-types.d.ts +74 -3
- package/dist/client-types.js +5 -1
- package/dist/client-types.js.map +1 -1
- package/dist/components/context.d.ts +218 -64
- package/dist/components/context.js +159 -67
- package/dist/components/context.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/optimizely-one-gadget/_notice.js +1 -0
- package/dist/components/optimizely-one-gadget/_notice.js.map +1 -1
- package/dist/components/optimizely-one-gadget/audiences-panel.js +1 -0
- package/dist/components/optimizely-one-gadget/audiences-panel.js.map +1 -1
- package/dist/components/optimizely-one-gadget/exp-panel.js +1 -0
- package/dist/components/optimizely-one-gadget/exp-panel.js.map +1 -1
- package/dist/components/optimizely-one-gadget/gadget.js +24 -16
- package/dist/components/optimizely-one-gadget/gadget.js.map +1 -1
- package/dist/components/optimizely-one-gadget/goals-panel.js +1 -0
- package/dist/components/optimizely-one-gadget/goals-panel.js.map +1 -1
- package/dist/components/optimizely-one-gadget/graph-panel.js +1 -0
- package/dist/components/optimizely-one-gadget/graph-panel.js.map +1 -1
- package/dist/components/optimizely-one-gadget/interests-panel.js +1 -0
- package/dist/components/optimizely-one-gadget/interests-panel.js.map +1 -1
- package/dist/components/optimizely-one-gadget/logo.js +1 -0
- package/dist/components/optimizely-one-gadget/logo.js.map +1 -1
- package/dist/components/optimizely-one-gadget/profile-panel.js +1 -0
- package/dist/components/optimizely-one-gadget/profile-panel.js.map +1 -1
- package/dist/components/page-activator.js +12 -31
- package/dist/components/page-activator.js.map +1 -1
- package/dist/components/service-filters.d.ts +46 -0
- package/dist/components/service-filters.js +56 -0
- package/dist/components/service-filters.js.map +1 -0
- package/dist/components/types.d.ts +2 -0
- package/dist/components/types.js +2 -0
- package/dist/components/types.js.map +1 -0
- package/dist/components/use-local-state.d.ts +24 -0
- package/dist/components/use-local-state.js +55 -0
- package/dist/components/use-local-state.js.map +1 -0
- package/dist/config.d.ts +119 -0
- package/dist/config.js +101 -2
- package/dist/config.js.map +1 -1
- package/dist/env-vars.d.ts +3 -0
- package/dist/env-vars.js +3 -0
- package/dist/env-vars.js.map +1 -1
- package/dist/products/content-recs/client.d.ts +10 -3
- package/dist/products/content-recs/client.js +38 -2
- package/dist/products/content-recs/client.js.map +1 -1
- package/dist/{api/content-goals.d.ts → products/content-recs/webservice-goals.d.ts} +1 -1
- package/dist/{api/content-goals.js → products/content-recs/webservice-goals.js} +4 -4
- package/dist/products/content-recs/webservice-goals.js.map +1 -0
- package/dist/{api/content-recs.d.ts → products/content-recs/webservice.d.ts} +1 -1
- package/dist/{api/content-recs.js → products/content-recs/webservice.js} +13 -12
- package/dist/products/content-recs/webservice.js.map +1 -0
- package/dist/products/data-platform/client.d.ts +11 -2
- package/dist/products/data-platform/client.js +52 -9
- package/dist/products/data-platform/client.js.map +1 -1
- package/dist/products/data-platform/snippet.js +3 -3
- package/dist/products/data-platform/snippet.js.map +1 -1
- package/dist/products/feature-experimentation/provider.d.ts +7 -0
- package/dist/products/feature-experimentation/provider.js +32 -0
- package/dist/products/feature-experimentation/provider.js.map +1 -0
- package/dist/products/web-experimentation/client.d.ts +5 -2
- package/dist/products/web-experimentation/client.js +21 -7
- package/dist/products/web-experimentation/client.js.map +1 -1
- package/dist/products/web-experimentation/snippet.js +2 -2
- package/dist/products/web-experimentation/snippet.js.map +1 -1
- package/dist/{api/experimentation-api.d.ts → products/web-experimentation/webservice.d.ts} +1 -1
- package/dist/{api/experimentation-api.js → products/web-experimentation/webservice.js} +2 -2
- package/dist/products/web-experimentation/webservice.js.map +1 -0
- package/dist/server-components/index.d.ts +3 -0
- package/dist/server-components/index.js +3 -0
- package/dist/server-components/index.js.map +1 -1
- package/dist/{components/optimizely-one-gadget/index.d.ts → server-components/optimizely-one-gadget.d.ts} +1 -1
- package/dist/{components/optimizely-one-gadget/index.js → server-components/optimizely-one-gadget.js} +4 -5
- package/dist/server-components/optimizely-one-gadget.js.map +1 -0
- package/dist/server-components/optimizely-one.d.ts +219 -0
- package/dist/server-components/optimizely-one.js +112 -0
- package/dist/server-components/optimizely-one.js.map +1 -0
- package/dist/server.d.ts +1 -2
- package/dist/server.js +1 -6
- package/dist/server.js.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/utils/products.d.ts +92 -0
- package/dist/utils/products.js +84 -0
- package/dist/utils/products.js.map +1 -0
- package/package.json +20 -25
- package/dist/api/content-goals.js.map +0 -1
- package/dist/api/content-recs.js.map +0 -1
- package/dist/api/experimentation-api.js.map +0 -1
- package/dist/components/optimizely-one-gadget/index.js.map +0 -1
- package/dist/components/rsc.d.ts +0 -2
- package/dist/components/rsc.js +0 -3
- package/dist/components/rsc.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
# Next.JS Optimizely One toolkit <!-- omit in toc -->
|
|
2
|
+
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> There'll be an update of Optimizely SaaS CMS that is incompatible with all SDK versions prior to 5.1.6. If you don't upgrade, you will see empty pages (main website) and "Component not found" messages (preview).
|
|
5
|
+
|
|
2
6
|
React components (both client & server) to integrate the browser-side products from Optimizely (Web Experimentation, Data Platform & Content Analytics / Recommendations)
|
|
3
7
|
|
|
4
8
|
## Table of Contents <!-- omit in toc -->
|
|
@@ -161,4 +165,4 @@ Using the Optimizely One Gadget it is possible to demonstrate the in-session beh
|
|
|
161
165
|
### 3.2. Selecting the Web Experimentation project in browser
|
|
162
166
|
When the `OPTIMIZELY_ONE_HELPER` is set to "1" - or the Scripts.Header component has been instructed to do so explicitly - it is possible to change the Optimizely Web Experimentation project on the fly. This is done by adding a query string parameter `?pid=`, with the new project id.
|
|
163
167
|
|
|
164
|
-
The project id is persisted in localStorage with the key `_pid` and needs to be removed manually to revert back to the configured Web Experimentation project.
|
|
168
|
+
The project id is persisted in localStorage with the key `_pid` and needs to be removed manually to revert back to the configured Web Experimentation project.
|
package/dist/api/index.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import 'server-only';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
3
|
import { cookies } from 'next/headers';
|
|
4
|
+
// General services
|
|
4
5
|
import ProfileApiService from './profile-api-service';
|
|
5
6
|
import GraphInfoApiService from './graph-info-service';
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
// Product specific services
|
|
8
|
+
import ExperimentationApiService from '../products/web-experimentation/webservice';
|
|
9
|
+
import ContentRecsApiService from '../products/content-recs/webservice';
|
|
10
|
+
import ContentRecsGoalsService from '../products/content-recs/webservice-goals';
|
|
9
11
|
export function createOptimizelyOneApi(config) {
|
|
10
12
|
const pathParameterName = config?.pathParameterName ?? 'path';
|
|
11
13
|
const services = [
|
package/dist/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAoB,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AACpB,OAAO,EAAoB,YAAY,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAGtC,mBAAmB;AACnB,OAAO,iBAAiB,MAAM,uBAAuB,CAAA;AACrD,OAAO,mBAAmB,MAAM,sBAAsB,CAAA;AAEtD,4BAA4B;AAC5B,OAAO,yBAAyB,MAAM,4CAA4C,CAAA;AAClF,OAAO,qBAAqB,MAAM,qCAAqC,CAAA;AACvE,OAAO,uBAAuB,MAAM,2CAA2C,CAAA;AAkB/E,MAAM,UAAU,sBAAsB,CAAC,MAAwC;IAC7E,MAAM,iBAAiB,GAAG,MAAM,EAAE,iBAAiB,IAAI,MAAM,CAAA;IAC7D,MAAM,QAAQ,GAAG;QACf,GAAG,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE,CAAC;QAC3B,iBAAiB;QACjB,mBAAmB;QACnB,yBAAyB;QACzB,qBAAqB;QACrB,uBAAuB;KACxB,CAAA;IAED,wDAAwD;IACxD,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY,EAAE,UAA6B;QAC7E,OAAO,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE;YACxD,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,CAAA;IACvD,CAAC;IAED,KAAK,UAAU,OAAO,CAAC,OAAoB,EAAE,EAAE,MAAM,EAAE,WAAW,EAAkB;QAClF,iEAAiE;QACjE,MAAM,MAAM,GAAG,MAAM,WAAW,CAAA;QAChC,IAAI,OAAO,GAAkC,MAAM,CAAC,iBAAiB,CAAC,CAAA;QACtE,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,GAAG,CAAA;aACtB,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;YAAE,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;aAC7D,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,GAAG,GAAG,OAAO,CAAA;QAC1D,MAAM,IAAI,GAAW,OAAO,CAAA;QAC5B,qMAAqM;QACrM,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAA;QAE3B,mBAAmB;QACnB,MAAM,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;QAClF,IAAI,CAAC,UAAU;YACb,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAA;QAE7F,qBAAqB;QACrB,MAAM,CAAC,GAAG,OAAO,EAAE,CAAA;QACnB,MAAM,CAAC,QAAQ,EAAE,UAAU,EAAE,WAAW,CAAC,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC,CAAA;QAErG,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;QAC9B,IAAI,WAAW;YACb,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAA;QAE1C,qBAAqB;QACrB,IAAI,OAAO,QAAQ,IAAI,QAAQ;YAC7B,OAAO,IAAI,YAAY,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;QACpE,OAAO,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAA;IACrE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/client-types.d.ts
CHANGED
|
@@ -5,10 +5,31 @@ declare global {
|
|
|
5
5
|
optimizely?: OptimizelyWebExperimentationApi;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Contract implemented by Optimizely One client services.
|
|
10
|
+
*
|
|
11
|
+
* A service can expose one or more optional capabilities (activation, tracking,
|
|
12
|
+
* profile updates/discovery) and provides access to an underlying browser API.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam T The concrete browser API client type exposed by the service.
|
|
15
|
+
* @typeParam SC The service code type used to identify the service.
|
|
16
|
+
*/
|
|
17
|
+
export interface OptimizelyOneService<T = any, SC = string> {
|
|
18
|
+
/**
|
|
19
|
+
* Sort order for service execution. Lower values run first.
|
|
20
|
+
*/
|
|
9
21
|
order: Readonly<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Indicates whether the service is currently active.
|
|
24
|
+
*/
|
|
10
25
|
isActive: Readonly<boolean>;
|
|
11
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Stable service identifier used to locate a service by code.
|
|
28
|
+
*/
|
|
29
|
+
code: Readonly<SC>;
|
|
30
|
+
/**
|
|
31
|
+
* Enables or disables debug logging for this service instance.
|
|
32
|
+
*/
|
|
12
33
|
debug: boolean;
|
|
13
34
|
/**
|
|
14
35
|
* Perform any actions that must be done to apply the capabilities of this
|
|
@@ -27,11 +48,37 @@ export interface OptimizelyOneService<T = any> {
|
|
|
27
48
|
* @returns void
|
|
28
49
|
*/
|
|
29
50
|
trackPage?: (path: string) => void;
|
|
51
|
+
/**
|
|
52
|
+
* Tracks a custom event through this service.
|
|
53
|
+
*
|
|
54
|
+
* @param event The event payload.
|
|
55
|
+
* @returns void
|
|
56
|
+
*/
|
|
30
57
|
trackEvent?: (event: OptimizelyOneEvent) => void;
|
|
58
|
+
/**
|
|
59
|
+
* Updates profile data known to this service.
|
|
60
|
+
*
|
|
61
|
+
* @param profileData Complete new profile
|
|
62
|
+
* @returns void
|
|
63
|
+
*/
|
|
31
64
|
updateProfile?: (profileData: OptimizelyOneProfileData) => void;
|
|
32
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Discovers profile data from this service.
|
|
67
|
+
*
|
|
68
|
+
* @param signal Optional abort signal used to cancel discovery.
|
|
69
|
+
* @returns A partial profile payload discovered by this service.
|
|
70
|
+
*/
|
|
71
|
+
discoverProfileData?: (signal?: AbortSignal | null) => Promise<Partial<OptimizelyOneProfileData>>;
|
|
72
|
+
/**
|
|
73
|
+
* Retrieves the underlying browser API client for this service.
|
|
74
|
+
*
|
|
75
|
+
* @returns The browser API instance, or `undefined` when unavailable.
|
|
76
|
+
*/
|
|
33
77
|
getBrowserApi: () => T | undefined;
|
|
34
78
|
}
|
|
79
|
+
export type OptimizelyOneServiceWithCapability<T = any, SC extends string = string, K extends keyof OptimizelyOneService = keyof OptimizelyOneService> = Omit<OptimizelyOneService<T, SC>, K | 'active'> & Required<Pick<OptimizelyOneService<T, SC>, K> & {
|
|
80
|
+
active: true;
|
|
81
|
+
}>;
|
|
35
82
|
export type OptimizelyOneEvent = NavigationSearchEvent | {
|
|
36
83
|
event: string;
|
|
37
84
|
action: string;
|
|
@@ -43,9 +90,33 @@ type NavigationSearchEvent = {
|
|
|
43
90
|
search_term: string;
|
|
44
91
|
};
|
|
45
92
|
export type OptimizelyOneProfileData = {
|
|
93
|
+
/**
|
|
94
|
+
* The Pseudo ID used by Optimizely Feature experimentation
|
|
95
|
+
*/
|
|
96
|
+
feature_experimentation_id?: string;
|
|
97
|
+
/**
|
|
98
|
+
* The Pseudo ID used by Optimizely Content Recommendations
|
|
99
|
+
* and intelligence
|
|
100
|
+
*/
|
|
46
101
|
content_intelligence_id?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Any other ID tracked within the profile, these IDs are
|
|
104
|
+
* considered PII and thus should not be sent to systems
|
|
105
|
+
* that may not process PII.
|
|
106
|
+
*/
|
|
107
|
+
ids: Record<string, string>;
|
|
108
|
+
/**
|
|
109
|
+
* Any custom field to be tracked within the profile, the
|
|
110
|
+
* values here may not be PII.
|
|
111
|
+
*/
|
|
47
112
|
custom: Record<string, string | number | boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Any custom field to be tracked within the profile, the
|
|
115
|
+
* values here may or may not be PII
|
|
116
|
+
*/
|
|
117
|
+
customPII: Record<string, string | number | boolean>;
|
|
48
118
|
};
|
|
119
|
+
export declare const DefaultProfileData: OptimizelyOneProfileData;
|
|
49
120
|
export type OptimizelyDataPlatformApi = {
|
|
50
121
|
event: (name: string, data?: {
|
|
51
122
|
[param: string]: any;
|
package/dist/client-types.js
CHANGED
package/dist/client-types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-types.js","sourceRoot":"","sources":["../src/client-types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"client-types.js","sourceRoot":"","sources":["../src/client-types.ts"],"names":[],"mappings":"AAqIA,MAAM,CAAC,MAAM,kBAAkB,GAA8B;IAC3D,MAAM,EAAE,EAAE;IACV,SAAS,EAAE,EAAE;IACb,GAAG,EAAE,EAAE;CACR,CAAA"}
|
|
@@ -1,102 +1,256 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
-
*
|
|
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
|
|
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
|
|
22
|
+
disableAutotracking: Readonly<boolean>;
|
|
22
23
|
/**
|
|
23
|
-
* The list of
|
|
24
|
-
* context.
|
|
25
|
-
*
|
|
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
|
|
28
|
+
services: ReadonlyArray<ClientApi.OptimizelyOneService>;
|
|
28
29
|
/**
|
|
29
|
-
* Whether
|
|
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
|
-
|
|
37
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
*
|
|
47
|
-
*
|
|
155
|
+
* Retrieves the current Optimizely One context value.
|
|
156
|
+
*
|
|
157
|
+
* @returns The active `OptimizelyOneContextType` instance.
|
|
48
158
|
*/
|
|
49
|
-
|
|
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
|
-
*
|
|
52
|
-
* Optimizely One services to receive this event
|
|
187
|
+
* Adds a service to the context.
|
|
53
188
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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
|
-
|
|
60
|
-
|
|
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
|
|
228
|
+
* @returns A list of active services with `activatePage` capability.
|
|
63
229
|
*/
|
|
64
|
-
getActivatePageServices: () =>
|
|
65
|
-
activatePage: NonNullable<ClientApi.OptimizelyOneService['activatePage']>;
|
|
66
|
-
isActive: true;
|
|
67
|
-
})[];
|
|
230
|
+
getActivatePageServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, "activatePage">[];
|
|
68
231
|
/**
|
|
69
|
-
*
|
|
70
|
-
* the execution cycle
|
|
232
|
+
* Retrieves active services that support page-view tracking.
|
|
71
233
|
*
|
|
72
|
-
* @returns
|
|
234
|
+
* @returns A list of active services with `trackPage` capability.
|
|
73
235
|
*/
|
|
74
|
-
getTrackPageServices: () =>
|
|
75
|
-
trackPage: NonNullable<ClientApi.OptimizelyOneService['trackPage']>;
|
|
76
|
-
isActive: true;
|
|
77
|
-
})[];
|
|
236
|
+
getTrackPageServices: () => ClientApi.OptimizelyOneServiceWithCapability<any, string, "trackPage">[];
|
|
78
237
|
/**
|
|
79
|
-
*
|
|
80
|
-
* been discovered
|
|
238
|
+
* Retrieves active services that support profile updates.
|
|
81
239
|
*
|
|
82
|
-
* @returns
|
|
240
|
+
* @returns A list of active services with `updateProfile` capability.
|
|
83
241
|
*/
|
|
84
|
-
getProfileServices: () =>
|
|
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
|
-
*
|
|
244
|
+
* Retrieves active services that can discover profile data.
|
|
94
245
|
*
|
|
95
|
-
* @
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
+
}>;
|