@sitecore-cloudsdk/events 0.1.0 → 0.1.2
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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/browser.d.ts +1 -1
- package/dist/cjs/src/lib/ep/EventApiClient.d.ts +18 -0
- package/dist/cjs/src/lib/{cdp → ep}/EventApiClient.js +3 -3
- package/dist/cjs/src/lib/eventStorage/addToEventQueue.d.ts +2 -2
- package/dist/cjs/src/lib/eventStorage/eventStorage.d.ts +7 -7
- package/dist/cjs/src/lib/eventStorage/eventStorage.js +2 -2
- package/dist/cjs/src/lib/events/base-event.d.ts +8 -8
- package/dist/cjs/src/lib/events/base-event.js +1 -1
- package/dist/cjs/src/lib/events/common-interfaces.d.ts +10 -18
- package/dist/cjs/src/lib/events/custom-event/custom-event.d.ts +17 -17
- package/dist/cjs/src/lib/events/custom-event/custom-event.js +2 -2
- package/dist/cjs/src/lib/events/custom-event/event.d.ts +4 -4
- package/dist/cjs/src/lib/events/custom-event/event.js +1 -1
- package/dist/cjs/src/lib/events/custom-event/eventServer.d.ts +5 -5
- package/dist/cjs/src/lib/events/custom-event/eventServer.js +1 -1
- package/dist/cjs/src/lib/events/custom-event/form.d.ts +3 -3
- package/dist/cjs/src/lib/events/custom-event/form.js +1 -1
- package/dist/cjs/src/lib/events/identity/identity-event.d.ts +20 -20
- package/dist/cjs/src/lib/events/identity/identity-event.js +3 -3
- package/dist/cjs/src/lib/events/identity/identity.d.ts +4 -4
- package/dist/cjs/src/lib/events/identity/identity.js +1 -1
- package/dist/cjs/src/lib/events/identity/identityServer.d.ts +5 -5
- package/dist/cjs/src/lib/events/identity/identityServer.js +1 -1
- package/dist/cjs/src/lib/events/index.d.ts +4 -4
- package/dist/cjs/src/lib/events/page-view/page-view-event.d.ts +25 -18
- package/dist/cjs/src/lib/events/page-view/page-view-event.js +21 -2
- package/dist/cjs/src/lib/events/page-view/page-view-server.d.ts +5 -5
- package/dist/cjs/src/lib/events/page-view/page-view-server.js +1 -1
- package/dist/cjs/src/lib/events/page-view/page-view.d.ts +5 -5
- package/dist/cjs/src/lib/events/page-view/page-view.js +1 -1
- package/dist/cjs/src/lib/initializer/browser/initializer.d.ts +7 -7
- package/dist/cjs/src/lib/initializer/browser/initializer.js +2 -2
- package/dist/cjs/src/lib/initializer/server/initializer.d.ts +8 -8
- package/dist/cjs/src/lib/initializer/server/initializer.js +2 -2
- package/dist/cjs/src/server.d.ts +2 -3
- package/dist/cjs/src/server.js +1 -3
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/package.json +1 -1
- package/dist/esm/src/browser.d.ts +1 -1
- package/dist/esm/src/lib/ep/EventApiClient.d.ts +18 -0
- package/dist/esm/src/lib/{cdp → ep}/EventApiClient.js +3 -3
- package/dist/esm/src/lib/eventStorage/addToEventQueue.d.ts +2 -2
- package/dist/esm/src/lib/eventStorage/eventStorage.d.ts +7 -7
- package/dist/esm/src/lib/eventStorage/eventStorage.js +2 -2
- package/dist/esm/src/lib/events/base-event.d.ts +8 -8
- package/dist/esm/src/lib/events/base-event.js +1 -1
- package/dist/esm/src/lib/events/common-interfaces.d.ts +10 -18
- package/dist/esm/src/lib/events/custom-event/custom-event.d.ts +17 -17
- package/dist/esm/src/lib/events/custom-event/custom-event.js +2 -2
- package/dist/esm/src/lib/events/custom-event/event.d.ts +4 -4
- package/dist/esm/src/lib/events/custom-event/event.js +1 -1
- package/dist/esm/src/lib/events/custom-event/eventServer.d.ts +5 -5
- package/dist/esm/src/lib/events/custom-event/eventServer.js +1 -1
- package/dist/esm/src/lib/events/custom-event/form.d.ts +3 -3
- package/dist/esm/src/lib/events/custom-event/form.js +1 -1
- package/dist/esm/src/lib/events/identity/identity-event.d.ts +20 -20
- package/dist/esm/src/lib/events/identity/identity-event.js +3 -3
- package/dist/esm/src/lib/events/identity/identity.d.ts +4 -4
- package/dist/esm/src/lib/events/identity/identity.js +1 -1
- package/dist/esm/src/lib/events/identity/identityServer.d.ts +5 -5
- package/dist/esm/src/lib/events/identity/identityServer.js +1 -1
- package/dist/esm/src/lib/events/index.d.ts +4 -4
- package/dist/esm/src/lib/events/page-view/page-view-event.d.ts +25 -18
- package/dist/esm/src/lib/events/page-view/page-view-event.js +22 -3
- package/dist/esm/src/lib/events/page-view/page-view-server.d.ts +5 -5
- package/dist/esm/src/lib/events/page-view/page-view-server.js +1 -1
- package/dist/esm/src/lib/events/page-view/page-view.d.ts +5 -5
- package/dist/esm/src/lib/events/page-view/page-view.js +1 -1
- package/dist/esm/src/lib/initializer/browser/initializer.d.ts +7 -7
- package/dist/esm/src/lib/initializer/browser/initializer.js +2 -2
- package/dist/esm/src/lib/initializer/server/initializer.d.ts +8 -8
- package/dist/esm/src/lib/initializer/server/initializer.js +3 -3
- package/dist/esm/src/server.d.ts +2 -3
- package/dist/esm/src/server.js +0 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/cjs/src/lib/cdp/EventApiClient.d.ts +0 -24
- package/dist/esm/src/lib/cdp/EventApiClient.d.ts +0 -24
package/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getBrowserId } from '@sitecore-cloudsdk/core';
|
|
2
2
|
export { init } from './lib/initializer/browser/initializer';
|
|
3
|
-
export type {
|
|
3
|
+
export type { PageViewEventInput, CustomEventInput, IdentityEventAttributesInput } from './lib/events';
|
|
4
4
|
export { addToEventQueue } from './lib/eventStorage/addToEventQueue';
|
|
5
5
|
export { processEventQueue } from './lib/eventStorage/processEventQueue';
|
|
6
6
|
export { clearEventQueue } from './lib/eventStorage/clearEventQueue';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import type { BasePayload, PageViewEventPayload, IdentityEventPayload, CustomEventPayload } from '../events';
|
|
3
|
+
export declare class EventApiClient implements EventApiClient {
|
|
4
|
+
private targetURL;
|
|
5
|
+
private readonly eventUrl;
|
|
6
|
+
constructor(targetURL: string, sitecoreEdgeContextId: string, siteName: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The interface of EventApiClient class
|
|
10
|
+
*/
|
|
11
|
+
export interface EventApiClient {
|
|
12
|
+
send(body: EPFetchBody & BasePayload): Promise<EPResponse | null>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The type describing all possible event payloads
|
|
16
|
+
*/
|
|
17
|
+
type EPFetchBody = PageViewEventPayload | IdentityEventPayload | CustomEventPayload;
|
|
18
|
+
export {};
|
|
@@ -10,9 +10,9 @@ class EventApiClient {
|
|
|
10
10
|
this.eventUrl = `${this.targetURL}/events/${core_1.API_VERSION}/events?sitecoreContextId=${sitecoreEdgeContextId}&siteId=${siteName}`;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
|
-
* A function that sends the payload to Sitecore
|
|
14
|
-
* @param body - The Request body for the Sitecore
|
|
15
|
-
* @returns - A promise that resolves with either the Sitecore
|
|
13
|
+
* A function that sends the payload to Sitecore EP
|
|
14
|
+
* @param body - The Request body for the Sitecore EP
|
|
15
|
+
* @returns - A promise that resolves with either the Sitecore EP response object or null
|
|
16
16
|
*/
|
|
17
17
|
async send(body) {
|
|
18
18
|
const fetchOptions = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomEventInput, ExtensionData } from '../events';
|
|
2
2
|
/**
|
|
3
3
|
* A function that adds event to the queue
|
|
4
4
|
* @param type - The required type of the event
|
|
@@ -6,4 +6,4 @@ import { ICustomEventInput, ExtensionData } from '../events';
|
|
|
6
6
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
7
7
|
* This object will be flattened and sent in the ext object of the payload
|
|
8
8
|
*/
|
|
9
|
-
export declare function addToEventQueue(type: string, eventData:
|
|
9
|
+
export declare function addToEventQueue(type: string, eventData: CustomEventInput, extensionData?: ExtensionData): void;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { EventApiClient } from '../
|
|
2
|
-
import {
|
|
1
|
+
import { EventApiClient } from '../ep/EventApiClient';
|
|
2
|
+
import { CustomEventArguments } from '../events';
|
|
3
3
|
export declare class EventQueue {
|
|
4
4
|
private storage;
|
|
5
5
|
private eventApiClient;
|
|
6
6
|
/**
|
|
7
7
|
* Initialize the Event Storage
|
|
8
8
|
* @param storage - Interface that describes the storage functionality
|
|
9
|
-
* @param eventApiClient - The API client which sends events to
|
|
9
|
+
* @param eventApiClient - The API client which sends events to EP
|
|
10
10
|
* @param infer - The instance of the infer class
|
|
11
11
|
*/
|
|
12
12
|
private key;
|
|
13
|
-
constructor(storage:
|
|
13
|
+
constructor(storage: Storage, eventApiClient: EventApiClient);
|
|
14
14
|
/** Returns the stored array of data with type QueueEventPayload, or empty array if the given key does not exist. */
|
|
15
15
|
private getEventQueue;
|
|
16
16
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class EventQueue {
|
|
|
20
20
|
*/
|
|
21
21
|
enqueueEvent(queueEventPayload: QueueEventPayload): void;
|
|
22
22
|
/**
|
|
23
|
-
* Iterates the queue, and sends sequently the custom events to Sitecore
|
|
23
|
+
* Iterates the queue, and sends sequently the custom events to Sitecore EP.
|
|
24
24
|
*/
|
|
25
25
|
sendAllEvents(): Promise<void>;
|
|
26
26
|
/**
|
|
@@ -31,9 +31,9 @@ export declare class EventQueue {
|
|
|
31
31
|
/**
|
|
32
32
|
* This Storage interface represents the required storage functionality.
|
|
33
33
|
*/
|
|
34
|
-
export interface
|
|
34
|
+
export interface Storage {
|
|
35
35
|
getItem(key: string): string | null;
|
|
36
36
|
setItem(key: string, value: string): void;
|
|
37
37
|
removeItem(key: string): void;
|
|
38
38
|
}
|
|
39
|
-
export type QueueEventPayload = Pick<
|
|
39
|
+
export type QueueEventPayload = Pick<CustomEventArguments, 'eventData' | 'extensionData' | 'type' | 'settings' | 'id'>;
|
|
@@ -11,7 +11,7 @@ class EventQueue {
|
|
|
11
11
|
/**
|
|
12
12
|
* Initialize the Event Storage
|
|
13
13
|
* @param storage - Interface that describes the storage functionality
|
|
14
|
-
* @param eventApiClient - The API client which sends events to
|
|
14
|
+
* @param eventApiClient - The API client which sends events to EP
|
|
15
15
|
* @param infer - The instance of the infer class
|
|
16
16
|
*/
|
|
17
17
|
this.key = 'EventQueue';
|
|
@@ -46,7 +46,7 @@ class EventQueue {
|
|
|
46
46
|
this.storage.setItem(this.key, JSON.stringify(eventQueue));
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Iterates the queue, and sends sequently the custom events to Sitecore
|
|
49
|
+
* Iterates the queue, and sends sequently the custom events to Sitecore EP.
|
|
50
50
|
*/
|
|
51
51
|
async sendAllEvents() {
|
|
52
52
|
const eventQueue = this.getEventQueue();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { Settings } from '@sitecore-cloudsdk/core';
|
|
2
|
+
import { EventAttributesInput } from './common-interfaces';
|
|
3
3
|
export declare class BaseEvent {
|
|
4
4
|
private baseEventData;
|
|
5
|
-
protected settings:
|
|
5
|
+
protected settings: Settings;
|
|
6
6
|
private readonly browserId;
|
|
7
7
|
private readonly language;
|
|
8
8
|
page: string;
|
|
@@ -13,17 +13,17 @@ export declare class BaseEvent {
|
|
|
13
13
|
* @param id - The browser id
|
|
14
14
|
* @param infer - The source of methods to estimate language and page parameters
|
|
15
15
|
*/
|
|
16
|
-
constructor(baseEventData:
|
|
16
|
+
constructor(baseEventData: BaseEventData, settings: Settings, id: string);
|
|
17
17
|
/**
|
|
18
|
-
* A function that returns the properties for sending events to Sitecore
|
|
18
|
+
* A function that returns the properties for sending events to Sitecore EP
|
|
19
19
|
* @returns an object that is required
|
|
20
20
|
*/
|
|
21
|
-
protected mapBaseEventPayload():
|
|
21
|
+
protected mapBaseEventPayload(): BasePayload;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* An interface describing the basic payload to be sent to the API
|
|
25
25
|
*/
|
|
26
|
-
export interface
|
|
26
|
+
export interface BasePayload {
|
|
27
27
|
browser_id: string;
|
|
28
28
|
channel?: string;
|
|
29
29
|
client_key: string;
|
|
@@ -32,5 +32,5 @@ export interface IBasePayload {
|
|
|
32
32
|
page?: string;
|
|
33
33
|
pos: string;
|
|
34
34
|
}
|
|
35
|
-
type
|
|
35
|
+
type BaseEventData = Partial<EventAttributesInput>;
|
|
36
36
|
export {};
|
|
@@ -19,7 +19,7 @@ class BaseEvent {
|
|
|
19
19
|
this.page = this.baseEventData.page ?? (0, core_1.pageName)();
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* A function that returns the properties for sending events to Sitecore
|
|
22
|
+
* A function that returns the properties for sending events to Sitecore EP
|
|
23
23
|
* @returns an object that is required
|
|
24
24
|
*/
|
|
25
25
|
mapBaseEventPayload() {
|
|
@@ -1,39 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NestedObject } from '@sitecore-cloudsdk/utils';
|
|
2
2
|
/**
|
|
3
|
-
* Event data received as input to be sent to Sitecore
|
|
3
|
+
* Event data received as input to be sent to Sitecore EP
|
|
4
4
|
*/
|
|
5
|
-
interface
|
|
5
|
+
interface MandatoryInput {
|
|
6
6
|
channel: string;
|
|
7
7
|
currency: string;
|
|
8
8
|
}
|
|
9
|
-
type
|
|
9
|
+
type MandatoryEventInput = MandatoryInput;
|
|
10
10
|
/**
|
|
11
|
-
* Event data that is sent to Sitecore
|
|
11
|
+
* Event data that is sent to Sitecore EP
|
|
12
12
|
*/
|
|
13
|
-
interface
|
|
13
|
+
interface InferrableInput {
|
|
14
14
|
/**
|
|
15
|
-
* To be restored back to
|
|
15
|
+
* To be restored back to MandatoryEventInput Interface
|
|
16
16
|
* as mandatory input parameter in version 1.0.0
|
|
17
17
|
*/
|
|
18
|
-
pointOfSale?: string;
|
|
19
18
|
language?: string;
|
|
20
19
|
page?: string;
|
|
21
20
|
}
|
|
22
|
-
type
|
|
21
|
+
type InferrableEventInput = InferrableInput;
|
|
23
22
|
/**
|
|
24
23
|
* Interface to hold the base event attributes
|
|
25
24
|
*/
|
|
26
|
-
export interface
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Interface to hold the "ext" data
|
|
30
|
-
*/
|
|
31
|
-
export interface IExtensionData {
|
|
32
|
-
pageVariantId?: string;
|
|
33
|
-
[key: string]: BasicTypes;
|
|
25
|
+
export interface EventAttributesInput extends MandatoryEventInput, InferrableEventInput {
|
|
34
26
|
}
|
|
35
27
|
/**
|
|
36
28
|
* Type of the extension data that the developer can pass to events
|
|
37
29
|
*/
|
|
38
|
-
export type ExtensionData =
|
|
30
|
+
export type ExtensionData = NestedObject;
|
|
39
31
|
export {};
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import { BaseEvent } from '../base-event';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { BasicTypes,
|
|
2
|
+
import { EventAttributesInput } from '../common-interfaces';
|
|
3
|
+
import { EventApiClient } from '../../ep/EventApiClient';
|
|
4
|
+
import { EPResponse, Settings } from '@sitecore-cloudsdk/core';
|
|
5
|
+
import { BasicTypes, NestedObject } from '@sitecore-cloudsdk/utils';
|
|
6
6
|
export declare class CustomEvent extends BaseEvent {
|
|
7
|
-
customEventPayload:
|
|
7
|
+
customEventPayload: CustomEventPayload;
|
|
8
8
|
private eventApiClient;
|
|
9
9
|
private extensionData;
|
|
10
10
|
/**
|
|
11
11
|
* A class that extends from {@link BaseEvent} and has all the required functionality to send a VIEW event
|
|
12
12
|
* @param args - Unified object containing the required properties
|
|
13
13
|
*/
|
|
14
|
-
constructor(args:
|
|
14
|
+
constructor(args: CustomEventArguments);
|
|
15
15
|
/**
|
|
16
|
-
* Sends the event to Sitecore
|
|
17
|
-
* @returns - A promise that resolves with either the Sitecore
|
|
16
|
+
* Sends the event to Sitecore EP
|
|
17
|
+
* @returns - A promise that resolves with either the Sitecore EP response object or null
|
|
18
18
|
*/
|
|
19
|
-
send(): Promise<
|
|
19
|
+
send(): Promise<EPResponse | null>;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Interface of the unified arguments object for custom event
|
|
23
23
|
*/
|
|
24
|
-
export interface
|
|
25
|
-
eventApiClient:
|
|
26
|
-
eventData:
|
|
24
|
+
export interface CustomEventArguments {
|
|
25
|
+
eventApiClient: EventApiClient;
|
|
26
|
+
eventData: CustomEventData;
|
|
27
27
|
id: string;
|
|
28
|
-
extensionData?:
|
|
29
|
-
settings:
|
|
28
|
+
extensionData?: NestedObject;
|
|
29
|
+
settings: Settings;
|
|
30
30
|
type: string;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* Interface with the required/optional attributes in order to send a custom event to SitecoreCloud API
|
|
34
34
|
*/
|
|
35
|
-
export interface
|
|
35
|
+
export interface CustomEventPayload extends NestedObject {
|
|
36
36
|
ext?: {
|
|
37
37
|
[key: string]: BasicTypes;
|
|
38
38
|
};
|
|
@@ -40,11 +40,11 @@ export interface ICustomEventPayload extends INestedObject {
|
|
|
40
40
|
/**
|
|
41
41
|
* Interface with the required/optional attributes in order to send a custom event to SitecoreCloud API
|
|
42
42
|
*/
|
|
43
|
-
export interface
|
|
43
|
+
export interface CustomEventInput extends EventAttributesInput, NestedObject {
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
46
|
* Internal interface with the required/optional attributes in order to send a custom event to SitecoreCloud API
|
|
47
47
|
*/
|
|
48
|
-
interface
|
|
48
|
+
interface CustomEventData extends Partial<EventAttributesInput>, NestedObject {
|
|
49
49
|
}
|
|
50
50
|
export {};
|
|
@@ -28,8 +28,8 @@ class CustomEvent extends base_event_1.BaseEvent {
|
|
|
28
28
|
this.customEventPayload.ext = this.extensionData;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
|
-
* Sends the event to Sitecore
|
|
32
|
-
* @returns - A promise that resolves with either the Sitecore
|
|
31
|
+
* Sends the event to Sitecore EP
|
|
32
|
+
* @returns - A promise that resolves with either the Sitecore EP response object or null
|
|
33
33
|
*/
|
|
34
34
|
async send() {
|
|
35
35
|
const baseAttr = this.mapBaseEventPayload();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
2
|
import { ExtensionData } from '../common-interfaces';
|
|
3
|
-
import {
|
|
3
|
+
import { CustomEventInput } from './custom-event';
|
|
4
4
|
/**
|
|
5
5
|
* A function that sends an event to SitecoreCloud API with the specified type
|
|
6
6
|
* @param type - The required type of the event
|
|
7
7
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
8
8
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
9
9
|
* This object will be flattened and sent in the ext object of the payload
|
|
10
|
-
* @returns The response object that Sitecore
|
|
10
|
+
* @returns The response object that Sitecore EP returns
|
|
11
11
|
*/
|
|
12
|
-
export declare function event(type: string, eventData:
|
|
12
|
+
export declare function event(type: string, eventData: CustomEventInput, extensionData?: ExtensionData): Promise<EPResponse | null>;
|
|
@@ -10,7 +10,7 @@ const initializer_1 = require("../../initializer/browser/initializer");
|
|
|
10
10
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
11
11
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
12
12
|
* This object will be flattened and sent in the ext object of the payload
|
|
13
|
-
* @returns The response object that Sitecore
|
|
13
|
+
* @returns The response object that Sitecore EP returns
|
|
14
14
|
*/
|
|
15
15
|
function event(type, eventData, extensionData) {
|
|
16
16
|
const { eventApiClient, id, settings } = (0, initializer_1.getDependencies)();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
2
|
import { ExtensionData } from '../common-interfaces';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { CustomEventInput } from './custom-event';
|
|
4
|
+
import { Request } from '@sitecore-cloudsdk/utils';
|
|
5
5
|
/**
|
|
6
6
|
* A function that sends an event to SitecoreCloud API with the specified type
|
|
7
7
|
* @param type - The required type of the event
|
|
8
8
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
9
9
|
* @param request - Interface with constraint for extending request
|
|
10
10
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
11
|
-
* @returns The response object that Sitecore
|
|
11
|
+
* @returns The response object that Sitecore EP returns
|
|
12
12
|
*/
|
|
13
|
-
export declare function eventServer<T extends
|
|
13
|
+
export declare function eventServer<T extends Request>(type: string, eventData: CustomEventInput, request: T, extensionData?: ExtensionData): Promise<EPResponse | null>;
|
|
@@ -11,7 +11,7 @@ const initializer_1 = require("../../initializer/server/initializer");
|
|
|
11
11
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
12
12
|
* @param request - Interface with constraint for extending request
|
|
13
13
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
14
|
-
* @returns The response object that Sitecore
|
|
14
|
+
* @returns The response object that Sitecore EP returns
|
|
15
15
|
*/
|
|
16
16
|
function eventServer(type, eventData, request, extensionData) {
|
|
17
17
|
const { eventApiClient, settings } = (0, initializer_1.getServerDependencies)();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
2
2
|
/**
|
|
3
3
|
* A function that sends a form event to SitecoreCloud API
|
|
4
4
|
* @param formId - The required form ID string
|
|
5
5
|
* @param interactionType - The required interaction type string. Possible values: "VIEWED", "SUBMITTED"
|
|
6
6
|
* settings object, you must specify it here
|
|
7
|
-
* @returns The response object that Sitecore
|
|
7
|
+
* @returns The response object that Sitecore EP returns or null
|
|
8
8
|
*/
|
|
9
|
-
export declare function form(formId: string, interactionType: 'VIEWED' | 'SUBMITTED'): Promise<
|
|
9
|
+
export declare function form(formId: string, interactionType: 'VIEWED' | 'SUBMITTED'): Promise<EPResponse | null>;
|
|
@@ -9,7 +9,7 @@ const custom_event_1 = require("./custom-event");
|
|
|
9
9
|
* @param formId - The required form ID string
|
|
10
10
|
* @param interactionType - The required interaction type string. Possible values: "VIEWED", "SUBMITTED"
|
|
11
11
|
* settings object, you must specify it here
|
|
12
|
-
* @returns The response object that Sitecore
|
|
12
|
+
* @returns The response object that Sitecore EP returns or null
|
|
13
13
|
*/
|
|
14
14
|
function form(formId, interactionType) {
|
|
15
15
|
const { eventApiClient, id, settings } = (0, initializer_1.getDependencies)();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BaseEvent } from '../base-event';
|
|
2
|
-
import { ExtensionData,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { ExtensionData, EventAttributesInput } from '../common-interfaces';
|
|
3
|
+
import { EventApiClient } from '../../ep/EventApiClient';
|
|
4
|
+
import { FlattenedObject } from '@sitecore-cloudsdk/utils';
|
|
5
|
+
import { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
|
|
6
6
|
export declare class IdentityEvent extends BaseEvent {
|
|
7
7
|
private eventData;
|
|
8
8
|
private eventApiClient;
|
|
@@ -12,7 +12,7 @@ export declare class IdentityEvent extends BaseEvent {
|
|
|
12
12
|
* A class that extends from {@link BaseEvent} and has all the required functionality to send a VIEW event
|
|
13
13
|
* @param args - Unified object containing the required properties
|
|
14
14
|
*/
|
|
15
|
-
constructor(args:
|
|
15
|
+
constructor(args: IdentityEventArguments);
|
|
16
16
|
/**
|
|
17
17
|
* Function that validates the identifiers object, email and date attributes for CDN users
|
|
18
18
|
* * @param eventData - The data to be validated
|
|
@@ -24,15 +24,15 @@ export declare class IdentityEvent extends BaseEvent {
|
|
|
24
24
|
*/
|
|
25
25
|
private mapAttributes;
|
|
26
26
|
/**
|
|
27
|
-
* Sends the event to Sitecore
|
|
28
|
-
* @returns - A promise that resolves with either the Sitecore
|
|
27
|
+
* Sends the event to Sitecore EP
|
|
28
|
+
* @returns - A promise that resolves with either the Sitecore EP response object or null
|
|
29
29
|
*/
|
|
30
|
-
send(): Promise<
|
|
30
|
+
send(): Promise<EPResponse | null>;
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
33
|
* The JSON array of objects that contain the identity identifiers
|
|
34
34
|
*/
|
|
35
|
-
interface
|
|
35
|
+
interface EPIdentifier {
|
|
36
36
|
expiry_date?: string;
|
|
37
37
|
id: string;
|
|
38
38
|
provider: string;
|
|
@@ -40,14 +40,14 @@ interface ICDPIdentifier {
|
|
|
40
40
|
/**
|
|
41
41
|
* Interface with the necessary attributes for the input for sending Identity events
|
|
42
42
|
*/
|
|
43
|
-
export interface
|
|
43
|
+
export interface IdentityEventAttributesInput extends EventAttributesInput {
|
|
44
44
|
city?: string;
|
|
45
45
|
country?: string;
|
|
46
46
|
dob?: string;
|
|
47
47
|
email?: string;
|
|
48
48
|
firstName?: string;
|
|
49
49
|
gender?: string;
|
|
50
|
-
identifiers:
|
|
50
|
+
identifiers: Identifier[];
|
|
51
51
|
lastName?: string;
|
|
52
52
|
mobile?: string;
|
|
53
53
|
phone?: string;
|
|
@@ -59,7 +59,7 @@ export interface IIdentityEventAttributesInput extends IEventAttributesInput {
|
|
|
59
59
|
/**
|
|
60
60
|
* The JSON array of objects that contain the identity identifiers
|
|
61
61
|
*/
|
|
62
|
-
export interface
|
|
62
|
+
export interface Identifier {
|
|
63
63
|
expiryDate?: string;
|
|
64
64
|
id: string;
|
|
65
65
|
provider: string;
|
|
@@ -67,14 +67,14 @@ export interface IIdentifier {
|
|
|
67
67
|
/**
|
|
68
68
|
* An interface describing the identity event specific payload to be sent to the API
|
|
69
69
|
*/
|
|
70
|
-
export interface
|
|
70
|
+
export interface IdentityEventPayload {
|
|
71
71
|
city?: string;
|
|
72
72
|
country?: string;
|
|
73
73
|
dob?: string;
|
|
74
74
|
email?: string;
|
|
75
75
|
firstname?: string;
|
|
76
76
|
gender?: string;
|
|
77
|
-
identifiers:
|
|
77
|
+
identifiers: EPIdentifier[];
|
|
78
78
|
lastname?: string;
|
|
79
79
|
mobile?: string;
|
|
80
80
|
phone?: string;
|
|
@@ -83,17 +83,17 @@ export interface IIdentityEventPayload {
|
|
|
83
83
|
street?: string[];
|
|
84
84
|
title?: string;
|
|
85
85
|
type: 'IDENTITY';
|
|
86
|
-
ext?:
|
|
86
|
+
ext?: FlattenedObject;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
89
|
* Interface of the unified arguments object for identity event
|
|
90
90
|
*/
|
|
91
|
-
export interface
|
|
92
|
-
eventApiClient:
|
|
93
|
-
eventData:
|
|
91
|
+
export interface IdentityEventArguments {
|
|
92
|
+
eventApiClient: EventApiClient;
|
|
93
|
+
eventData: IdentityEventAttributesInput;
|
|
94
94
|
extensionData?: ExtensionData;
|
|
95
95
|
id: string;
|
|
96
|
-
settings:
|
|
97
|
-
infer?:
|
|
96
|
+
settings: Settings;
|
|
97
|
+
infer?: Infer;
|
|
98
98
|
}
|
|
99
99
|
export {};
|
|
@@ -30,7 +30,7 @@ class IdentityEvent extends base_event_1.BaseEvent {
|
|
|
30
30
|
*/
|
|
31
31
|
validateAttributes(eventData) {
|
|
32
32
|
if (eventData.identifiers.length === 0)
|
|
33
|
-
throw new Error(`[MV-
|
|
33
|
+
throw new Error(`[MV-0003] "identifiers" is required.`);
|
|
34
34
|
if (eventData.dob !== undefined && !(0, utils_1.isShortISODateString)(eventData.dob))
|
|
35
35
|
throw new Error(`[IV-0002] Incorrect value for "dob". Format the value according to ISO 8601.`);
|
|
36
36
|
eventData.identifiers.forEach((identifier) => {
|
|
@@ -75,8 +75,8 @@ class IdentityEvent extends base_event_1.BaseEvent {
|
|
|
75
75
|
return identityPayload;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* Sends the event to Sitecore
|
|
79
|
-
* @returns - A promise that resolves with either the Sitecore
|
|
78
|
+
* Sends the event to Sitecore EP
|
|
79
|
+
* @returns - A promise that resolves with either the Sitecore EP response object or null
|
|
80
80
|
*/
|
|
81
81
|
async send() {
|
|
82
82
|
const baseAttr = this.mapBaseEventPayload();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ExtensionData } from '../common-interfaces';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
3
|
+
import { IdentityEventAttributesInput } from './identity-event';
|
|
4
4
|
/**
|
|
5
5
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
6
6
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
7
7
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
8
8
|
* This object will be flattened and sent in the ext object of the payload
|
|
9
|
-
* @returns The response object that Sitecore
|
|
9
|
+
* @returns The response object that Sitecore EP returns
|
|
10
10
|
*/
|
|
11
|
-
export declare function identity(eventData:
|
|
11
|
+
export declare function identity(eventData: IdentityEventAttributesInput, extensionData?: ExtensionData): Promise<EPResponse | null>;
|
|
@@ -9,7 +9,7 @@ const identity_event_1 = require("./identity-event");
|
|
|
9
9
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
10
10
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
11
11
|
* This object will be flattened and sent in the ext object of the payload
|
|
12
|
-
* @returns The response object that Sitecore
|
|
12
|
+
* @returns The response object that Sitecore EP returns
|
|
13
13
|
*/
|
|
14
14
|
function identity(eventData, extensionData) {
|
|
15
15
|
const { eventApiClient, id, settings } = (0, initializer_1.getDependencies)();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { ExtensionData } from '../common-interfaces';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Request } from '@sitecore-cloudsdk/utils';
|
|
3
|
+
import { EPResponse } from '@sitecore-cloudsdk/core';
|
|
4
|
+
import { IdentityEventAttributesInput } from './identity-event';
|
|
5
5
|
/**
|
|
6
6
|
* A function that sends an IDENTITY event to SitecoreCloud API
|
|
7
7
|
* @param eventData - The required/optional attributes in order to be send to SitecoreCloud API
|
|
8
8
|
* @param request - Interface with constraint for extending request
|
|
9
9
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
10
10
|
* This object will be flattened and sent in the ext object of the payload
|
|
11
|
-
* @returns The response object that Sitecore
|
|
11
|
+
* @returns The response object that Sitecore EP returns
|
|
12
12
|
*/
|
|
13
|
-
export declare function identityServer(eventData:
|
|
13
|
+
export declare function identityServer(eventData: IdentityEventAttributesInput, request: Request, extensionData?: ExtensionData): Promise<EPResponse | null>;
|
|
@@ -11,7 +11,7 @@ const identity_event_1 = require("./identity-event");
|
|
|
11
11
|
* @param request - Interface with constraint for extending request
|
|
12
12
|
* @param extensionData - The optional extensionData attributes that will be sent to SitecoreCloud API.
|
|
13
13
|
* This object will be flattened and sent in the ext object of the payload
|
|
14
|
-
* @returns The response object that Sitecore
|
|
14
|
+
* @returns The response object that Sitecore EP returns
|
|
15
15
|
*/
|
|
16
16
|
function identityServer(eventData, request, extensionData) {
|
|
17
17
|
const { eventApiClient, settings } = (0, initializer_1.getServerDependencies)();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { BaseEvent } from './base-event';
|
|
2
|
-
export type {
|
|
2
|
+
export type { BasePayload } from './base-event';
|
|
3
3
|
export { PageViewEvent } from './page-view/page-view-event';
|
|
4
|
-
export type {
|
|
4
|
+
export type { PageViewEventInput, PageViewEventPayload } from './page-view/page-view-event';
|
|
5
5
|
export { CustomEvent } from './custom-event/custom-event';
|
|
6
|
-
export type {
|
|
6
|
+
export type { CustomEventInput, CustomEventPayload, CustomEventArguments } from './custom-event/custom-event';
|
|
7
7
|
export { IdentityEvent } from './identity/identity-event';
|
|
8
|
-
export type {
|
|
8
|
+
export type { IdentityEventAttributesInput, IdentityEventPayload } from './identity/identity-event';
|
|
9
9
|
export type { ExtensionData } from './common-interfaces';
|