# Privacy helpers

Mask sensitive elements, leave them out of session replays, and give elements a stable ID that targeting can rely on.

Privacy helpers control how an element of your interface appears in [session replays](https://developers.screeb.app/sdk-browser/session-replay). Use them on content the workspace settings do not hide already: a card number in a custom field, a block with personal details, an account balance.

The privacy level an admin sets for the workspace decides what replays hide automatically, see [Protect privacy in session replays](https://help.screeb.app/observe/session-replay-privacy/). The helpers hide more, whatever that level.

There are three helpers:

- **Mask text**: the element stays in the replay, its text is hidden.
- **No capture**: the element and its children are left out of the replay.
- **Stable ID**: the element gets an ID that survives redesigns, so the element targeting of in-app messages and product tours keeps finding it. Use a snake_case name that says what the element is, not where it sits (`checkout_button`), and keep it the same across releases.

```html
<input class="screeb-mask-text" name="card_number" />
<section class="screeb-no-capture">
  <p>12 rue de la Paix, 75002 Paris</p>
</section>
<button data-screeb-id="checkout_button">Checkout</button>
```

## Mark elements from code

When you do not write the markup yourself (a component library, elements created at runtime), call the helpers on the element instead. They add the same class or attribute and return the element.

```ts
import { ScreebId, ScreebMaskText, ScreebNoCapture } from "@screeb/sdk-browser";

const cardNumber = document.querySelector("#card-number");
const personalInfo = document.querySelector("#personal-info");
const checkoutButton = document.querySelector("#checkout-button");

if (cardNumber) ScreebMaskText(cardNumber);
if (personalInfo) ScreebNoCapture(personalInfo);
if (checkoutButton) ScreebId(checkoutButton, "checkout_button");
```

`ScreebNoCapture(element)` and `ScreebId(element, "checkout_button")` work the same way.
