@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.
Files changed (79) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/browser.d.ts +1 -1
  3. package/dist/cjs/src/lib/ep/EventApiClient.d.ts +18 -0
  4. package/dist/cjs/src/lib/{cdp → ep}/EventApiClient.js +3 -3
  5. package/dist/cjs/src/lib/eventStorage/addToEventQueue.d.ts +2 -2
  6. package/dist/cjs/src/lib/eventStorage/eventStorage.d.ts +7 -7
  7. package/dist/cjs/src/lib/eventStorage/eventStorage.js +2 -2
  8. package/dist/cjs/src/lib/events/base-event.d.ts +8 -8
  9. package/dist/cjs/src/lib/events/base-event.js +1 -1
  10. package/dist/cjs/src/lib/events/common-interfaces.d.ts +10 -18
  11. package/dist/cjs/src/lib/events/custom-event/custom-event.d.ts +17 -17
  12. package/dist/cjs/src/lib/events/custom-event/custom-event.js +2 -2
  13. package/dist/cjs/src/lib/events/custom-event/event.d.ts +4 -4
  14. package/dist/cjs/src/lib/events/custom-event/event.js +1 -1
  15. package/dist/cjs/src/lib/events/custom-event/eventServer.d.ts +5 -5
  16. package/dist/cjs/src/lib/events/custom-event/eventServer.js +1 -1
  17. package/dist/cjs/src/lib/events/custom-event/form.d.ts +3 -3
  18. package/dist/cjs/src/lib/events/custom-event/form.js +1 -1
  19. package/dist/cjs/src/lib/events/identity/identity-event.d.ts +20 -20
  20. package/dist/cjs/src/lib/events/identity/identity-event.js +3 -3
  21. package/dist/cjs/src/lib/events/identity/identity.d.ts +4 -4
  22. package/dist/cjs/src/lib/events/identity/identity.js +1 -1
  23. package/dist/cjs/src/lib/events/identity/identityServer.d.ts +5 -5
  24. package/dist/cjs/src/lib/events/identity/identityServer.js +1 -1
  25. package/dist/cjs/src/lib/events/index.d.ts +4 -4
  26. package/dist/cjs/src/lib/events/page-view/page-view-event.d.ts +25 -18
  27. package/dist/cjs/src/lib/events/page-view/page-view-event.js +21 -2
  28. package/dist/cjs/src/lib/events/page-view/page-view-server.d.ts +5 -5
  29. package/dist/cjs/src/lib/events/page-view/page-view-server.js +1 -1
  30. package/dist/cjs/src/lib/events/page-view/page-view.d.ts +5 -5
  31. package/dist/cjs/src/lib/events/page-view/page-view.js +1 -1
  32. package/dist/cjs/src/lib/initializer/browser/initializer.d.ts +7 -7
  33. package/dist/cjs/src/lib/initializer/browser/initializer.js +2 -2
  34. package/dist/cjs/src/lib/initializer/server/initializer.d.ts +8 -8
  35. package/dist/cjs/src/lib/initializer/server/initializer.js +2 -2
  36. package/dist/cjs/src/server.d.ts +2 -3
  37. package/dist/cjs/src/server.js +1 -3
  38. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  39. package/dist/esm/package.json +1 -1
  40. package/dist/esm/src/browser.d.ts +1 -1
  41. package/dist/esm/src/lib/ep/EventApiClient.d.ts +18 -0
  42. package/dist/esm/src/lib/{cdp → ep}/EventApiClient.js +3 -3
  43. package/dist/esm/src/lib/eventStorage/addToEventQueue.d.ts +2 -2
  44. package/dist/esm/src/lib/eventStorage/eventStorage.d.ts +7 -7
  45. package/dist/esm/src/lib/eventStorage/eventStorage.js +2 -2
  46. package/dist/esm/src/lib/events/base-event.d.ts +8 -8
  47. package/dist/esm/src/lib/events/base-event.js +1 -1
  48. package/dist/esm/src/lib/events/common-interfaces.d.ts +10 -18
  49. package/dist/esm/src/lib/events/custom-event/custom-event.d.ts +17 -17
  50. package/dist/esm/src/lib/events/custom-event/custom-event.js +2 -2
  51. package/dist/esm/src/lib/events/custom-event/event.d.ts +4 -4
  52. package/dist/esm/src/lib/events/custom-event/event.js +1 -1
  53. package/dist/esm/src/lib/events/custom-event/eventServer.d.ts +5 -5
  54. package/dist/esm/src/lib/events/custom-event/eventServer.js +1 -1
  55. package/dist/esm/src/lib/events/custom-event/form.d.ts +3 -3
  56. package/dist/esm/src/lib/events/custom-event/form.js +1 -1
  57. package/dist/esm/src/lib/events/identity/identity-event.d.ts +20 -20
  58. package/dist/esm/src/lib/events/identity/identity-event.js +3 -3
  59. package/dist/esm/src/lib/events/identity/identity.d.ts +4 -4
  60. package/dist/esm/src/lib/events/identity/identity.js +1 -1
  61. package/dist/esm/src/lib/events/identity/identityServer.d.ts +5 -5
  62. package/dist/esm/src/lib/events/identity/identityServer.js +1 -1
  63. package/dist/esm/src/lib/events/index.d.ts +4 -4
  64. package/dist/esm/src/lib/events/page-view/page-view-event.d.ts +25 -18
  65. package/dist/esm/src/lib/events/page-view/page-view-event.js +22 -3
  66. package/dist/esm/src/lib/events/page-view/page-view-server.d.ts +5 -5
  67. package/dist/esm/src/lib/events/page-view/page-view-server.js +1 -1
  68. package/dist/esm/src/lib/events/page-view/page-view.d.ts +5 -5
  69. package/dist/esm/src/lib/events/page-view/page-view.js +1 -1
  70. package/dist/esm/src/lib/initializer/browser/initializer.d.ts +7 -7
  71. package/dist/esm/src/lib/initializer/browser/initializer.js +2 -2
  72. package/dist/esm/src/lib/initializer/server/initializer.d.ts +8 -8
  73. package/dist/esm/src/lib/initializer/server/initializer.js +3 -3
  74. package/dist/esm/src/server.d.ts +2 -3
  75. package/dist/esm/src/server.js +0 -1
  76. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  77. package/package.json +1 -1
  78. package/dist/cjs/src/lib/cdp/EventApiClient.d.ts +0 -24
  79. package/dist/esm/src/lib/cdp/EventApiClient.d.ts +0 -24
