app.service('Amplitude',function($amplitude,$rootScope,amplitudeApiKey,$location){functioninit(){$amplitude.init(amplitudeApiKey);// if using angular-ui-router$rootScope.$on('$locationChangeStart',function(){logEvent('visited_app_page',{page: $location.$$path});});}functionidentifyUser(userId,userProperties){$amplitude.setUserId(userId);$amplitude.setUserProperties(userProperties);}functionlogEvent(eventName,params){$amplitude.logEvent(eventName,params);}return{init: init,logEvent: logEvent,identifyUser: identifyUser};});