@remkoj/optimizely-one-nextjs 6.0.0-pre8 → 6.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -12
- package/README.md +168 -164
- 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/products/content-recs/snippet.js +16 -16
- 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 +17 -17
- 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 +25 -30
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/products/data-platform/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/products/data-platform/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAKZ,MAAM,OAAO,mBAAmB;IAEpB,WAAW,GAAa,IAAI,CAAA;IACpC,YAAY,eAAgE;QACxE,IAAI,eAAe;YACf,IAAI,CAAC,WAAW,GAAG,eAAe,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;IACnE,CAAC;IAEM,KAAK,GAAsB,GAAG,CAAA;IAC9B,IAAI,GAAqB,KAAK,CAAA;IAC9B,KAAK,GAAY,KAAK,CAAA;IAC7B,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,WAAW,CAAA;IAC3B,CAAC;IAEM,SAAS;QAEZ,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,OAAM;QAC7B,MAA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_jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
/* eslint @next/next/no-before-interactive-script-outside-document: 0 */
|
|
3
3
|
import Script from 'next/script';
|
|
4
4
|
export const OptimizelyDataPlatformScript = (props) => {
|
|
5
5
|
const odp_id = props.trackerId.split('.').shift() ?? '';
|
|
6
6
|
if (odp_id == '')
|
|
7
7
|
return null;
|
|
8
|
-
return _jsx(Script, { id: 'data-platform-script', strategy: 'beforeInteractive', children: `
|
|
8
|
+
return _jsxs(_Fragment, { children: [_jsx(Script, { id: 'data-platform-script', strategy: 'beforeInteractive', children: `
|
|
9
9
|
var zaius = window['zaius'] || (window['zaius'] = []);
|
|
10
10
|
zaius.methods = ['initialize', 'onload', 'customer', 'entity', 'event', 'subscribe', 'unsubscribe', 'consent', 'identify', 'anonymize', 'dispatch'];
|
|
11
11
|
|
|
@@ -33,7 +33,7 @@ export const OptimizelyDataPlatformScript = (props) => {
|
|
|
33
33
|
var firstScript = document.getElementsByTagName('script')[0];
|
|
34
34
|
firstScript.parentNode.insertBefore(script, firstScript);
|
|
35
35
|
})();
|
|
36
|
-
` });
|
|
36
|
+
` }), _jsx("link", { rel: "preconnect", href: "https://api.zaius.com" })] });
|
|
37
37
|
};
|
|
38
38
|
export default OptimizelyDataPlatformScript;
|
|
39
39
|
//# sourceMappingURL=snippet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../../src/products/data-platform/snippet.tsx"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,OAAO,MAAM,MAAM,aAAa,CAAA;AAMhC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC/E,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAA;IACvD,IAAI,MAAM,IAAI,EAAE;QACZ,OAAO,IAAI,CAAA;IACf,OAAO,KAAC,MAAM,IAAC,EAAE,EAAC,sBAAsB,EAAC,QAAQ,EAAC,mBAAmB,YAAE;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../../src/products/data-platform/snippet.tsx"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,OAAO,MAAM,MAAM,aAAa,CAAA;AAMhC,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAkC,EAAE,EAAE;IAC/E,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,CAAA;IACvD,IAAI,MAAM,IAAI,EAAE;QACZ,OAAO,IAAI,CAAA;IACf,OAAO,8BACP,KAAC,MAAM,IAAC,EAAE,EAAC,sBAAsB,EAAC,QAAQ,EAAC,mBAAmB,YAAE;;;;;;;;;;;;;;;;;;;;;;;;gIAwB6D,MAAO;;;;CAIvI,GACQ,EACL,eAAM,GAAG,EAAC,YAAY,EAAC,IAAI,EAAC,uBAAuB,GAAG,IACrD,CAAA;AACL,CAAC,CAAA;AAED,eAAe,4BAA4B,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PropsWithChildren } from 'react';
|
|
2
|
+
export type FeatureExperimentationProviderProps = PropsWithChildren<{
|
|
3
|
+
sdkKey: string;
|
|
4
|
+
frontendCookie: string;
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export default function FeatureExperimentationProvider({ sdkKey, frontendCookie, debug, children }: FeatureExperimentationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createInstance, OptimizelyProvider } from '@optimizely/react-sdk';
|
|
4
|
+
import { useMemo, useEffect } from 'react';
|
|
5
|
+
import { useCookie } from '../../components/use-cookie.js';
|
|
6
|
+
export default function FeatureExperimentationProvider({ sdkKey, frontendCookie, debug = false, children }) {
|
|
7
|
+
const optimizelyClient = useMemo(() => createInstance({
|
|
8
|
+
sdkKey,
|
|
9
|
+
datafileOptions: {
|
|
10
|
+
autoUpdate: true,
|
|
11
|
+
updateInterval: 1000 * 60, // Update every minute
|
|
12
|
+
},
|
|
13
|
+
eventBatchSize: 10,
|
|
14
|
+
eventFlushInterval: 1000 * 30, // Flush every 30 seconds
|
|
15
|
+
logLevel: debug ? 'debug' : 'error',
|
|
16
|
+
odpOptions: {
|
|
17
|
+
disabled: false
|
|
18
|
+
}
|
|
19
|
+
}), [sdkKey, debug]);
|
|
20
|
+
const [userId] = useCookie(frontendCookie, `optimizely-one-user-${Math.random().toString(36).substring(2, 15)}`);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (debug || process.env.NODE_ENV === 'development') {
|
|
23
|
+
console.groupCollapsed('🔧 [FeatureExperimentationProvider] Debug mode enabled');
|
|
24
|
+
console.log('🔑 SDK Key:', sdkKey);
|
|
25
|
+
console.log('🍪 Frontend Cookie:', frontendCookie);
|
|
26
|
+
console.log('👤 User ID:', userId);
|
|
27
|
+
console.groupEnd();
|
|
28
|
+
}
|
|
29
|
+
}, [sdkKey, frontendCookie, userId, debug]);
|
|
30
|
+
return (_jsx(OptimizelyProvider, { optimizely: optimizelyClient, user: { id: userId }, children: children }));
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/products/feature-experimentation/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,SAAS,EAA0B,MAAM,OAAO,CAAC;AACnE,OAAO,E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C,CAAC,CAAC;IAE5C,OAAO,CACL,KAAC,kBAAkB,IAAC,UAAU,EAAE,gBAAgB,EAAE,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,YACnE,QAAQ,GACU,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import * as ClientApi from '../../client-types';
|
|
2
|
-
|
|
2
|
+
import * as GlobalClientTypes from '../../components/types';
|
|
3
|
+
export declare class WebExperimenationService implements ClientApi.OptimizelyOneService<ClientApi.OptimizelyWebExperimentationApi, 'webex'> {
|
|
4
|
+
private _wxEnabled;
|
|
5
|
+
constructor(enabledServices?: Array<GlobalClientTypes.SupportedProductNames>);
|
|
3
6
|
order: Readonly<number>;
|
|
4
|
-
code: Readonly<
|
|
7
|
+
code: Readonly<'webex'>;
|
|
5
8
|
debug: boolean;
|
|
6
9
|
get isActive(): boolean;
|
|
7
10
|
activatePage(): void;
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
export class WebExperimenationService {
|
|
3
|
+
_wxEnabled = true;
|
|
4
|
+
constructor(enabledServices) {
|
|
5
|
+
if (enabledServices)
|
|
6
|
+
this._wxEnabled = enabledServices.includes("dataPlatform");
|
|
7
|
+
}
|
|
3
8
|
order = 100;
|
|
4
|
-
code =
|
|
9
|
+
code = 'webex';
|
|
5
10
|
debug = false;
|
|
6
11
|
get isActive() {
|
|
7
|
-
return this.
|
|
12
|
+
return this._wxEnabled;
|
|
8
13
|
}
|
|
9
14
|
activatePage() {
|
|
15
|
+
if (!this._wxEnabled)
|
|
16
|
+
return;
|
|
10
17
|
const webex = this.getBrowserApi();
|
|
11
18
|
if (!webex)
|
|
12
19
|
return;
|
|
@@ -15,21 +22,26 @@ export class WebExperimenationService {
|
|
|
15
22
|
console.log("🚀 Web Experimentation - Activating pages");
|
|
16
23
|
}
|
|
17
24
|
trackEvent(event) {
|
|
25
|
+
if (!this._wxEnabled)
|
|
26
|
+
return;
|
|
18
27
|
const webex = this.getBrowserApi();
|
|
19
28
|
if (!webex)
|
|
20
29
|
return;
|
|
21
30
|
const eventName = `${event.event}_${event.action}`;
|
|
22
|
-
const eventTags = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
const eventTags = Object.entries(event).reduce((tags, [prop_name, prop_value]) => {
|
|
32
|
+
if (prop_name.startsWith('tag_')) {
|
|
33
|
+
tags[prop_name.substring(4)] = prop_value;
|
|
34
|
+
}
|
|
35
|
+
return tags;
|
|
36
|
+
}, {});
|
|
27
37
|
if (this.debug)
|
|
28
38
|
console.log("🚀 Web Experimentation - Tracking event:", { type: 'event', eventName, tags: eventTags });
|
|
29
39
|
webex.push({ type: 'event', eventName, tags: eventTags });
|
|
30
40
|
}
|
|
31
41
|
getBrowserApi() {
|
|
32
42
|
try {
|
|
43
|
+
if (!this._wxEnabled)
|
|
44
|
+
return undefined;
|
|
33
45
|
if (!window.optimizely)
|
|
34
46
|
window.optimizely = [];
|
|
35
47
|
return window.optimizely;
|
|
@@ -39,6 +51,8 @@ export class WebExperimenationService {
|
|
|
39
51
|
}
|
|
40
52
|
}
|
|
41
53
|
updateProfile(profileData) {
|
|
54
|
+
if (!this._wxEnabled)
|
|
55
|
+
return;
|
|
42
56
|
const webex = this.getBrowserApi();
|
|
43
57
|
if (!webex)
|
|
44
58
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/products/web-experimentation/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/products/web-experimentation/client.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAKZ,MAAM,OAAO,wBAAwB;IAEzB,UAAU,GAAa,IAAI,CAAA;IACnC,YAAY,eAAgE;QACxE,IAAI,eAAe;YACf,IAAI,CAAC,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC,cAA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AAE,SAAS,EAAE,CAAC,CAAA;QACtH,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAA;IAC7D,CAAC;IAEM,aAAa;QAEhB,IAAI,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,UAAU;gBAAE,OAAO,SAAS,CAAA;YACtC,IAAI,CAAC,MAAM,CAAC,UAAU;gBAClB,MAAM,CAAC,UAAU,GAAG,EAA0D,CAAA;YAClF,OAAO,MAAM,CAAC,UAAU,CAAA;QAC5B,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,SAAS,CAAA;QACpB,CAAC;IACL,CAAC;IAEM,aAAa,CAAC,WAA+C;QAEhE,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAM;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QAClC,IAAI,CAAC,KAAK;YAAE,OAAM;QAClB,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,CAAC,GAAG,CAAC,+CAA+C,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAA;QAC9H,KAAK,CAAC,IAAI,CAAC;YACP,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,WAAW,CAAC,MAAM;SACjC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,eAAe,wBAAwB,CAAA"}
|
|
@@ -4,27 +4,27 @@ import Script from 'next/script';
|
|
|
4
4
|
export const OptimizelyWebExperimentationScript = ({ projectId, allowProjectOverride = false, useProxy = false, apiPrefix = '/api/me' }) => {
|
|
5
5
|
function buildUrl(pid) {
|
|
6
6
|
return useProxy ?
|
|
7
|
-
`${apiPrefix}/exp?pid
|
|
7
|
+
`${apiPrefix}/exp${allowProjectOverride ? '?pid=' + pid : ''}` :
|
|
8
8
|
`https://cdn.optimizely.com/js/${pid}.js`;
|
|
9
9
|
}
|
|
10
10
|
return _jsxs(_Fragment, { children: [_jsx(Script, { id: 'web-experimentation-startup', strategy: 'beforeInteractive', children: `window["optimizely"] = window["optimizely"] || [];` }), allowProjectOverride ?
|
|
11
|
-
_jsx(Script, { id: 'web-experimentation-project', strategy: 'beforeInteractive', children: `
|
|
12
|
-
((w,d,l) => {
|
|
13
|
-
const localProject = l.getItem('_pid');
|
|
14
|
-
const queryProject = (new URLSearchParams(w.location.search)).get('pid');
|
|
15
|
-
const currentProject = queryProject || localProject || '${projectId}';
|
|
16
|
-
if (currentProject != localProject)
|
|
17
|
-
l.setItem('_pid', currentProject)
|
|
18
|
-
|
|
19
|
-
let wx = d.createElement('script');
|
|
20
|
-
wx.fetchpriority = 'high';
|
|
21
|
-
wx.src='${buildUrl('\'+ currentProject +\'')}';
|
|
22
|
-
wx.id='web-experimentation-snippet';
|
|
23
|
-
let s=d.getElementById('web-experimentation-project');
|
|
24
|
-
s.parentNode.insertBefore(wx,s);
|
|
25
|
-
})(window,document,localStorage)
|
|
11
|
+
_jsx(Script, { id: 'web-experimentation-project', strategy: 'beforeInteractive', children: `
|
|
12
|
+
((w,d,l) => {
|
|
13
|
+
const localProject = l.getItem('_pid');
|
|
14
|
+
const queryProject = (new URLSearchParams(w.location.search)).get('pid');
|
|
15
|
+
const currentProject = queryProject || localProject || '${projectId}';
|
|
16
|
+
if (currentProject != localProject)
|
|
17
|
+
l.setItem('_pid', currentProject)
|
|
18
|
+
|
|
19
|
+
let wx = d.createElement('script');
|
|
20
|
+
wx.fetchpriority = 'high';
|
|
21
|
+
wx.src='${buildUrl('\'+ currentProject +\'')}';
|
|
22
|
+
wx.id='web-experimentation-snippet';
|
|
23
|
+
let s=d.getElementById('web-experimentation-project');
|
|
24
|
+
s.parentNode.insertBefore(wx,s);
|
|
25
|
+
})(window,document,localStorage)
|
|
26
26
|
` }) :
|
|
27
|
-
_jsx(Script, { id: 'web-experimentation-project', strategy: 'beforeInteractive', src: buildUrl(projectId) })] });
|
|
27
|
+
_jsx(Script, { id: 'web-experimentation-project', strategy: 'beforeInteractive', src: buildUrl(projectId) }), _jsx("link", { rel: "preconnect", href: "https://logx.optimizely.com/v1/events" })] });
|
|
28
28
|
};
|
|
29
29
|
export default OptimizelyWebExperimentationScript;
|
|
30
30
|
//# sourceMappingURL=snippet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../../src/products/web-experimentation/snippet.tsx"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,OAAO,MAAM,MAAM,aAAa,CAAA;AAShC,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,EAAE,SAAS,EAAE,oBAAoB,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,SAAS,GAAG,SAAS,EAAqC,EAAE,EAAE;IAE1K,SAAS,QAAQ,CAAC,GAAkB;QAEhC,OAAO,QAAQ,CAAC,CAAC;YACb,GAAI,SAAU,
|
|
1
|
+
{"version":3,"file":"snippet.js","sourceRoot":"","sources":["../../../src/products/web-experimentation/snippet.tsx"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,OAAO,MAAM,MAAM,aAAa,CAAA;AAShC,MAAM,CAAC,MAAM,kCAAkC,GAAG,CAAC,EAAE,SAAS,EAAE,oBAAoB,GAAG,KAAK,EAAE,QAAQ,GAAG,KAAK,EAAE,SAAS,GAAG,SAAS,EAAqC,EAAE,EAAE;IAE1K,SAAS,QAAQ,CAAC,GAAkB;QAEhC,OAAO,QAAQ,CAAC,CAAC;YACb,GAAI,SAAU,OAAQ,oBAAoB,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,EAAG,EAAE,CAAC,CAAC;YACpE,iCAAkC,GAAI,KAAK,CAAA;IACnD,CAAC;IAED,OAAO,8BACH,KAAC,MAAM,IAAC,EAAE,EAAC,6BAA6B,EAAC,QAAQ,EAAC,mBAAmB,YAAG,oDAAoD,GAAU,EACpI,oBAAoB,CAAC,CAAC;gBACpB,KAAC,MAAM,IAAC,EAAE,EAAC,6BAA6B,EAAC,QAAQ,EAAC,mBAAmB,YAAE;;;;8DAIpB,SAAU;;;;;;cAM1D,QAAQ,CAAC,wBAAwB,CAAE;;;;;aAKrC,GAAU,CAAC,CAAC;gBACb,KAAC,MAAM,IAAC,EAAE,EAAC,6BAA6B,EAAC,QAAQ,EAAC,mBAAmB,EAAC,GAAG,EAAG,QAAQ,CAAC,SAAS,CAAC,GAAK,EAExG,eAAM,GAAG,EAAC,YAAY,EAAC,IAAI,EAAC,uCAAuC,GAAG,IACvE,CAAA;AACP,CAAC,CAAA;AAED,eAAe,kCAAkC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import getConfig from '
|
|
1
|
+
import getConfig from '../../config.js';
|
|
2
2
|
export const ExperimentationApiService = {
|
|
3
3
|
for: { path: '/exp', verb: 'get' },
|
|
4
4
|
handler: async (query) => {
|
|
@@ -27,4 +27,4 @@ export const ExperimentationApiService = {
|
|
|
27
27
|
},
|
|
28
28
|
};
|
|
29
29
|
export default ExperimentationApiService;
|
|
30
|
-
//# sourceMappingURL=
|
|
30
|
+
//# sourceMappingURL=webservice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webservice.js","sourceRoot":"","sources":["../../../src/products/web-experimentation/webservice.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,iBAAiB,CAAA;AAEvC,MAAM,CAAC,MAAM,yBAAyB,GAAqB;IACvD,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE;IAClC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,CAAA;QAC5H,MAAM,cAAc,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,SAAS,CAAA;QACpD,MAAM,SAAS,GAAG,aAAa,CAAC,CAAC,CAAC,cAAc,IAAI,mBAAmB,CAAC,CAAC,CAAC,mBAAmB,CAAA;QAE7F,iCAAiC;QACjC,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,IAAI,KAAK;gBACL,OAAO,CAAC,GAAG,CAAC,4DAA4D,CAAC,CAAA;YAC7E,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG,EAAE,EAAC,EAAE,GAAG,CAAC,CAAA;QACzE,CAAC;QAGD,MAAM,eAAe,GAAG,MAAM,KAAK,CAAC,iCAAkC,SAAU,KAAK,EAAE;YACnF,0CAA0C;YAC1C,IAAI,EAAE;gBACF,UAAU,EAAE,GAAG,CAAC,kCAAkC;aACrD;SACJ,CAAC,CAAA;QACF,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC;YACtB,IAAI,KAAK;gBACL,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAA;YACjF,OAAO,CAAC,EAAC,KAAK,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,eAAe,CAAC,MAAM,EAAC,EAAC,EAAE,eAAe,CAAC,MAAM,CAAE,CAAA;QACrH,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,IAAI,EAAE,CAAA;QAEzC,OAAO,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,EAAE,gCAAgC,CAAC,CAAA;IAC3E,CAAC;CACJ,CAAA;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server-components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server-components/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,CAAA;AAEpB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OptimizelyOneGadgetProps } from '
|
|
1
|
+
import type { OptimizelyOneGadgetProps } from '../components/optimizely-one-gadget/_types.js';
|
|
2
2
|
import 'server-only';
|
|
3
3
|
export declare const OptimizelyOneGadget: ({ refreshInterval, servicePrefix, show, }: OptimizelyOneGadgetProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
4
4
|
export default OptimizelyOneGadget;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import getConfig, { checkProductStatus } from '
|
|
2
|
+
import getConfig, { checkProductStatus } from '../config.js';
|
|
3
3
|
import dynamic from 'next/dynamic';
|
|
4
|
-
import { Suspense } from 'react';
|
|
5
4
|
import 'server-only';
|
|
6
|
-
const OptimizelyOneClientGadget = dynamic(() => import('
|
|
5
|
+
const OptimizelyOneClientGadget = dynamic(() => import('../components/optimizely-one-gadget/gadget.js'), { ssr: false, loading: () => null });
|
|
7
6
|
export const OptimizelyOneGadget = ({ refreshInterval = 0, servicePrefix = '/api/me', show, }) => {
|
|
8
7
|
const optiOneConfig = getConfig();
|
|
9
8
|
const { HelperEnabled, OptimizelyDebug } = optiOneConfig;
|
|
10
9
|
const productStatus = checkProductStatus(optiOneConfig);
|
|
11
10
|
if (show || (show === undefined && HelperEnabled)) {
|
|
12
|
-
return (_jsx(
|
|
11
|
+
return (_jsx(OptimizelyOneClientGadget, { refreshInterval: refreshInterval, servicePrefix: servicePrefix, show: show, showContentRecs: productStatus.contentRecsApi, showDataPlatform: productStatus.dataPlatform, showWebEx: productStatus.webExperimentation }));
|
|
13
12
|
}
|
|
14
13
|
if (OptimizelyDebug)
|
|
15
14
|
console.log(`🚀 [OptimizelyOne Gadget] Gadget disabled by ${show === undefined ? 'configuration' : 'parameter'}`);
|
|
16
15
|
return null;
|
|
17
16
|
};
|
|
18
17
|
export default OptimizelyOneGadget;
|
|
19
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=optimizely-one-gadget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optimizely-one-gadget.js","sourceRoot":"","sources":["../../src/server-components/optimizely-one-gadget.tsx"],"names":[],"mappings":";AACA,OAAO,SAAS,EAAE,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAC5D,OAAO,OAAO,MAAM,cAAc,CAAA;AAElC,OAAO,aAAa,CAAA;AAEpB,MAAM,yBAAyB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,+CAA+C,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAA;AAE7I,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAClC,eAAe,GAAG,CAAC,EACnB,aAAa,GAAG,SAAS,EACzB,IAAI,GACqB,EAAE,EAAE;IAC7B,MAAM,aAAa,GAAG,SAAS,EAAE,CAAA;IACjC,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,aAAa,CAAA;IACxD,MAAM,aAAa,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAA;IAEvD,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,aAAa,CAAC,EAAE,CAAC;QAClD,OAAO,CACL,KAAC,yBAAyB,IACxB,eAAe,EAAE,eAAe,EAChC,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,IAAI,EACV,eAAe,EAAE,aAAa,CAAC,cAAc,EAC7C,gBAAgB,EAAE,aAAa,CAAC,YAAY,EAC5C,SAAS,EAAE,aAAa,CAAC,kBAAkB,GAC3C,CACH,CAAA;IACH,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,CAAC,GAAG,CACT,gDAAgD,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,EAAE,CACrG,CAAA;IACH,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import 'server-only';
|
|
2
|
+
import { PropsWithChildren } from "react";
|
|
3
|
+
import { type OptiOneConfig } from "../config.js";
|
|
4
|
+
/**
|
|
5
|
+
* Properties for the `OptimizelyOne` root component.
|
|
6
|
+
*
|
|
7
|
+
* `OptimizelyOne` configures and initializes the Optimizely One platform
|
|
8
|
+
* within your Next.js application, managing product services, tracking,
|
|
9
|
+
* and developer gadget visibility.
|
|
10
|
+
*
|
|
11
|
+
* All properties are optional and default to safe, production-appropriate values.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { OptimizelyOne } from '@remkoj/optimizely-one-nextjs'
|
|
16
|
+
*
|
|
17
|
+
* export default function App({ children }: { children: React.ReactNode }) {
|
|
18
|
+
* return (
|
|
19
|
+
* <OptimizelyOne debug={false}>
|
|
20
|
+
* {children}
|
|
21
|
+
* </OptimizelyOne>
|
|
22
|
+
* )
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* // Development mode with debugging and auto-tracking enabled
|
|
29
|
+
* <OptimizelyOne debug={true} disableAutoTracking={false}>
|
|
30
|
+
* <YourPageLayout />
|
|
31
|
+
* </OptimizelyOne>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export type OptimizelyOneProps = PropsWithChildren<{
|
|
35
|
+
config?: Partial<OptiOneConfig>;
|
|
36
|
+
/**
|
|
37
|
+
* Disable automatic page activation and tracking.
|
|
38
|
+
*
|
|
39
|
+
* - `true`: the PageActivator component is not rendered; manual tracking required.
|
|
40
|
+
* - `false` (default): automatic page view tracking is enabled.
|
|
41
|
+
*
|
|
42
|
+
* Set to `true` if you implement custom page activation/tracking logic.
|
|
43
|
+
*/
|
|
44
|
+
disableAutoTracking?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Disable all Optimizely tracking features.
|
|
47
|
+
*
|
|
48
|
+
* - `true`: no events are sent to Optimizely services.
|
|
49
|
+
* - `false` (default): tracking is enabled.
|
|
50
|
+
*
|
|
51
|
+
* Use when: implementing custom tracking only, GDPR/privacy compliance,
|
|
52
|
+
* or testing without analytics.
|
|
53
|
+
*/
|
|
54
|
+
disableTracking?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Disable the Optimizely One developer gadget.
|
|
57
|
+
*
|
|
58
|
+
* - `true`: gadget is not rendered.
|
|
59
|
+
* - `false` (default): gadget is rendered in the page.
|
|
60
|
+
*
|
|
61
|
+
* The gadget provides debugging tools and inspection capabilities.
|
|
62
|
+
* Recommended: hide in production with `disableGadget={!isDevelopment}`.
|
|
63
|
+
*/
|
|
64
|
+
disableGadget?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Enable debug mode for detailed Optimizely One diagnostics.
|
|
67
|
+
*
|
|
68
|
+
* - `true`: enables verbose logging to browser console.
|
|
69
|
+
* - `false` (default): no debug output.
|
|
70
|
+
*
|
|
71
|
+
* Use during development and local testing to troubleshoot integration issues,
|
|
72
|
+
* configuration problems, or service loading failures.
|
|
73
|
+
*/
|
|
74
|
+
debug?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* API endpoint path for the Optimizely One gadget data.
|
|
77
|
+
*
|
|
78
|
+
* - Default: `'/api/me'`
|
|
79
|
+
* - Set this to your custom API endpoint path if your API differs from the standard path.
|
|
80
|
+
*
|
|
81
|
+
* This endpoint is used by the developer gadget to fetch user/session data for
|
|
82
|
+
* display in the gadget interface.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```tsx
|
|
86
|
+
* <OptimizelyOne apiPath="/api/v2/user-info" debug={true}>
|
|
87
|
+
* {children}
|
|
88
|
+
* </OptimizelyOne>
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
apiPath?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Refresh interval (in milliseconds) for gadget data updates.
|
|
94
|
+
*
|
|
95
|
+
* - Default: `0`
|
|
96
|
+
* - `0` means data is refreshed **only** when a tab is activated (brought into focus).
|
|
97
|
+
* No automatic background updates occur.
|
|
98
|
+
* - `> 0`: enables automatic polling at the specified interval (in milliseconds).
|
|
99
|
+
* For example, `30000` refreshes every 30 seconds.
|
|
100
|
+
* - `null` or `undefined`: defaults to `0` (tab activation only).
|
|
101
|
+
*
|
|
102
|
+
* **Recommendation:** Use `0` (default) for production to minimize background
|
|
103
|
+
* network activity. Use `> 0` during development for real-time monitoring.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* // Production: refresh only on tab activation (default)
|
|
108
|
+
* <OptimizelyOne>
|
|
109
|
+
* {children}
|
|
110
|
+
* </OptimizelyOne>
|
|
111
|
+
* ```
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```tsx
|
|
115
|
+
* // Development: refresh every 10 seconds for monitoring
|
|
116
|
+
* <OptimizelyOne gadgetRefreshInterval={10000} debug={true}>
|
|
117
|
+
* {children}
|
|
118
|
+
* </OptimizelyOne>
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* // Explicit tab-only activation
|
|
124
|
+
* <OptimizelyOne gadgetRefreshInterval={0}>
|
|
125
|
+
* {children}
|
|
126
|
+
* </OptimizelyOne>
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
gadgetRefreshInterval?: number;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* Root provider component for Optimizely One integration in Next.js applications.
|
|
133
|
+
*
|
|
134
|
+
* `OptimizelyOne` initializes the Optimizely One platform services and wraps
|
|
135
|
+
* your application content with the necessary context and configuration. It handles:
|
|
136
|
+
*
|
|
137
|
+
* - Loading enabled Optimizely products from configuration.
|
|
138
|
+
* - Injecting the PageActivator for automatic page view tracking (when enabled).
|
|
139
|
+
* - Providing CMS context to child components.
|
|
140
|
+
* - Rendering the developer gadget (when enabled).
|
|
141
|
+
*
|
|
142
|
+
* **Key Behavior:**
|
|
143
|
+
*
|
|
144
|
+
* - If `disableAutoTracking` is `false` (default), automatic page view tracking
|
|
145
|
+
* is enabled via the `PageActivator` component.
|
|
146
|
+
* - If `disableGadget` is `false` (default), the developer gadget is rendered
|
|
147
|
+
* in the DOM for debugging/inspection.
|
|
148
|
+
* - The `debug` flag affects internal context and may influence child
|
|
149
|
+
* component logging behavior.
|
|
150
|
+
* - All disabled flags default to `false`, enabling features by default.
|
|
151
|
+
*
|
|
152
|
+
* **Where to use:**
|
|
153
|
+
*
|
|
154
|
+
* Place `OptimizelyOne` as high as possible in your component tree, typically
|
|
155
|
+
* in your root layout or top-level page component.
|
|
156
|
+
*
|
|
157
|
+
* @param props - Configuration properties for Optimizely One initialization.
|
|
158
|
+
* @param props.disableAutoTracking - Set to `true` to prevent automatic page activation/tracking.
|
|
159
|
+
* @param props.disableTracking - Set to `true` to disable all tracking to Optimizely.
|
|
160
|
+
* @param props.disableGadget - Set to `true` to hide the developer gadget.
|
|
161
|
+
* @param props.debug - Set to `true` to enable verbose debug logging.
|
|
162
|
+
* @param props.children - Nested React content to render within the Optimizely One context.
|
|
163
|
+
* @returns A provider component that wraps children with Optimizely One context.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```tsx
|
|
167
|
+
* // Basic usage in Next.js layout
|
|
168
|
+
* import { OptimizelyOne } from '@remkoj/optimizely-one-nextjs'
|
|
169
|
+
*
|
|
170
|
+
* export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
171
|
+
* return (
|
|
172
|
+
* <html>
|
|
173
|
+
* <body>
|
|
174
|
+
* <OptimizelyOne>
|
|
175
|
+
* <Header />
|
|
176
|
+
* <main>{children}</main>
|
|
177
|
+
* <Footer />
|
|
178
|
+
* </OptimizelyOne>
|
|
179
|
+
* </body>
|
|
180
|
+
* </html>
|
|
181
|
+
* )
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```tsx
|
|
187
|
+
* // Development configuration with debug and tracking control
|
|
188
|
+
* import { OptimizelyOne } from '@remkoj/optimizely-one-nextjs'
|
|
189
|
+
*
|
|
190
|
+
* const isDevelopment = process.env.NODE_ENV === 'development'
|
|
191
|
+
*
|
|
192
|
+
* export function RootProvider({ children }: { children: React.ReactNode }) {
|
|
193
|
+
* return (
|
|
194
|
+
* <OptimizelyOne
|
|
195
|
+
* debug={isDevelopment}
|
|
196
|
+
* disableAutoTracking={false}
|
|
197
|
+
* disableTracking={false}
|
|
198
|
+
* disableGadget={!isDevelopment}
|
|
199
|
+
* >
|
|
200
|
+
* {children}
|
|
201
|
+
* </OptimizelyOne>
|
|
202
|
+
* )
|
|
203
|
+
* }
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```tsx
|
|
208
|
+
* // Privacy-first configuration with tracking disabled
|
|
209
|
+
* <OptimizelyOne
|
|
210
|
+
* disableTracking
|
|
211
|
+
* disableAutoTracking
|
|
212
|
+
* disableGadget
|
|
213
|
+
* debug={false}
|
|
214
|
+
* >
|
|
215
|
+
* <App />
|
|
216
|
+
* </OptimizelyOne>
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
export declare function OptimizelyOne({ config: partialConfig, apiPath, disableAutoTracking, disableTracking, disableGadget, debug: requestedDebug, children, gadgetRefreshInterval }: OptimizelyOneProps): import("react/jsx-runtime").JSX.Element;
|