Skip to content

Commit 08ef5e2

Browse files
Elle Meredithelle
authored andcommitted
Change from Google Analytics to Segment.io
Use a different value for production and development environments. = Add SEGMENT_TRACKING_ID to .env.developemt - On Render SEGMENT_TRACKING_ID is et to be the same as in dev env because Render uses the same env variables across prod and PR review apps - Override the value of the SEGMENT_TRACKING_ID variable in Dockerfile so that production env will use a different key Linear: https://linear.app/buildkite/issue/ONB-29/🔗-integrate-docs-with-segment
1 parent 4df3f2a commit 08ef5e2

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
RENDER_PR_APP=true
1+
SEGMENT_TRACKING_ID=EuoLh8Z8RQR0GXhCWz3H0ddTSIV4ysJv

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
# Ignore master key for decrypting credentials and more.
2424
/config/master.key
2525

26-
# Ignore algolia api key
2726
/.env
2827

2928
/vendor/bundle

Dockerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ EXPOSE 3000
5454
# Let puma serve the static files
5555
ENV RAILS_SERVE_STATIC_FILES=true
5656

57-
# Set Render PR App switch
58-
ENV RENDER_PR_APP=false
57+
ENV SGEMENT_TRACKING_ID=q0LtPl49tgnyHHY8PGBsPsshHk9AVNKm
5958

6059
CMD ["bundle", "exec", "puma", "-C", "./config/puma.rb"]
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
<% unless Rails.env.test? %>
2-
<%= javascript_include_tag "https://www.googletagmanager.com/gtag/js?id=G-08J9WTTHMP", async: true %>
3-
<% end %>
4-
51
<%= javascript_tag nonce: true do %>
6-
window.dataLayer = window.dataLayer || [];
7-
function gtag(){dataLayer.push(arguments);}
8-
gtag('js', new Date());
9-
10-
gtag('config', 'G-08J9WTTHMP');
11-
gtag('config', 'UA-189329674-2');
12-
<% end %>
2+
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics._writeKey="<%= ENV['SEGMENT_TRACKING_ID'] %>";;analytics.SNIPPET_VERSION="4.15.3";
3+
analytics.load("<%= ENV['SEGMENT_TRACKING_ID'] %>");
4+
analytics.page();
5+
}}();
6+
<% end %>

0 commit comments

Comments
 (0)