Skip to content

Commit cd009b4

Browse files
author
Paul Boocock
committed
Change white and black lists to allow and deny lists (close #908)
1 parent 438a4cb commit cd009b4

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

libraries/browser-tracker-core/src/helpers.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ var windowAlias = window,
4444
*/
4545
export interface FilterCriterion<T> {
4646
/** A collection of class names to include */
47-
whitelist?: string[];
47+
allowlist?: string[];
4848
/** A collector of class names to exclude */
49-
blacklist?: string[];
49+
denylist?: string[];
5050
/** A callback which returns a boolean as to whether the element should be included */
5151
filter?: (elt: T) => boolean;
5252
}
@@ -470,10 +470,10 @@ export function parseAndValidateFloat(obj: unknown) {
470470
/**
471471
* Convert a criterion object to a filter function
472472
*
473-
* @param object criterion Either {whitelist: [array of allowable strings]}
474-
* or {blacklist: [array of allowable strings]}
473+
* @param object criterion Either {allowlist: [array of allowable strings]}
474+
* or {denylist: [array of allowable strings]}
475475
* or {filter: function (elt) {return whether to track the element}
476-
* @param boolean byClass Whether to whitelist/blacklist based on an element's classes (for forms)
476+
* @param boolean byClass Whether to allowlist/denylist based on an element's classes (for forms)
477477
* or name attribute (for fields)
478478
*/
479479
export function getFilterByClass(criterion?: FilterCriterion<HTMLElement> | null): (elt: HTMLElement) => boolean {
@@ -484,7 +484,7 @@ export function getFilterByClass(criterion?: FilterCriterion<HTMLElement> | null
484484
};
485485
}
486486

487-
const inclusive = Object.prototype.hasOwnProperty.call(criterion, 'whitelist');
487+
const inclusive = Object.prototype.hasOwnProperty.call(criterion, 'allowlist');
488488
const specifiedClassesSet = getSpecifiedClassesSet(criterion);
489489

490490
return getFilter(criterion, function (elt: HTMLElement) {
@@ -495,8 +495,8 @@ export function getFilterByClass(criterion?: FilterCriterion<HTMLElement> | null
495495
/**
496496
* Convert a criterion object to a filter function
497497
*
498-
* @param object criterion Either {whitelist: [array of allowable strings]}
499-
* or {blacklist: [array of allowable strings]}
498+
* @param object criterion Either {allowlist: [array of allowable strings]}
499+
* or {denylist: [array of allowable strings]}
500500
* or {filter: function (elt) {return whether to track the element}
501501
*/
502502
export function getFilterByName<T extends { name: string }>(criterion: FilterCriterion<T>): (elt: T) => boolean {
@@ -507,7 +507,7 @@ export function getFilterByName<T extends { name: string }>(criterion: FilterCri
507507
};
508508
}
509509

510-
const inclusive = criterion.hasOwnProperty('whitelist');
510+
const inclusive = criterion.hasOwnProperty('allowlist');
511511
const specifiedClassesSet = getSpecifiedClassesSet(criterion);
512512

513513
return getFilter(criterion, function (elt: T) {
@@ -548,7 +548,7 @@ function getFilter<T>(criterion: FilterCriterion<T>, fallbackFilter: (elt: T) =>
548548
function getSpecifiedClassesSet<T>(criterion: FilterCriterion<T>) {
549549
// Convert the array of classes to an object of the form {class1: true, class2: true, ...}
550550
var specifiedClassesSet: Record<string, boolean> = {};
551-
var specifiedClasses = criterion.whitelist || criterion.blacklist;
551+
var specifiedClasses = criterion.allowlist || criterion.denylist;
552552

553553
if (specifiedClasses) {
554554
if (!Array.isArray(specifiedClasses)) {

trackers/javascript-tracker/test/pages/form-tracking.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@
8585

8686
switch (parseQuery().filter) {
8787
case 'exclude':
88-
snowplow('enableFormTracking', { options: { fields: { blacklist: ['fname'] } } });
88+
snowplow('enableFormTracking', { options: { fields: { denylist: ['fname'] } } });
8989
break;
9090
case 'include':
91-
snowplow('enableFormTracking', { options: { fields: { whitelist: ['lname'] } } });
91+
snowplow('enableFormTracking', { options: { fields: { allowlist: ['lname'] } } });
9292
break;
9393
case 'filter':
9494
snowplow('enableFormTracking', {
9595
options: {
96-
forms: { whitelist: ['formy-mcformface'] },
96+
forms: { allowlist: ['formy-mcformface'] },
9797
fields: { filter: formFilter },
9898
},
9999
});
100100
break;
101101
case 'excludedForm':
102-
snowplow('enableFormTracking', { options: { forms: { blacklist: ['excluded-form'] } } });
102+
snowplow('enableFormTracking', { options: { forms: { denylist: ['excluded-form'] } } });
103103
break;
104104
default:
105105
snowplow('enableFormTracking', {

trackers/javascript-tracker/test/pages/link-tracking.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@
6161
switch (parseQuery().filter) {
6262
case 'exclude':
6363
snowplow('enableLinkClickTracking', {
64-
options: { blacklist: ['exclude'] },
64+
options: { denylist: ['exclude'] },
6565
pseudoClicks: true,
6666
trackContent: true,
6767
});
6868
break;
6969
case 'include':
7070
snowplow('enableLinkClickTracking', {
71-
options: { whitelist: ['example'] },
71+
options: { allowlist: ['example'] },
7272
pseudoClicks: true,
7373
trackContent: true,
7474
});

0 commit comments

Comments
 (0)