Skip to content

Commit

Permalink
Analytics: Remove problematic "blacklist"/"whitelist" language #43395 (
Browse files Browse the repository at this point in the history
…#43643)

* Analytics: Remove problematic "blacklist"/"whitelist" language #43303

* s/exluded/excluded/
  • Loading branch information
sarayourfriend committed Jun 29, 2020
1 parent 569c50b commit d5bebcd
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
Expand Up @@ -42,7 +42,7 @@ As Promotions only exist in memory state on the client at this point, the defini

### appliesTo

The `appliesTo` object for a promotion is a complex object which describes what all the promotion can be applied to. At this point, exluded products or categories are not supported.
The `appliesTo` object for a promotion is a complex object which describes what all the promotion can be applied to. At this point, excluded products or categories are not supported.

#### Example: all products.

Expand Down
8 changes: 4 additions & 4 deletions client/lib/analytics/sem.js
Expand Up @@ -20,7 +20,7 @@ const MAX_URL_PARAM_VALUE_LENGTH = 50;
const MAX_KEYWORD_PARAM_VALUE_LENGTH = 80;
const MAX_GCLID_PARAM_VALUE_LENGTH = 100;
// These are the URL params that end up in the `ad_details` cookie
const URL_PARAM_WHITELIST = [
const ALLOWED_URL_PARAMS = [
'adgroupid',
'campaignid',
'device',
Expand Down Expand Up @@ -58,8 +58,8 @@ function isValidOtherUrlParamValue( key, value ) {
return value.length <= MAX_URL_PARAM_VALUE_LENGTH;
}

function isValidWhitelistedUrlParamValue( key, value ) {
if ( -1 === URL_PARAM_WHITELIST.indexOf( key ) ) {
function isValidAndAllowedUrlParamValue( key, value ) {
if ( -1 === ALLOWED_URL_PARAMS.indexOf( key ) ) {
return false;
} else if ( 'utm_source' === key || 'utm_campaign' === value ) {
return isValidUtmSourceOrCampaign( value );
Expand Down Expand Up @@ -94,7 +94,7 @@ export function updateQueryParamsTracking() {

if ( searchParams ) {
const validEntries = Array.from( searchParams.entries() ).filter( ( [ key, value ] ) =>
isValidWhitelistedUrlParamValue( key, value )
isValidAndAllowedUrlParamValue( key, value )
);
sanitizedQuery = new URLSearchParams( validEntries );

Expand Down
6 changes: 3 additions & 3 deletions client/lib/analytics/track-affiliate-referral.js
Expand Up @@ -11,7 +11,7 @@ import { recordTracksEvent } from 'lib/analytics/tracks';

const referDebug = debug( 'calypso:analytics:refer' );

const whitelistedEventProps = [
const allowedEventProps = [
'status',
'success',
'duplicate',
Expand Down Expand Up @@ -54,7 +54,7 @@ export async function trackAffiliateReferral( { affiliateId, campaignId, subId,
if ( response.ok ) {
referDebug( 'Recording Refer platform success response.', json );
recordTracksEvent( 'calypso_refer_visit_response', {
...pick( json.data, whitelistedEventProps ),
...pick( json.data, allowedEventProps ),
status: response.status || '',
success: json.success || true,
description: json.message || 'success',
Expand All @@ -64,7 +64,7 @@ export async function trackAffiliateReferral( { affiliateId, campaignId, subId,

referDebug( 'Recording Refer platform error response.', json );
recordTracksEvent( 'calypso_refer_visit_response', {
...pick( json.data, whitelistedEventProps ),
...pick( json.data, allowedEventProps ),
status: response.status || '',
success: json.success || false,
description: json.message || 'error',
Expand Down
2 changes: 1 addition & 1 deletion client/lib/analytics/utils/index.js
Expand Up @@ -5,7 +5,7 @@ export { default as MARKETING_COUPONS_KEY } from './marketing-coupons-key';
export { default as costToUSD } from './cost-to-usd';
export { default as hashPii } from './hash-pii';
export { default as isPiiUrl } from './is-pii-url';
export { default as isUrlBlacklistedForPerformance } from './is-url-blacklisted-for-performance';
export { default as isUrlExcludedForPerformance } from './is-url-excluded-for-performance';
export { default as isAdTrackingAllowed } from './is-ad-tracking-allowed';
export { default as mayWeTrackCurrentUserGdpr } from './may-we-track-current-user-gdpr';
export { default as isCurrentUserMaybeInGdprZone } from './is-current-user-maybe-in-gdpr-zone';
Expand Down
4 changes: 2 additions & 2 deletions client/lib/analytics/utils/is-ad-tracking-allowed.js
Expand Up @@ -3,7 +3,7 @@
*/
import config from 'config';
import debug from './debug';
import isUrlBlacklistedForPerformance from './is-url-blacklisted-for-performance';
import isUrlExcludedForPerformance from './is-url-excluded-for-performance';
import isPiiUrl from './is-pii-url';
import mayWeTrackCurrentUserGdpr from './may-we-track-current-user-gdpr';
import { getDoNotTrack } from '@automattic/calypso-analytics';
Expand All @@ -23,7 +23,7 @@ export default function isAdTrackingAllowed() {
const result =
config.isEnabled( 'ad-tracking' ) &&
! getDoNotTrack() &&
! isUrlBlacklistedForPerformance() &&
! isUrlExcludedForPerformance() &&
! isPiiUrl() &&
mayWeTrackCurrentUserGdpr();
debug( `isAdTrackingAllowed: ${ result }` );
Expand Down
21 changes: 0 additions & 21 deletions client/lib/analytics/utils/is-url-blacklisted-for-performance.js

This file was deleted.

21 changes: 21 additions & 0 deletions client/lib/analytics/utils/is-url-excluded-for-performance.js
@@ -0,0 +1,21 @@
/**
* Internal dependencies
*/
import debug from './debug';

// For better load performance, these routes are excluded from loading ads.
const excludedRoutes = [ '/log-in' ];

/**
* Are tracking pixels forbidden from the given URL for better performance (except for Google Analytics)?
*
* @returns {boolean} true if the current URL is excluded.
*/
export default function isUrlExcludedForPerformance() {
const { href } = document.location;
const match = ( pattern ) => href.indexOf( pattern ) !== -1;
const result = excludedRoutes.some( match );

debug( `Is URL Excluded for Performance: ${ result }` );
return result;
}

0 comments on commit d5bebcd

Please sign in to comment.