@adaptif/capture
v0.1.0
Published
Record clicks and form activity on elements you mark, for Adaptif.
Maintainers
Readme
@adaptif/capture
Declared capture for Adaptif: only elements and forms you explicitly mark are recorded, identified by names you write. Field values and checked states stay on the page unless you allowlist them where you register capture and configure a scrubber.
npm install @adaptif/captureSee Add capture for the full guide.
import { useCaptureForm, useCaptureRef } from "@adaptif/capture/react";
const sendInviteRef = useCaptureRef<HTMLButtonElement>("send_invite");
const formRef = useCaptureForm("invite", {
ignoreFields: ["message"],
additionalProperties: {
allowList: { role: ["value"] },
enableSimplePIIScrubber: true,
},
});import { createAdaptifCaptureListeners } from "@adaptif/capture";
const capture = createAdaptifCaptureListeners({
forms: {
invite: {
additionalProperties: {
allowList: { role: ["value"] },
scrubber: (rawValue) => rawValue,
},
},
},
});
<AdaptifProvider capture={capture}>
<button data-adaptif-capture="send_invite">…</button>
<form data-adaptif-capture-form="invite">…</form>
</AdaptifProvider>;Vanilla: captureElement(element, name, sink) and captureForm(form, name, sink, options) return a stop function. createAdaptifCaptureListeners() returns a plugin; the provider attaches its listeners on start.
- Names must match
/^[a-z][a-z0-9_.-]{0,39}$/i; others are skipped with a development warning. Fields are identified by theirnameattribute (fieldsrenames,ignoreFieldsskips). - Validation messages are included only with
includeValidationMessages: true, scrubbed and truncated. additionalProperties.allowListopts a field intovalueorcheckedonfield_input. SetscrubberorenableSimplePIIScrubber: true; otherwise nothing extra is read. The simple scrubber is a backstop (emails, card numbers, long numbers, tokens), not a guarantee. At most 8 fields per form. Password, file, and hidden values are never read.- A field focused for at least 1 second records
field_dwellwith the duration only. - Safe to import on the server; everything is a no-op without a DOM.
