@blux.ai/web-sdk 0.0.3
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/.prettierrc +5 -0
- package/.vscode/settings.json +7 -0
- package/LICENSE +1 -0
- package/README.md +21 -0
- package/dist/BluxClient.d.ts +17 -0
- package/dist/BluxClient.js +104 -0
- package/dist/core/BaseErrorHandler.d.ts +3 -0
- package/dist/core/BaseErrorHandler.js +13 -0
- package/dist/core/HTTPClient.d.ts +10 -0
- package/dist/core/HTTPClient.js +122 -0
- package/dist/core/LocalStorage.d.ts +13 -0
- package/dist/core/LocalStorage.js +43 -0
- package/dist/core/Logger.d.ts +14 -0
- package/dist/core/Logger.js +90 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +18 -0
- package/dist/requests/Devices/ActivateDevice.d.ts +8 -0
- package/dist/requests/Devices/ActivateDevice.js +39 -0
- package/dist/requests/Devices/CreateDevice.d.ts +14 -0
- package/dist/requests/Devices/CreateDevice.js +54 -0
- package/dist/requests/Devices/UpdateDevice.d.ts +17 -0
- package/dist/requests/Devices/UpdateDevice.js +61 -0
- package/dist/requests/Devices/index.d.ts +3 -0
- package/dist/requests/Devices/index.js +19 -0
- package/dist/requests/Events/AddCartaddEvent.d.ts +5 -0
- package/dist/requests/Events/AddCartaddEvent.js +39 -0
- package/dist/requests/Events/AddCustomEvent.d.ts +5 -0
- package/dist/requests/Events/AddCustomEvent.js +40 -0
- package/dist/requests/Events/AddLikeEvent.d.ts +5 -0
- package/dist/requests/Events/AddLikeEvent.js +39 -0
- package/dist/requests/Events/AddPageViewEvent.d.ts +5 -0
- package/dist/requests/Events/AddPageViewEvent.js +37 -0
- package/dist/requests/Events/AddProductDetailViewEvent.d.ts +5 -0
- package/dist/requests/Events/AddProductDetailViewEvent.js +39 -0
- package/dist/requests/Events/AddPurchaseEvent.d.ts +5 -0
- package/dist/requests/Events/AddPurchaseEvent.js +38 -0
- package/dist/requests/Events/AddRateEvent.d.ts +5 -0
- package/dist/requests/Events/AddRateEvent.js +40 -0
- package/dist/requests/Events/AddRecommendationViewEvent.d.ts +5 -0
- package/dist/requests/Events/AddRecommendationViewEvent.js +38 -0
- package/dist/requests/Events/EventRequest.d.ts +17 -0
- package/dist/requests/Events/EventRequest.js +56 -0
- package/dist/requests/Events/index.d.ts +8 -0
- package/dist/requests/Events/index.js +24 -0
- package/dist/requests/Events/types.d.ts +42 -0
- package/dist/requests/Events/types.js +2 -0
- package/dist/requests/Request.d.ts +12 -0
- package/dist/requests/Request.js +22 -0
- package/dist/requests/Users/UpdateUserProperties.d.ts +17 -0
- package/dist/requests/Users/UpdateUserProperties.js +54 -0
- package/dist/requests/Users/index.d.ts +1 -0
- package/dist/requests/Users/index.js +17 -0
- package/dist/requests/Users/types.d.ts +12 -0
- package/dist/requests/Users/types.js +2 -0
- package/dist/requests/index.d.ts +3 -0
- package/dist/requests/index.js +19 -0
- package/dist/utils/helper.d.ts +1 -0
- package/dist/utils/helper.js +7 -0
- package/dist/utils/types.d.ts +2 -0
- package/dist/utils/types.js +11 -0
- package/package.json +20 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
exports.__esModule = true;
|
|
21
|
+
exports.UpdateDevice = void 0;
|
|
22
|
+
var BluxClient_1 = __importDefault(require("../../BluxClient"));
|
|
23
|
+
var Request_1 = require("../Request");
|
|
24
|
+
var UpdateDevice = /** @class */ (function (_super) {
|
|
25
|
+
__extends(UpdateDevice, _super);
|
|
26
|
+
function UpdateDevice(bluxId, deviceId, userId) {
|
|
27
|
+
var _this = _super.call(this, "PUT", "/devices") || this;
|
|
28
|
+
_this.bluxId = bluxId;
|
|
29
|
+
_this.deviceId = deviceId;
|
|
30
|
+
_this.userId = userId;
|
|
31
|
+
_this.platform = "typescript";
|
|
32
|
+
_this.deviceModel = navigator.userAgent; // 기기 모델;
|
|
33
|
+
_this.osVersion = navigator.userAgent; // OS 버전 (navigator.userAgent를 통해 확인);
|
|
34
|
+
_this.sdkVersion = BluxClient_1["default"].sdkInfo.version;
|
|
35
|
+
_this.sdkType = BluxClient_1["default"].sdkInfo.type;
|
|
36
|
+
_this.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
37
|
+
_this.languageCode = navigator.language.split("-")[0];
|
|
38
|
+
_this.countryCode = navigator.language.split("-")[1];
|
|
39
|
+
_this.lastActiveAt = new Date().toISOString();
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
UpdateDevice.prototype.getPayload = function () {
|
|
43
|
+
var payload = {
|
|
44
|
+
blux_id: this.bluxId,
|
|
45
|
+
device_id: this.deviceId,
|
|
46
|
+
user_id: this.userId,
|
|
47
|
+
platform: this.platform,
|
|
48
|
+
device_model: this.deviceModel,
|
|
49
|
+
os_version: this.osVersion,
|
|
50
|
+
sdk_version: this.sdkVersion,
|
|
51
|
+
sdk_type: this.sdkType,
|
|
52
|
+
timezone: this.timezone,
|
|
53
|
+
language_code: this.languageCode,
|
|
54
|
+
country_code: this.countryCode,
|
|
55
|
+
last_active_at: this.lastActiveAt
|
|
56
|
+
};
|
|
57
|
+
return payload;
|
|
58
|
+
};
|
|
59
|
+
return UpdateDevice;
|
|
60
|
+
}(Request_1.Request));
|
|
61
|
+
exports.UpdateDevice = UpdateDevice;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
exports.__esModule = true;
|
|
17
|
+
__exportStar(require("./ActivateDevice"), exports);
|
|
18
|
+
__exportStar(require("./UpdateDevice"), exports);
|
|
19
|
+
__exportStar(require("./CreateDevice"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EventRequest } from "./EventRequest";
|
|
2
|
+
import { IAddCartaddEvent } from "./types";
|
|
3
|
+
export declare class AddCartaddEvent extends EventRequest {
|
|
4
|
+
constructor({ itemId, url, ref, recommendationId, from, timestamp, userProperties, eventProperties, }: IAddCartaddEvent);
|
|
5
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddCartaddEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddCartaddEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddCartaddEvent, _super);
|
|
23
|
+
function AddCartaddEvent(_a) {
|
|
24
|
+
var itemId = _a.itemId, url = _a.url, ref = _a.ref, recommendationId = _a.recommendationId, from = _a.from, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
itemId: itemId,
|
|
27
|
+
eventType: "cartadd",
|
|
28
|
+
timestamp: timestamp,
|
|
29
|
+
url: url,
|
|
30
|
+
ref: ref,
|
|
31
|
+
recommendationId: recommendationId,
|
|
32
|
+
from: from,
|
|
33
|
+
userProperties: userProperties,
|
|
34
|
+
eventProperties: eventProperties
|
|
35
|
+
}) || this;
|
|
36
|
+
}
|
|
37
|
+
return AddCartaddEvent;
|
|
38
|
+
}(EventRequest_1.EventRequest));
|
|
39
|
+
exports.AddCartaddEvent = AddCartaddEvent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EventRequest } from "./EventRequest";
|
|
2
|
+
import { IAddCustomEvent } from "./types";
|
|
3
|
+
export declare class AddCustomEvent extends EventRequest {
|
|
4
|
+
constructor({ itemId, eventType, eventValue, url, ref, timestamp, recommendationId, from, userProperties, eventProperties, }: IAddCustomEvent);
|
|
5
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddCustomEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddCustomEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddCustomEvent, _super);
|
|
23
|
+
function AddCustomEvent(_a) {
|
|
24
|
+
var itemId = _a.itemId, eventType = _a.eventType, eventValue = _a.eventValue, url = _a.url, ref = _a.ref, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, recommendationId = _a.recommendationId, from = _a.from, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
itemId: itemId,
|
|
27
|
+
eventType: eventType,
|
|
28
|
+
eventValue: eventValue,
|
|
29
|
+
timestamp: timestamp,
|
|
30
|
+
recommendationId: recommendationId,
|
|
31
|
+
from: from,
|
|
32
|
+
url: url,
|
|
33
|
+
ref: ref,
|
|
34
|
+
userProperties: userProperties,
|
|
35
|
+
eventProperties: eventProperties
|
|
36
|
+
}) || this;
|
|
37
|
+
}
|
|
38
|
+
return AddCustomEvent;
|
|
39
|
+
}(EventRequest_1.EventRequest));
|
|
40
|
+
exports.AddCustomEvent = AddCustomEvent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EventRequest } from "./EventRequest";
|
|
2
|
+
import { IAddLikeEvent } from "./types";
|
|
3
|
+
export declare class AddLikeEvent extends EventRequest {
|
|
4
|
+
constructor({ itemId, url, ref, recommendationId, from, timestamp, userProperties, eventProperties, }: IAddLikeEvent);
|
|
5
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddLikeEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddLikeEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddLikeEvent, _super);
|
|
23
|
+
function AddLikeEvent(_a) {
|
|
24
|
+
var itemId = _a.itemId, url = _a.url, ref = _a.ref, recommendationId = _a.recommendationId, from = _a.from, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
itemId: itemId,
|
|
27
|
+
eventType: "like",
|
|
28
|
+
timestamp: timestamp,
|
|
29
|
+
url: url,
|
|
30
|
+
ref: ref,
|
|
31
|
+
recommendationId: recommendationId,
|
|
32
|
+
from: from,
|
|
33
|
+
userProperties: userProperties,
|
|
34
|
+
eventProperties: eventProperties
|
|
35
|
+
}) || this;
|
|
36
|
+
}
|
|
37
|
+
return AddLikeEvent;
|
|
38
|
+
}(EventRequest_1.EventRequest));
|
|
39
|
+
exports.AddLikeEvent = AddLikeEvent;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddPageViewEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddPageViewEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddPageViewEvent, _super);
|
|
23
|
+
function AddPageViewEvent(_a) {
|
|
24
|
+
var pageType = _a.pageType, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, url = _a.url, ref = _a.ref, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
eventType: "page_view",
|
|
27
|
+
timestamp: timestamp,
|
|
28
|
+
url: url,
|
|
29
|
+
ref: ref,
|
|
30
|
+
from: pageType,
|
|
31
|
+
userProperties: userProperties,
|
|
32
|
+
eventProperties: eventProperties
|
|
33
|
+
}) || this;
|
|
34
|
+
}
|
|
35
|
+
return AddPageViewEvent;
|
|
36
|
+
}(EventRequest_1.EventRequest));
|
|
37
|
+
exports.AddPageViewEvent = AddPageViewEvent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EventRequest } from "./EventRequest";
|
|
2
|
+
import { IAddProductDetailViewEvent } from "./types";
|
|
3
|
+
export declare class AddProductDetailViewEvent extends EventRequest {
|
|
4
|
+
constructor({ itemId, url, ref, recommendationId, from, timestamp, userProperties, eventProperties, }: IAddProductDetailViewEvent);
|
|
5
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddProductDetailViewEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddProductDetailViewEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddProductDetailViewEvent, _super);
|
|
23
|
+
function AddProductDetailViewEvent(_a) {
|
|
24
|
+
var itemId = _a.itemId, url = _a.url, ref = _a.ref, recommendationId = _a.recommendationId, from = _a.from, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
itemId: itemId,
|
|
27
|
+
eventType: "product_detail_view",
|
|
28
|
+
timestamp: timestamp,
|
|
29
|
+
url: url,
|
|
30
|
+
ref: ref,
|
|
31
|
+
recommendationId: recommendationId,
|
|
32
|
+
from: from,
|
|
33
|
+
userProperties: userProperties,
|
|
34
|
+
eventProperties: eventProperties
|
|
35
|
+
}) || this;
|
|
36
|
+
}
|
|
37
|
+
return AddProductDetailViewEvent;
|
|
38
|
+
}(EventRequest_1.EventRequest));
|
|
39
|
+
exports.AddProductDetailViewEvent = AddProductDetailViewEvent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddPurchaseEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddPurchaseEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddPurchaseEvent, _super);
|
|
23
|
+
function AddPurchaseEvent(_a) {
|
|
24
|
+
var itemId = _a.itemId, price = _a.price, url = _a.url, ref = _a.ref, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
itemId: itemId,
|
|
27
|
+
eventType: "purchase",
|
|
28
|
+
eventValue: price.toString(),
|
|
29
|
+
timestamp: timestamp,
|
|
30
|
+
url: url,
|
|
31
|
+
ref: ref,
|
|
32
|
+
userProperties: userProperties,
|
|
33
|
+
eventProperties: eventProperties
|
|
34
|
+
}) || this;
|
|
35
|
+
}
|
|
36
|
+
return AddPurchaseEvent;
|
|
37
|
+
}(EventRequest_1.EventRequest));
|
|
38
|
+
exports.AddPurchaseEvent = AddPurchaseEvent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EventRequest } from "./EventRequest";
|
|
2
|
+
import { IAddRateEvent } from "./types";
|
|
3
|
+
export declare class AddRateEvent extends EventRequest {
|
|
4
|
+
constructor({ itemId, rating, url, ref, recommendationId, from, timestamp, userProperties, eventProperties, }: IAddRateEvent);
|
|
5
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddRateEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddRateEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddRateEvent, _super);
|
|
23
|
+
function AddRateEvent(_a) {
|
|
24
|
+
var itemId = _a.itemId, rating = _a.rating, url = _a.url, ref = _a.ref, recommendationId = _a.recommendationId, from = _a.from, _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
itemId: itemId,
|
|
27
|
+
eventType: "rate",
|
|
28
|
+
eventValue: rating.toString(),
|
|
29
|
+
timestamp: timestamp,
|
|
30
|
+
url: url,
|
|
31
|
+
ref: ref,
|
|
32
|
+
recommendationId: recommendationId,
|
|
33
|
+
from: from,
|
|
34
|
+
userProperties: userProperties,
|
|
35
|
+
eventProperties: eventProperties
|
|
36
|
+
}) || this;
|
|
37
|
+
}
|
|
38
|
+
return AddRateEvent;
|
|
39
|
+
}(EventRequest_1.EventRequest));
|
|
40
|
+
exports.AddRateEvent = AddRateEvent;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EventRequest } from "./EventRequest";
|
|
2
|
+
import { IAddRecommendationViewEvent } from "./types";
|
|
3
|
+
export declare class AddRecommendationViewEvent extends EventRequest {
|
|
4
|
+
constructor({ timestamp, url, ref, recommendationId, from, userProperties, eventProperties, }: IAddRecommendationViewEvent);
|
|
5
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.AddRecommendationViewEvent = void 0;
|
|
19
|
+
var helper_1 = require("../../utils/helper");
|
|
20
|
+
var EventRequest_1 = require("./EventRequest");
|
|
21
|
+
var AddRecommendationViewEvent = /** @class */ (function (_super) {
|
|
22
|
+
__extends(AddRecommendationViewEvent, _super);
|
|
23
|
+
function AddRecommendationViewEvent(_a) {
|
|
24
|
+
var _b = _a.timestamp, timestamp = _b === void 0 ? (0, helper_1.getCurrentUnixTimestamp)() : _b, url = _a.url, ref = _a.ref, recommendationId = _a.recommendationId, from = _a.from, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
25
|
+
return _super.call(this, {
|
|
26
|
+
eventType: "recommendation_view",
|
|
27
|
+
timestamp: timestamp,
|
|
28
|
+
url: url,
|
|
29
|
+
ref: ref,
|
|
30
|
+
recommendationId: recommendationId,
|
|
31
|
+
from: from,
|
|
32
|
+
userProperties: userProperties,
|
|
33
|
+
eventProperties: eventProperties
|
|
34
|
+
}) || this;
|
|
35
|
+
}
|
|
36
|
+
return AddRecommendationViewEvent;
|
|
37
|
+
}(EventRequest_1.EventRequest));
|
|
38
|
+
exports.AddRecommendationViewEvent = AddRecommendationViewEvent;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Request } from "../Request";
|
|
2
|
+
import { IEventRequest } from "./types";
|
|
3
|
+
export declare class EventRequest extends Request {
|
|
4
|
+
protected itemId?: string;
|
|
5
|
+
protected timestamp: number;
|
|
6
|
+
protected eventType: string;
|
|
7
|
+
protected eventValue?: string;
|
|
8
|
+
protected from?: string;
|
|
9
|
+
protected url?: string;
|
|
10
|
+
protected ref?: string;
|
|
11
|
+
protected recommendationId?: string;
|
|
12
|
+
protected userProperties?: Record<string, any>;
|
|
13
|
+
protected eventProperties?: Record<string, any>;
|
|
14
|
+
constructor({ itemId, timestamp, eventType, eventValue, from, url, ref, recommendationId, userProperties, eventProperties, }: IEventRequest);
|
|
15
|
+
getTimestamp(): number;
|
|
16
|
+
getPayload(): object;
|
|
17
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
exports.__esModule = true;
|
|
18
|
+
exports.EventRequest = void 0;
|
|
19
|
+
var Request_1 = require("../Request");
|
|
20
|
+
var EventRequest = /** @class */ (function (_super) {
|
|
21
|
+
__extends(EventRequest, _super);
|
|
22
|
+
function EventRequest(_a) {
|
|
23
|
+
var itemId = _a.itemId, timestamp = _a.timestamp, eventType = _a.eventType, eventValue = _a.eventValue, from = _a.from, url = _a.url, ref = _a.ref, recommendationId = _a.recommendationId, userProperties = _a.userProperties, eventProperties = _a.eventProperties;
|
|
24
|
+
var _this = _super.call(this, "POST", "/events") || this;
|
|
25
|
+
_this.itemId = itemId;
|
|
26
|
+
_this.timestamp = timestamp;
|
|
27
|
+
_this.eventType = eventType;
|
|
28
|
+
_this.eventValue = eventValue;
|
|
29
|
+
_this.from = from;
|
|
30
|
+
_this.url = url;
|
|
31
|
+
_this.ref = ref;
|
|
32
|
+
_this.recommendationId = recommendationId;
|
|
33
|
+
_this.userProperties = userProperties;
|
|
34
|
+
_this.eventProperties = eventProperties;
|
|
35
|
+
return _this;
|
|
36
|
+
}
|
|
37
|
+
EventRequest.prototype.getTimestamp = function () {
|
|
38
|
+
return this.timestamp;
|
|
39
|
+
};
|
|
40
|
+
EventRequest.prototype.getPayload = function () {
|
|
41
|
+
return {
|
|
42
|
+
item_id: this.itemId,
|
|
43
|
+
timestamp: this.timestamp,
|
|
44
|
+
event_type: this.eventType,
|
|
45
|
+
event_value: this.eventValue,
|
|
46
|
+
from: this.from,
|
|
47
|
+
url: this.url,
|
|
48
|
+
ref: this.ref,
|
|
49
|
+
recommendation_id: this.recommendationId,
|
|
50
|
+
user_properties: this.userProperties,
|
|
51
|
+
event_properties: this.eventProperties
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
return EventRequest;
|
|
55
|
+
}(Request_1.Request));
|
|
56
|
+
exports.EventRequest = EventRequest;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./AddProductDetailViewEvent";
|
|
2
|
+
export * from "./AddLikeEvent";
|
|
3
|
+
export * from "./AddCartaddEvent";
|
|
4
|
+
export * from "./AddPageViewEvent";
|
|
5
|
+
export * from "./AddRecommendationViewEvent";
|
|
6
|
+
export * from "./AddRateEvent";
|
|
7
|
+
export * from "./AddPurchaseEvent";
|
|
8
|
+
export * from "./AddCustomEvent";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
exports.__esModule = true;
|
|
17
|
+
__exportStar(require("./AddProductDetailViewEvent"), exports);
|
|
18
|
+
__exportStar(require("./AddLikeEvent"), exports);
|
|
19
|
+
__exportStar(require("./AddCartaddEvent"), exports);
|
|
20
|
+
__exportStar(require("./AddPageViewEvent"), exports);
|
|
21
|
+
__exportStar(require("./AddRecommendationViewEvent"), exports);
|
|
22
|
+
__exportStar(require("./AddRateEvent"), exports);
|
|
23
|
+
__exportStar(require("./AddPurchaseEvent"), exports);
|
|
24
|
+
__exportStar(require("./AddCustomEvent"), exports);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface IBaseEvent {
|
|
2
|
+
itemId?: string;
|
|
3
|
+
timestamp?: number;
|
|
4
|
+
url?: string;
|
|
5
|
+
ref?: string;
|
|
6
|
+
recommendationId?: string;
|
|
7
|
+
from?: string;
|
|
8
|
+
userProperties?: Record<string, any>;
|
|
9
|
+
eventProperties?: Record<string, any>;
|
|
10
|
+
}
|
|
11
|
+
export interface IEventRequest extends IBaseEvent {
|
|
12
|
+
timestamp: number;
|
|
13
|
+
eventType: string;
|
|
14
|
+
eventValue?: string;
|
|
15
|
+
}
|
|
16
|
+
export interface IAddProductDetailViewEvent extends IBaseEvent {
|
|
17
|
+
itemId: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IAddLikeEvent extends IBaseEvent {
|
|
20
|
+
itemId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface IAddCartaddEvent extends IBaseEvent {
|
|
23
|
+
itemId: string;
|
|
24
|
+
}
|
|
25
|
+
export interface IAddRateEvent extends IBaseEvent {
|
|
26
|
+
itemId: string;
|
|
27
|
+
rating: number;
|
|
28
|
+
}
|
|
29
|
+
export interface IAddPurchaseEvent extends IBaseEvent {
|
|
30
|
+
itemId: string;
|
|
31
|
+
price: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IAddCustomEvent extends IBaseEvent {
|
|
34
|
+
itemId: string;
|
|
35
|
+
eventType: string;
|
|
36
|
+
eventValue?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface IAddRecommendationViewEvent extends IBaseEvent {
|
|
39
|
+
}
|
|
40
|
+
export interface IAddPageViewEvent extends IBaseEvent {
|
|
41
|
+
pageType: string;
|
|
42
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare class Request {
|
|
2
|
+
method: string;
|
|
3
|
+
path: string;
|
|
4
|
+
/**
|
|
5
|
+
* Construct the basis of request
|
|
6
|
+
* @param {string} method - POST/PUT/PATCH
|
|
7
|
+
* @param {string} path
|
|
8
|
+
*/
|
|
9
|
+
constructor(method: "POST" | "PATCH" | "PUT", path: string);
|
|
10
|
+
getTimestamp(): number;
|
|
11
|
+
getPayload(): object;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
exports.__esModule = true;
|
|
3
|
+
exports.Request = void 0;
|
|
4
|
+
var Request = /** @class */ (function () {
|
|
5
|
+
/**
|
|
6
|
+
* Construct the basis of request
|
|
7
|
+
* @param {string} method - POST/PUT/PATCH
|
|
8
|
+
* @param {string} path
|
|
9
|
+
*/
|
|
10
|
+
function Request(method, path) {
|
|
11
|
+
this.method = method;
|
|
12
|
+
this.path = path;
|
|
13
|
+
}
|
|
14
|
+
Request.prototype.getTimestamp = function () {
|
|
15
|
+
return 0;
|
|
16
|
+
};
|
|
17
|
+
Request.prototype.getPayload = function () {
|
|
18
|
+
return {};
|
|
19
|
+
};
|
|
20
|
+
return Request;
|
|
21
|
+
}());
|
|
22
|
+
exports.Request = Request;
|