Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security solution] Remove extra data from tracking clicks #164378

Merged
merged 9 commits into from
Sep 14, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,17 @@
import { fromEvent } from 'rxjs';
import type { AnalyticsClient } from '@kbn/analytics-client';

/** HTML attributes that should be skipped from reporting because they might contain user data */
const POTENTIAL_PII_HTML_ATTRIBUTES = ['value'];
/** HTML attributes that should be skipped from reporting because they might contain data we do not wish to collect */
const HTML_ATTRIBUTES_TO_REMOVE = [
'data-href',
'data-ech-series-name',
'data-provider-id',
'data-rfd-drag-handle-draggable-id',
'data-rfd-droppable-id',
'data-rfd-draggable-id',
'href',
'value',
];

/**
* Registers the event type "click" in the analytics client.
Expand Down Expand Up @@ -71,7 +80,7 @@ function getTargetDefinition(target: HTMLElement): string[] {
...(target.parentElement ? getTargetDefinition(target.parentElement) : []),
target.tagName,
...[...target.attributes]
.filter((attr) => !POTENTIAL_PII_HTML_ATTRIBUTES.includes(attr.name))
.filter((attr) => !HTML_ATTRIBUTES_TO_REMOVE.includes(attr.name))
.map((attr) => `${attr.name}=${attr.value}`),
];
}
Loading