@sitecore-content-sdk/events 2.0.0-canary.12

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 (103) hide show
  1. package/LICENSE.MD +202 -0
  2. package/README.md +91 -0
  3. package/browser.d.ts +2 -0
  4. package/dist/cjs/package.json +80 -0
  5. package/dist/cjs/src/browser.js +9 -0
  6. package/dist/cjs/src/consts.js +21 -0
  7. package/dist/cjs/src/debug.js +12 -0
  8. package/dist/cjs/src/eventStorage/addToEventQueue.js +25 -0
  9. package/dist/cjs/src/eventStorage/clearEventQueue.js +15 -0
  10. package/dist/cjs/src/eventStorage/eventStorage.js +67 -0
  11. package/dist/cjs/src/eventStorage/processEventQueue.js +16 -0
  12. package/dist/cjs/src/events/base-event.js +35 -0
  13. package/dist/cjs/src/events/common-interfaces.js +2 -0
  14. package/dist/cjs/src/events/consts.js +5 -0
  15. package/dist/cjs/src/events/custom-event/custom-event.js +62 -0
  16. package/dist/cjs/src/events/custom-event/event.js +27 -0
  17. package/dist/cjs/src/events/custom-event/form.js +38 -0
  18. package/dist/cjs/src/events/identity/identity-event.js +93 -0
  19. package/dist/cjs/src/events/identity/identity.js +27 -0
  20. package/dist/cjs/src/events/index.js +11 -0
  21. package/dist/cjs/src/events/page-view/page-view-event.js +131 -0
  22. package/dist/cjs/src/events/page-view/page-view.js +30 -0
  23. package/dist/cjs/src/events/send-event/sendEvent.js +36 -0
  24. package/dist/cjs/src/index.js +13 -0
  25. package/dist/cjs/src/initialization/const.js +8 -0
  26. package/dist/cjs/src/initialization/plugin.js +56 -0
  27. package/dist/cjs/src/initialization/types.js +2 -0
  28. package/dist/cjs/src/internal.js +8 -0
  29. package/dist/esm/package.json +80 -0
  30. package/dist/esm/src/browser.js +3 -0
  31. package/dist/esm/src/consts.js +15 -0
  32. package/dist/esm/src/debug.js +9 -0
  33. package/dist/esm/src/eventStorage/addToEventQueue.js +22 -0
  34. package/dist/esm/src/eventStorage/clearEventQueue.js +12 -0
  35. package/dist/esm/src/eventStorage/eventStorage.js +64 -0
  36. package/dist/esm/src/eventStorage/processEventQueue.js +13 -0
  37. package/dist/esm/src/events/base-event.js +31 -0
  38. package/dist/esm/src/events/common-interfaces.js +1 -0
  39. package/dist/esm/src/events/consts.js +2 -0
  40. package/dist/esm/src/events/custom-event/custom-event.js +58 -0
  41. package/dist/esm/src/events/custom-event/event.js +24 -0
  42. package/dist/esm/src/events/custom-event/form.js +35 -0
  43. package/dist/esm/src/events/identity/identity-event.js +89 -0
  44. package/dist/esm/src/events/identity/identity.js +24 -0
  45. package/dist/esm/src/events/index.js +4 -0
  46. package/dist/esm/src/events/page-view/page-view-event.js +127 -0
  47. package/dist/esm/src/events/page-view/page-view.js +27 -0
  48. package/dist/esm/src/events/send-event/sendEvent.js +33 -0
  49. package/dist/esm/src/index.js +5 -0
  50. package/dist/esm/src/initialization/const.js +5 -0
  51. package/dist/esm/src/initialization/plugin.js +52 -0
  52. package/dist/esm/src/initialization/types.js +1 -0
  53. package/dist/esm/src/internal.js +2 -0
  54. package/internal.d.ts +2 -0
  55. package/package.json +80 -0
  56. package/types/src/browser.d.ts +4 -0
  57. package/types/src/browser.d.ts.map +1 -0
  58. package/types/src/consts.d.ts +15 -0
  59. package/types/src/consts.d.ts.map +1 -0
  60. package/types/src/debug.d.ts +9 -0
  61. package/types/src/debug.d.ts.map +1 -0
  62. package/types/src/eventStorage/addToEventQueue.d.ts +8 -0
  63. package/types/src/eventStorage/addToEventQueue.d.ts.map +1 -0
  64. package/types/src/eventStorage/clearEventQueue.d.ts +6 -0
  65. package/types/src/eventStorage/clearEventQueue.d.ts.map +1 -0
  66. package/types/src/eventStorage/eventStorage.d.ts +31 -0
  67. package/types/src/eventStorage/eventStorage.d.ts.map +1 -0
  68. package/types/src/eventStorage/processEventQueue.d.ts +7 -0
  69. package/types/src/eventStorage/processEventQueue.d.ts.map +1 -0
  70. package/types/src/events/base-event.d.ts +35 -0
  71. package/types/src/events/base-event.d.ts.map +1 -0
  72. package/types/src/events/common-interfaces.d.ts +53 -0
  73. package/types/src/events/common-interfaces.d.ts.map +1 -0
  74. package/types/src/events/consts.d.ts +3 -0
  75. package/types/src/events/consts.d.ts.map +1 -0
  76. package/types/src/events/custom-event/custom-event.d.ts +79 -0
  77. package/types/src/events/custom-event/custom-event.d.ts.map +1 -0
  78. package/types/src/events/custom-event/event.d.ts +10 -0
  79. package/types/src/events/custom-event/event.d.ts.map +1 -0
  80. package/types/src/events/custom-event/form.d.ts +11 -0
  81. package/types/src/events/custom-event/form.d.ts.map +1 -0
  82. package/types/src/events/identity/identity-event.d.ts +184 -0
  83. package/types/src/events/identity/identity-event.d.ts.map +1 -0
  84. package/types/src/events/identity/identity.d.ts +10 -0
  85. package/types/src/events/identity/identity.d.ts.map +1 -0
  86. package/types/src/events/index.d.ts +10 -0
  87. package/types/src/events/index.d.ts.map +1 -0
  88. package/types/src/events/page-view/page-view-event.d.ts +125 -0
  89. package/types/src/events/page-view/page-view-event.d.ts.map +1 -0
  90. package/types/src/events/page-view/page-view.d.ts +11 -0
  91. package/types/src/events/page-view/page-view.d.ts.map +1 -0
  92. package/types/src/events/send-event/sendEvent.d.ts +22 -0
  93. package/types/src/events/send-event/sendEvent.d.ts.map +1 -0
  94. package/types/src/index.d.ts +10 -0
  95. package/types/src/index.d.ts.map +1 -0
  96. package/types/src/initialization/const.d.ts +6 -0
  97. package/types/src/initialization/const.d.ts.map +1 -0
  98. package/types/src/initialization/plugin.d.ts +35 -0
  99. package/types/src/initialization/plugin.d.ts.map +1 -0
  100. package/types/src/initialization/types.d.ts +22 -0
  101. package/types/src/initialization/types.d.ts.map +1 -0
  102. package/types/src/internal.d.ts +3 -0
  103. package/types/src/internal.d.ts.map +1 -0
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "author": {
3
+ "name": "Sitecore Corporation",
4
+ "url": "https://doc.sitecore.com/xmc/en/developers/content-sdk/index.html"
5
+ },
6
+ "bugs": {
7
+ "url": "https://github.com/Sitecore/content-sdk/issues"
8
+ },
9
+ "dependencies": {
10
+ "@sitecore-content-sdk/analytics-core": "2.0.0-canary.12",
11
+ "@sitecore-content-sdk/core": "2.0.0-canary.12",
12
+ "debug": "^4.4.3"
13
+ },
14
+ "description": "Enables real-time, unified tracking to send events to Sitecore.",
15
+ "devDependencies": {
16
+ "@jest/globals": "^30.2.0",
17
+ "@jest/types": "^29.6.3",
18
+ "@stylistic/eslint-plugin": "^5.2.2",
19
+ "@types/debug": "^4.1.12",
20
+ "@types/jest": "^29.5.12",
21
+ "@typescript-eslint/eslint-plugin": "8.39.0",
22
+ "@typescript-eslint/parser": "8.39.0",
23
+ "del-cli": "^6.0.0",
24
+ "eslint": "^9.32.0",
25
+ "eslint-config-prettier": "^10.1.8",
26
+ "eslint-plugin-import": "2.32.0",
27
+ "eslint-plugin-jsdoc": "52.0.3",
28
+ "eslint-plugin-prettier": "^4.0.0",
29
+ "jest": "^29.7.0",
30
+ "jest-environment-jsdom": "^29.7.0",
31
+ "jest-environment-node": "^29.7.0",
32
+ "ts-jest": "^29.4.6",
33
+ "ts-node": "^10.9.2"
34
+ },
35
+ "main": "dist/cjs/index.js",
36
+ "module": "dist/esm/index.js",
37
+ "types": "types/src/index.d.ts",
38
+ "exports": {
39
+ ".": {
40
+ "import": "./dist/esm/src/index.js",
41
+ "require": "./dist/cjs/src/index.js",
42
+ "types": "./types/src/index.d.ts"
43
+ },
44
+ "./browser": {
45
+ "import": "./dist/esm/src/browser.js",
46
+ "require": "./dist/cjs/src/browser.js",
47
+ "types": "./types/src/browser.d.ts"
48
+ },
49
+ "./internal": {
50
+ "import": "./dist/esm/src/internal.js",
51
+ "require": "./dist/cjs/src/internal.js",
52
+ "types": "./types/src/internal.d.ts"
53
+ }
54
+ },
55
+ "files": [
56
+ "dist",
57
+ "types",
58
+ "/*.d.ts"
59
+ ],
60
+ "homepage": "https://doc.sitecore.com/xmc/en/developers/content-sdk/index.html",
61
+ "license": "Apache-2.0",
62
+ "name": "@sitecore-content-sdk/events",
63
+ "publishConfig": {
64
+ "access": "public",
65
+ "registry": "https://registry.npmjs.org/"
66
+ },
67
+ "scripts": {
68
+ "build": "npm run clean && tsc -p tsconfig.json && tsc -p tsconfig-esm.json",
69
+ "clean": "del-cli dist types",
70
+ "coverage": "jest --config jest.config.ts --coverage",
71
+ "generate-docs": "npx typedoc --plugin typedoc-plugin-markdown --outputFileStrategy Members --parametersFormat table --readme none --out ../../ref-docs/events --entryPoints src/browser.ts --entryPoints src/internal.ts --entryPoints src/index.ts --githubPages false",
72
+ "lint": "eslint \"./src/**/*.ts\"",
73
+ "prepublishOnly": "npm run build",
74
+ "test": "jest --config jest.config.ts",
75
+ "api-extractor": "npm run build && api-extractor run --local --verbose",
76
+ "api-extractor:verify": "api-extractor run"
77
+ },
78
+ "version": "2.0.0-canary.12",
79
+ "gitHead": "4a26005860f4931f25d8c63d765a030e04a5b1f4"
80
+ }
@@ -0,0 +1,4 @@
1
+ export { addToEventQueue } from './eventStorage/addToEventQueue';
2
+ export { processEventQueue } from './eventStorage/processEventQueue';
3
+ export { clearEventQueue } from './eventStorage/clearEventQueue';
4
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The package version.
3
+ * @internal
4
+ */
5
+ export declare const PACKAGE_VERSION: string;
6
+ /**
7
+ * The package version.
8
+ * @internal
9
+ */
10
+ export declare const PACKAGE_NAME: string;
11
+ /**
12
+ * Returns the name & version of the library in a String.
13
+ */
14
+ export declare const X_CLIENT_SOFTWARE_ID: string;
15
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../src/consts.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAsB,CAAC;AACnD;;;GAGG;AACH,eAAO,MAAM,YAAY,QAAmB,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,oBAAoB,QAAuC,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare const EVENTS_NAMESPACE = "events";
2
+ /**
3
+ * Debug module for events package
4
+ * @public
5
+ */
6
+ export declare const debug: {
7
+ events: import("debug").Debugger;
8
+ };
9
+ //# sourceMappingURL=debug.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.ts","sourceRoot":"","sources":["../../src/debug.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,WAAW,CAAC;AACzC;;;GAGG;AACH,eAAO,MAAM,KAAK;;CAEjB,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { EventData } from '../events';
2
+ /**
3
+ * A function that adds an event to the queue
4
+ * @param {EventData} eventData - The required/optional attributes in order to be sent to SitecoreCloud API
5
+ * @public
6
+ */
7
+ export declare function addToEventQueue(eventData: EventData): Promise<void>;
8
+ //# sourceMappingURL=addToEventQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addToEventQueue.d.ts","sourceRoot":"","sources":["../../../src/eventStorage/addToEventQueue.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAM3C;;;;GAIG;AACH,wBAAsB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAezE"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Deletes the queue from session.
3
+ * @public
4
+ */
5
+ export declare function clearEventQueue(): Promise<void>;
6
+ //# sourceMappingURL=clearEventQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clearEventQueue.d.ts","sourceRoot":"","sources":["../../../src/eventStorage/clearEventQueue.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAKrD"}
@@ -0,0 +1,31 @@
1
+ import type { CustomEventArguments } from '../events';
2
+ declare class EventQueue {
3
+ /**
4
+ * Initialize the Event Storage
5
+ */
6
+ private key;
7
+ /**
8
+ * Adds the required event data to the queue and stores it in the storage.
9
+ * @param {QueueEventPayload} queueEventPayload - The required event data for the creation of a `CustomEvent`.
10
+ * Validates by creating a new `CustomEvent`.
11
+ */
12
+ enqueueEvent(queueEventPayload: QueueEventPayload): void;
13
+ /**
14
+ * Iterates the queue and sends sequentially the custom events to Sitecore Edge Proxy.
15
+ */
16
+ sendAllEvents(): Promise<void>;
17
+ /**
18
+ * Clears the queue from storage.
19
+ */
20
+ clearQueue(): void;
21
+ /** Returns the stored array of data with type `QueueEventPayload`, or empty array if the given key does not exist. */
22
+ private getEventQueue;
23
+ private getSessionStorage;
24
+ }
25
+ /**
26
+ * @internal
27
+ */
28
+ export type QueueEventPayload = Pick<CustomEventArguments, 'eventData' | 'config' | 'id'>;
29
+ export declare const eventQueue: EventQueue;
30
+ export {};
31
+ //# sourceMappingURL=eventStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eventStorage.d.ts","sourceRoot":"","sources":["../../../src/eventStorage/eventStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAGtD,cAAM,UAAU;IACd;;OAEG;IACH,OAAO,CAAC,GAAG,CAAgB;IAE3B;;;;OAIG;IACH,YAAY,CAAC,iBAAiB,EAAE,iBAAiB;IAgBjD;;OAEG;IACG,aAAa;IAcnB;;OAEG;IACH,UAAU;IAKV,sHAAsH;IACtH,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,iBAAiB;CAG1B;AAED;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,EAAE,WAAW,GAAG,QAAQ,GAAG,IAAI,CAAC,CAAC;AAE1F,eAAO,MAAM,UAAU,YAAmB,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * A function that sends all queue events to the SitecoreCloud API.
3
+ * Clears the queue upon completion.
4
+ * @public
5
+ */
6
+ export declare function processEventQueue(): Promise<void>;
7
+ //# sourceMappingURL=processEventQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"processEventQueue.d.ts","sourceRoot":"","sources":["../../../src/eventStorage/processEventQueue.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAKvD"}
@@ -0,0 +1,35 @@
1
+ import type { EventAttributesInput } from './common-interfaces';
2
+ export declare class BaseEvent {
3
+ private baseEventData;
4
+ page: string;
5
+ private readonly clientId;
6
+ private readonly language;
7
+ /**
8
+ * The base event class that has all the shared functions between Events
9
+ * @param {BaseEventData} baseEventData - The event data to send
10
+ * @param {string} id - The client id
11
+ */
12
+ constructor(baseEventData: BaseEventData, id: string);
13
+ /**
14
+ * A function that returns the properties for sending events to the Sitecore Edge Proxy.
15
+ * @returns an object that is required
16
+ */
17
+ protected mapBaseEventPayload(): BasePayload;
18
+ }
19
+ /**
20
+ * An interface describing the basic payload to be sent to the API
21
+ * @internal
22
+ */
23
+ export interface BasePayload {
24
+ browser_id: string;
25
+ channel?: string;
26
+ client_key: string;
27
+ currency?: string;
28
+ language?: string;
29
+ page?: string;
30
+ pos: string;
31
+ requested_at: string;
32
+ }
33
+ type BaseEventData = EventAttributesInput;
34
+ export {};
35
+ //# sourceMappingURL=base-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-event.d.ts","sourceRoot":"","sources":["../../../src/events/base-event.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAEhE,qBAAa,SAAS;IASR,OAAO,CAAC,aAAa;IAR1B,IAAI,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C;;;;OAIG;gBACiB,aAAa,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM;IAM5D;;;OAGG;IACH,SAAS,CAAC,mBAAmB,IAAI,WAAW;CAY7C;AAED;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,KAAK,aAAa,GAAG,oBAAoB,CAAC"}
@@ -0,0 +1,53 @@
1
+ import type { NestedObject } from '@sitecore-content-sdk/analytics-core/utils';
2
+ /**
3
+ * Event data that is sent to Sitecore Edge Proxy.
4
+ * @public
5
+ */
6
+ export interface EventAttributesInput {
7
+ /**
8
+ * The language the site visitor interacts with your brand in.
9
+ *
10
+ * For example, if the site visitor selects the Japanese language in your app, the language is "JA".
11
+ *
12
+ * Format: uppercase ISO 639.
13
+ *
14
+ * Default for browser-side events: inferred from the HTML lang attribute. If lang is not specified, the default is an empty string.
15
+ *
16
+ * Default for server-side events: empty string.
17
+ */
18
+ language?: string;
19
+ /**
20
+ * The name of the webpage where the interaction with your brand takes place.
21
+ *
22
+ * Default for browser-side events: for the website root page, "Home Page". For other webpages, inferred from the URL pathname.
23
+ *
24
+ * Default for server-side events: empty string.
25
+ */
26
+ page?: string;
27
+ /**
28
+ * The touchpoint where the user interacts with your brand.
29
+ *
30
+ * For example, for webpages, the channel is "WEB". For mobile app screens, the channel is "MOBILE_APP".
31
+ *
32
+ * Format: uppercase.
33
+ *
34
+ * If unset, this property will not be part of the payload.
35
+ */
36
+ channel?: string;
37
+ /**
38
+ * The alphabetic currency code of the currency the site visitor uses in your app.
39
+ *
40
+ * For example, if the site visitor selects Australian dollars as the currency, the currency is "AUD".
41
+ *
42
+ * Format: uppercase ISO 4217.
43
+ *
44
+ * If unset, this property will not be part of the payload.
45
+ */
46
+ currency?: string;
47
+ }
48
+ /**
49
+ * Type of the extension data that the developer can pass to events.
50
+ * @public
51
+ */
52
+ export type ExtensionData = NestedObject;
53
+ //# sourceMappingURL=common-interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common-interfaces.d.ts","sourceRoot":"","sources":["../../../src/events/common-interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE/E;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;;;;;OAQG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const MAX_EXT_ATTRIBUTES = 50;
2
+ export declare const UTM_PREFIX = "utm_";
3
+ //# sourceMappingURL=consts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../../../src/events/consts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,KAAK,CAAC;AACrC,eAAO,MAAM,UAAU,SAAS,CAAC"}
@@ -0,0 +1,79 @@
1
+ import type { EPResponse } from '@sitecore-content-sdk/analytics-core/internal';
2
+ import type { BasicTypes, NestedObject } from '@sitecore-content-sdk/analytics-core/utils';
3
+ import { BaseEvent } from '../base-event';
4
+ import type { EventAttributesInput, ExtensionData } from '../common-interfaces';
5
+ import type { SendEvent } from '../send-event/sendEvent';
6
+ import { CoreContext } from '@sitecore-content-sdk/core';
7
+ /**
8
+ * A class that extends from {@link BaseEvent} and has all the required functionality to send a custom event
9
+ * @internal
10
+ */
11
+ export declare class CustomEvent extends BaseEvent {
12
+ customEventPayload: CustomEventPayload;
13
+ private sendEvent;
14
+ private extensionData;
15
+ private config;
16
+ /**
17
+ * A class that extends from {@link BaseEvent} and has all the required functionality to send a custom event
18
+ * @param {CustomEventArguments} args - Unified object containing the required properties
19
+ */
20
+ constructor(args: CustomEventArguments);
21
+ /**
22
+ * Sends the event to Sitecore Edge Proxy
23
+ * @returns - A promise that resolves with either the Sitecore Edge Proxy response object or null
24
+ */
25
+ send(): Promise<EPResponse | null>;
26
+ }
27
+ /**
28
+ * Interface of the unified arguments object for custom event
29
+ * @internal
30
+ */
31
+ export interface CustomEventArguments {
32
+ sendEvent: SendEvent;
33
+ eventData: EventData;
34
+ id: string;
35
+ config: CoreContext['config'];
36
+ }
37
+ /**
38
+ * Interface with the required/optional attributes to send a custom event to the SitecoreCloud API
39
+ * @internal
40
+ */
41
+ export interface CustomEventPayload extends NestedObject {
42
+ sc_search?: {
43
+ data: NestedObject;
44
+ metadata: {
45
+ ut_api_version: string;
46
+ };
47
+ };
48
+ ext?: {
49
+ [key: string]: BasicTypes;
50
+ };
51
+ }
52
+ /**
53
+ * Interface with the required/optional attributes to send a custom event to the SitecoreCloud API
54
+ * @public
55
+ */
56
+ export interface EventData extends EventAttributesInput, NestedObject {
57
+ /**
58
+ * The type of the event.
59
+ * To send a custom event using event, or to add a custom event to the event queue using addToEventQueue, set type to a unique value. Do not set type to a reserved event name.
60
+ *
61
+ * Recommendation: Include the name of the site in the unique value, for example, "myretailsite:CLICKED_PROMO".
62
+ */
63
+ type: string;
64
+ /**
65
+ * Sitecore Search data about the event.
66
+ *
67
+ * Use only in the following, standard events:
68
+ * `SC_SEARCH_WIDGET_VIEW`, `SC_SEARCH_WIDGET_CLICK`
69
+ *
70
+ * If set, the event and all its data will be available in Sitecore Search.
71
+ * Construct according to the Sitecore Search Events API reference and data model.
72
+ */
73
+ searchData?: NestedObject;
74
+ /**
75
+ * Any custom data to collect about an event in addition to the other attributes provided for the event data.
76
+ */
77
+ extensionData?: ExtensionData;
78
+ }
79
+ //# sourceMappingURL=custom-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-event.d.ts","sourceRoot":"","sources":["../../../../src/events/custom-event/custom-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAChF,OAAO,KAAK,EACV,UAAU,EAEV,YAAY,EACb,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAa,MAAM,4BAA4B,CAAC;AAIpE;;;GAGG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACxC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,aAAa,CAAuB;IAC5C,OAAO,CAAC,MAAM,CAAwB;IAEtC;;;OAGG;gBACS,IAAI,EAAE,oBAAoB;IAgCtC;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;CAMzC;AAED;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,SAAS,CAAC;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD,SAAS,CAAC,EAAE;QACV,IAAI,EAAE,YAAY,CAAC;QACnB,QAAQ,EAAE;YAAE,cAAc,EAAE,MAAM,CAAA;SAAE,CAAC;KACtC,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;KAC3B,CAAC;CACH;AAED;;;GAGG;AACH,MAAM,WAAW,SAAU,SAAQ,oBAAoB,EAAE,YAAY;IACnE;;;;;OAKG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;;;;;;;OAQG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B"}
@@ -0,0 +1,10 @@
1
+ import type { EPResponse } from '@sitecore-content-sdk/analytics-core/internal';
2
+ import type { EventData } from './custom-event';
3
+ /**
4
+ * A function that sends an event to the SitecoreCloud API with the specified type
5
+ * @param {EventData} eventData - The required/optional attributes to be sent to the SitecoreCloud API
6
+ * @returns The response object that Sitecore Edge Proxy returns
7
+ * @public
8
+ */
9
+ export declare function event(eventData: EventData): Promise<EPResponse | null>;
10
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../../src/events/custom-event/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAIhF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;;;;GAKG;AACH,wBAAsB,KAAK,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAe5E"}
@@ -0,0 +1,11 @@
1
+ import type { EPResponse } from '@sitecore-content-sdk/analytics-core/internal';
2
+ /**
3
+ * A function that sends a form event to the SitecoreCloud API
4
+ * @param {string} formId - The required form ID string
5
+ * @param {'VIEWED' | 'SUBMITTED'} interactionType - The required interaction type string. Possible values: `VIEWED`, `SUBMITTED`
6
+ * @param {string} componentInstanceId - The required component instance ID string
7
+ * @returns The response object that Sitecore Edge Proxy returns or null
8
+ * @public
9
+ */
10
+ export declare function form(formId: string, interactionType: 'VIEWED' | 'SUBMITTED', componentInstanceId: string): Promise<EPResponse | null>;
11
+ //# sourceMappingURL=form.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../src/events/custom-event/form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAOhF;;;;;;;GAOG;AACH,wBAAsB,IAAI,CACxB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,QAAQ,GAAG,WAAW,EACvC,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CA0B5B"}
@@ -0,0 +1,184 @@
1
+ import type { EPResponse, Infer } from '@sitecore-content-sdk/analytics-core/internal';
2
+ import type { EventAttributesInput, ExtensionData } from '../common-interfaces';
3
+ import { BaseEvent } from '../base-event';
4
+ import type { FlattenedObject } from '@sitecore-content-sdk/analytics-core/utils';
5
+ import type { SendEvent } from '../send-event/sendEvent';
6
+ import { CoreContext } from '@sitecore-content-sdk/core';
7
+ /**
8
+ * A class that extends from {@link BaseEvent} and has all the required functionality to send an IDENTITY event
9
+ */
10
+ export declare class IdentityEvent extends BaseEvent {
11
+ private identityData;
12
+ private sendEvent;
13
+ private extensionData;
14
+ private numberOfExtensionDataProperties;
15
+ private config;
16
+ /**
17
+ * A class that extends from {@link BaseEvent} and has all the required functionality to send an IDENTITY event
18
+ * @param {IdentityEventArguments} args - Unified object containing the required properties
19
+ */
20
+ constructor(args: IdentityEventArguments);
21
+ /**
22
+ * Sends the event to Sitecore Edge Proxy
23
+ * @returns - A promise that resolves with either the Sitecore Edge Proxy response object or null
24
+ */
25
+ send(): Promise<EPResponse | null>;
26
+ /**
27
+ * Function that validates the identifiers object, email, and date attributes for CDN users
28
+ * @param {IdentityData} identityData - The data to be validated
29
+ */
30
+ private validateAttributes;
31
+ /**
32
+ * A function that maps the identity event input data with the payload sent to the API
33
+ * @returns - The payload object
34
+ */
35
+ private mapAttributes;
36
+ }
37
+ /**
38
+ * The JSON array of objects that contain the identity identifiers
39
+ * @internal
40
+ */
41
+ interface EPIdentifier {
42
+ expiry_date?: string;
43
+ id: string;
44
+ provider: string;
45
+ }
46
+ /**
47
+ * Interface with the necessary attributes for the input for sending identity events
48
+ * @public
49
+ */
50
+ export interface IdentityData extends EventAttributesInput {
51
+ /**
52
+ * The site visitor's city address.
53
+ *
54
+ * Format: title case recommended.
55
+ */
56
+ city?: string;
57
+ /**
58
+ * The site visitor's country address.
59
+ *
60
+ * Format: uppercase ISO 3166-1 alpha-2.
61
+ */
62
+ country?: string;
63
+ /**
64
+ * The site visitor's date of birth.
65
+ *
66
+ * Format: ISO 8601.
67
+ */
68
+ dob?: string;
69
+ /**
70
+ * The site visitor's email address.
71
+ *
72
+ * Format: lowercase recommended.
73
+ */
74
+ email?: string;
75
+ /**
76
+ * The site visitor's first name.
77
+ *
78
+ * Format: title case recommended.
79
+ */
80
+ firstName?: string;
81
+ /**
82
+ * The site visitor's gender.
83
+ */
84
+ gender?: string;
85
+ /**
86
+ * The identifiers used for identifying site visitors.
87
+ */
88
+ identifiers: Identifier[];
89
+ /**
90
+ * The site visitor's last name.
91
+ *
92
+ * Format: title case recommended.
93
+ */
94
+ lastName?: string;
95
+ /**
96
+ * The site visitor's mobile number.
97
+ */
98
+ mobile?: string;
99
+ /**
100
+ * The site visitor's phone number.
101
+ */
102
+ phone?: string;
103
+ /**
104
+ * The site visitor's postal code.
105
+ */
106
+ postalCode?: string;
107
+ /**
108
+ * The site visitor's state address.
109
+ *
110
+ * Format: title case recommended.
111
+ */
112
+ state?: string;
113
+ /**
114
+ * The site visitor's street address.
115
+ *
116
+ * Format: title case recommended.
117
+ */
118
+ street?: string[];
119
+ /**
120
+ * The site visitor's title.
121
+ *
122
+ * Format: title case.
123
+ */
124
+ title?: string;
125
+ /**
126
+ * Any custom data to collect about an event in addition to the other attributes provided for the event data.
127
+ */
128
+ extensionData?: ExtensionData;
129
+ }
130
+ /**
131
+ * The JSON array of objects that contain the identity identifiers
132
+ * @public
133
+ */
134
+ export interface Identifier {
135
+ /**
136
+ * The date the unique guest (site visitor) identifier expires. This is determined by your organization's identity system.
137
+ *
138
+ * Format: ISO 8601.
139
+ */
140
+ expiryDate?: string;
141
+ /**
142
+ * The unique guest (site visitor) identifier provided by your organization's identity system, such as a Customer Relationship Management (CRM) system.
143
+ */
144
+ id: string;
145
+ /**
146
+ * The name of your organization's identity system, external to SitecoreAI, that provided the unique guest (site visitor) identifier.
147
+ */
148
+ provider: string;
149
+ }
150
+ /**
151
+ * An interface describing the identity event specific payload to be sent to the API
152
+ * @internal
153
+ */
154
+ export interface IdentityEventPayload {
155
+ city?: string;
156
+ country?: string;
157
+ dob?: string;
158
+ email?: string;
159
+ firstname?: string;
160
+ gender?: string;
161
+ identifiers: EPIdentifier[];
162
+ lastname?: string;
163
+ mobile?: string;
164
+ phone?: string;
165
+ postal_code?: string;
166
+ state?: string;
167
+ street?: string[];
168
+ title?: string;
169
+ type: 'IDENTITY';
170
+ ext?: FlattenedObject;
171
+ }
172
+ /**
173
+ * Interface of the unified arguments object for the identity event
174
+ * @internal
175
+ */
176
+ export interface IdentityEventArguments {
177
+ sendEvent: SendEvent;
178
+ identityData: IdentityData;
179
+ id: string;
180
+ config: CoreContext['config'];
181
+ infer?: Infer;
182
+ }
183
+ export {};
184
+ //# sourceMappingURL=identity-event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity-event.d.ts","sourceRoot":"","sources":["../../../../src/events/identity/identity-event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,+CAA+C,CAAC;AACvF,OAAO,KAA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SAAS,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf"}
@@ -0,0 +1,10 @@
1
+ import type { EPResponse } from '@sitecore-content-sdk/analytics-core/internal';
2
+ import type { IdentityData } from './identity-event';
3
+ /**
4
+ * A function that sends an IDENTITY event to the SitecoreCloud API
5
+ * @param {IdentityData} identityData - The required/optional attributes to be sent to the SitecoreCloud API
6
+ * @returns The response object that Sitecore Edge Proxy returns
7
+ * @public
8
+ */
9
+ export declare function identity(identityData: IdentityData): Promise<EPResponse | null>;
10
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../../src/events/identity/identity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAGhF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAKrD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAerF"}
@@ -0,0 +1,10 @@
1
+ export { BaseEvent } from './base-event';
2
+ export type { BasePayload } from './base-event';
3
+ export { PageViewEvent } from './page-view/page-view-event';
4
+ export type { PageViewData, PageViewEventPayload } from './page-view/page-view-event';
5
+ export { CustomEvent } from './custom-event/custom-event';
6
+ export type { EventData, CustomEventPayload, CustomEventArguments, } from './custom-event/custom-event';
7
+ export { IdentityEvent } from './identity/identity-event';
8
+ export type { IdentityData, IdentityEventPayload } from './identity/identity-event';
9
+ export type { ExtensionData } from './common-interfaces';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,YAAY,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEpF,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}