forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcore.ts
More file actions
19 lines (17 loc) · 762 Bytes
/
Copy pathcore.ts
File metadata and controls
19 lines (17 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { PayloadBuilder, buildSelfDescribingEvent, removeEmptyProperties } from '@snowplow/tracker-core';
import { ButtonClickEvent } from './types';
/**
* Build a Button Click Event
* Used when a user clicks on a <button> tag on a webpage
*
* @param event - Contains the properties for the Button Click event
* @returns PayloadBuilder to be sent to {@link @snowplow/tracker-core#TrackerCore.track}
*/
export function buildButtonClick(event: ButtonClickEvent): PayloadBuilder {
const { label, id, classes, name } = event;
const eventJson = {
schema: 'iglu:com.snowplowanalytics.snowplow/button_click/jsonschema/1-0-0',
data: removeEmptyProperties({ label, id, classes, name }),
};
return buildSelfDescribingEvent({ event: eventJson });
}