Skip to content

Commit

Permalink
Merge pull request #44 from barriosnahuel/hotfix/analytics
Browse files Browse the repository at this point in the history
Fix Analytics configuration
  • Loading branch information
barriosnahuel committed Mar 1, 2016
2 parents df76ca4 + 5121bf6 commit d2167e2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 18 deletions.
23 changes: 23 additions & 0 deletions extension/js/fend/analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* This is the famous snippet we're used to see directly in the HTML page, but for Chrome extensions and its Content Security Policy (CSP) we must load it from an external *.js file.
* Created by Nahuel Barrios on 29/02/16.
*/
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32410648-9']);
_gaq.push(['_trackPageview']);

/**
* Below is a modified version of the Google Analytics asynchronous tracking
* code snippet. It has been modified to pull the HTTPS version of ga.js
* instead of the default HTTP version. It is recommended that you use this
* snippet instead of the standard tracking snippet provided when setting up
* a Google Analytics account.
*/
(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
11 changes: 10 additions & 1 deletion extension/js/fend/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ $(document).ready(function () {
}
}).on('hidden.bs.popover', function () {
$changelog.popover('destroy');
_gaq.push(['_trackEvent', 'Changelog', 'Closed']);
}).popover('show');

$('html,body').animate({scrollTop: $('div.popover').offset().top});
Expand Down Expand Up @@ -115,8 +116,10 @@ $(document).ready(function () {

if ($this.prop('checked')) {
issues.push($this.val());
_gaq.push(['_trackEvent', 'Issues', 'Enabled', $this.val()]);
} else {
issues.splice(issues.indexOf($this.val()), 1);
_gaq.push(['_trackEvent', 'Issues', 'Disabled', $this.val()]);
}

saveIssues();
Expand Down Expand Up @@ -160,7 +163,11 @@ $(document).ready(function () {

saveEnabledEvents();

console.dir(supportedEvents);
if (eventType.enabled) {
_gaq.push(['_trackEvent', 'Events', 'Enabled', eventType.event]);
} else {
_gaq.push(['_trackEvent', 'Events', 'Disabled', eventType.event]);
}
});
}
}
Expand Down Expand Up @@ -223,6 +230,8 @@ $(document).ready(function () {
return item !== '';
});

_gaq.push(['_trackEvent', 'Branches', 'Added', branch]);

saveBranches(function () {
$check.show();
if (branch == '') {
Expand Down
4 changes: 2 additions & 2 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Spokesman - GitHub's notifications",
"short_name": "Spokesman",
"version": "1.1.0",
"version": "1.1.1",
"description": "Get desktop notifications of events that occur on GitHub that really interest you.",
"browser_action": {
"default_icon": {
Expand Down Expand Up @@ -47,6 +47,6 @@
],
"persistent": false
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'; script-src 'self' https://ssl.google-analytics.com; object-src 'self'",
"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'",
"author": "Nahuel Barrios"
}
17 changes: 2 additions & 15 deletions extension/views/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,7 @@
<link rel="stylesheet" href="../css/settings.css">

<title>Spokesman Settings - Chrome Extensions</title>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-32410648-9']);
_gaq.push(['_trackPageview']);

(function () {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>
<script src="../js/fend/analytics.js"></script>
</head>
<body>

Expand All @@ -34,7 +21,7 @@
<div class="row">
<div class="col-md-12">
<div class="page-header">
<h1>Spokesman v1.1.0 - Settings page</h1>
<h1>Spokesman v1.1.1 - Settings page</h1>
<img class="pull-right" src="../img/megaphone17-128.png">
</div>
</div>
Expand Down

0 comments on commit d2167e2

Please sign in to comment.