fix(core): update

This commit is contained in:
2018-10-28 23:29:45 +01:00
parent febf6c1911
commit fcb12d5734
9 changed files with 1129 additions and 53 deletions

View File

@ -1 +1 @@
export { Analytics } from './smartanalytics.classes.analytics'
export { Analytics } from './smartanalytics.classes.analytics';

View File

@ -1,39 +1,41 @@
import * as plugins from './smartanalytics.plugins'
import * as plugins from './smartanalytics.plugins';
export class Analytics {
projectId: string
appName: string
apiEndPoint: string
secretKey: string = ''
constructor (optionsArg: {
projectId: string
appName: string
apiEndPoint: string
secretKey?: string
public projectId: string;
public appName: string;
public apiEndPoint: string;
public secretKey: string = '';
constructor(optionsArg: {
projectId: string;
appName: string;
apiEndPoint: string;
secretKey?: string;
}) {
this.projectId = optionsArg.projectId
this.appName = optionsArg.appName
this.apiEndPoint = optionsArg.apiEndPoint
this.projectId = optionsArg.projectId;
this.appName = optionsArg.appName;
this.apiEndPoint = optionsArg.apiEndPoint;
if (optionsArg.secretKey) {
this.secretKey = optionsArg.secretKey
this.secretKey = optionsArg.secretKey;
}
}
async recordEvent (eventIdArg: string, analyticsDataArg: any) {
async recordEvent(eventIdArg: string, analyticsDataArg: any) {
let dataToSend = {
projectId: this.projectId,
appName: this.appName,
eventId: eventIdArg,
analyticsData: analyticsDataArg
}
await plugins.smartrequest.post(this.apiEndPoint, {
headers: {
'authenticate': this.secretKey,
'Content-Type': 'application/json'
},
requestBody: dataToSend
}).catch(err => {
console.log(err)
})
};
await plugins.smartrequest
.postJson(this.apiEndPoint, {
headers: {
authenticate: this.secretKey,
'Content-Type': 'application/json'
},
requestBody: dataToSend
})
.catch(err => {
console.log(err);
});
}
}

View File

@ -1,8 +1,7 @@
import 'typings-global'
import * as smartrequest from 'smartrequest'
import * as smartq from 'smartq'
import * as smartrequest from '@pushrocks/smartrequest';
import * as smartpromise from '@pushrocks/smartpromise';
export {
smartrequest,
smartq
smartpromise
}