1
0
mirror of https://github.com/bitwarden/desktop.git synced 2024-11-14 10:16:02 +01:00

setup google analytics with pageview tracking

This commit is contained in:
Kyle Spearrin 2016-09-27 22:44:42 -04:00
parent d49f0fcac3
commit a727e107fe
8 changed files with 51 additions and 2 deletions

View File

@ -106,6 +106,12 @@ gulp.task('lib', ['clean:lib'], function () {
src: [paths.npmDir + 'sweetalert/dist/sweetalert.css', paths.npmDir + 'sweetalert/dist/sweetalert.min.js',
paths.npmDir + 'angular-sweetalert/SweetAlert.js'],
dest: paths.libDir + 'sweetalert'
},
{
src: [paths.npmDir + 'angulartics-google-analytics/lib/angulartics*.js',
paths.npmDir + 'angulartics/src/angulartics.js'
],
dest: paths.libDir + 'angulartics'
}
];

View File

@ -26,6 +26,8 @@
"q": "1.4.1",
"angularjs-slider": "5.5.0",
"sweetalert": "1.1.3",
"angular-sweetalert": "1.1.1"
"angular-sweetalert": "1.1.1",
"angulartics": "1.2.1",
"angulartics-google-analytics": "0.2.1"
}
}

View File

@ -1,3 +1,4 @@
var isBackground = true;
var utilsService = new UtilsService();
var cryptoService = new CryptoService();
var tokenService = new TokenService();

View File

@ -12,6 +12,7 @@
"96": "images/icon96.png",
"128": "images/icon128.png"
},
"content_security_policy": "script-src 'self' https://www.google-analytics.com; object-src 'self'",
"content_scripts": [
{
"js": [ "content/autoFill.js" ],
@ -32,6 +33,7 @@
"lib/sjcl/bitArray.js",
"lib/q/q.js",
"scripts/tld.js",
"scripts/analyticsCode.js",
"models/api/requestModels.js",
"models/api/responseModels.js",
"models/dataModels.js",
@ -47,7 +49,8 @@
"services/autofillService.js",
"services/appIdService.js",
"services/passwordGenerationService.js",
"background.js"
"background.js",
"scripts/analytics.js"
],
"persistent": true
},

View File

@ -3,6 +3,8 @@
'ui.router',
'ngAnimate',
'toastr',
'angulartics',
'angulartics.google.analytics',
'bit.directives',
'bit.services',

View File

@ -14,6 +14,8 @@
<script src="../lib/jquery/jquery.js"></script>
<script src="../lib/bootstrap/js/bootstrap.js"></script>
<script src="../lib/clipboard/clipboard.js"></script>
<script src="../scripts/analyticsCode.js"></script>
<script src="../scripts/analytics.js"></script>
<script src="../lib/angular/angular.js"></script>
<script src="../lib/angular-animate/angular-animate.js"></script>
@ -23,6 +25,8 @@
<script src="../lib/sweetalert/SweetAlert.js"></script>
<script src="../lib/sweetalert/sweetalert.min.js"></script>
<script src="../lib/angularjs-slider/rzslider.js"></script>
<script src="../lib/angulartics/angulartics.js"></script>
<script src="../lib/angulartics/angulartics-ga.js"></script>
<script src="app/app.js"></script>
<script src="app/settings.js"></script>

26
src/scripts/analytics.js Normal file
View File

@ -0,0 +1,26 @@
var gaUtils = chrome.extension.getBackgroundPage().utilsService,
gaTrackingId = null;
if (gaUtils.isChrome()) {
gaTrackingId = 'UA-81915606-6';
}
else if (gaUtils.isFirefox()) {
gaTrackingId = 'UA-81915606-7';
}
else if (gaUtils.isEdge()) {
gaTrackingId = 'UA-81915606-9';
}
else if (gaUtils.isOpera()) {
gaTrackingId = 'UA-81915606-8';
}
if (gaTrackingId) {
ga('create', gaTrackingId, 'auto');
}
// Removes failing protocol check. ref: http://stackoverflow.com/a/22152353/1958200
ga('set', 'checkProtocolTask', function () { });
if (typeof isBackground !== 'undefined') {
ga('send', 'pageview', '/background.html');
}

View File

@ -0,0 +1,5 @@
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');