forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
49 lines (43 loc) · 1.86 KB
/
Copy pathtypes.ts
File metadata and controls
49 lines (43 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { DynamicContext } from '@snowplow/tracker-core';
/** A list of CSS classes that will have their clicks tracked */
export type AllowList = { allowlist: string[] };
/** A list of CSS classes that will _not_ have their clicks tracked */
export type DenyList = { denylist: string[] };
/** A function which determines whether a button click should be tracked */
export type FilterFunction = (element: HTMLElement) => boolean;
/** A filter for button click tracking */
export type Filter = AllowList | DenyList | FilterFunction;
/** The configuration for automatic button click tracking */
export interface ButtonClickTrackingConfiguration {
/** The filter options for the button click tracking */
filter?: Filter;
/** The dynamic context which will be evaluated for each button click event */
context?: DynamicContext;
/** A default label to use if one can not be determined by the content or data attributes */
defaultLabel?: string | ((element: HTMLElement) => string);
}
/**
* A Button Click event
*
* Used when a user clicks on a <button> tag on a webpage
* <input type="submit"> tags are intentionally not tracked by this event,
* as this functionality is provided by the Form Tracking plugin
* see: https://docs.snowplow.io/docs/collecting-data/collecting-from-own-applications/javascript-trackers/web-tracker/plugins/form-tracking/
*/
export interface ButtonClickEvent {
/** The text on the button clicked
*
* This can be overridden by setting the `data-sp-button-label` attribute on the button:
*
* `<button data-sp-button-label="show-modal">Click Here!</button>`
*
* will result in `{ label: 'show-modal' }`
*/
label: string;
/** The ID of the button clicked, if present */
id?: string;
/** An array of class names from the button clicked */
classes?: Array<string>;
/** The name of the button, if present */
name?: string;
}