smartanalytics/dist/smartanalytics.classes.analytics.js

43 lines
3.0 KiB
JavaScript
Raw Permalink Normal View History

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-23 23:06:09 +00:00
this.projectId = optionsArg.projectIdArg;
2017-08-23 12:55:11 +00:00
this.appName = optionsArg.appNameArg;
this.apiEndPoint = optionsArg.apiEndPointArg;
if (optionsArg.secretKeyArg) {
this.secretKey = optionsArg.secretKeyArg;
}
}
recordEvent(identifierArg, analyticsDataArg) {
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,
identifier: identifierArg,
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-23 23:06:09 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhbmFseXRpY3MuY2xhc3Nlcy5hbmFseXRpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFuYWx5dGljcy5jbGFzc2VzLmFuY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