# Masking

> What Sypnia hides in recordings and events without being asked, what you can hide yourself, exactly what masking does to the page, and how to check it.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service). Status: at launch.  
Source: https://docs.sypnia.com/privacy/masking/

This page is for whoever decides what a replay may show. Masking is done by the browser SDK, so it works the same for the open-source engine and Sypnia Cloud. This page gives the rules; the options and their exact names in code are in [Privacy and masking](https://docs.sypnia.com/sdks/privacy-and-masking).

**Masking happens in the person's browser, before anything is sent.** Masked content never reaches Sypnia, so it cannot be shown, leaked or sent to a model later.

## The default for a new project

| Content                                                                                                     | Default                                                  | Can you change it?                           |
| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------- |
| What a person types, in any field. This includes the choice in a dropdown and the text of an editable area. | **Masked, always**                                       | No. There is no option to record typed text. |
| The content of password, card and one-time-code fields                                                      | **Masked, always**                                       | No.                                          |
| Hidden fields                                                                                               | Their value is removed                                   | No.                                          |
| Text shown on the page                                                                                      | Recorded as shown                                        | Yes: mask an element, or all text.           |
| Frames and videos                                                                                           | Left out                                                 | No.                                          |
| Canvas drawings                                                                                             | Not recorded                                             | No.                                          |
| Images                                                                                                      | Not copied; the player loads them from their own address | Leave one out with a block.                  |

The default is built so that a project nobody configured does not record secrets. It still records the text your pages display. If your pages display things that must not be seen, use the options below.

## What you can add

### Mask an element: `data-sypnia-mask`

Put the attribute on any element. Everything inside it is masked: text, field values, and what appears there later.

`checkout.html`

```html
<section data-sypnia-mask>
  <h2>Shipping address</h2>
  <p>Ada Park, 12 Elm Street, Springfield</p>
</section>
```

In the replay the section keeps its shape, and the address reads `*** ****, ** *** ******, ***********`.

### Leave an element out: `data-sypnia-block`

Put the attribute on any element. It is not recorded at all. The replay shows an empty box of the same size, so the layout stays right.

`account.html`

```html
<div data-sypnia-block>
  <img src="/documents/id-card.jpg" alt="Identity card" />
</div>
```

Use a block for images and for anything whose shape alone says too much.

For elements you cannot put an attribute on, such as a widget from another company, the SDK takes a list of selectors to mask and a list to block.

### Mask all text: `maskAllText`

One option of the SDK masks every text of every page. Replays then show the layout, the clicks and the movement, with every word replaced. Events change too: clicks carry no label, and form failures no field name. Choose it for an app that is sensitive throughout, such as health, finance or anything about children.

A project can also turn this on in its settings, for every browser at once and without shipping the app again. Either one is enough: all text is masked when the option or the setting says so.

### Switch recording off on a path

A project can list paths where nothing is recorded: no replay and no page snapshot. Recording stops when the person enters such a path and resumes when they leave. Events are still sent from those pages, so problems are still found there. The list is part of the project's settings, so you can change it without shipping your app again, and the engine refuses recordings of the paths in it, so a tab that is still running old code cannot send them.

## Exactly what masking does

Inside a masked element, and everywhere when all text is masked:

| What                                                                          | Becomes                                                                          |
| ----------------------------------------------------------------------------- | -------------------------------------------------------------------------------- |
| Letters and digits in text                                                    | An asterisk each. Spaces and punctuation stay, so the shape of the text is kept. |
| Values of fields                                                              | An asterisk for each character.                                                  |
| Checkboxes, radio buttons, selected options                                   | Shown as not chosen.                                                             |
| Text in attributes: titles, alternative text, placeholders, accessible labels | Masked the same way.                                                             |
| Links to an e-mail address or a phone number                                  | Masked after `mailto:` or `tel:`.                                                |
| Content added later                                                           | Masked. A masked area stays masked when the page changes.                        |

And outside recordings:

- **Clicks.** An element inside a masked area is reported without a label. A click that lands on masked content has no label even when the button around it is outside the mask.
- **Page snapshots** follow the same rules as replays.
- **Addresses.** Sign-in parameters (`access_token`, `refresh_token`, `token`, `code`) are removed from links inside recordings, masked or not.

### Which fields count as password, card or one-time code

All typed input is masked, so this list changes nothing you can see. It matters because these fields are also protected against any future option: they can never be recorded.

- Fields of type `password`.
- Fields whose `autocomplete` is `cc-number`, `cc-csc`, `cc-exp`, `cc-exp-month`, `cc-exp-year`, `one-time-code`, `current-password` or `new-password`.
- Fields whose `name` or `id` contains `card`, `cvv`, `cvc`, `pin`, `otp` or `password`.

## What masking does not cover

Masking works on text and fields. Know its edges:

- **Text inside an image is not masked**, because the recording holds only the image's address. Block the image.
- **Error messages are sent as your code wrote them**, up to 500 characters, with one exception: e-mail addresses are replaced by `[email]`. If your code throws `Customer Ada Park not found`, that name is in the error. The same goes for the error message your API returns with a failed call, and for the properties of custom events. The SDK lets you change or drop any event before it is sent.
- **Paths are sent as they are.** `/customers/ada-park` keeps the name. Queries and hashes are never sent.
- **Ingest does not inspect recordings.** It stores what the SDK sends and trusts the SDK's masking. Each recording carries the version of the masking rules it was made with.

## Check your masking

**At the end you will have** seen with your own eyes what a replay of your sensitive pages shows.

### 1. Open the page in development

Run your app with the SDK sending to the `development` environment, and open a page that shows sensitive data.

**You should see:**The page looks normal. Masking does not change what your users see.

### 2. Make sure the session is recorded

Type something into a field and click around. Then cause an error, for example with the test button from [Your first problem](https://docs.sypnia.com/start/your-first-problem): a session with an error is always recorded.

**You should see:**Requests to your ingest address in the browser's Network tab.

### 3. Watch the replay

Leave the page idle for 2 minutes, then open the session in Sypnia and play it.

**You should see:**What you typed is asterisks. Every element you marked with `data-sypnia-mask` is asterisks. Every element you marked with `data-sypnia-block` is an empty box.

### 4. Fix what you see, and repeat

Anything readable that should not be: add `data-sypnia-mask` or `data-sypnia-block`, reload and record again. Recordings made before the change keep what they recorded; delete them if needed. See [Deleting data](https://docs.sypnia.com/privacy/deleting-data).

## Example: the shop's checkout

| Part of the checkout                              | In the replay                                                           | Why                                                                    |
| ------------------------------------------------- | ----------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| «Your order: Linen shirt, Shipping, Total $64.00» | Readable                                                                | Page text is recorded as shown, and the order is what you need to see. |
| The e-mail field                                  | Asterisks                                                               | Typed input is always masked.                                          |
| The card fields                                   | Asterisks, or an empty box if they live in the payment provider's frame | Card fields are always masked; frames are left out.                    |
| The shipping address, shown for confirmation      | Asterisks                                                               | The shop marked that section with `data-sypnia-mask`.                  |
| The **Pay** button and the five clicks on it      | Visible                                                                 | That is the problem Sypnia is there to show.                           |

## Reference

Option names, defaults and how to set them: [Privacy and masking](https://docs.sypnia.com/sdks/privacy-and-masking). What a replay records in general: [Sessions and replay](https://docs.sypnia.com/concepts/sessions-and-replay).
