client/lib/analytics/ad-tracking.js
function maybeRefreshCountryCodeCookieGdpr( callback ) {
	const cookieMaxAgeSeconds = 6 * 60 * 60;
	const cookies = cookie.parse( document.cookie );

	if ( ! cookies.country_code ) {
		// cache buster
		const v = new Date().getTime();
		request
			.get( 'https://public-api.wordpress.com/geo/?v=' + v )
			.then( res => {
				document.cookie = cookie.serialize( 'country_code', res.body.country_short, {
					path: '/',
					maxAge: cookieMaxAgeSeconds,
				} );
				callback();
			} )
			.catch( err => {
				document.cookie = cookie.serialize( 'country_code', 'unknown', {
					path: '/',
					maxAge: cookieMaxAgeSeconds,
				} );
				debug( 'refreshGeoIpCountryCookieGdpr Error: ', err );
			} );

		return true;
	}

	return false;
}
function maybeRefreshCountryCodeCookieGdpr( callback ) {
	const cookieMaxAgeSeconds = 6 * 60 * 60;
	const cookies = cookie.parse( document.cookie );

	if ( ! cookies.country_code ) {
		// cache buster
		const v = new Date().getTime();
		request
			.get( 'https://public-api.wordpress.com/geo/?v=' + v )
			.then( res => {
				document.cookie = cookie.serialize( 'country_code', res.body.country_short, {
					path: '/',
					maxAge: cookieMaxAgeSeconds,
				} );
				callback();
			} )
			.catch( err => {
				document.cookie = cookie.serialize( 'country_code', 'unknown', {
					path: '/',
					maxAge: cookieMaxAgeSeconds,
				} );
				debug( 'refreshGeoIpCountryCookieGdpr Error: ', err );
			} );

		return true;
	}

	return false;
}
function maybeRefreshCountryCodeCookieGdpr ( callback ) { const cookieMaxAgeSeconds = 6 * 60 * 60 ; const cookies = cookie . parse ( document . cookie ) ; if ( ! cookies . country_code ) { // cache buster const v = new Date ( ) . getTime ( ) ; request . get ( 'https://public-api.wordpress.com/geo/?v=' + v ) . then ( res => { document . cookie = cookie . serialize ( 'country_code' , res . body . country_short , { path : '/' , maxAge : cookieMaxAgeSeconds , } ) ; callback ( ) ; } ) . catch ( err => { document . cookie = cookie . serialize ( 'country_code' , 'unknown' , { path : '/' , maxAge : cookieMaxAgeSeconds , } ) ; debug ( 'refreshGeoIpCountryCookieGdpr Error: ' , err ) ; } ) ; return true ; } return false ; }
Refreshes the GDPR `country_code` cookie every 6 hours (like A8C_Analytics wpcom plugin).

@param {Function} callback - Callback functon to call once the `country_code` cooke has been succesfully refreshed.
@returns {Boolean} Returns `true` if the `country_code` cooke needs to be refreshed.
Refreshes the GDPR country_code cookie every 6 hours ( like A8C_Analytics wpcom plugin ) .