Skip to content

Commit

Permalink
feat: Add PostHog analytics tracking for page views
Browse files Browse the repository at this point in the history
  • Loading branch information
Illyism committed Jun 17, 2024
1 parent ddb82ef commit 2c56715
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/coffee/views/UI.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ UI = Backbone.View.extend
# Show the changes in navigation
Dispatcher.trigger Constants.PAGE_CHANGING, @number, page

posthog.capture('$pageview', {
page: page
})

getElement: (page) ->
@$("[data-page=#{page}]")

Expand Down
13 changes: 6 additions & 7 deletions src/pug/includes/gtm.pug
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
noscript
iframe(src="//www.googletagmanager.com/ns.html?id=GTM-P9KR4K", height="0" width="0" style="display:none;visibility:hidden")
script.
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P9KR4K');
!function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.createElement("script")).type="text/javascript",p.async=!0,p.src=s.api_host+"/static/array.js",(r=t.getElementsByTagName("script")[0]).parentNode.insertBefore(p,r);var u=e;for(void 0!==a?u=e[a]=[]:a="posthog",u.people=u.people||[],u.toString=function(t){var e="posthog";return"posthog"!==a&&(e+="."+a),t||(e+=" (stub)"),e},u.people.toString=function(){return u.toString(1)+".people (stub)"},o="capture identify alias people.set people.set_once set_config register register_once unregister opt_out_capturing has_opted_out_capturing opt_in_capturing reset isFeatureEnabled onFeatureFlags getFeatureFlag getFeatureFlagPayload reloadFeatureFlags group updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures getActiveMatchingSurveys getSurveys".split(" "),n=0;n<o.length;n++)g(u,o[n]);e._i.push([i,s,a])},e.__SV=1)}(document,window.posthog||[]);
posthog.init('phc_Y8mRb8IwIQDvDQx3u63ZXIYLzeqdfaJV4ndKkEamSHV',{
api_host: 'https://magicproxy-dnfo3dcduq-ew.a.run.app',
ui_host: 'https://eu.posthog.com',
})
if (user_authentication) posthog.identify(user_authentication.id, user_authentication);
22 changes: 14 additions & 8 deletions src/pug/includes/titlebar.pug
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@
.page.icon.link.item(data-page="remote", class={active: page == "remote"})
i.icon.wifi
| Remote Control
a.icon.item(href="https://github.com/musicplayer-io/redditmusicplayer", target="_blank")
a.icon.item(href="https://github.com/musicplayer-io/redditmusicplayer", target="_blank", rel="nofollow")
i.icon.github.alternative
| Source Code
a.icon.item(href="https://www.reddit.com/r/musicplayer", target="_blank")
a.icon.item(href="https://www.reddit.com/r/musicplayer", target="_blank", rel="nofollow")
i.icon.reddit
| Reddit
a.icon.item(href="https://twitter.com/musicplayer_io", target="_blank")
i.icon.twitter
| Twitter
a.icon.item(href="https://www.facebook.com/musicplayer.io", target="_blank")
i.icon.facebook
| Facebook
a.icon.item(href="https://il.ly", target="_blank")
i.icon.birthday.cake
| Ilias Ism
a.item(href="https://magicbuddy.chat", target="_blank")
i.icon.hand.point.right.outline
| ChatGPT in Telegram
a.item(href="https://swissobserver.com", target="_blank")
i.icon.hand.point.right.outline
| Swiss News
a.item(href="https://magicspace.agency", target="_blank")
i.icon.hand.point.right.outline
| SEO Agency
span.authentication
a.item.log-in(href="/login")
i.icon.user
Expand Down

0 comments on commit 2c56715

Please sign in to comment.