@@ -1,16 +1,16 @@
1
- import { EventApiClient } from '../cdp/EventApiClient';
2
- import { ICustomEventArguments } from '../events';
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 CDP
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: IStorage, eventApiClient: EventApiClient);
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 CDP.
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 IStorage {
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<ICustomEventArguments, 'eventData' | 'extensionData' | 'type' | 'settings' | 'id'>;
39
+ export type QueueEventPayload = Pick<CustomEventArguments, 'eventData' | 'extensionData' | 'type' | 'settings' | 'id'>;
@@ -8,7 +8,7 @@ export class EventQueue {
8
8
  /**
9
9
  * Initialize the Event Storage
10
10
  * @param storage - Interface that describes the storage functionality
11
- * @param eventApiClient - The API client which sends events to CDP
11
+ * @param eventApiClient - The API client which sends events to EP
12
12
  * @param infer - The instance of the infer class
13
13
  */
14
14
  this.key = 'EventQueue';
@@ -43,7 +43,7 @@ export class EventQueue {
43
43
  this.storage.setItem(this.key, JSON.stringify(eventQueue));
44
44
  }
45
45
  /**
46
- * Iterates the queue, and sends sequently the custom events to Sitecore CDP.
46
+ * Iterates the queue, and sends sequently the custom events to Sitecore EP.
47
47
  */
48
48
  async sendAllEvents() {
49
49
  const eventQueue = this.getEventQueue();
@@ -1,8 +1,8 @@
1
- import type { ISettings } from '@sitecore-cloudsdk/core';
2
- import { IEventAttributesInput } from './common-interfaces';
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: ISettings;
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: IBaseEventData, settings: ISettings, id: string);
16
+ constructor(baseEventData: BaseEventData, settings: Settings, id: string);
17
17
  /**
18
- * A function that returns the properties for sending events to Sitecore CDP
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(): IBasePayload;
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 IBasePayload {
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 IBaseEventData = Partial<IEventAttributesInput>;
35
+ type BaseEventData = Partial<EventAttributesInput>;
36
36
  export {};
@@ -16,7 +16,7 @@ export class BaseEvent {
16
16
  this.page = this.baseEventData.page ?? pageName();
17
17
  }
18
18
  /**
19
- * A function that returns the properties for sending events to Sitecore CDP
19
+ * A function that returns the properties for sending events to Sitecore EP
20
20
  * @returns an object that is required
21
21
  */
22
22
  mapBaseEventPayload() {
@@ -1,39 +1,31 @@
1
- import { BasicTypes, INestedObject } from '@sitecore-cloudsdk/utils';
1
+ import { NestedObject } from '@sitecore-cloudsdk/utils';
2
2
  /**
3
- * Event data received as input to be sent to Sitecore CDP
3
+ * Event data received as input to be sent to Sitecore EP
4
4
  */
5
- interface IMandatoryInput {
5
+ interface MandatoryInput {
6
6
  channel: string;
7
7
  currency: string;
8
8
  }
9
- type IMandatoryEventInput = IMandatoryInput;
9
+ type MandatoryEventInput = MandatoryInput;
10
10
  /**
11
- * Event data that is sent to Sitecore CDP
11
+ * Event data that is sent to Sitecore EP
12
12
  */
13
- interface IInferrableInput {
13
+ interface InferrableInput {
14
14
  /**
15
- * To be restored back to IMandatoryEventInput Interface
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 IInferrableEventInput = IInferrableInput;
21
+ type InferrableEventInput = InferrableInput;
23
22
  /**
24
23
  * Interface to hold the base event attributes
25
24
  */
26
- export interface IEventAttributesInput extends IMandatoryEventInput, IInferrableEventInput {
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 = INestedObject;
30
+ export type ExtensionData = NestedObject;
39
31
  export {};
@@ -1,38 +1,38 @@
1
1
  import { BaseEvent } from '../base-event';
2
- import { IEventAttributesInput } from '../common-interfaces';
3
- import { IEventApiClient } from '../../cdp/EventApiClient';
4
- import { ICdpResponse, ISettings } from '@sitecore-cloudsdk/core';
5
- import { BasicTypes, INestedObject } from '@sitecore-cloudsdk/utils';
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: ICustomEventPayload;
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: ICustomEventArguments);
14
+ constructor(args: CustomEventArguments);
15
15
  /**
16
- * Sends the event to Sitecore CDP
17
- * @returns - A promise that resolves with either the Sitecore CDP response object or null
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<ICdpResponse | null>;
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 ICustomEventArguments {
25
- eventApiClient: IEventApiClient;
26
- eventData: ICustomEventData;
24
+ export interface CustomEventArguments {
25
+ eventApiClient: EventApiClient;
26
+ eventData: CustomEventData;
27
27
  id: string;
28
- extensionData?: INestedObject;
29
- settings: ISettings;
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 ICustomEventPayload extends INestedObject {
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 ICustomEventInput extends IEventAttributesInput, INestedObject {
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 ICustomEventData extends Partial<IEventAttributesInput>, INestedObject {
48
+ interface CustomEventData extends Partial<EventAttributesInput>, NestedObject {
49
49
  }
50
50
  export {};
@@ -25,8 +25,8 @@ export class CustomEvent extends BaseEvent {
25
25
  this.customEventPayload.ext = this.extensionData;
26
26
  }
27
27
  /**
28
- * Sends the event to Sitecore CDP
29
- * @returns - A promise that resolves with either the Sitecore CDP response object or null
28
+ * Sends the event to Sitecore EP
29
+ * @returns - A promise that resolves with either the Sitecore EP response object or null
30
30
  */
31
31
  async send() {
32
32
  const baseAttr = this.mapBaseEventPayload();
@@ -1,12 +1,12 @@
1
- import { ICdpResponse } from '@sitecore-cloudsdk/core';
1
+ import { EPResponse } from '@sitecore-cloudsdk/core';
2
2
  import { ExtensionData } from '../common-interfaces';
3
- import { ICustomEventInput } from './custom-event';
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 CDP returns
10
+ * @returns The response object that Sitecore EP returns
11
11
  */
12
- export declare function event(type: string, eventData: ICustomEventInput, extensionData?: ExtensionData): Promise<ICdpResponse | null>;
12
+ export declare function event(type: string, eventData: CustomEventInput, extensionData?: ExtensionData): Promise<EPResponse | null>;
@@ -7,7 +7,7 @@ import { getDependencies } from '../../initializer/browser/initializer';
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 CDP returns
10
+ * @returns The response object that Sitecore EP returns
11
11
  */
12
12
  export function event(type, eventData, extensionData) {
13
13
  const { eventApiClient, id, settings } = getDependencies();
@@ -1,13 +1,13 @@
1
- import { ICdpResponse } from '@sitecore-cloudsdk/core';
1
+ import { EPResponse } from '@sitecore-cloudsdk/core';
2
2
  import { ExtensionData } from '../common-interfaces';
3
- import { ICustomEventInput } from './custom-event';
4
- import { TRequest } from '@sitecore-cloudsdk/utils';
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 CDP returns
11
+ * @returns The response object that Sitecore EP returns
12
12
  */
13
- export declare function eventServer<T extends TRequest>(type: string, eventData: ICustomEventInput, request: T, extensionData?: ExtensionData): Promise<ICdpResponse | null>;
13
+ export declare function eventServer<T extends Request>(type: string, eventData: CustomEventInput, request: T, extensionData?: ExtensionData): Promise<EPResponse | null>;
@@ -8,7 +8,7 @@ import { getServerDependencies } from '../../initializer/server/initializer';
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 CDP returns
11
+ * @returns The response object that Sitecore EP returns
12
12
  */
13
13
  export function eventServer(type, eventData, request, extensionData) {
14
14
  const { eventApiClient, settings } = getServerDependencies();
@@ -1,9 +1,9 @@
1
- import { ICdpResponse } from '@sitecore-cloudsdk/core';
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 CDP returns or null
7
+ * @returns The response object that Sitecore EP returns or null
8
8
  */
9
- export declare function form(formId: string, interactionType: 'VIEWED' | 'SUBMITTED'): Promise<ICdpResponse | null>;
9
+ export declare function form(formId: string, interactionType: 'VIEWED' | 'SUBMITTED'): Promise<EPResponse | null>;
@@ -6,7 +6,7 @@ import { CustomEvent } from './custom-event';
6
6
  * @param formId - The required form ID string
7
7
  * @param interactionType - The required interaction type string. Possible values: "VIEWED", "SUBMITTED"
8
8
  * settings object, you must specify it here
9
- * @returns The response object that Sitecore CDP returns or null
9
+ * @returns The response object that Sitecore EP returns or null
10
10
  */
11
11
  export function form(formId, interactionType) {
12
12
  const { eventApiClient, id, settings } = getDependencies();
@@ -1,8 +1,8 @@
1
1
  import { BaseEvent } from '../base-event';
2
- import { ExtensionData, IEventAttributesInput } from '../common-interfaces';
3
- import { IEventApiClient } from '../../cdp/EventApiClient';
4
- import { IFlattenedObject } from '@sitecore-cloudsdk/utils';
5
- import { ICdpResponse, IInfer, ISettings } from '@sitecore-cloudsdk/core';
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: IIdentityEventArguments);
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 CDP
28
- * @returns - A promise that resolves with either the Sitecore CDP response object or null
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<ICdpResponse | null>;
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 ICDPIdentifier {
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 IIdentityEventAttributesInput extends IEventAttributesInput {
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: IIdentifier[];
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 IIdentifier {
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 IIdentityEventPayload {
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: ICDPIdentifier[];
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?: IFlattenedObject;
86
+ ext?: FlattenedObject;
87
87
  }
88
88
  /**
89
89
  * Interface of the unified arguments object for identity event
90
90
  */
91
- export interface IIdentityEventArguments {
92
- eventApiClient: IEventApiClient;
93
- eventData: IIdentityEventAttributesInput;
91
+ export interface IdentityEventArguments {
92
+ eventApiClient: EventApiClient;
93
+ eventData: IdentityEventAttributesInput;
94
94
  extensionData?: ExtensionData;
95
95
  id: string;
96
- settings: ISettings;
97
- infer?: IInfer;
96
+ settings: Settings;
97
+ infer?: Infer;
98
98
  }
99
99
  export {};
@@ -27,7 +27,7 @@ export class IdentityEvent extends BaseEvent {
27
27
  */
28
28
  validateAttributes(eventData) {
29
29
  if (eventData.identifiers.length === 0)
30
- throw new Error(`[MV-0004] "identifiers" is required.`);
30
+ throw new Error(`[MV-0003] "identifiers" is required.`);
31
31
  if (eventData.dob !== undefined && !isShortISODateString(eventData.dob))
32
32
  throw new Error(`[IV-0002] Incorrect value for "dob". Format the value according to ISO 8601.`);
33
33
  eventData.identifiers.forEach((identifier) => {
@@ -72,8 +72,8 @@ export class IdentityEvent extends BaseEvent {
72
72
  return identityPayload;
73
73
  }
74
74
  /**
75
- * Sends the event to Sitecore CDP
76
- * @returns - A promise that resolves with either the Sitecore CDP response object or null
75
+ * Sends the event to Sitecore EP
76
+ * @returns - A promise that resolves with either the Sitecore EP response object or null
77
77
  */
78
78
  async send() {
79
79
  const baseAttr = this.mapBaseEventPayload();
@@ -1,11 +1,11 @@
1
1
  import { ExtensionData } from '../common-interfaces';
2
- import { ICdpResponse } from '@sitecore-cloudsdk/core';
3
- import { IIdentityEventAttributesInput } from './identity-event';
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 CDP returns
9
+ * @returns The response object that Sitecore EP returns
10
10
  */
11
- export declare function identity(eventData: IIdentityEventAttributesInput, extensionData?: ExtensionData): Promise<ICdpResponse | null>;
11
+ export declare function identity(eventData: IdentityEventAttributesInput, extensionData?: ExtensionData): Promise<EPResponse | null>;
@@ -6,7 +6,7 @@ import { IdentityEvent } from './identity-event';
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 CDP returns
9
+ * @returns The response object that Sitecore EP returns
10
10
  */
11
11
  export function identity(eventData, extensionData) {
12
12
  const { eventApiClient, id, settings } = getDependencies();
@@ -1,13 +1,13 @@
1
1
  import { ExtensionData } from '../common-interfaces';
2
- import { TRequest } from '@sitecore-cloudsdk/utils';
3
- import { ICdpResponse } from '@sitecore-cloudsdk/core';
4
- import { IIdentityEventAttributesInput } from './identity-event';
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 CDP returns
11
+ * @returns The response object that Sitecore EP returns
12
12
  */
13
- export declare function identityServer(eventData: IIdentityEventAttributesInput, request: TRequest, extensionData?: ExtensionData): Promise<ICdpResponse | null>;
13
+ export declare function identityServer(eventData: IdentityEventAttributesInput, request: Request, extensionData?: ExtensionData): Promise<EPResponse | null>;
@@ -8,7 +8,7 @@ import { IdentityEvent } from './identity-event';
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 CDP returns
11
+ * @returns The response object that Sitecore EP returns
12
12
  */
13
13
  export function identityServer(eventData, request, extensionData) {
14
14
  const { eventApiClient, settings } = getServerDependencies();
@@ -1,9 +1,9 @@
1
1
  export { BaseEvent } from './base-event';
2
- export type { IBasePayload } from './base-event';
2
+ export type { BasePayload } from './base-event';
3
3
  export { PageViewEvent } from './page-view/page-view-event';
4
- export type { IPageViewEventInput, IPageViewEventPayload } from './page-view/page-view-event';
4
+ export type { PageViewEventInput, PageViewEventPayload } from './page-view/page-view-event';
5
5
  export { CustomEvent } from './custom-event/custom-event';
6
- export type { ICustomEventInput, ICustomEventPayload, ICustomEventArguments } from './custom-event/custom-event';
6
+ export type { CustomEventInput, CustomEventPayload, CustomEventArguments } from './custom-event/custom-event';
7
7
  export { IdentityEvent } from './identity/identity-event';
8
- export type { IIdentityEventAttributesInput, IIdentityEventPayload } from './identity/identity-event';
8
+ export type { IdentityEventAttributesInput, IdentityEventPayload } from './identity/identity-event';
9
9
  export type { ExtensionData } from './common-interfaces';
@@ -1,19 +1,20 @@
1
- import { ICdpResponse, IInfer, ISettings } from '@sitecore-cloudsdk/core';
2
- import { IFlattenedObject, INestedObject } from '@sitecore-cloudsdk/utils';
1
+ import { EPResponse, Infer, Settings } from '@sitecore-cloudsdk/core';
2
+ import { FlattenedObject, NestedObject } from '@sitecore-cloudsdk/utils';
3
3
  import { BaseEvent } from '../base-event';
4
- import { IEventApiClient } from '../../cdp/EventApiClient';
5
- import { IEventAttributesInput } from '../common-interfaces';
4
+ import { EventApiClient } from '../../ep/EventApiClient';
5
+ import { EventAttributesInput } from '../common-interfaces';
6
6
  export declare class PageViewEvent extends BaseEvent {
7
7
  static isFirstPageView: boolean;
8
8
  private eventApiClient;
9
9
  private eventData;
10
10
  private extensionData;
11
11
  private urlSearchParams;
12
+ private includeUTMParameters;
12
13
  /**
13
14
  * A class that extends from {@link BaseEvent} and has all the required functionality to send a VIEW event
14
15
  * @param args - Unified object containing the required properties
15
16
  */
16
- constructor(args: IPageViewEventArguments);
17
+ constructor(args: PageViewEventArguments);
17
18
  /**
18
19
  * Gets the variant ID from the url if not passed by the developer
19
20
  * Gets the variant ID from the extension data if not found from the url
@@ -32,44 +33,50 @@ export declare class PageViewEvent extends BaseEvent {
32
33
  */
33
34
  private mapAttributes;
34
35
  /**
35
- * Sends the event to Sitecore CDP
36
- * @returns - A promise that resolves with either the Sitecore CDP response object or null
36
+ * Sends the event to Sitecore EP
37
+ * @returns - A promise that resolves with either the Sitecore EP response object or null
37
38
  */
38
- send(): Promise<ICdpResponse | null>;
39
+ send(): Promise<EPResponse | null>;
40
+ /**
41
+ * Retrieves UTM parameters from the url query string
42
+ * @returns - an object containing the UTM parameters if they exist
43
+ */
44
+ private getUTMParameters;
39
45
  }
40
46
  /**
41
47
  * Interface of the unified arguments object for page view event
42
48
  */
43
- export interface IPageViewEventArguments {
44
- eventApiClient: IEventApiClient;
45
- eventData: IPageViewEventInput;
49
+ export interface PageViewEventArguments {
50
+ eventApiClient: EventApiClient;
51
+ eventData: PageViewEventInput;
46
52
  id: string;
47
- settings: ISettings;
48
- infer?: IInfer;
49
- extensionData?: INestedObject;
53
+ settings: Settings;
54
+ infer?: Infer;
55
+ extensionData?: NestedObject;
50
56
  searchParams: string;
51
57
  }
52
58
  /**
53
59
  * Type with the required/optional attributes in order to send a view event to SitecoreCloud API
54
60
  */
55
- export interface IPageViewEventInput extends IEventAttributesInput {
61
+ export interface PageViewEventInput extends EventAttributesInput {
56
62
  pageVariantId?: string;
57
63
  referrer?: string;
64
+ includeUTMParameters?: boolean;
58
65
  }
59
66
  /**
60
67
  * Interface with the utm_ parameters
61
68
  */
62
- interface IUtmParameters {
69
+ interface UtmParameters {
63
70
  [key: `utm_${string}`]: string;
64
71
  }
65
72
  /**
66
73
  * An interface describing the page view event specific payload to be sent * to the API
67
74
  */
68
- export interface IPageViewEventPayload extends IUtmParameters {
75
+ export interface PageViewEventPayload extends UtmParameters {
69
76
  type: 'VIEW';
70
77
  referrer?: string;
71
78
  ext?: {
72
79
  pageVariantId?: string;
73
- } & IFlattenedObject;
80
+ } & FlattenedObject;
74
81
  }
75
82
  export {};