Skip to content

Commit 2dbc7fe

Browse files
bkboothclaude
andcommitted
chore(pixel): tighten scroll_depth README, drop unnecessary cast
- Trim scroll_depth README cell; iframe limitation belongs in docs.immutable.com (separate PR) and isn't scroll-specific anyway - Drop unnecessary (el as HTMLElement) cast — Element.scrollTop is in the DOM spec - Tighten setupAutocapture docstring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1d0e63f commit 2dbc7fe

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

packages/audience/pixel/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ All events fire automatically with no instrumentation required.
8585
| `session_end` | Page unload (`visibilitychange` / `pagehide`) | `sessionId`, `duration` (seconds) |
8686
| `form_submitted` | HTML form submission | `formAction`, `formId`, `formName`, `fieldNames`. `emailHash` at `full` consent only. |
8787
| `link_clicked` | Outbound link click (external domains only) | `linkUrl`, `linkText`, `elementId`, `outbound: true` |
88-
| `scroll_depth` | Scroll milestone reached (25%, 50%, 75%, 90%, 100%) | `depth` (integer). Fires on both standard document scroll and SPA internal scroll containers (e.g. `overflow: auto` divs) larger than 50% of the viewport. Milestones reset on each `page` call so SPA route changes start fresh. No event fires on pages with no scrollable area at all. **iframe limitation:** a cross-origin iframe cannot be observed from the parent page — install the pixel inside the iframe itself for those integrations. |
88+
| `scroll_depth` | Scroll milestone reached (25%, 50%, 75%, 90%, 100%) | `depth` (integer). Fires on standard document scroll or on any internal scroll container larger than half the viewport. Milestones reset on each `page` call. |
8989

9090
### Disabling specific auto-capture
9191

packages/audience/pixel/src/autocapture.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function setupScrollTracking(
117117
if (!el) return;
118118
const scrollPos = el === document.documentElement
119119
? window.scrollY
120-
: (el as HTMLElement).scrollTop;
120+
: el.scrollTop;
121121
checkAndFire(el, scrollPos);
122122
});
123123
};
@@ -140,10 +140,8 @@ function setupScrollTracking(
140140

141141
/**
142142
* Attach document-level listeners for form submissions, outbound link clicks,
143-
* and scroll depth milestones.
144-
* Returns `{ teardown, resetScroll }` — call `teardown()` to remove all
145-
* listeners, and `resetScroll()` to clear fired milestones (e.g. on SPA
146-
* route changes).
143+
* and scroll depth milestones. `resetScroll()` clears fired scroll milestones
144+
* (call from `Pixel.page()` on SPA route changes).
147145
*
148146
* - Single document-level listener per event type (event delegation).
149147
* - Consent is checked at fire time, not at attach time.

0 commit comments

Comments
 (0)