@sitecore-cloudsdk/events 0.3.1 → 0.4.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 +31 -59
- package/dist/cjs/package.json +3 -3
- package/dist/cjs/src/browser.d.ts +4 -3
- package/dist/cjs/src/browser.js +8 -5
- package/dist/cjs/src/lib/consts.d.ts +7 -6
- package/dist/cjs/src/lib/consts.js +9 -8
- package/dist/cjs/src/lib/eventStorage/addToEventQueue.js +23 -10
- package/dist/cjs/src/lib/eventStorage/clearEventQueue.js +1 -1
- package/dist/cjs/src/lib/eventStorage/eventStorage.js +3 -3
- package/dist/cjs/src/lib/eventStorage/processEventQueue.js +1 -1
- package/dist/cjs/src/lib/events/base-event.js +3 -3
- package/dist/cjs/src/lib/events/custom-event/custom-event.d.ts +1 -1
- package/dist/cjs/src/lib/events/custom-event/event.d.ts +1 -1
- package/dist/cjs/src/lib/events/custom-event/event.js +24 -12
- package/dist/cjs/src/lib/events/custom-event/eventServer.d.ts +2 -2
- package/dist/cjs/src/lib/events/custom-event/eventServer.js +16 -7
- package/dist/cjs/src/lib/events/custom-event/form.d.ts +3 -3
- package/dist/cjs/src/lib/events/custom-event/form.js +43 -21
- package/dist/cjs/src/lib/events/identity/identity-event.d.ts +1 -1
- package/dist/cjs/src/lib/events/identity/identity.d.ts +1 -1
- package/dist/cjs/src/lib/events/identity/identity.js +24 -12
- package/dist/cjs/src/lib/events/identity/identityServer.d.ts +2 -2
- package/dist/cjs/src/lib/events/identity/identityServer.js +17 -6
- package/dist/cjs/src/lib/events/page-view/page-view-event.d.ts +1 -1
- package/dist/cjs/src/lib/events/page-view/page-view-server.d.ts +2 -2
- package/dist/cjs/src/lib/events/page-view/page-view-server.js +17 -6
- package/dist/cjs/src/lib/events/page-view/page-view.d.ts +1 -1
- package/dist/cjs/src/lib/events/page-view/page-view.js +26 -13
- package/dist/cjs/src/lib/events/send-event/sendEvent.d.ts +1 -1
- package/dist/cjs/src/lib/events/send-event/sendEvent.js +7 -7
- package/dist/cjs/src/lib/getBrowserId/getBrowserId.d.ts +8 -0
- package/dist/cjs/src/lib/getBrowserId/getBrowserId.js +16 -0
- package/dist/cjs/src/lib/getGuestId/getGuestId.d.ts +6 -3
- package/dist/cjs/src/lib/getGuestId/getGuestId.js +19 -8
- package/dist/cjs/src/lib/init/browser/initializer.d.ts +13 -0
- package/dist/cjs/src/lib/init/browser/initializer.js +48 -0
- package/dist/cjs/src/lib/init/server/initializer.d.ts +11 -0
- package/dist/cjs/src/lib/init/server/initializer.js +26 -0
- package/dist/cjs/src/lib/initializer/browser/initializer.d.ts +11 -22
- package/dist/cjs/src/lib/initializer/browser/initializer.js +20 -31
- package/dist/cjs/src/lib/initializer/server/initializer.d.ts +11 -8
- package/dist/cjs/src/lib/initializer/server/initializer.js +17 -17
- package/dist/cjs/src/server.d.ts +3 -2
- package/dist/cjs/src/server.js +6 -3
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/package.json +3 -3
- package/dist/esm/src/browser.d.ts +4 -3
- package/dist/esm/src/browser.js +4 -3
- package/dist/esm/src/lib/consts.d.ts +7 -6
- package/dist/esm/src/lib/consts.js +8 -7
- package/dist/esm/src/lib/eventStorage/addToEventQueue.js +24 -11
- package/dist/esm/src/lib/eventStorage/clearEventQueue.js +1 -1
- package/dist/esm/src/lib/eventStorage/eventStorage.js +1 -1
- package/dist/esm/src/lib/eventStorage/processEventQueue.js +1 -1
- package/dist/esm/src/lib/events/base-event.js +1 -1
- package/dist/esm/src/lib/events/custom-event/custom-event.d.ts +1 -1
- package/dist/esm/src/lib/events/custom-event/event.d.ts +1 -1
- package/dist/esm/src/lib/events/custom-event/event.js +25 -13
- package/dist/esm/src/lib/events/custom-event/eventServer.d.ts +2 -2
- package/dist/esm/src/lib/events/custom-event/eventServer.js +17 -8
- package/dist/esm/src/lib/events/custom-event/form.d.ts +3 -3
- package/dist/esm/src/lib/events/custom-event/form.js +44 -22
- package/dist/esm/src/lib/events/identity/identity-event.d.ts +1 -1
- package/dist/esm/src/lib/events/identity/identity.d.ts +1 -1
- package/dist/esm/src/lib/events/identity/identity.js +25 -13
- package/dist/esm/src/lib/events/identity/identityServer.d.ts +2 -2
- package/dist/esm/src/lib/events/identity/identityServer.js +17 -6
- package/dist/esm/src/lib/events/page-view/page-view-event.d.ts +1 -1
- package/dist/esm/src/lib/events/page-view/page-view-server.d.ts +2 -2
- package/dist/esm/src/lib/events/page-view/page-view-server.js +18 -7
- package/dist/esm/src/lib/events/page-view/page-view.d.ts +1 -1
- package/dist/esm/src/lib/events/page-view/page-view.js +27 -14
- package/dist/esm/src/lib/events/send-event/sendEvent.d.ts +1 -1
- package/dist/esm/src/lib/events/send-event/sendEvent.js +3 -3
- package/dist/esm/src/lib/getBrowserId/getBrowserId.d.ts +8 -0
- package/dist/esm/src/lib/getBrowserId/getBrowserId.js +12 -0
- package/dist/esm/src/lib/getGuestId/getGuestId.d.ts +6 -3
- package/dist/esm/src/lib/getGuestId/getGuestId.js +20 -9
- package/dist/esm/src/lib/init/browser/initializer.d.ts +13 -0
- package/dist/esm/src/lib/init/browser/initializer.js +43 -0
- package/dist/esm/src/lib/init/server/initializer.d.ts +11 -0
- package/dist/esm/src/lib/init/server/initializer.js +22 -0
- package/dist/esm/src/lib/initializer/browser/initializer.d.ts +11 -22
- package/dist/esm/src/lib/initializer/browser/initializer.js +18 -29
- package/dist/esm/src/lib/initializer/server/initializer.d.ts +11 -8
- package/dist/esm/src/lib/initializer/server/initializer.js +15 -16
- package/dist/esm/src/server.d.ts +3 -2
- package/dist/esm/src/server.js +3 -2
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.identity = void 0;
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
5
|
+
const utils_1 = require("@sitecore-cloudsdk/utils");
|
|
6
6
|
const consts_1 = require("../../consts");
|
|
7
|
-
const
|
|
8
|
-
const initializer_1 = require("../../initializer/browser/initializer");
|
|
7
|
+
const initializer_1 = require("../../init/browser/initializer");
|
|
9
8
|
const sendEvent_1 = require("../send-event/sendEvent");
|
|
9
|
+
const identity_event_1 = require("./identity-event");
|
|
10
10
|
/**
|
|
11
11
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
12
12
|
*
|
|
@@ -15,13 +15,25 @@ const sendEvent_1 = require("../send-event/sendEvent");
|
|
|
15
15
|
*/
|
|
16
16
|
async function identity(identityData) {
|
|
17
17
|
await (0, initializer_1.awaitInit)();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
if ((0, internal_1.getEnabledPackageBrowser)(consts_1.PACKAGE_NAME)?.initState) {
|
|
19
|
+
const settings = (0, internal_1.getCloudSDKSettingsBrowser)();
|
|
20
|
+
const id = (0, utils_1.getCookieValueClientSide)(settings.cookieSettings.name.browserId);
|
|
21
|
+
return new identity_event_1.IdentityEvent({
|
|
22
|
+
id,
|
|
23
|
+
identityData,
|
|
24
|
+
sendEvent: sendEvent_1.sendEvent,
|
|
25
|
+
settings: settings
|
|
26
|
+
}).send();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const settings = (0, internal_1.handleGetSettingsError)(internal_1.getSettings, consts_1.ErrorMessages.IE_0014);
|
|
30
|
+
const id = (0, internal_1.getBrowserId)();
|
|
31
|
+
return new identity_event_1.IdentityEvent({
|
|
32
|
+
id,
|
|
33
|
+
identityData,
|
|
34
|
+
sendEvent: sendEvent_1.sendEvent,
|
|
35
|
+
settings
|
|
36
|
+
}).send();
|
|
37
|
+
}
|
|
26
38
|
}
|
|
27
39
|
exports.identity = identity;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { IdentityData } from './identity-event';
|
|
1
|
+
import { type EPResponse } from '@sitecore-cloudsdk/core/internal';
|
|
3
2
|
import type { Request } from '@sitecore-cloudsdk/utils';
|
|
3
|
+
import type { IdentityData } from './identity-event';
|
|
4
4
|
/**
|
|
5
5
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
6
6
|
*
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.identityServer = void 0;
|
|
5
|
-
|
|
4
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
6
|
+
const internal_2 = require("@sitecore-cloudsdk/core/internal");
|
|
6
7
|
const consts_1 = require("../../consts");
|
|
7
|
-
const identity_event_1 = require("./identity-event");
|
|
8
8
|
const sendEvent_1 = require("../send-event/sendEvent");
|
|
9
|
+
const identity_event_1 = require("./identity-event");
|
|
9
10
|
/**
|
|
10
11
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
11
12
|
*
|
|
@@ -14,10 +15,20 @@ const sendEvent_1 = require("../send-event/sendEvent");
|
|
|
14
15
|
* @returns The response object that Sitecore EP returns
|
|
15
16
|
*/
|
|
16
17
|
function identityServer(request, identityData) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let settings;
|
|
19
|
+
let browserId;
|
|
20
|
+
if (internal_1.builderInstanceServer) {
|
|
21
|
+
if (!(0, internal_2.getEnabledPackageServer)(consts_1.PACKAGE_NAME))
|
|
22
|
+
throw new Error(consts_1.ErrorMessages.IE_0015);
|
|
23
|
+
settings = (0, internal_2.getCloudSDKSettingsServer)();
|
|
24
|
+
browserId = (0, internal_1.getCookieValueFromRequest)(request, settings.cookieSettings.name.browserId);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
settings = (0, internal_1.handleGetSettingsError)(internal_2.getSettingsServer, consts_1.ErrorMessages.IE_0015);
|
|
28
|
+
browserId = (0, internal_1.getCookieValueFromRequest)(request, settings.cookieSettings.cookieNames.browserId);
|
|
29
|
+
}
|
|
19
30
|
return new identity_event_1.IdentityEvent({
|
|
20
|
-
id,
|
|
31
|
+
id: browserId,
|
|
21
32
|
identityData,
|
|
22
33
|
sendEvent: sendEvent_1.sendEvent,
|
|
23
34
|
settings: settings
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
|
|
1
|
+
import type { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core/internal';
|
|
2
2
|
import type { EventAttributesInput, ExtensionData } from '../common-interfaces';
|
|
3
3
|
import type { FlattenedObject, NestedObject } from '@sitecore-cloudsdk/utils';
|
|
4
4
|
import { BaseEvent } from '../base-event';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { PageViewData } from './page-view-event';
|
|
1
|
+
import { type EPResponse } from '@sitecore-cloudsdk/core/internal';
|
|
3
2
|
import type { Request } from '@sitecore-cloudsdk/utils';
|
|
3
|
+
import type { PageViewData } from './page-view-event';
|
|
4
4
|
/**
|
|
5
5
|
* A function that sends a VIEW event to SitecoreCloud API
|
|
6
6
|
*
|
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pageViewServer = void 0;
|
|
4
4
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
6
|
+
const internal_2 = require("@sitecore-cloudsdk/core/internal");
|
|
6
7
|
const consts_1 = require("../../consts");
|
|
7
|
-
const page_view_event_1 = require("./page-view-event");
|
|
8
8
|
const sendEvent_1 = require("../send-event/sendEvent");
|
|
9
|
+
const page_view_event_1 = require("./page-view-event");
|
|
9
10
|
/**
|
|
10
11
|
* A function that sends a VIEW event to SitecoreCloud API
|
|
11
12
|
*
|
|
@@ -14,16 +15,26 @@ const sendEvent_1 = require("../send-event/sendEvent");
|
|
|
14
15
|
* @returns The response object that Sitecore EP returns
|
|
15
16
|
*/
|
|
16
17
|
function pageViewServer(request, pageViewData) {
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
let settings;
|
|
19
|
+
let browserId;
|
|
19
20
|
// Host is irrelevant but necessary to support relative URL
|
|
20
21
|
const requestUrl = new URL(request.url, `https://localhost`);
|
|
22
|
+
if (internal_2.builderInstanceServer) {
|
|
23
|
+
if (!(0, internal_2.getEnabledPackageServer)(consts_1.PACKAGE_NAME))
|
|
24
|
+
throw new Error(consts_1.ErrorMessages.IE_0015);
|
|
25
|
+
settings = (0, internal_2.getCloudSDKSettingsServer)();
|
|
26
|
+
browserId = (0, internal_2.getCookieValueFromRequest)(request, settings.cookieSettings.name.browserId);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
settings = (0, internal_1.handleGetSettingsError)(internal_2.getSettingsServer, consts_1.ErrorMessages.IE_0015);
|
|
30
|
+
browserId = (0, internal_2.getCookieValueFromRequest)(request, settings.cookieSettings.cookieNames.browserId);
|
|
31
|
+
}
|
|
21
32
|
return new page_view_event_1.PageViewEvent({
|
|
22
|
-
id,
|
|
33
|
+
id: browserId,
|
|
23
34
|
pageViewData,
|
|
24
35
|
searchParams: requestUrl.search,
|
|
25
36
|
sendEvent: sendEvent_1.sendEvent,
|
|
26
|
-
settings
|
|
37
|
+
settings: settings
|
|
27
38
|
}).send();
|
|
28
39
|
}
|
|
29
40
|
exports.pageViewServer = pageViewServer;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pageView = void 0;
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
5
|
+
const utils_1 = require("@sitecore-cloudsdk/utils");
|
|
6
6
|
const consts_1 = require("../../consts");
|
|
7
|
-
const
|
|
8
|
-
const initializer_1 = require("../../initializer/browser/initializer");
|
|
7
|
+
const initializer_1 = require("../../init/browser/initializer");
|
|
9
8
|
const sendEvent_1 = require("../send-event/sendEvent");
|
|
9
|
+
const page_view_event_1 = require("./page-view-event");
|
|
10
10
|
/**
|
|
11
11
|
* A function that sends a VIEW event to SitecoreCloud API
|
|
12
12
|
*
|
|
@@ -16,14 +16,27 @@ const sendEvent_1 = require("../send-event/sendEvent");
|
|
|
16
16
|
*/
|
|
17
17
|
async function pageView(pageViewData) {
|
|
18
18
|
await (0, initializer_1.awaitInit)();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
if ((0, internal_1.getEnabledPackageBrowser)(consts_1.PACKAGE_NAME)?.initState) {
|
|
20
|
+
const settings = (0, internal_1.getCloudSDKSettingsBrowser)();
|
|
21
|
+
const id = (0, utils_1.getCookieValueClientSide)(settings.cookieSettings.name.browserId);
|
|
22
|
+
return new page_view_event_1.PageViewEvent({
|
|
23
|
+
id,
|
|
24
|
+
pageViewData,
|
|
25
|
+
searchParams: window.location.search,
|
|
26
|
+
sendEvent: sendEvent_1.sendEvent,
|
|
27
|
+
settings: settings
|
|
28
|
+
}).send();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const settings = (0, internal_1.handleGetSettingsError)(internal_1.getSettings, consts_1.ErrorMessages.IE_0014);
|
|
32
|
+
const id = (0, internal_1.getBrowserId)();
|
|
33
|
+
return new page_view_event_1.PageViewEvent({
|
|
34
|
+
id,
|
|
35
|
+
pageViewData,
|
|
36
|
+
searchParams: window.location.search,
|
|
37
|
+
sendEvent: sendEvent_1.sendEvent,
|
|
38
|
+
settings
|
|
39
|
+
}).send();
|
|
40
|
+
}
|
|
28
41
|
}
|
|
29
42
|
exports.pageView = pageView;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BasePayload, CustomEventPayload, IdentityEventPayload, PageViewEventPayload } from '..';
|
|
2
|
-
import type { EPResponse, Settings } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { EPResponse, Settings } from '@sitecore-cloudsdk/core/internal';
|
|
3
3
|
/**
|
|
4
4
|
* This factory function sends an event to Edge Proxy
|
|
5
5
|
* @param body - The event data to send
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.sendEvent = void 0;
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
6
6
|
const consts_1 = require("../../consts");
|
|
7
7
|
/**
|
|
8
8
|
* This factory function sends an event to Edge Proxy
|
|
@@ -11,7 +11,7 @@ const consts_1 = require("../../consts");
|
|
|
11
11
|
*/
|
|
12
12
|
async function sendEvent(body, settings) {
|
|
13
13
|
// eslint-disable-next-line max-len
|
|
14
|
-
const eventUrl = `${settings.sitecoreEdgeUrl}/v1/events/${
|
|
14
|
+
const eventUrl = `${settings.sitecoreEdgeUrl}/v1/events/${internal_1.API_VERSION}/events?sitecoreContextId=${settings.sitecoreEdgeContextId}&siteId=${settings.siteName}`;
|
|
15
15
|
const startTimestamp = Date.now();
|
|
16
16
|
let debugResponse = {};
|
|
17
17
|
const fetchOptions = {
|
|
@@ -20,24 +20,24 @@ async function sendEvent(body, settings) {
|
|
|
20
20
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
21
21
|
'Content-Type': 'application/json',
|
|
22
22
|
'X-Client-Software-ID': consts_1.X_CLIENT_SOFTWARE_ID,
|
|
23
|
-
'X-Library-Version': consts_1.
|
|
23
|
+
'X-Library-Version': consts_1.PACKAGE_VERSION
|
|
24
24
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
25
25
|
},
|
|
26
26
|
method: 'POST'
|
|
27
27
|
};
|
|
28
|
-
(0,
|
|
28
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('Events request: %s with options: %O', eventUrl, fetchOptions);
|
|
29
29
|
return await fetch(eventUrl, fetchOptions)
|
|
30
30
|
.then((response) => {
|
|
31
|
-
debugResponse = (0,
|
|
31
|
+
debugResponse = (0, internal_1.processDebugResponse)(consts_1.EVENTS_NAMESPACE, response);
|
|
32
32
|
return response.json();
|
|
33
33
|
})
|
|
34
34
|
.then((data) => {
|
|
35
35
|
debugResponse.body = data;
|
|
36
|
-
(0,
|
|
36
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('Events response in %dms : %O', Date.now() - startTimestamp, debugResponse);
|
|
37
37
|
return data;
|
|
38
38
|
})
|
|
39
39
|
.catch((error) => {
|
|
40
|
-
(0,
|
|
40
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('Error: events response: %O', error);
|
|
41
41
|
return null;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the browser ID from the cookie
|
|
3
|
+
* @returns The browser ID if the cookie exists
|
|
4
|
+
* @deprecated Cloud SDK v0.4 introduces a new getBrowserId function. If you are upgrading from v0.3, we recommend that
|
|
5
|
+
* you use the getBrowserId function that is exposed from \@sitecore-cloudsdk/core/browser. The v0.3 function will be
|
|
6
|
+
* deprecated and removed in a future Cloud SDK release.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getBrowserId(): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBrowserId = void 0;
|
|
4
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
+
const browser_1 = require("@sitecore-cloudsdk/core/browser");
|
|
6
|
+
/**
|
|
7
|
+
* Get the browser ID from the cookie
|
|
8
|
+
* @returns The browser ID if the cookie exists
|
|
9
|
+
* @deprecated Cloud SDK v0.4 introduces a new getBrowserId function. If you are upgrading from v0.3, we recommend that
|
|
10
|
+
* you use the getBrowserId function that is exposed from \@sitecore-cloudsdk/core/browser. The v0.3 function will be
|
|
11
|
+
* deprecated and removed in a future Cloud SDK release.
|
|
12
|
+
*/
|
|
13
|
+
function getBrowserId() {
|
|
14
|
+
return (0, browser_1.getBrowserId)();
|
|
15
|
+
}
|
|
16
|
+
exports.getBrowserId = getBrowserId;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A function that returns the guest
|
|
3
|
-
* @returns - A promise that resolves with the guest
|
|
4
|
-
* @throws - Will throw an error if the
|
|
2
|
+
* A function that returns the guest ID.
|
|
3
|
+
* @returns - A promise that resolves with the guest ID
|
|
4
|
+
* @throws - Will throw an error if the sitecoreEdgeContextId is incorrect
|
|
5
|
+
* @deprecated Cloud SDK v0.4 introduces a new getGuestId function. If you are upgrading from v0.3, we recommend that
|
|
6
|
+
* you use the getGuestId function that is exposed from \@sitecore-cloudsdk/core/browser. The v0.3 function will be
|
|
7
|
+
* deprecated and removed in a future Cloud SDK release.
|
|
5
8
|
*/
|
|
6
9
|
export declare function getGuestId(): Promise<string>;
|
|
@@ -2,18 +2,29 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getGuestId = void 0;
|
|
4
4
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
-
const
|
|
5
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
6
|
+
const utils_1 = require("@sitecore-cloudsdk/utils");
|
|
6
7
|
const consts_1 = require("../consts");
|
|
7
|
-
const initializer_1 = require("../
|
|
8
|
+
const initializer_1 = require("../init/browser/initializer");
|
|
8
9
|
/**
|
|
9
|
-
* A function that returns the guest
|
|
10
|
-
* @returns - A promise that resolves with the guest
|
|
11
|
-
* @throws - Will throw an error if the
|
|
10
|
+
* A function that returns the guest ID.
|
|
11
|
+
* @returns - A promise that resolves with the guest ID
|
|
12
|
+
* @throws - Will throw an error if the sitecoreEdgeContextId is incorrect
|
|
13
|
+
* @deprecated Cloud SDK v0.4 introduces a new getGuestId function. If you are upgrading from v0.3, we recommend that
|
|
14
|
+
* you use the getGuestId function that is exposed from \@sitecore-cloudsdk/core/browser. The v0.3 function will be
|
|
15
|
+
* deprecated and removed in a future Cloud SDK release.
|
|
12
16
|
*/
|
|
13
17
|
async function getGuestId() {
|
|
14
18
|
await (0, initializer_1.awaitInit)();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
if ((0, internal_1.getEnabledPackageBrowser)(consts_1.PACKAGE_NAME)?.initState) {
|
|
20
|
+
const settings = (0, internal_1.getCloudSDKSettingsBrowser)();
|
|
21
|
+
const id = (0, utils_1.getCookieValueClientSide)(settings.cookieSettings.name.browserId);
|
|
22
|
+
return (0, internal_1.getGuestId)(id, settings.sitecoreEdgeContextId, settings.sitecoreEdgeUrl);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
const settings = (0, internal_1.handleGetSettingsError)(internal_1.getSettings, consts_1.ErrorMessages.IE_0014);
|
|
26
|
+
const id = (0, internal_1.getBrowserId)();
|
|
27
|
+
return (0, internal_1.getGuestId)(id, settings.sitecoreEdgeContextId, settings.sitecoreEdgeUrl);
|
|
28
|
+
}
|
|
18
29
|
}
|
|
19
30
|
exports.getGuestId = getGuestId;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BrowserSettings } from '@sitecore-cloudsdk/core/internal';
|
|
2
|
+
export declare let initPromise: Promise<void> | null;
|
|
3
|
+
/**
|
|
4
|
+
* Initiates the Events library using the global settings added by the developer
|
|
5
|
+
* @param settings - Global settings added by the developer
|
|
6
|
+
* @returns A promise that resolves with an object that handles the library functionality
|
|
7
|
+
* @deprecated Cloud SDK v0.4 introduces new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code. The v0.3 initialization logic will be deprecated and removed in a future Cloud SDK release.
|
|
8
|
+
*/
|
|
9
|
+
export declare function init(settings: BrowserSettings): Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* A function that handles the async browser init logic. Throws an error or awaits the promise.
|
|
12
|
+
*/
|
|
13
|
+
export declare function awaitInit(): Promise<void>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awaitInit = exports.init = exports.initPromise = void 0;
|
|
4
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
+
const consts_1 = require("../../consts");
|
|
6
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
7
|
+
exports.initPromise = null;
|
|
8
|
+
/* eslint-disable max-len */
|
|
9
|
+
/**
|
|
10
|
+
* Initiates the Events library using the global settings added by the developer
|
|
11
|
+
* @param settings - Global settings added by the developer
|
|
12
|
+
* @returns A promise that resolves with an object that handles the library functionality
|
|
13
|
+
* @deprecated Cloud SDK v0.4 introduces new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code. The v0.3 initialization logic will be deprecated and removed in a future Cloud SDK release.
|
|
14
|
+
*/
|
|
15
|
+
/* eslint-enable max-len */
|
|
16
|
+
async function init(settings) {
|
|
17
|
+
if (typeof window === 'undefined')
|
|
18
|
+
throw new Error(consts_1.ErrorMessages.IE_0001);
|
|
19
|
+
try {
|
|
20
|
+
exports.initPromise = (0, internal_1.initCore)(settings);
|
|
21
|
+
await exports.initPromise;
|
|
22
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('eventsClient library initialized');
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('Error on initializing eventsClient library: %o', error);
|
|
26
|
+
exports.initPromise = null;
|
|
27
|
+
throw new Error(error);
|
|
28
|
+
}
|
|
29
|
+
window.Engage = {
|
|
30
|
+
...window.Engage,
|
|
31
|
+
getBrowserId: () => (0, internal_1.getBrowserId)(),
|
|
32
|
+
versions: {
|
|
33
|
+
...window.Engage?.versions,
|
|
34
|
+
events: consts_1.PACKAGE_VERSION
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.init = init;
|
|
39
|
+
/**
|
|
40
|
+
* A function that handles the async browser init logic. Throws an error or awaits the promise.
|
|
41
|
+
*/
|
|
42
|
+
async function awaitInit() {
|
|
43
|
+
const initState = (0, internal_1.getEnabledPackageBrowser)(consts_1.PACKAGE_NAME)?.initState;
|
|
44
|
+
if (exports.initPromise === null && !initState)
|
|
45
|
+
throw new Error(consts_1.ErrorMessages.IE_0014);
|
|
46
|
+
exports.initPromise ? await exports.initPromise : await initState;
|
|
47
|
+
}
|
|
48
|
+
exports.awaitInit = awaitInit;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Request, Response } from '@sitecore-cloudsdk/utils';
|
|
2
|
+
import type { ServerSettings } from '@sitecore-cloudsdk/core/internal';
|
|
3
|
+
/**
|
|
4
|
+
* Initiates the server Events library using the global settings added by the developer
|
|
5
|
+
* @param request - The request object, either a Middleware Request or an HTTP Request
|
|
6
|
+
* @param response - The response object, either a Middleware Next Response or an HTTP Response
|
|
7
|
+
* @param settings - Global settings added by the developer
|
|
8
|
+
* @returns A promise that resolves with an object that handles the library functionality
|
|
9
|
+
* @deprecated Cloud SDK v0.4 introduces new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code. The v0.3 initialization logic will be deprecated and removed in a future Cloud SDK release.
|
|
10
|
+
*/
|
|
11
|
+
export declare function initServer(request: Request, response: Response, settings: ServerSettings): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initServer = void 0;
|
|
4
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
5
|
+
const consts_1 = require("../../consts");
|
|
6
|
+
/* eslint-disable max-len */
|
|
7
|
+
/**
|
|
8
|
+
* Initiates the server Events library using the global settings added by the developer
|
|
9
|
+
* @param request - The request object, either a Middleware Request or an HTTP Request
|
|
10
|
+
* @param response - The response object, either a Middleware Next Response or an HTTP Response
|
|
11
|
+
* @param settings - Global settings added by the developer
|
|
12
|
+
* @returns A promise that resolves with an object that handles the library functionality
|
|
13
|
+
* @deprecated Cloud SDK v0.4 introduces new initialization logic. If you are upgrading from v0.3, we recommend that you upgrade your initialization code. The v0.3 initialization logic will be deprecated and removed in a future Cloud SDK release.
|
|
14
|
+
*/
|
|
15
|
+
/* eslint-enable max-len */
|
|
16
|
+
async function initServer(request, response, settings) {
|
|
17
|
+
try {
|
|
18
|
+
await (0, internal_1.initCoreServer)(settings, request, response);
|
|
19
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('eventsServer library initialized');
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('Error on initializing eventsServer library with error: %o', error);
|
|
23
|
+
throw new Error(error);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.initServer = initServer;
|
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
Engage: {
|
|
6
|
-
[x: string]: any;
|
|
7
|
-
getBrowserId?: () => string;
|
|
8
|
-
versions?: {
|
|
9
|
-
personalize?: string;
|
|
10
|
-
events?: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Initiates the Events library using the global settings added by the developer
|
|
17
|
-
* @param settings - Global settings added by the developer
|
|
18
|
-
* @returns A promise that resolves with an object that handles the library functionality
|
|
19
|
-
*/
|
|
20
|
-
export declare function init(settings: BrowserSettings): Promise<void>;
|
|
1
|
+
import { CloudSDKBrowserInitializer } from '@sitecore-cloudsdk/core/browser';
|
|
2
|
+
export declare function sideEffects(): Promise<void>;
|
|
21
3
|
/**
|
|
22
|
-
*
|
|
4
|
+
* Makes the functionality of the events package available.
|
|
5
|
+
*
|
|
6
|
+
* @returns An instance of {@link CloudSDKBrowserInitializer}
|
|
23
7
|
*/
|
|
24
|
-
export declare function
|
|
8
|
+
export declare function addEvents(this: CloudSDKBrowserInitializer): CloudSDKBrowserInitializer;
|
|
9
|
+
declare module '@sitecore-cloudsdk/core/browser' {
|
|
10
|
+
interface CloudSDKBrowserInitializer {
|
|
11
|
+
addEvents: typeof addEvents;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.addEvents = exports.sideEffects = void 0;
|
|
4
4
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
|
+
const browser_1 = require("@sitecore-cloudsdk/core/browser");
|
|
6
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
7
|
+
const utils_1 = require("@sitecore-cloudsdk/utils");
|
|
5
8
|
const consts_1 = require("../../consts");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Initiates the Events library using the global settings added by the developer
|
|
10
|
-
* @param settings - Global settings added by the developer
|
|
11
|
-
* @returns A promise that resolves with an object that handles the library functionality
|
|
12
|
-
*/
|
|
13
|
-
async function init(settings) {
|
|
14
|
-
if (typeof window === 'undefined')
|
|
15
|
-
throw new Error(consts_1.ErrorMessages.IE_0001);
|
|
16
|
-
try {
|
|
17
|
-
exports.initPromise = (0, core_1.initCore)(settings);
|
|
18
|
-
await exports.initPromise;
|
|
19
|
-
(0, core_1.debug)(consts_1.EVENTS_NAMESPACE)('eventsClient library initialized');
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
(0, core_1.debug)(consts_1.EVENTS_NAMESPACE)('Error on initializing eventsClient library: %o', error);
|
|
23
|
-
exports.initPromise = null;
|
|
24
|
-
throw new Error(error);
|
|
25
|
-
}
|
|
9
|
+
async function sideEffects() {
|
|
10
|
+
window.Engage ?? (window.Engage = {});
|
|
26
11
|
window.Engage = {
|
|
27
12
|
...window.Engage,
|
|
28
|
-
getBrowserId: () => (0,
|
|
13
|
+
getBrowserId: () => (0, utils_1.getCookieValueClientSide)((0, internal_1.getCloudSDKSettingsBrowser)().cookieSettings.name.browserId),
|
|
29
14
|
versions: {
|
|
30
|
-
...window.Engage
|
|
31
|
-
events: consts_1.
|
|
15
|
+
...window.Engage.versions,
|
|
16
|
+
events: consts_1.PACKAGE_VERSION
|
|
32
17
|
}
|
|
33
18
|
};
|
|
19
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('eventsClient library initialized');
|
|
34
20
|
}
|
|
35
|
-
exports.
|
|
21
|
+
exports.sideEffects = sideEffects;
|
|
36
22
|
/**
|
|
37
|
-
*
|
|
23
|
+
* Makes the functionality of the events package available.
|
|
24
|
+
*
|
|
25
|
+
* @returns An instance of {@link CloudSDKBrowserInitializer}
|
|
38
26
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
function addEvents() {
|
|
28
|
+
const eventsInitializer = new internal_1.PackageInitializer({ sideEffects });
|
|
29
|
+
internal_1.enabledPackagesBrowser.set(consts_1.PACKAGE_NAME, eventsInitializer);
|
|
30
|
+
return this;
|
|
43
31
|
}
|
|
44
|
-
exports.
|
|
32
|
+
exports.addEvents = addEvents;
|
|
33
|
+
browser_1.CloudSDKBrowserInitializer.prototype.addEvents = addEvents;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { CloudSDKServerInitializer } from '@sitecore-cloudsdk/core/server';
|
|
2
|
+
export declare function sideEffects(): Promise<void>;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param settings - Global settings added by the developer
|
|
8
|
-
* @returns A promise that resolves with an object that handles the library functionality
|
|
4
|
+
* Makes the functionality of the events package available.
|
|
5
|
+
*
|
|
6
|
+
* @returns An instance of {@link CloudSDKServerInitializer}
|
|
9
7
|
*/
|
|
10
|
-
export declare function
|
|
8
|
+
export declare function addEvents(this: CloudSDKServerInitializer): CloudSDKServerInitializer;
|
|
9
|
+
declare module '@sitecore-cloudsdk/core/server' {
|
|
10
|
+
interface CloudSDKServerInitializer {
|
|
11
|
+
addEvents: typeof addEvents;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.addEvents = exports.sideEffects = void 0;
|
|
4
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
5
5
|
const consts_1 = require("../../consts");
|
|
6
|
+
const internal_1 = require("@sitecore-cloudsdk/core/internal");
|
|
7
|
+
const server_1 = require("@sitecore-cloudsdk/core/server");
|
|
8
|
+
async function sideEffects() {
|
|
9
|
+
(0, internal_1.debug)(consts_1.EVENTS_NAMESPACE)('eventsServer library initialized');
|
|
10
|
+
}
|
|
11
|
+
exports.sideEffects = sideEffects;
|
|
6
12
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @
|
|
10
|
-
* @param settings - Global settings added by the developer
|
|
11
|
-
* @returns A promise that resolves with an object that handles the library functionality
|
|
13
|
+
* Makes the functionality of the events package available.
|
|
14
|
+
*
|
|
15
|
+
* @returns An instance of {@link CloudSDKServerInitializer}
|
|
12
16
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
(0, core_1.debug)(consts_1.EVENTS_NAMESPACE)('Error on initializing eventsServer library with error: %o', error);
|
|
20
|
-
throw new Error(error);
|
|
21
|
-
}
|
|
17
|
+
function addEvents() {
|
|
18
|
+
const eventsInitializer = new internal_1.PackageInitializerServer({ sideEffects });
|
|
19
|
+
internal_1.enabledPackagesServer.set(consts_1.PACKAGE_NAME, eventsInitializer);
|
|
20
|
+
return this;
|
|
22
21
|
}
|
|
23
|
-
exports.
|
|
22
|
+
exports.addEvents = addEvents;
|
|
23
|
+
server_1.CloudSDKServerInitializer.prototype.addEvents = addEvents;
|