2017-02-24 02:00:15 +00:00
|
|
|
import * as plugins from './smartanalytics.plugins'
|
|
|
|
|
|
|
|
export let event = (trackingIdArg: string, appNameArg: string, eventCategoryArg: string, eventActionArg, eventLabelArg: string = 'null') => {
|
2017-02-24 02:06:51 +00:00
|
|
|
let payload: string = 'v=1' +
|
|
|
|
`&tid=${trackingIdArg}` + // the tracking ID
|
|
|
|
'&cid=555' +
|
|
|
|
'&aip=1' + // anonymize the IP
|
|
|
|
'&t=event' +
|
2017-04-17 15:20:56 +00:00
|
|
|
`&ec=${eventCategoryArg}` + // event category
|
|
|
|
`&ea=${eventActionArg}` + // event action
|
|
|
|
`&el=${eventLabelArg}` + // event label
|
2017-02-24 02:06:51 +00:00
|
|
|
'&ev=300' +
|
2017-04-21 10:40:48 +00:00
|
|
|
`&an=${appNameArg}`
|
2017-02-24 02:06:51 +00:00
|
|
|
send(payload)
|
2017-02-24 02:00:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let send = async (requestBodyArg: string) => {
|
2017-02-24 02:06:51 +00:00
|
|
|
await plugins.smartrequest.post('https://www.google-analytics.com/collect', {
|
|
|
|
requestBody: requestBodyArg
|
|
|
|
})
|
2017-02-24 02:00:15 +00:00
|
|
|
}
|