fix(core): update
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user