Skip to content

Commit

Permalink
fix(debug): Track front-end errors with Datadog RUM (#412)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienjoly committed Nov 29, 2020
1 parent ea404bf commit f4719e7
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions app/templates/mainTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,32 @@ var htmlHeading = [
];

exports.makeAnalyticsHeading = function (user) {
const errorTracking = `
<script>
(function(h,o,u,n,d) {
h=h[d]=h[d]||{q:[],onReady:function(c){h.q.push(c)}}
d=o.createElement(u);d.async=1;d.src=n
n=o.getElementsByTagName(u)[0];n.parentNode.insertBefore(d,n)
})(window,document,'script','https://www.datadoghq-browser-agent.com/datadog-rum.js','DD_RUM')
DD_RUM.onReady(function() {
DD_RUM.init({
clientToken: 'pub8eeb8858448e59bbb3db9e58371cc3d2',
applicationId: '5897e862-9942-4dd4-98a7-87a51a93fb91',
site: 'datadoghq.com',
service: 'openwhyd.org',
// env: 'production',
// version: '1.0.0',
sampleRate: 100,
trackInteractions: true,
})
})
</script>`;
// only render opengraph preferences (in order to avoid rendering a date object for nextEmail/nextEN)
var userPrefs = {};
for (let i in (user || {}).pref)
if (i.indexOf('og') == 0) userPrefs[i] = user.pref[i];
return [
...errorTracking.split('\n'), // --> https://app.datadoghq.com/rum
'<script>',
' window.user = ' +
(!user
Expand Down

0 comments on commit f4719e7

Please sign in to comment.