fix(core): update
This commit is contained in:
@ -1 +1 @@
|
||||
export { Analytics } from './smartanalytics.classes.analytics'
|
||||
export { Analytics } from './smartanalytics.classes.analytics';
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user