From a3063f185a60e1de7842d4fd2f334e4861673ea5 Mon Sep 17 00:00:00 2001 From: Gagan Deep Singh Date: Mon, 26 Feb 2024 11:38:14 +0800 Subject: [PATCH] Streamline CHIPS demo --- src/demos/chips/analytics-first-party.ejs | 3 +-- src/demos/chips/analytics-third-party.ejs | 4 +--- src/demos/chips/analytics.ejs | 2 +- src/demos/chips/routes.js | 20 ++++++++------------ src/scenarios/analytics/index.ejs | 1 - 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/demos/chips/analytics-first-party.ejs b/src/demos/chips/analytics-first-party.ejs index 874e3fa..9fa7065 100644 --- a/src/demos/chips/analytics-first-party.ejs +++ b/src/demos/chips/analytics-first-party.ejs @@ -1,13 +1,12 @@ <%- include(commonPath + '/header.ejs') %> <%- include(commonPath + '/internal-page/header.ejs') %> -

Track user interactions using the analytics code provided below:

diff --git a/src/demos/chips/analytics-third-party.ejs b/src/demos/chips/analytics-third-party.ejs index 947b919..71c698f 100644 --- a/src/demos/chips/analytics-third-party.ejs +++ b/src/demos/chips/analytics-third-party.ejs @@ -1,14 +1,12 @@ <%- include(commonPath + '/header.ejs') %> <%- include(commonPath + '/internal-page/header.ejs') %> -

Track user interactions using the analytics code provided below:

-
diff --git a/src/demos/chips/analytics.ejs b/src/demos/chips/analytics.ejs index c22d777..c2f6512 100644 --- a/src/demos/chips/analytics.ejs +++ b/src/demos/chips/analytics.ejs @@ -22,7 +22,7 @@ } ).then( function ( data ) { var statusDiv = document.getElementById( 'status' ); if ( statusDiv ) { - statusDiv.textContent = 'Interaction tracked for ID : ' + data; + statusDiv.textContent = 'Interaction tracked!'; statusDiv.style.color = 'green'; } } ).catch( function ( error ) { diff --git a/src/demos/chips/routes.js b/src/demos/chips/routes.js index 854acc3..799d7d2 100644 --- a/src/demos/chips/routes.js +++ b/src/demos/chips/routes.js @@ -5,19 +5,15 @@ const uuid = require( 'uuid' ); router.get('/', (req, res) => { // Send the default page - res.render(path.join(__dirname,'index'), { + res.render(path.join(__dirname,'analytics-third-party'), { title: 'CHIPS' }); }); -router.get('/analytics-first-party', (req, res) => { - res.render(path.join(__dirname,'analytics-first-party'), { - title: 'First Party Cookie Experiments' - }); -}); + router.get('/analytics-third-party', (req, res) => { // Send the default page res.render(path.join(__dirname,'analytics-third-party'), { - title: 'Third Party Cookie Experiments' + title: 'CHIPS' }); }); // Serve the analytics.js file to the site @@ -39,16 +35,16 @@ router.get( '/analytics.js', ( req, res ) => { } - let analyticsIdCHIPS = req.cookies['__Host-analyticsId-chips']; + let analyticsIdCHIPS = req.cookies['analyticsId-chips']; if ( !analyticsIdCHIPS ) { analyticsIdCHIPS = uuid.v4(); let expire = 30 * 24 * 60 * 60 * 1000; - res.append( + /*res.append( 'Set-Cookie', '__Host-analyticsId-chips=' + analyticsIdCHIPS + '; Max-Age=' + expire + '; HttpOnly; Secure; Path=/; SameSite=None; Partitioned;' - ); + );*/ res.append( - 'Set-Cookie', 'analyticsId-chips-test=' + analyticsIdCHIPS + ';Domain='+res.locals.domainC+'; Max-Age=' + expire + '; HttpOnly; Secure; Path=/; SameSite=None; Partitioned;' + 'Set-Cookie', 'analyticsId-chips=' + analyticsIdCHIPS + ';Domain='+res.locals.domainC+'; Max-Age=' + expire + '; HttpOnly; Secure; Path=/; SameSite=None; Partitioned;' ); } @@ -73,7 +69,7 @@ router.post( '/track', ( req, res ) => { router.post( '/trackCHIPS', ( req, res ) => { const {interaction} = req.body; - const analyticsIdCHIPS = req.cookies['__Host-analyticsId-chips']; + const analyticsIdCHIPS = req.cookies['analyticsId-chips']; if ( interaction && analyticsIdCHIPS ) { diff --git a/src/scenarios/analytics/index.ejs b/src/scenarios/analytics/index.ejs index 5150bec..2e67308 100644 --- a/src/scenarios/analytics/index.ejs +++ b/src/scenarios/analytics/index.ejs @@ -1,7 +1,6 @@ <%- include(commonPath + '/header.ejs') %> <%- include(commonPath + '/internal-page/header.ejs') %> -

Here is a button that tracks clicks using a third-party analytics service; check if it works.