@sitecore-cloudsdk/events 0.2.4 → 0.3.1-rc.0
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 +8 -30
- package/dist/cjs/package.json +5 -6
- package/dist/cjs/src/browser.d.ts +1 -1
- package/dist/cjs/src/lib/consts.d.ts +5 -1
- package/dist/cjs/src/lib/consts.js +9 -3
- package/dist/cjs/src/lib/eventStorage/addToEventQueue.d.ts +3 -5
- package/dist/cjs/src/lib/eventStorage/addToEventQueue.js +5 -9
- package/dist/cjs/src/lib/eventStorage/eventStorage.d.ts +2 -2
- package/dist/cjs/src/lib/eventStorage/eventStorage.js +3 -6
- package/dist/cjs/src/lib/events/base-event.d.ts +3 -2
- package/dist/cjs/src/lib/events/base-event.js +3 -2
- package/dist/cjs/src/lib/events/common-interfaces.d.ts +4 -21
- package/dist/cjs/src/lib/events/custom-event/custom-event.d.ts +15 -14
- package/dist/cjs/src/lib/events/custom-event/custom-event.js +17 -10
- package/dist/cjs/src/lib/events/custom-event/event.d.ts +4 -7
- package/dist/cjs/src/lib/events/custom-event/event.js +4 -8
- package/dist/cjs/src/lib/events/custom-event/eventServer.d.ts +6 -8
- package/dist/cjs/src/lib/events/custom-event/eventServer.js +6 -9
- package/dist/cjs/src/lib/events/custom-event/form.d.ts +2 -1
- package/dist/cjs/src/lib/events/custom-event/form.js +10 -8
- package/dist/cjs/src/lib/events/identity/identity-event.d.ts +10 -9
- package/dist/cjs/src/lib/events/identity/identity-event.js +37 -37
- package/dist/cjs/src/lib/events/identity/identity.d.ts +4 -6
- package/dist/cjs/src/lib/events/identity/identity.js +6 -7
- package/dist/cjs/src/lib/events/identity/identityServer.d.ts +6 -8
- package/dist/cjs/src/lib/events/identity/identityServer.js +7 -9
- package/dist/cjs/src/lib/events/index.d.ts +3 -3
- package/dist/cjs/src/lib/events/page-view/page-view-event.d.ts +15 -7
- package/dist/cjs/src/lib/events/page-view/page-view-event.js +31 -24
- package/dist/cjs/src/lib/events/page-view/page-view-server.d.ts +6 -7
- package/dist/cjs/src/lib/events/page-view/page-view-server.js +7 -9
- package/dist/cjs/src/lib/events/page-view/page-view.d.ts +5 -6
- package/dist/cjs/src/lib/events/page-view/page-view.js +6 -7
- package/dist/cjs/src/lib/events/send-event/sendEvent.d.ts +2 -2
- package/dist/cjs/src/lib/events/send-event/sendEvent.js +12 -7
- package/dist/cjs/src/lib/getGuestId/getGuestId.js +1 -1
- package/dist/cjs/src/lib/initializer/browser/initializer.d.ts +15 -3
- package/dist/cjs/src/lib/initializer/browser/initializer.js +6 -6
- package/dist/cjs/src/lib/initializer/server/initializer.d.ts +5 -3
- package/dist/cjs/src/lib/initializer/server/initializer.js +4 -3
- package/dist/cjs/src/server.d.ts +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/package.json +5 -6
- package/dist/esm/src/browser.d.ts +1 -1
- package/dist/esm/src/lib/consts.d.ts +5 -1
- package/dist/esm/src/lib/consts.js +8 -2
- package/dist/esm/src/lib/eventStorage/addToEventQueue.d.ts +3 -5
- package/dist/esm/src/lib/eventStorage/addToEventQueue.js +5 -9
- package/dist/esm/src/lib/eventStorage/eventStorage.d.ts +2 -2
- package/dist/esm/src/lib/eventStorage/eventStorage.js +4 -7
- package/dist/esm/src/lib/events/base-event.d.ts +3 -2
- package/dist/esm/src/lib/events/base-event.js +3 -2
- package/dist/esm/src/lib/events/common-interfaces.d.ts +4 -21
- package/dist/esm/src/lib/events/custom-event/custom-event.d.ts +15 -14
- package/dist/esm/src/lib/events/custom-event/custom-event.js +15 -8
- package/dist/esm/src/lib/events/custom-event/event.d.ts +4 -7
- package/dist/esm/src/lib/events/custom-event/event.js +4 -8
- package/dist/esm/src/lib/events/custom-event/eventServer.d.ts +6 -8
- package/dist/esm/src/lib/events/custom-event/eventServer.js +7 -10
- package/dist/esm/src/lib/events/custom-event/form.d.ts +2 -1
- package/dist/esm/src/lib/events/custom-event/form.js +10 -8
- package/dist/esm/src/lib/events/identity/identity-event.d.ts +10 -9
- package/dist/esm/src/lib/events/identity/identity-event.js +30 -30
- package/dist/esm/src/lib/events/identity/identity.d.ts +4 -6
- package/dist/esm/src/lib/events/identity/identity.js +6 -7
- package/dist/esm/src/lib/events/identity/identityServer.d.ts +6 -8
- package/dist/esm/src/lib/events/identity/identityServer.js +8 -10
- package/dist/esm/src/lib/events/index.d.ts +3 -3
- package/dist/esm/src/lib/events/page-view/page-view-event.d.ts +15 -7
- package/dist/esm/src/lib/events/page-view/page-view-event.js +31 -24
- package/dist/esm/src/lib/events/page-view/page-view-server.d.ts +6 -7
- package/dist/esm/src/lib/events/page-view/page-view-server.js +8 -10
- package/dist/esm/src/lib/events/page-view/page-view.d.ts +5 -6
- package/dist/esm/src/lib/events/page-view/page-view.js +6 -7
- package/dist/esm/src/lib/events/send-event/sendEvent.d.ts +2 -2
- package/dist/esm/src/lib/events/send-event/sendEvent.js +13 -8
- package/dist/esm/src/lib/getGuestId/getGuestId.js +1 -1
- package/dist/esm/src/lib/initializer/browser/initializer.d.ts +15 -3
- package/dist/esm/src/lib/initializer/browser/initializer.js +7 -7
- package/dist/esm/src/lib/initializer/server/initializer.d.ts +5 -3
- package/dist/esm/src/lib/initializer/server/initializer.js +5 -4
- package/dist/esm/src/server.d.ts +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -6
|
@@ -1,30 +1,37 @@
|
|
|
1
|
-
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
1
|
import { BaseEvent } from '../base-event';
|
|
3
|
-
import { flattenObject } from '@sitecore-cloudsdk/utils';
|
|
4
|
-
import { MAX_EXT_ATTRIBUTES } from '../consts';
|
|
5
2
|
import { ErrorMessages } from '../../consts';
|
|
3
|
+
import { MAX_EXT_ATTRIBUTES } from '../consts';
|
|
4
|
+
import { flattenObject } from '@sitecore-cloudsdk/utils';
|
|
6
5
|
export class CustomEvent extends BaseEvent {
|
|
7
6
|
/**
|
|
8
7
|
* A class that extends from {@link BaseEvent} and has all the required functionality to send a VIEW event
|
|
9
8
|
* @param args - Unified object containing the required properties
|
|
10
9
|
*/
|
|
11
10
|
constructor(args) {
|
|
12
|
-
const { channel, currency, language, page, ...rest } = args.eventData;
|
|
11
|
+
const { channel, currency, language, page, type, extensionData, searchData, ...rest } = args.eventData;
|
|
13
12
|
super({ channel, currency, language, page }, args.id);
|
|
14
13
|
this.extensionData = {};
|
|
15
14
|
this.sendEvent = args.sendEvent;
|
|
16
15
|
this.settings = args.settings;
|
|
17
16
|
this.customEventPayload = {
|
|
18
|
-
type
|
|
19
|
-
...rest
|
|
17
|
+
type,
|
|
18
|
+
...rest
|
|
20
19
|
};
|
|
21
|
-
if (
|
|
22
|
-
this.extensionData = flattenObject({ object:
|
|
20
|
+
if (extensionData)
|
|
21
|
+
this.extensionData = flattenObject({ object: extensionData });
|
|
23
22
|
const numberOfExtensionDataProperties = Object.entries(this.extensionData).length;
|
|
24
23
|
if (numberOfExtensionDataProperties > MAX_EXT_ATTRIBUTES)
|
|
25
24
|
throw new Error(ErrorMessages.IV_0005);
|
|
26
25
|
if (numberOfExtensionDataProperties > 0)
|
|
27
26
|
this.customEventPayload.ext = this.extensionData;
|
|
27
|
+
if (searchData)
|
|
28
|
+
this.customEventPayload.sc_search = {
|
|
29
|
+
data: searchData,
|
|
30
|
+
metadata: {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
32
|
+
ut_api_version: '1.0'
|
|
33
|
+
}
|
|
34
|
+
};
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
37
|
* Sends the event to Sitecore EP
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
-
import {
|
|
3
|
-
import { CustomEventInput } from './custom-event';
|
|
1
|
+
import type { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { EventData } from './custom-event';
|
|
4
3
|
/**
|
|
5
4
|
* A function that sends an event to SitecoreCloud API with the specified type
|
|
6
|
-
*
|
|
5
|
+
*
|
|
7
6
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
8
|
-
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
9
|
-
* This object will be flattened and sent in the ext object of the payload
|
|
10
7
|
* @returns The response object that Sitecore EP returns
|
|
11
8
|
*/
|
|
12
|
-
export declare function event(
|
|
9
|
+
export declare function event(eventData: EventData): Promise<EPResponse | null>;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
2
|
import { getBrowserId, getSettings, handleGetSettingsError } from '@sitecore-cloudsdk/core';
|
|
3
3
|
import { CustomEvent } from './custom-event';
|
|
4
|
+
import { ErrorMessages } from '../../consts';
|
|
4
5
|
import { awaitInit } from '../../initializer/browser/initializer';
|
|
5
6
|
import { sendEvent } from '../send-event/sendEvent';
|
|
6
|
-
import { ErrorMessages } from '../../consts';
|
|
7
7
|
/**
|
|
8
8
|
* A function that sends an event to SitecoreCloud API with the specified type
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
11
|
-
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
12
|
-
* This object will be flattened and sent in the ext object of the payload
|
|
13
11
|
* @returns The response object that Sitecore EP returns
|
|
14
12
|
*/
|
|
15
|
-
export async function event(
|
|
13
|
+
export async function event(eventData) {
|
|
16
14
|
await awaitInit();
|
|
17
15
|
const settings = handleGetSettingsError(getSettings, ErrorMessages.IE_0004);
|
|
18
16
|
const id = getBrowserId();
|
|
19
17
|
return new CustomEvent({
|
|
20
18
|
eventData,
|
|
21
|
-
extensionData,
|
|
22
19
|
id,
|
|
23
20
|
sendEvent,
|
|
24
|
-
settings
|
|
25
|
-
type,
|
|
21
|
+
settings
|
|
26
22
|
}).send();
|
|
27
23
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { Request } from '@sitecore-cloudsdk/utils';
|
|
1
|
+
import type { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { EventData } from './custom-event';
|
|
3
|
+
import type { Request } from '@sitecore-cloudsdk/utils';
|
|
5
4
|
/**
|
|
6
5
|
* A function that sends an event to SitecoreCloud API with the specified type
|
|
7
|
-
*
|
|
8
|
-
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
6
|
+
*
|
|
9
7
|
* @param request - Interface with constraint for extending request
|
|
10
|
-
* @param
|
|
8
|
+
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
11
9
|
* @returns The response object that Sitecore EP returns
|
|
12
10
|
*/
|
|
13
|
-
export declare function eventServer<T extends Request>(
|
|
11
|
+
export declare function eventServer<T extends Request>(request: T, eventData: EventData): Promise<EPResponse | null>;
|
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
-
import {
|
|
2
|
+
import { getCookieValueFromRequest, getSettingsServer, handleGetSettingsError } from '@sitecore-cloudsdk/core';
|
|
3
3
|
import { CustomEvent } from './custom-event';
|
|
4
|
-
import { sendEvent } from '../send-event/sendEvent';
|
|
5
4
|
import { ErrorMessages } from '../../consts';
|
|
5
|
+
import { sendEvent } from '../send-event/sendEvent';
|
|
6
6
|
/**
|
|
7
7
|
* A function that sends an event to SitecoreCloud API with the specified type
|
|
8
|
-
*
|
|
9
|
-
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
8
|
+
*
|
|
10
9
|
* @param request - Interface with constraint for extending request
|
|
11
|
-
* @param
|
|
10
|
+
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
12
11
|
* @returns The response object that Sitecore EP returns
|
|
13
12
|
*/
|
|
14
|
-
export function eventServer(
|
|
13
|
+
export function eventServer(request, eventData) {
|
|
15
14
|
const settings = handleGetSettingsError(getSettingsServer, ErrorMessages.IE_0005);
|
|
16
|
-
const id =
|
|
15
|
+
const id = getCookieValueFromRequest(request, settings.cookieSettings.cookieNames.browserId);
|
|
17
16
|
return new CustomEvent({
|
|
18
17
|
eventData,
|
|
19
|
-
extensionData,
|
|
20
18
|
id,
|
|
21
19
|
sendEvent,
|
|
22
|
-
settings
|
|
23
|
-
type,
|
|
20
|
+
settings
|
|
24
21
|
}).send();
|
|
25
22
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
1
|
+
import type { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
2
|
/**
|
|
3
3
|
* A function that sends a form event to SitecoreCloud API
|
|
4
|
+
*
|
|
4
5
|
* @param formId - The required form ID string
|
|
5
6
|
* @param interactionType - The required interaction type string. Possible values: "VIEWED", "SUBMITTED"
|
|
6
7
|
* settings object, you must specify it here
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
2
|
import { getBrowserId, getSettings, handleGetSettingsError } from '@sitecore-cloudsdk/core';
|
|
3
3
|
import { CustomEvent } from './custom-event';
|
|
4
|
-
import { sendEvent } from '../send-event/sendEvent';
|
|
5
|
-
import { awaitInit } from '../../initializer/browser/initializer';
|
|
6
4
|
import { ErrorMessages } from '../../consts';
|
|
5
|
+
import { awaitInit } from '../../initializer/browser/initializer';
|
|
6
|
+
import { sendEvent } from '../send-event/sendEvent';
|
|
7
7
|
/**
|
|
8
8
|
* A function that sends a form event to SitecoreCloud API
|
|
9
|
+
*
|
|
9
10
|
* @param formId - The required form ID string
|
|
10
11
|
* @param interactionType - The required interaction type string. Possible values: "VIEWED", "SUBMITTED"
|
|
11
12
|
* settings object, you must specify it here
|
|
@@ -16,15 +17,16 @@ export async function form(formId, interactionType) {
|
|
|
16
17
|
const settings = handleGetSettingsError(getSettings, ErrorMessages.IE_0004);
|
|
17
18
|
const id = getBrowserId();
|
|
18
19
|
const formEvent = new CustomEvent({
|
|
19
|
-
eventData: {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
eventData: {
|
|
21
|
+
extensionData: {
|
|
22
|
+
formId,
|
|
23
|
+
interactionType: interactionType.toUpperCase()
|
|
24
|
+
},
|
|
25
|
+
type: 'FORM'
|
|
23
26
|
},
|
|
24
27
|
id,
|
|
25
28
|
sendEvent,
|
|
26
|
-
settings
|
|
27
|
-
type: 'FORM',
|
|
29
|
+
settings
|
|
28
30
|
});
|
|
29
31
|
formEvent.page = undefined;
|
|
30
32
|
return formEvent.send();
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
import type { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { EventAttributesInput, ExtensionData } from '../common-interfaces';
|
|
1
3
|
import { BaseEvent } from '../base-event';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
|
|
5
|
-
import { SendEvent } from '../send-event/sendEvent';
|
|
4
|
+
import type { FlattenedObject } from '@sitecore-cloudsdk/utils';
|
|
5
|
+
import type { SendEvent } from '../send-event/sendEvent';
|
|
6
6
|
export declare class IdentityEvent extends BaseEvent {
|
|
7
|
-
private
|
|
7
|
+
private identityData;
|
|
8
8
|
private sendEvent;
|
|
9
9
|
private extensionData;
|
|
10
10
|
private numberOfExtensionDataProperties;
|
|
11
11
|
private settings;
|
|
12
12
|
/**
|
|
13
13
|
* A class that extends from {@link BaseEvent} and has all the required functionality to send a VIEW event
|
|
14
|
+
*
|
|
14
15
|
* @param args - Unified object containing the required properties
|
|
15
16
|
*/
|
|
16
17
|
constructor(args: IdentityEventArguments);
|
|
17
18
|
/**
|
|
18
19
|
* Function that validates the identifiers object, email and date attributes for CDN users
|
|
19
|
-
* * @param
|
|
20
|
+
* * @param identityData - The data to be validated
|
|
20
21
|
*/
|
|
21
22
|
private validateAttributes;
|
|
22
23
|
/**
|
|
@@ -41,7 +42,7 @@ interface EPIdentifier {
|
|
|
41
42
|
/**
|
|
42
43
|
* Interface with the necessary attributes for the input for sending Identity events
|
|
43
44
|
*/
|
|
44
|
-
export interface
|
|
45
|
+
export interface IdentityData extends EventAttributesInput {
|
|
45
46
|
city?: string;
|
|
46
47
|
country?: string;
|
|
47
48
|
dob?: string;
|
|
@@ -56,6 +57,7 @@ export interface IdentityEventAttributesInput extends EventAttributesInput {
|
|
|
56
57
|
state?: string;
|
|
57
58
|
street?: string[];
|
|
58
59
|
title?: string;
|
|
60
|
+
extensionData?: ExtensionData;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* The JSON array of objects that contain the identity identifiers
|
|
@@ -91,8 +93,7 @@ export interface IdentityEventPayload {
|
|
|
91
93
|
*/
|
|
92
94
|
export interface IdentityEventArguments {
|
|
93
95
|
sendEvent: SendEvent;
|
|
94
|
-
|
|
95
|
-
extensionData?: ExtensionData;
|
|
96
|
+
identityData: IdentityData;
|
|
96
97
|
id: string;
|
|
97
98
|
settings: Settings;
|
|
98
99
|
infer?: Infer;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
|
|
1
|
+
import { flattenObject, isShortISODateString, isValidEmail } from '@sitecore-cloudsdk/utils';
|
|
2
2
|
import { BaseEvent } from '../base-event';
|
|
3
|
-
import { MAX_EXT_ATTRIBUTES } from '../consts';
|
|
4
|
-
import { isShortISODateString, isValidEmail, flattenObject } from '@sitecore-cloudsdk/utils';
|
|
5
3
|
import { ErrorMessages } from '../../consts';
|
|
4
|
+
import { MAX_EXT_ATTRIBUTES } from '../consts';
|
|
6
5
|
export class IdentityEvent extends BaseEvent {
|
|
7
6
|
/**
|
|
8
7
|
* A class that extends from {@link BaseEvent} and has all the required functionality to send a VIEW event
|
|
8
|
+
*
|
|
9
9
|
* @param args - Unified object containing the required properties
|
|
10
10
|
*/
|
|
11
11
|
constructor(args) {
|
|
12
|
-
const { channel, currency, language, page } = args.
|
|
12
|
+
const { channel, currency, language, page, extensionData } = args.identityData;
|
|
13
13
|
super({ channel, currency, language, page }, args.id);
|
|
14
14
|
this.extensionData = {};
|
|
15
15
|
this.numberOfExtensionDataProperties = 0;
|
|
16
|
-
this.validateAttributes(args.
|
|
17
|
-
this.
|
|
16
|
+
this.validateAttributes(args.identityData);
|
|
17
|
+
this.identityData = args.identityData;
|
|
18
18
|
this.sendEvent = args.sendEvent;
|
|
19
19
|
this.settings = args.settings;
|
|
20
|
-
if (
|
|
21
|
-
this.extensionData = flattenObject({ object:
|
|
20
|
+
if (extensionData)
|
|
21
|
+
this.extensionData = flattenObject({ object: extensionData });
|
|
22
22
|
this.numberOfExtensionDataProperties = Object.entries(this.extensionData).length;
|
|
23
23
|
if (this.numberOfExtensionDataProperties > MAX_EXT_ATTRIBUTES)
|
|
24
24
|
throw new Error(ErrorMessages.IV_0005);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Function that validates the identifiers object, email and date attributes for CDN users
|
|
28
|
-
* * @param
|
|
28
|
+
* * @param identityData - The data to be validated
|
|
29
29
|
*/
|
|
30
|
-
validateAttributes(
|
|
31
|
-
if (
|
|
30
|
+
validateAttributes(identityData) {
|
|
31
|
+
if (identityData.identifiers.length === 0)
|
|
32
32
|
throw new Error(ErrorMessages.MV_0003);
|
|
33
|
-
if (
|
|
33
|
+
if (identityData.dob !== undefined && !isShortISODateString(identityData.dob))
|
|
34
34
|
throw new Error(ErrorMessages.IV_0002);
|
|
35
|
-
|
|
35
|
+
identityData.identifiers.forEach((identifier) => {
|
|
36
36
|
if (identifier.expiryDate && !isShortISODateString(identifier.expiryDate))
|
|
37
37
|
throw new Error(ErrorMessages.IV_0004);
|
|
38
38
|
});
|
|
39
|
-
if (
|
|
39
|
+
if (identityData.email && !isValidEmail(identityData.email))
|
|
40
40
|
throw new Error(ErrorMessages.IV_0003);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -45,29 +45,29 @@ export class IdentityEvent extends BaseEvent {
|
|
|
45
45
|
*/
|
|
46
46
|
mapAttributes() {
|
|
47
47
|
const identityPayload = {
|
|
48
|
-
city: this.
|
|
49
|
-
country: this.
|
|
50
|
-
dob: this.
|
|
51
|
-
email: this.
|
|
52
|
-
firstname: this.
|
|
53
|
-
gender: this.
|
|
54
|
-
identifiers: this.
|
|
48
|
+
city: this.identityData.city,
|
|
49
|
+
country: this.identityData.country,
|
|
50
|
+
dob: this.identityData.dob,
|
|
51
|
+
email: this.identityData.email,
|
|
52
|
+
firstname: this.identityData.firstName,
|
|
53
|
+
gender: this.identityData.gender,
|
|
54
|
+
identifiers: this.identityData.identifiers.map((value) => {
|
|
55
55
|
return {
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
57
57
|
expiry_date: value.expiryDate,
|
|
58
58
|
id: value.id,
|
|
59
|
-
provider: value.provider
|
|
59
|
+
provider: value.provider
|
|
60
60
|
};
|
|
61
61
|
}),
|
|
62
|
-
lastname: this.
|
|
63
|
-
mobile: this.
|
|
64
|
-
phone: this.
|
|
62
|
+
lastname: this.identityData.lastName,
|
|
63
|
+
mobile: this.identityData.mobile,
|
|
64
|
+
phone: this.identityData.phone,
|
|
65
65
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
66
|
-
postal_code: this.
|
|
67
|
-
state: this.
|
|
68
|
-
street: this.
|
|
69
|
-
title: this.
|
|
70
|
-
type: 'IDENTITY'
|
|
66
|
+
postal_code: this.identityData.postalCode,
|
|
67
|
+
state: this.identityData.state,
|
|
68
|
+
street: this.identityData.street,
|
|
69
|
+
title: this.identityData.title,
|
|
70
|
+
type: 'IDENTITY'
|
|
71
71
|
};
|
|
72
72
|
if (this.numberOfExtensionDataProperties > 0)
|
|
73
73
|
identityPayload.ext = this.extensionData;
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { IdentityEventAttributesInput } from './identity-event';
|
|
1
|
+
import type { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { IdentityData } from './identity-event';
|
|
4
3
|
/**
|
|
5
4
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
5
|
+
*
|
|
6
6
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
7
|
-
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
8
|
-
* This object will be flattened and sent in the ext object of the payload
|
|
9
7
|
* @returns The response object that Sitecore EP returns
|
|
10
8
|
*/
|
|
11
|
-
export declare function identity(
|
|
9
|
+
export declare function identity(identityData: IdentityData): Promise<EPResponse | null>;
|
|
@@ -1,24 +1,23 @@
|
|
|
1
|
+
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
1
2
|
import { getBrowserId, getSettings, handleGetSettingsError } from '@sitecore-cloudsdk/core';
|
|
3
|
+
import { ErrorMessages } from '../../consts';
|
|
2
4
|
import { IdentityEvent } from './identity-event';
|
|
3
5
|
import { awaitInit } from '../../initializer/browser/initializer';
|
|
4
6
|
import { sendEvent } from '../send-event/sendEvent';
|
|
5
|
-
import { ErrorMessages } from '../../consts';
|
|
6
7
|
/**
|
|
7
8
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
9
|
+
*
|
|
8
10
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
9
|
-
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
10
|
-
* This object will be flattened and sent in the ext object of the payload
|
|
11
11
|
* @returns The response object that Sitecore EP returns
|
|
12
12
|
*/
|
|
13
|
-
export async function identity(
|
|
13
|
+
export async function identity(identityData) {
|
|
14
14
|
await awaitInit();
|
|
15
15
|
const settings = handleGetSettingsError(getSettings, ErrorMessages.IE_0004);
|
|
16
16
|
const id = getBrowserId();
|
|
17
17
|
return new IdentityEvent({
|
|
18
|
-
eventData,
|
|
19
|
-
extensionData,
|
|
20
18
|
id,
|
|
19
|
+
identityData,
|
|
21
20
|
sendEvent,
|
|
22
|
-
settings
|
|
21
|
+
settings
|
|
23
22
|
}).send();
|
|
24
23
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { IdentityEventAttributesInput } from './identity-event';
|
|
1
|
+
import type { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { IdentityData } from './identity-event';
|
|
3
|
+
import type { Request } from '@sitecore-cloudsdk/utils';
|
|
5
4
|
/**
|
|
6
5
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
7
|
-
*
|
|
6
|
+
*
|
|
8
7
|
* @param request - Interface with constraint for extending request
|
|
9
|
-
* @param
|
|
10
|
-
* This object will be flattened and sent in the ext object of the payload
|
|
8
|
+
* @param identityData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
11
9
|
* @returns The response object that Sitecore EP returns
|
|
12
10
|
*/
|
|
13
|
-
export declare function identityServer(
|
|
11
|
+
export declare function identityServer(request: Request, identityData: IdentityData): Promise<EPResponse | null>;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
// © Sitecore Corporation A/S. All rights reserved. Sitecore® is a registered trademark of Sitecore Corporation A/S.
|
|
2
|
-
import {
|
|
2
|
+
import { getCookieValueFromRequest, getSettingsServer, handleGetSettingsError } from '@sitecore-cloudsdk/core';
|
|
3
|
+
import { ErrorMessages } from '../../consts';
|
|
3
4
|
import { IdentityEvent } from './identity-event';
|
|
4
5
|
import { sendEvent } from '../send-event/sendEvent';
|
|
5
|
-
import { ErrorMessages } from '../../consts';
|
|
6
6
|
/**
|
|
7
7
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
8
|
-
*
|
|
8
|
+
*
|
|
9
9
|
* @param request - Interface with constraint for extending request
|
|
10
|
-
* @param
|
|
11
|
-
* This object will be flattened and sent in the ext object of the payload
|
|
10
|
+
* @param identityData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
12
11
|
* @returns The response object that Sitecore EP returns
|
|
13
12
|
*/
|
|
14
|
-
export function identityServer(
|
|
13
|
+
export function identityServer(request, identityData) {
|
|
15
14
|
const settings = handleGetSettingsError(getSettingsServer, ErrorMessages.IE_0005);
|
|
16
|
-
const id =
|
|
15
|
+
const id = getCookieValueFromRequest(request, settings.cookieSettings.cookieNames.browserId);
|
|
17
16
|
return new IdentityEvent({
|
|
18
|
-
eventData,
|
|
19
|
-
extensionData,
|
|
20
17
|
id,
|
|
18
|
+
identityData,
|
|
21
19
|
sendEvent,
|
|
22
|
-
settings: settings
|
|
20
|
+
settings: settings
|
|
23
21
|
}).send();
|
|
24
22
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { BaseEvent } from './base-event';
|
|
2
2
|
export type { BasePayload } from './base-event';
|
|
3
3
|
export { PageViewEvent } from './page-view/page-view-event';
|
|
4
|
-
export type {
|
|
4
|
+
export type { PageViewData, PageViewEventPayload } from './page-view/page-view-event';
|
|
5
5
|
export { CustomEvent } from './custom-event/custom-event';
|
|
6
|
-
export type {
|
|
6
|
+
export type { EventData, CustomEventPayload, CustomEventArguments } from './custom-event/custom-event';
|
|
7
7
|
export { IdentityEvent } from './identity/identity-event';
|
|
8
|
-
export type {
|
|
8
|
+
export type { IdentityData, IdentityEventPayload } from './identity/identity-event';
|
|
9
9
|
export type { ExtensionData } from './common-interfaces';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
|
|
2
|
-
import {
|
|
1
|
+
import type { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { EventAttributesInput, ExtensionData } from '../common-interfaces';
|
|
3
|
+
import type { FlattenedObject, NestedObject } from '@sitecore-cloudsdk/utils';
|
|
3
4
|
import { BaseEvent } from '../base-event';
|
|
4
|
-
import {
|
|
5
|
-
import { SendEvent } from '../send-event/sendEvent';
|
|
5
|
+
import type { SendEvent } from '../send-event/sendEvent';
|
|
6
6
|
export declare class PageViewEvent extends BaseEvent {
|
|
7
7
|
static isFirstPageView: boolean;
|
|
8
8
|
private sendEvent;
|
|
9
|
-
private
|
|
9
|
+
private pageViewData?;
|
|
10
10
|
private extensionData;
|
|
11
11
|
private urlSearchParams;
|
|
12
12
|
private includeUTMParameters;
|
|
@@ -49,7 +49,7 @@ export declare class PageViewEvent extends BaseEvent {
|
|
|
49
49
|
*/
|
|
50
50
|
export interface PageViewEventArguments {
|
|
51
51
|
sendEvent: SendEvent;
|
|
52
|
-
|
|
52
|
+
pageViewData?: PageViewData;
|
|
53
53
|
id: string;
|
|
54
54
|
settings: Settings;
|
|
55
55
|
infer?: Infer;
|
|
@@ -59,10 +59,12 @@ export interface PageViewEventArguments {
|
|
|
59
59
|
/**
|
|
60
60
|
* Type with the required/optional attributes in order to send a view event to SitecoreCloud API
|
|
61
61
|
*/
|
|
62
|
-
export interface
|
|
62
|
+
export interface PageViewData extends EventAttributesInput {
|
|
63
63
|
pageVariantId?: string;
|
|
64
64
|
referrer?: string;
|
|
65
65
|
includeUTMParameters?: boolean;
|
|
66
|
+
extensionData?: ExtensionData;
|
|
67
|
+
searchData?: NestedObject;
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
68
70
|
* Interface with the utm_ parameters
|
|
@@ -79,5 +81,11 @@ export interface PageViewEventPayload extends UtmParameters {
|
|
|
79
81
|
ext?: {
|
|
80
82
|
pageVariantId?: string;
|
|
81
83
|
} & FlattenedObject;
|
|
84
|
+
sc_search?: {
|
|
85
|
+
data: NestedObject;
|
|
86
|
+
metadata: {
|
|
87
|
+
ut_api_version: string;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
82
90
|
}
|
|
83
91
|
export {};
|