Skip to content

Commit

Permalink
Merge pull request #171 from keen/dlacheta-position-pointer
Browse files Browse the repository at this point in the history
auto-tracking tracking position pointer
  • Loading branch information
dariuszlacheta authored Apr 3, 2019
2 parents c921f06 + 95e9535 commit 5ac39e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/auto-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ client.initAutoTracking({
recordScrollState: true, // see how far people scrolled

recordClicks: true, // record clicks on A links

recordClicksPositionPointer: false, // record pointer position for clicks

// FORMS
recordFormSubmits: true,
ignoreDisabledFormFields: false,
Expand Down
14 changes: 12 additions & 2 deletions lib/browser-auto-tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function initAutoTrackingCore(lib) {
ignoreDisabledFormFields: false,
ignoreFormFieldTypes: ['password'],
recordClicks: true,
recordClicksPositionPointer: false,
recordFormSubmits: true,
recordPageViews: true,
recordPageViewsOnExit: false,
Expand Down Expand Up @@ -196,11 +197,20 @@ export function initAutoTrackingCore(lib) {
if (options.recordClicks === true) {
utils.listener('a, a *').on('click', function(e) {
const el = e.target;
const event = {
let event = {
element: helpers.getDomNodeProfile(el),
local_time_full: new Date().toISOString()
local_time_full: new Date().toISOString(),
};

// pointer position tracking
if(options.recordClicksPositionPointer === true) {
const pointer = {
x_position: e.pageX,
y_position: e.pageY,
}
event = {...event, pointer};
}

if (options.catchError) {
return client
.recordEvent({
Expand Down

0 comments on commit 5ac39e4

Please sign in to comment.