2017-08-23 12:55:11 +00:00
|
|
|
"use strict";
|
|
|
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
});
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const plugins = require("./smartanalytics.plugins");
|
|
|
|
class Analytics {
|
|
|
|
constructor(optionsArg) {
|
|
|
|
this.secretKey = '';
|
2017-08-29 13:18:10 +00:00
|
|
|
this.projectId = optionsArg.projectId;
|
|
|
|
this.appName = optionsArg.appName;
|
|
|
|
this.apiEndPoint = optionsArg.apiEndPoint;
|
|
|
|
if (optionsArg.secretKey) {
|
|
|
|
this.secretKey = optionsArg.secretKey;
|
2017-08-23 12:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-29 13:18:10 +00:00
|
|
|
recordEvent(eventIdArg, analyticsDataArg) {
|
2017-08-23 12:55:11 +00:00
|
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
|
|
let dataToSend = {
|
2017-08-23 23:06:09 +00:00
|
|
|
projectId: this.projectId,
|
2017-08-23 12:55:11 +00:00
|
|
|
appName: this.appName,
|
2017-08-29 13:18:10 +00:00
|
|
|
eventId: eventIdArg,
|
2017-08-23 12:55:11 +00:00
|
|
|
analyticsData: analyticsDataArg
|
|
|
|
};
|
|
|
|
yield plugins.smartrequest.post(this.apiEndPoint, {
|
|
|
|
headers: {
|
2017-08-23 15:33:30 +00:00
|
|
|
'authenticate': this.secretKey,
|
|
|
|
'Content-Type': 'application/json'
|
2017-08-23 12:55:11 +00:00
|
|
|
},
|
2017-08-23 15:33:30 +00:00
|
|
|
requestBody: dataToSend
|
|
|
|
}).catch(err => {
|
|
|
|
console.log(err);
|
2017-08-23 12:55:11 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
exports.Analytics = Analytics;
|
2017-08-29 13:18:10 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhbmFseXRpY3MuY2xhc3Nlcy5hbmFseXRpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFuYWx5dGljcy5jbGFzc2VzLmFuYWx5dGljcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsb0RBQW1EO0FBRW5EO0lBS0UsWUFBYSxVQUtaO1FBTkQsY0FBUyxHQUFXLEVBQUUsQ0FBQTtRQU9wQixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxTQUFTLENBQUE7UUFDckMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsT0FBTyxDQUFBO1FBQ2pDLElBQUksQ0FBQyxXQUFXLEdBQUcsVUFBVSxDQUFDLFdBQVcsQ0FBQTtRQUN6QyxFQUFFLENBQUMsQ0FBQyxVQUFVLENBQUMsU0FBUyxDQUFDLENBQUMsQ0FBQztZQUN6QixJQUFJLENBQUMsU0FBUyxHQUFHLFVBQVUsQ0FBQyxTQUFTLENBQUE7UUFDdkMsQ0FBQztJQUNILENBQUM7SUFFSyxXQUFXLENBQUUsVUFBa0IsRUFBRSxnQkFBcUI7O1lBQzFELElBQUksVUFBVSxHQUFHO2dCQUNmLFNBQVMsRUFBRSxJQUFJLENBQUMsU0FBUztnQkFDekIsT0FBTyxFQUFFLElBQUksQ0FBQyxPQUFPO2dCQUNyQixPQUFPLEVBQUUsVUFBVTtnQkFDbkIsYUFBYSxFQUFFLGdCQUFnQj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