Skip to content

Commit

Permalink
Forward yotta-specific query parameters to yotta, see #66
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanolson committed Mar 18, 2024
1 parent 810a7f3 commit 6506c3d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions js/analytics/google-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,25 @@
}
}, true );

const pingParams = `${'pingver=3&' +
'project='}${encodeURIComponent( phet.chipper.project )}&` +
`brand=${encodeURIComponent( phet.chipper.brand )}&` +
`version=${encodeURIComponent( phet.chipper.version )}&` +
`locale=${encodeURIComponent( phet.chipper.locale )}&` +
`buildTimestamp=${encodeURIComponent( phet.chipper.buildTimestamp )}&` +
`domain=${encodeURIComponent( document.domain )}&` +
`href=${encodeURIComponent( window.location.href )}&` +
'type=html&' +
`timestamp=${encodeURIComponent( Date.now() )}&` +
`loadType=${encodeURIComponent( loadType )}&` +
`ref=${encodeURIComponent( document.referrer )}`;
let pingParams = `${'pingver=3&' +
'project='}${encodeURIComponent( phet.chipper.project )}&` +
`brand=${encodeURIComponent( phet.chipper.brand )}&` +
`version=${encodeURIComponent( phet.chipper.version )}&` +
`locale=${encodeURIComponent( phet.chipper.locale )}&` +
`buildTimestamp=${encodeURIComponent( phet.chipper.buildTimestamp )}&` +
`domain=${encodeURIComponent( document.domain )}&` +
`href=${encodeURIComponent( window.location.href )}&` +
'type=html&' +
`timestamp=${encodeURIComponent( Date.now() )}&` +
`loadType=${encodeURIComponent( loadType )}&` +
`ref=${encodeURIComponent( document.referrer )}`;

// Forward yotta-specific query parameters, see https://github.com/phetsims/phetcommon/issues/66
for ( const [ key, value ] of new URLSearchParams( window.location.search ) ) {
if ( key.startsWith( 'yotta' ) ) {
pingParams += `&${encodeURIComponent( key )}=${encodeURIComponent( value )}`;
}
}

function pingURL( url ) {
const img = document.createElement( 'img' );
Expand Down

0 comments on commit 6506c3d

Please sign in to comment.