-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correct formatting in analytics.ejs files
- Loading branch information
Showing
2 changed files
with
74 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,40 @@ | ||
<% // views/analytics.ejs %> | ||
(function(window) { | ||
// Track user interactions | ||
function trackInteraction(interaction) { | ||
if('buttonClickedCHIPS' === interaction ){ | ||
var remoteURL = '<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/chips/trackCHIPS'; | ||
} else { | ||
var remoteURL = '<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/chips/track'; | ||
} | ||
fetch(remoteURL, { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({interaction: interaction}) | ||
}).then(function(response) { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.text(); | ||
}).then(function(data) { | ||
var statusDiv = document.getElementById('status'); | ||
if (statusDiv) { | ||
statusDiv.textContent = 'Interaction tracked for ID : ' + data; | ||
statusDiv.style.color = 'green'; | ||
} | ||
}).catch(function(error) { | ||
var statusDiv = document.getElementById('status'); | ||
if (statusDiv) { | ||
statusDiv.textContent = 'Interaction could not be tracked.'; | ||
statusDiv.style.color = 'red'; | ||
} | ||
}); | ||
} | ||
( | ||
function ( window ) { | ||
// Track user interactions | ||
function trackInteraction( interaction ) { | ||
if ( 'buttonClickedCHIPS' === interaction ) { | ||
var remoteURL = '<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/chips/trackCHIPS'; | ||
} else { | ||
var remoteURL = '<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/chips/track'; | ||
} | ||
fetch( remoteURL, { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify( {interaction: interaction} ) | ||
} ).then( function ( response ) { | ||
if ( !response.ok ) { | ||
throw new Error( 'Network response was not ok' ); | ||
} | ||
return response.text(); | ||
} ).then( function ( data ) { | ||
var statusDiv = document.getElementById( 'status' ); | ||
if ( statusDiv ) { | ||
statusDiv.textContent = 'Interaction tracked for ID : ' + data; | ||
statusDiv.style.color = 'green'; | ||
} | ||
} ).catch( function ( error ) { | ||
var statusDiv = document.getElementById( 'status' ); | ||
if ( statusDiv ) { | ||
statusDiv.textContent = 'Interaction could not be tracked.'; | ||
statusDiv.style.color = 'red'; | ||
} | ||
} ); | ||
} | ||
|
||
// Expose the trackInteraction function globally | ||
window.trackInteraction = trackInteraction; | ||
})(window); | ||
// Expose the trackInteraction function globally | ||
window.trackInteraction = trackInteraction; | ||
} | ||
)( window ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
<% // views/analytics.ejs %> | ||
(function(window) { | ||
// Track user interactions | ||
function trackInteraction(interaction) { | ||
var remoteURL = '<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/analytics/track'; | ||
fetch(remoteURL, { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({interaction: interaction}) | ||
}).then(function(response) { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
return response.text(); | ||
}).then(function(data) { | ||
var statusDiv = document.getElementById('status'); | ||
if (statusDiv) { | ||
statusDiv.textContent = 'Interaction tracked for User : ' + data; | ||
statusDiv.style.color = 'green'; | ||
} | ||
}).catch(function(error) { | ||
var statusDiv = document.getElementById('status'); | ||
if (statusDiv) { | ||
statusDiv.textContent = 'Interaction could not be tracked.'; | ||
statusDiv.style.color = 'red'; | ||
} | ||
}); | ||
} | ||
( | ||
function ( window ) { | ||
// Track user interactions | ||
function trackInteraction( interaction ) { | ||
var remoteURL = '<%= protocol %>://<%= domainC %><% if (isPortPresent) { %>:<%= port %><% } %>/analytics/track'; | ||
fetch( remoteURL, { | ||
method: 'POST', | ||
credentials: 'include', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify( {interaction: interaction} ) | ||
} ).then( function ( response ) { | ||
if ( !response.ok ) { | ||
throw new Error( 'Network response was not ok' ); | ||
} | ||
return response.text(); | ||
} ).then( function ( data ) { | ||
var statusDiv = document.getElementById( 'status' ); | ||
if ( statusDiv ) { | ||
statusDiv.textContent = 'Interaction tracked for User : ' + data; | ||
statusDiv.style.color = 'green'; | ||
} | ||
} ).catch( function ( error ) { | ||
var statusDiv = document.getElementById( 'status' ); | ||
if ( statusDiv ) { | ||
statusDiv.textContent = 'Interaction could not be tracked.'; | ||
statusDiv.style.color = 'red'; | ||
} | ||
} ); | ||
} | ||
|
||
// Expose the trackInteraction function globally | ||
window.trackInteraction = trackInteraction; | ||
})(window); | ||
// Expose the trackInteraction function globally | ||
window.trackInteraction = trackInteraction; | ||
} | ||
)( window ); |