angular.module("mixpanelAPI", []) .service('mixpanelAPI', function() { this.send = function(eventName, properties) { if (typeof properties == 'undefined') { properties = Object; } properties['appName'] = appName; properties['userId'] = userId; properties['userName'] = userName; properties['companyId'] = companyId; properties['companyName'] = companyName; mixpanel.track(eventName, properties); }; this.sendServerError = function (methodName, messageText) { this.send('servererror', {method: methodName, message: messageText}); }; this.decorateDetailsWithPlayerInfo = function (detailsObject, player) { detailsObject.playerId = player.id; detailsObject.playerFullname = player.firstName + " " + player.lastName; detailsObject.playerPosition = player.position; return detailsObject; } this.decorateDetailsWithTeamInfo = function (detailsObject, team) { detailsObject.teamId = team.id; detailsObject.teamFullname = team.location + " " + team.name; return detailsObject; } this.decorateDetailsWithGameInfo = function (detailsObject, game) { detailsObject.gameId = game.id; detailsObject.gameDate = game.date; detailsObject.homeTeamId = game.home.id; detailsObject.homeTeamFullname = game.home.location + ' ' + game.home.name; detailsObject.awayTeamId = game.visitors.id; detailsObject.awayTeamFullname = game.visitors.location + ' ' + game.visitors.name; return detailsObject; } }); // end of service factory