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

fix(analytics-types): update element interactions options #862

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion packages/analytics-types/src/element-interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@ export const DEFAULT_CSS_SELECTOR_ALLOWLIST = [
'select',
'textarea',
'label',
'video',
'audio',
'[contenteditable="true" i]',
'[data-amp-default-track]',
'.amp-default-track',
];

/**
* Default prefix to allo the plugin to capture data attributes as an event property.
* Default prefix to allow the plugin to capture data attributes as an event property.
*/
export const DEFAULT_DATA_ATTRIBUTE_PREFIX = 'data-amp-track-';

/**
* Default list of elements on the page should be tracked when the page changes.
*/
export const DEFAULT_ACTION_CLICK_ALLOWLIST = ['div', 'span', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];

export interface ElementInteractionsOptions {
/**
* List of CSS selectors to allow auto tracking on.
Expand Down Expand Up @@ -65,13 +73,26 @@ export interface ElementInteractionsOptions {
enabled?: boolean;
messenger?: Messenger;
};

/**
* Debounce time in milliseconds for tracking events.
* This is used to detect rage clicks.
*/
debounceTime?: number;

/**
* CSS selector allowlist for tracking clicks that result in a DOM change/navigation on elements not already allowed by the cssSelectorAllowlist
*/
actionClickAllowlist?: string[];
}

export interface Messenger {
logger?: Logger;
setup: () => void;
}

// The [Element](https://developer.mozilla.org/en-US/docs/Web/API/Element) type is used when the dom library is included in tsconfig.json
// This interface is for packages without the dom library, for example, analytics-node
interface Element {
id: string;
className: string;
Expand Down
1 change: 1 addition & 0 deletions packages/analytics-types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ export {
ActionType,
DEFAULT_CSS_SELECTOR_ALLOWLIST,
DEFAULT_DATA_ATTRIBUTE_PREFIX,
DEFAULT_ACTION_CLICK_ALLOWLIST,
} from './element-interactions';
Loading