Skip to content

Commit

Permalink
fix(analytics-types): update element interactions options (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercy811 authored Sep 10, 2024
1 parent b27c506 commit fbce96b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
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';

0 comments on commit fbce96b

Please sign in to comment.