Last active
September 9, 2015 10:51
-
-
Save andrewconnell/9bbcc996fdde0d06ff5b to your computer and use it in GitHub Desktop.
azure.appInsights.service.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (function () { | |
| 'use strict'; | |
| angular.module('appng-ffldraft-xlsaddin') | |
| .service('azAppInsightService', [azAppInsightService]); | |
| /** | |
| * Custom Angular service. | |
| * | |
| */ | |
| function azAppInsightService() { | |
| return { | |
| trackPageView: trackPageView, | |
| trackEvent: trackEvent | |
| } | |
| init(); | |
| /** *********************************************************** */ | |
| function init() { | |
| var config = appInsights.config; | |
| config.enableDebug = true; | |
| config.verboseLogging = true; | |
| appInsights.config = config; | |
| } | |
| /** | |
| * Track a page view. | |
| */ | |
| function trackPageView(pageName, url, leagueId, teamId) { | |
| var configData = { | |
| App: 'ExcelDraftAddin' | |
| } | |
| if (leagueId !== null && leagueId !== undefined) { | |
| configData.LeagueId = leagueId; | |
| } | |
| if (teamId !== null && teamId !== undefined) { | |
| configData.TeamId = teamId; | |
| } | |
| appInsights.trackPageView(pageName, url, configData); | |
| } | |
| /** | |
| * Track custom event. | |
| */ | |
| function trackEvent(event, leagueId, teamId, data) { | |
| var configData = {} | |
| if (data !== null && data !== undefined) { | |
| configData = data; | |
| } | |
| configData.App = 'ExcelDraftAddin'; | |
| if (leagueId !== null && leagueId !== undefined) { | |
| configData.LeagueId = leagueId; | |
| } | |
| if (teamId !== null && teamId !== undefined) { | |
| configData.TeamId = teamId; | |
| } | |
| appInsights.trackEvent(event, configData); | |
| } | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment