BDMS-857: PostHog analytics additions — search recording, copy/paste tracking, accessibility props#291
Open
jeremyzilar wants to merge 1 commit into
Open
BDMS-857: PostHog analytics additions — search recording, copy/paste tracking, accessibility props#291jeremyzilar wants to merge 1 commit into
jeremyzilar wants to merge 1 commit into
Conversation
…y props to PostHog 1. Search recording: replace data-posthog-unmask-search attribute with ph-no-mask CSS class on the search input in SearchModal. Update maskInputFn in posthog.ts to check for ph-no-mask so the custom masking function respects the standard class. 2. Copy/paste tracking: new useCopyPasteTracking hook attaches document-level listeners for copy, cut, and paste events. Fires text_copied (with path and selection_length) and text_pasted (with path). No actual text is captured. Wired up via a new renderless CopyPasteTracking component mounted in AppProviders. 3. Accessibility preferences: new getAccessibilityProps() in posthog.ts reads browser_font_size_px, font_size_increased, device_pixel_ratio, prefers_reduced_motion, and prefers_high_contrast once per session. PostHogIdentify now calls setPersonProperties(getAccessibilityProps()) after the user is identified so the values are attached to the person record.
Preview DeploymentPreview URL: https://preview-bdms-857-posthog-additions-auejgdbofq-uc.a.run.app Note: This preview uses the staging API endpoints. |
chasetmartin
approved these changes
Jun 12, 2026
chasetmartin
left a comment
Collaborator
There was a problem hiding this comment.
This looks good @jeremyzilar, just one comment. My only broad question is: why collect copy paste events? Have you found that helpful in other applications for signs that a user is making their own shortcuts?
| } | ||
|
|
||
| const handleCut = () => { | ||
| captureEvent('text_copied', { |
Collaborator
There was a problem hiding this comment.
do you want this to be text_cut so that it can be registered as it's own event outside of a copy?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Three small instrumentation additions to improve what we can see in PostHog session recordings and the person/event data.
What changed
1. Search text in session recordings
SearchModal.tsxnow addsclassName: 'ph-no-mask'to the search input instead of the previousdata-posthog-unmask-searchattribute.ph-no-maskis PostHog's standard class for opting inputs out of masking.The custom
maskInputFninposthog.tswas updated to check forph-no-mask(class on element or ancestor) so it respects the standard approach.2. Copy/paste tracking
New
src/hooks/useCopyPasteTracking.tsattaches document-levelcopy,cut, andpastelisteners. Fires two events:text_copied— properties:path,selection_lengthtext_pasted— properties:pathNo actual copied or pasted text is captured.
Wired up via a new renderless
src/components/analytics/CopyPasteTracking.tsxcomponent mounted inAppProviders.tsx.3. Browser accessibility preferences
New
getAccessibilityProps()inposthog.tsreads five values from the browser once per session:browser_font_size_pxfont_size_increased(true if root font size > 16px)device_pixel_ratioprefers_reduced_motionprefers_high_contrastPostHogIdentify.tsxnow callssetPersonProperties(getAccessibilityProps())immediately after the user is identified so the values are stored on the PostHog person record.Notes