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