update to fit in with keen.io

This commit is contained in:
Philipp Kunz 2017-08-24 01:06:09 +02:00
parent ca585b20e3
commit b3023d61f3
4 changed files with 11 additions and 13 deletions

View File

@ -1,10 +1,10 @@
export declare class Analytics {
project: string;
projectId: string;
appName: string;
apiEndPoint: string;
secretKey: string;
constructor(optionsArg: {
projectArg: string;
projectIdArg: string;
appNameArg: string;
apiEndPointArg: string;
secretKeyArg?: string;

View File

@ -12,7 +12,7 @@ const plugins = require("./smartanalytics.plugins");
class Analytics {
constructor(optionsArg) {
this.secretKey = '';
this.project = optionsArg.projectArg;
this.projectId = optionsArg.projectIdArg;
this.appName = optionsArg.appNameArg;
this.apiEndPoint = optionsArg.apiEndPointArg;
if (optionsArg.secretKeyArg) {
@ -22,12 +22,11 @@ class Analytics {
recordEvent(identifierArg, analyticsDataArg) {
return __awaiter(this, void 0, void 0, function* () {
let dataToSend = {
project: this.project,
projectId: this.projectId,
appName: this.appName,
identifier: identifierArg,
analyticsData: analyticsDataArg
};
console.log(dataToSend);
yield plugins.smartrequest.post(this.apiEndPoint, {
headers: {
'authenticate': this.secretKey,
@ -41,4 +40,4 @@ class Analytics {
}
}
exports.Analytics = Analytics;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRhbmFseXRpY3MuY2xhc3Nlcy5hbmFseXRpY3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9zbWFydGFuYWx5dGljcy5jbGFzc2VzLmFuYWx5dGljcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7O0FBQUEsb0RBQW1EO0FBRW5EO0lBS0UsWUFBYSxVQUtaO1FBTkQsY0FBUyxHQUFXLEVBQUUsQ0FBQTtRQU9wQixJQUFJLENBQUMsT0FBTyxHQUFHLFVBQVUsQ0FBQyxVQUFVLENBQUE7UUFDcEMsSUFBSSxDQUFDLE9BQU8sR0FBRyxVQUFVLENBQUMsVUFBVSxD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QUNsQixDQUFDLENBQUMsQ0FBQTtRQUNKLENBQUM7S0FBQTtDQUNGO0FBcENELDhCQW9DQyJ9

View File

@ -6,9 +6,9 @@ let testAnalytics: smartanalytics.Analytics
tap.test('should create a valid AnalyticsAccount', async () => {
testAnalytics = new smartanalytics.Analytics({
projectArg: 'pushrocks',
projectIdArg: 'pushrocks',
appNameArg: 'smartanalytics',
apiEndPointArg: 'https://pubapi-1.herokuapp.com/analytics'
apiEndPointArg: 'https://pubapi-1.lossless.one/analytics'
})
})

View File

@ -1,17 +1,17 @@
import * as plugins from './smartanalytics.plugins'
export class Analytics {
project: string
projectId: string
appName: string
apiEndPoint: string
secretKey: string = ''
constructor (optionsArg: {
projectArg: string
projectIdArg: string
appNameArg: string
apiEndPointArg: string
secretKeyArg?: string
}) {
this.project = optionsArg.projectArg
this.projectId = optionsArg.projectIdArg
this.appName = optionsArg.appNameArg
this.apiEndPoint = optionsArg.apiEndPointArg
if (optionsArg.secretKeyArg) {
@ -21,12 +21,11 @@ export class Analytics {
async recordEvent (identifierArg: string, analyticsDataArg: any) {
let dataToSend = {
project: this.project,
projectId: this.projectId,
appName: this.appName,
identifier: identifierArg,
analyticsData: analyticsDataArg
}
console.log(dataToSend)
await plugins.smartrequest.post(this.apiEndPoint, {
headers: {
'authenticate': this.secretKey,