An angular service to submit events to Talis Echo with a debounce.
For internal use at Talis as you'll need some way of obtaining Talis OAuth tokens to use (we inject these with transformRequest) but provided for intellectual interest in case anyone else is thinking of doing something similar. MIT licenced so rip, remix and enjoy.
Include via bower:
bower install echo-angular --save-dev
You'll need to define a constant somewhere for the ECHO_ENDPOINT
. We do it like this:
angular.module('talis.environment', [], function($provide) {}).
constant('ECHO_ENDPOINT', 'https://analytics.talis.com');
We have our environment set up by a dynamic env.js
script that is served from Express, using the user agent middleware to pass back sanitised information about the browser back to angular. It esablishes these futher constants that are injected into the service:
constant('BROWSER_NAME','Chrome').
constant('BROWSER_VERSION','34.0.1847.116').
constant('BROWSER_COMPAT_MODE','false');
These are set in the props
of the event sent back to echo.
You'll also need app-logger-angular
(see repo here) which bower will install for you, but you'll need to reference that and this module somewhere:
angular.module('myapp', [
'talis.services.echo',
'talis.services.logging',
]);