Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 454478
Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.core/web/orion/metrics.js (-30 / +26 lines)
Lines 15-21 Link Here
15
	var queue = [];
15
	var queue = [];
16
16
17
	var init = function(serviceRegistry, args) {
17
	var init = function(serviceRegistry, args) {
18
		var promise = new Deferred();
19
		var refs = serviceRegistry.getServiceReferences("orion.analytics.google"); //$NON-NLS-0$
18
		var refs = serviceRegistry.getServiceReferences("orion.analytics.google"); //$NON-NLS-0$
20
		if (refs.length) {
19
		if (refs.length) {
21
			var ref = refs[0];
20
			var ref = refs[0];
Lines 28-51 Link Here
28
							return;
27
							return;
29
						}
28
						}
30
29
31
						(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
30
						var userService = serviceRegistry.getService("orion.core.user"); //$NON-NLS-0$
32
						(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
31
						var authServices = serviceRegistry.getServiceReferences("orion.core.auth"); //$NON-NLS-0$
33
						m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
32
						for (var i = 0; i < authServices.length; i++) {
34
						})(window,document,'script','//www.google-analytics.com/analytics.js',GA_ID);
33
							var authService = serviceRegistry.getService(authServices[i]);		
34
							authService.getUser().then(function(jsonData) {
35
								userService.getUserInfo(jsonData.Location).then(function(accountData) {
36
									(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
37
									(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
38
									m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
39
									})(window,document,'script','//www.google-analytics.com/analytics.js',GA_ID);
35
40
36
						args = args || {};
41
									args = args || {};
37
						if (result.siteSpeedSampleRate) {
42
									if (result.siteSpeedSampleRate) {
38
							args.siteSpeedSampleRate = result.siteSpeedSampleRate;
43
										args.siteSpeedSampleRate = result.siteSpeedSampleRate;
44
									}
45
									window[GA_ID]("create", result.tid, args); //$NON-NLS-0$
46
									window[GA_ID]("send", "pageview"); //$NON-NLS-1$ //$NON-NLS-0$
47
									window[GA_ID]("set", "dimension2", window.btoa(accountData.UserName)); //$NON-NLS-1$ //$NON-NLS-0$
48
49
									queue.forEach(function(current) {
50
										window[GA_ID](current.command, current.arg0, current.arg1, current.arg2, current.arg3, current.arg4); //$NON-NLS-0$
51
									});
52
									queue = null; /* no longer needed */
53
								});
54
							});
39
						}
55
						}
40
						window[GA_ID]("create", result.tid, args); //$NON-NLS-0$
41
						window[GA_ID]("send", "pageview"); //$NON-NLS-1$ //$NON-NLS-0$
42
43
						queue.forEach(function(current) {
44
							window[GA_ID](current.command, current.arg0, current.arg1, current.arg2, current.arg3, current.arg4); //$NON-NLS-0$
45
						});
46
						queue = null; /* no longer needed */
47
						
48
						promise.resolve();
49
					}
56
					}
50
				);
57
				);
51
			}
58
			}
Lines 53-63 Link Here
53
		if (!(service && service.init)) {
60
		if (!(service && service.init)) {
54
			queue = null; /* not tracking */
61
			queue = null; /* not tracking */
55
		}
62
		}
56
		return promise;
57
	};
63
	};
58
64
59
	function logEvent(category, action, label, value) {
65
	function logEvent(category, action, label, value) {
60
		if (window[GA_ID]) {
66
		if (window[GA_ID]) {
67
window.console.log(category + "..." + action + "..." + label + "..." + value)
61
			window[GA_ID]("send", "event", category, action, label, value); //$NON-NLS-1$ //$NON-NLS-0$
68
			window[GA_ID]("send", "event", category, action, label, value); //$NON-NLS-1$ //$NON-NLS-0$
62
		} else {
69
		} else {
63
			if (queue) {
70
			if (queue) {
Lines 87-107 Link Here
87
		}
94
		}
88
	}
95
	}
89
96
90
	function setDimension(dimensionId, value) {
91
		if (window[GA_ID]) {
92
			window[GA_ID]("set", dimensionId, value); //$NON-NLS-0$
93
		} else {
94
			if (queue) {
95
				queue.push({command: "set", arg0: dimensionId, arg1: value}); //$NON-NLS-0$
96
			}
97
		}
98
	}
99
100
	return {
97
	return {
101
		init: init,
98
		init: init,
102
		logEvent: logEvent,
99
		logEvent: logEvent,
103
		logPageLoadTiming: logPageLoadTiming,
100
		logPageLoadTiming: logPageLoadTiming,
104
		logTiming: logTiming,
101
		logTiming: logTiming
105
		setDimension: setDimension
106
	};
102
	};
107
});
103
});
(-)a/bundles/org.eclipse.orion.client.ui/web/orion/globalCommands.js (-15 lines)
Lines 556-576 Link Here
556
	 * @param {Boolean} closeSplitter true to make the splitter's initial state "closed".
556
	 * @param {Boolean} closeSplitter true to make the splitter's initial state "closed".
557
	 */
557
	 */
558
	function generateBanner(parentId, serviceRegistry, commandRegistry, prefsService, searcher, handler, /* optional */ editor, closeSplitter, fileClient) {
558
	function generateBanner(parentId, serviceRegistry, commandRegistry, prefsService, searcher, handler, /* optional */ editor, closeSplitter, fileClient) {
559
		mMetrics.init(serviceRegistry).then(
560
			function() {
561
				var userService = serviceRegistry.getService("orion.core.user"); //$NON-NLS-0$
562
				var authServices = serviceRegistry.getServiceReferences("orion.core.auth"); //$NON-NLS-0$
563
				for (var i = 0; i < authServices.length; i++) {
564
					var authService = serviceRegistry.getService(authServices[i]);		
565
					authService.getUser().then(function(jsonData){
566
						userService.getUserInfo(jsonData.Location).then(function(accountData) {
567
							mMetrics.setDimension("dimension2", window.btoa(accountData.UserName)); //$NON-NLS-0$
568
						});
569
					});
570
				}
571
			}
572
		);
573
574
		new mThemePreferences.ThemePreferences(prefsService, new mThemeData.ThemeData()).apply();
559
		new mThemePreferences.ThemePreferences(prefsService, new mThemeData.ThemeData()).apply();
575
560
576
		var parent = lib.node(parentId);
561
		var parent = lib.node(parentId);

Return to bug 454478