LANDSCAPE

Autocapture

Control which DOM events Landscape records after init.

Start capture

import { init } from "@hyperreal/landscape-core";

init({ endpoint: "/api/events" });

Autocapture registers DOM listeners in the browser when init() runs. Categories live in AUTOCAPTURE_COLLECTORS (packages/core/src/autocapture/index.ts). Omitted keys default to enabled.

Categories

Category Event Trigger Properties Default
clicks $click capture-phase click tag, id, classList, data, href, x, y; text when captureElementText is true on
forms $form_submit submit formId, formName, action, fieldNames on
outboundLinks $outbound_link click on a cross-origin <a> click properties plus host on
downloads $file_download click on a download link click properties plus filename, extension on
scroll $scroll_depth throttled scroll percent: 25, 50, 75, or 100 on
rageClicks $rage_click 3 or more clicks in 1000 ms within 32px click properties plus count on
pageViews $pageview init in the browser, page(), or a router tracker url, path, title on

Toggle categories

init({
  endpoint: "/api/events",
  autocapture: true,
  captureElementText: false,
  downloadExtensions: ["pdf", "zip", "doc", "docx", "xls", "xlsx", "csv", "dmg", "exe", "pkg"],
  debug: false,
});
Option Default Effect
autocapture: true yes all categories on
autocapture: false all categories off
autocapture: { forms: false, rageClicks: false } listed categories off; others on
captureElementText false set true to include trimmed text (max 128 characters) on $click / $rage_click
downloadExtensions pdf, zip, doc, docx, xls, xlsx, csv, dmg, exe, pkg extensions treated as $file_download; the download attribute also counts
debug false set true to console.debug each autocapture event

Limitations

  • Click attribution walks up to a, button, input, select, textarea, label, summary, or an element with id or data-*. Otherwise the event target is used. data is the element’s dataset object.
  • Form values are never captured. Only field names.
  • Scroll thresholds fire once per page. page() resets them.
  • redactPath also applies to click href pathnames, not only $path. Default is no redaction. See init.
  • SPA navigations do not emit $pageview unless you call page() or mount a router tracker.

Custom events: track.