8000 Add Piwik analytics · TailorDev/assignees@480e7af · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Add Piwik analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
willdurand committed Feb 4, 2017
1 parent 5d3e0ed commit 480e7af
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ userSchema.methods.hasAccessTo = function hasAccessTo(feature) {
return this.features.includes(feature);
};

userSchema.methods.getUsername = function getUsername() {
return this.github_login;
};

userSchema.statics.findOneById = function findOneById(id) {
return this.findOne({ _id: id }).catch(() => null);
};
Expand Down
15 changes: 15 additions & 0 deletions views/global-mixins.pug
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,18 @@ mixin sign-in
label
input(type='checkbox', name='private', checked=true)
| Include #[strong private repositories]

mixin analytics
script(type='text/javascript')
| var _paq = _paq || [];
if user
| _paq.push(['setUserId', '#{user.getUsername()}']);
| _paq.push(['trackPageView']);
| _paq.push(['enableLinkTracking']);
| (function() {
| var u="//analytics.tailordev.fr/";
| _paq.push(['setTrackerUrl', u+'piwik.php']);
| _paq.push(['setSiteId', '7']);
| var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
| g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
| })();
1 change: 1 addition & 0 deletions views/layout.pug
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ html
script(src='/js/lib/bootstrap-select.min.js')
if user
script(src='/js/beacon.js')
+analytics

0 comments on commit 480e7af

Please sign in to comment.
0