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: dead click fixes from watching in prod #1508

Merged
merged 2 commits into from
Nov 1, 2024
Merged

Conversation

pauldambra
Copy link
Member

turned on dead clicks in prod
watched what we captured realised some things could be improved

Copy link

vercel bot commented Oct 31, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Nov 1, 2024 9:00am

@pauldambra pauldambra requested a review from a team October 31, 2024 21:13
const absoluteTimeout = checkTimeout(click.absoluteDelayMs, this._config.mutation_threshold_ms)
// we want to timeout eventually even if nothing else catches it...
// we leave a little longer than the maximum threshold to give the other checks a chance to catch it
const absoluteTimeout = checkTimeout(click.absoluteDelayMs, this._config.mutation_threshold_ms * 1.1)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we saw absolute timeouts, without seeing mutation timeouts, that also seems wrong so...

$dead_click_selection_changed_delay_ms: click.selectionChangedDelayMs,
},
{
timestamp: new Date(click.timestamp),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

turns out this is how you set the timestamp on an event

Comment on lines +24 to +63
/*
* Check whether an element has nodeType Node.ELEMENT_NODE
* @param {Element} el - element to check
* @returns {boolean} whether el is of the correct nodeType
*/
export function isElementNode(el: Node | Element | undefined | null): el is Element {
return !!el && el.nodeType === 1 // Node.ELEMENT_NODE - use integer constant for browser portability
}

/*
* Check whether an element is of a given tag type.
* Due to potential reference discrepancies (such as the webcomponents.js polyfill),
* we want to match tagNames instead of specific references because something like
* element === document.body won't always work because element might not be a native
* element.
* @param {Element} el - element to check
* @param {string} tag - tag name (e.g., "div")
* @returns {boolean} whether el is of the given tag type
*/
export function isTag(el: Element | undefined | null, tag: string): el is HTMLElement {
return !!el && !!el.tagName && el.tagName.toLowerCase() === tag.toLowerCase()
}

/*
* Check whether an element has nodeType Node.TEXT_NODE
* @param {Element} el - element to check
* @returns {boolean} whether el is of the correct nodeType
*/
export function isTextNode(el: Element | undefined | null): el is HTMLElement {
return !!el && el.nodeType === 3 // Node.TEXT_NODE - use integer constant for browser portability
}

/*
* Check whether an element has nodeType Node.DOCUMENT_FRAGMENT_NODE
* @param {Element} el - element to check
* @returns {boolean} whether el is of the correct nodeType
*/
export function isDocumentFragment(el: Element | ParentNode | undefined | null): el is DocumentFragment {
return !!el && el.nodeType === 11 // Node.DOCUMENT_FRAGMENT_NODE - use integer constant for browser portability
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved these from auto capture code since we now have an element utils for them to live in

@pauldambra pauldambra added the bump patch Bump patch version when this PR gets merged label Oct 31, 2024
Copy link

github-actions bot commented Oct 31, 2024

Size Change: +90 B (0%)

Total Size: 3.01 MB

Filename Size Change
dist/all-external-dependencies.js 193 kB +10 B (+0.01%)
dist/array.full.js 342 kB +16 B (0%)
dist/array.full.no-external.js 341 kB +16 B (0%)
dist/dead-clicks-autocapture.js 12.8 kB +16 B (+0.13%)
dist/module.full.js 342 kB +16 B (0%)
dist/module.full.no-external.js 341 kB +16 B (0%)
ℹ️ View Unchanged
Filename Size
dist/array.full.es5.js 251 kB
dist/array.js 168 kB
dist/array.no-external.js 167 kB
dist/exception-autocapture.js 8.77 kB
dist/external-scripts-loader.js 2.19 kB
dist/main.js 169 kB
dist/module.js 168 kB
dist/module.no-external.js 167 kB
dist/recorder-v2.js 102 kB
dist/recorder.js 103 kB
dist/surveys-preview.js 56.7 kB
dist/surveys.js 62.1 kB
dist/tracing-headers.js 1.33 kB
dist/web-vitals.js 10.3 kB

compressed-size-action

@pauldambra pauldambra merged commit 4439511 into main Nov 1, 2024
13 checks passed
@pauldambra pauldambra deleted the fix/deadclick-fangling branch November 1, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants