skip to content

build a detection system · lesson 2 of 9 · sources checked 2026-11-22

the collection script: signals, build, delivery, and legal inputs

This lesson specifies a collection script with error markers, a payload budget, a remote configuration, and a record of the data-protection decisions.

status of this lesson: from a public source

this page is not legal advice.

purpose

A detection system reads many of its signals from a script in the page of the user. That script costs the user time and bytes, and it can fail in the browser. A precise specification gives the server the contents of each payload, and a record of the legal decisions comes before the first collection.

objectives

  1. Write a signal list in which each signal has an error marker.
  2. Set a time budget and a payload budget for the collector, and check a payload against them.
  3. Explain what a check in a Web Worker adds to the same check on the main thread.
  4. Give a remote configuration a version, and put that version in each payload.
  5. List the decisions of a data-protection record.

new terms

error marker
A value that a collector records when one signal fails, and that is itself a signal.

how it works

The collector is a script that the site puts in its pages. It reads values in the browser, puts them in one payload, and sends the payload to the detection server. The server checks the payload and gives the results to the decision chain.

each signal has an error marker

The collector reads a list of signals. Each signal can fail: an interface is missing, a check throws an error, or the time ends. An error marker is the value that the collector records in place of the signal.

For example, a drawing check throws "not available". The payload then holds "draw-check": "error: not available", not an empty field. The marker is itself a signal. A real browser and a changed browser can fail at different checks.

Thus the server treats a failed signal as data, not as noise. A missing payload is also data. A page view with no payload can mean a blocked script.

build and delivery

A build step minifies the script and can obfuscate it. Obfuscation makes the code harder to read. It cannot hide which values the script reads, because the browser must run the code.

Thus treat obfuscation as a delay for a reader of the code. Keep the decision on the server. The score and the combine rule never go into the script.

Give each build a version, for example c-1.4.0. The payload carries the version, so that the server knows which signals the payload can hold.

two budgets

The collector runs in the page of a real user. Thus it has a time budget and a payload budget.

  • Time budget: the collector stops a check that does not fit in the time that is left. The check gets the marker "time budget".
  • Payload budget: the server refuses a payload over a size limit, for example 400 bytes in the code example.

Order the signal list by value. The most useful signals then come first, and a slow check comes last.

the worker repeat

A worker repeat runs some checks again in a Web Worker. A worker has its own scope, and a page script that changes a value on the main thread does not change it there.

For example, the main thread gives the language list "en", and the worker gives "en,de". The two values do not agree. The collector records the name of the check in a list of differences. The difference is a signal of a change in the page scope.

remote configuration

remote configuration is the settings for each site that the server sends to one shared collector. It gives the signal list, the time budget, and the payload budget. It has a version, for example site-7.v12.

The payload carries the version of the remote configuration and of the build. Thus a rule can know which signals a payload can contain. A signal that the remote configuration did not ask for is not a missing signal.

the cost of collection in a public study

The chart in the section "Data" gives the cost of a collection script in a large study of browser fingerprints of 2016 and 2017. The values are statements of the paper. Collection took seconds, not milliseconds, and mobile browsers took longer than desktop browsers. Browsers and networks of today can differ.

the data-protection record

The collector reads values from the device of the user. Thus the site writes a data-protection record before the first collection. The record keeps these decisions:

  • The purpose of the collection.
  • The legal basis, as the legal team of the site decides it.
  • The consent decision for each signal, and the rule that the team applies.
  • The signal list, with the version of the remote configuration.
  • The retention period of the payloads and of the scores.
  • The deletion rule, and a check that the deletion happens.

A signal that the record does not accept goes out of the signal list. The remote configuration and the record then change together.

the two sides

automation sidedetection side
A client that blocks or changes the collector leaves a signal. Examples are a missing payload, an error marker, and a worker value that differs from the main thread. Obfuscation slows a reader of the script, but the signal list stays readable in the browser.Treat a failed signal as data, not as noise. Give the build and the remote configuration a version, so that a rule knows which signals a payload can contain. Write the data-protection record before the first collection.

design decisions

optiongaincostwhen it is correct
An error marker for each signalA failure becomes dataA larger payloadAlways
Obfuscate the buildA reader of the code must spend more timeA larger script, and harder debuggingAs a delay only, with the decision on the server
A worker repeatFinds a change of the page scopeMore time and more codeFor the few checks that a page script can change
One collector with a remote configurationOne build for all sitesThe server must know the version of each payloadWhen many sites share one collector
A small payload budgetLess time and fewer bytes for the userFewer signalsOn mobile pages and slow networks

diagram

The first diagram shows the life of a collector.

the life of a collector: build, delivery, collection, and the remote configuration loop

The server sends the remote configuration, and each payload carries the versions of the build and of the remote configuration.source: My model of the life of a collector

The second diagram shows the data-protection record.

the data-protection record: the decisions that come before the first collection

The consent decision for each signal can remove a signal from the list before the first collection.source: My model of a data-protection record for a collector

code example

The example wraps synthetic signal readers. No reader touches a real browser, and each value is synthetic.

m37-x03-collector.tstypescript

Read synthetic signals with an error marker for each failure, a time budget, and a worker repeat, and check the payload size against its budget.

// A collector wrapper on synthetic signal readers. No reader touches a real browser.
type Reader = { name: string; costMs: number; read: () => string | number; workerValue?: string | number };
type Settings = { version: string; signals: string[]; timeBudgetMs: number; payloadBudgetBytes: number };

const COLLECTOR_VERSION = "c-1.4.0";

// Synthetic readers: each one has a fixed cost and a fixed value.
const readers: Reader[] = [
  { name: "width", costMs: 2, read: () => 1280 },
  { name: "zone", costMs: 1, read: () => "Example/Zone" },
  { name: "draw-check", costMs: 5, read: () => { throw new Error("not available"); } },
  { name: "threads", costMs: 1, read: () => 8, workerValue: 8 },
  { name: "languages", costMs: 1, read: () => "en", workerValue: "en,de" },
  { name: "slow-check", costMs: 40, read: () => "done" },
];

// The remote settings for one site, with a version.
const settings: Settings = {
  version: "site-7.v12",
  signals: ["width", "zone", "draw-check", "threads", "languages", "slow-check"],
  timeBudgetMs: 30,
  payloadBudgetBytes: 400,
};

const values: Record<string, string | number> = {};
const errors: Record<string, string> = {};
const workerDiff: string[] = [];
let spentMs = 0;

for (const name of settings.signals) {
  const r = readers.find((x) => x.name === name);
  if (!r) { errors[name] = "unknown signal"; continue; }
  // The time budget: a reader that does not fit gets an error marker.
  if (spentMs + r.costMs > settings.timeBudgetMs) { errors[name] = "time budget"; continue; }
  spentMs += r.costMs;
  try {
    values[name] = r.read();
  } catch (e) {
    errors[name] = `error: ${(e as Error).message}`; // the failure is itself a signal
    continue;
  }
  // The worker repeat: compare the main-thread value with the worker value.
  if (r.workerValue !== undefined && r.workerValue !== values[name]) workerDiff.push(name);
}

const payload = {
  collector: COLLECTOR_VERSION,
  settings: settings.version,
  values,
  errors,
  workerDiff,
};
const text = JSON.stringify(payload);
const bytes = Buffer.byteLength(text, "utf8");

console.log(text);
console.log(`time used: ${spentMs} ms of ${settings.timeBudgetMs} ms`);
console.log(`payload: ${bytes} bytes of ${settings.payloadBudgetBytes} bytes, ${bytes <= settings.payloadBudgetBytes ? "inside" : "over"} the budget`);

output

The payload as JSON, the time that the readers used, and the payload size against its budget.

{"collector":"c-1.4.0","settings":"site-7.v12","values":{"width":1280,"zone":"Example/Zone","threads":8,"languages":"en"},"errors":{"draw-check":"error: not available","slow-check":"time budget"},"workerDiff":["languages"]}
time used: 10 ms of 30 ms
payload: 223 bytes of 400 bytes, inside the budget

The output shows two error markers: one for the check that failed and one for the check over the time budget. The language list is in the list of worker differences, and the payload of 223 bytes is inside its budget.

data

the cost of a collection script in one large public study

status of this figure: from a public source

the cost of a collection script in one large public studycollection timemedian, all browsers2.9median, desktop2.6median, mobile4.495th percentile, allbrowsers10.42unit: spayload, meanmean size of one fingerprint7692unit: bytespayload, 99% undersize that 99% offingerprints stay under14unit: KB

source: Peer-reviewed paper, 2020: a large study of browser fingerprints (public source, https://ar5iv.labs.arxiv.org/html/2005.09353, read 2026-11-13); period 2016-12-01 to 2017-06-30; sample of 4,145,408; condition: n is the count of collected fingerprints. The desktop and mobile medians use only a part of them.

data table
the cost of a collection script in one large public study
seriesmeasurevalueunit
collection timemedian, all browsers2.9s
collection timemedian, desktop2.6s
collection timemedian, mobile4.4s
collection time95th percentile, all browsers10.42s
payload, meanmean size of one fingerprint7692bytes
payload, 99% undersize that 99% of fingerprints stay under14KB
Collection time in seconds, and the size of one collected fingerprint. The data are from a study of one site, December 2016 to June 2017. Browsers and networks of today can differ.

The chart shows the time and the bytes that one collection cost the users of one site. The time panel gives medians and a 95th percentile, and the payload panels give a mean and an upper limit.

failure modes

problemcausecorrection
A failed check looks like a real browser.The collector leaves the field empty.Record an error marker for each failure.
A rule flags payloads with no value for a new signal.The rule does not know the version of the remote configuration.Put the versions of the build and of the remote configuration in each payload.
Pages are slow on mobile networks.The collector has no time budget, and a slow check comes first.Set a time budget, and order the signals by value.
A reader of the script finds the signal list.The team expected obfuscation to hide it.Treat obfuscation as a delay, and keep the decision on the server.
The site collects a signal that its record does not accept.The remote configuration changed, but the record did not.Change the remote configuration and the record together.

check questions

  1. A drawing check of the collector throws an error. What does the payload hold for that check?

    1. An error marker, for example "error: not available"
    2. An empty field
    3. Nothing, because the collector removes the check from the payload
    answer

    a. An error marker, for example "error: not available"

    Each signal has an error marker. The marker is itself a signal, because a real browser and a changed browser can fail at different checks.

  2. The time budget is 30 ms. The readers used 28 ms, and the next check costs 5 ms. What does the collector do?

    1. It runs the check, because the payload budget is not full.
    2. It runs the check and removes an earlier value.
    3. It records the marker "time budget" for that check, and does not run it.
    answer

    c. It records the marker "time budget" for that check, and does not run it.

    28 ms plus 5 ms is 33 ms, which is more than 30 ms. A check that does not fit in the time that is left gets the marker "time budget".

  3. Explain what a worker repeat adds to the same check on the main thread.

    sample answer

    A Web Worker has its own scope. A page script that changes a value on the main thread does not change it in the worker. When the two values do not agree, the collector records the name of the check in a list of differences. The difference is a signal of a change in the page scope.

  4. Why does each payload carry the version of the build and the version of the remote configuration?

    1. So that the payload is smaller
    2. So that a rule knows which signals the payload can contain
    3. So that the browser can cache the script
    answer

    b. So that a rule knows which signals the payload can contain

    A signal that the remote configuration did not ask for is not a missing signal. The versions give the rule the list of signals to expect.

  5. List the decisions that a data-protection record of a collector keeps.

    sample answer

    The purpose of the collection and the legal basis, as the legal team of the site decides it. The consent decision for each signal. The signal list with the version of the remote configuration. The retention period of the payloads and the scores. The deletion rule with its check.

exercise

exercise Do this task on paper. Your collector has a time budget of 20 ms and a payload budget of 300 bytes. The remote configuration asks for these synthetic signals, in this order:

  • width: cost 2 ms, reads 1280.
  • draw-check: cost 6 ms, throws "not available".
  • languages: cost 1 ms, reads "en" on the main thread and "en" in the worker.
  • slow-check: cost 15 ms, reads "done".
  1. Add the costs in order, and find the first signal that does not fit in the time budget.
  2. Write the value or the error marker of each signal.
  3. Write the list of worker differences.
  4. Write two fields that the payload must carry beside the values.
sample answer

The answer uses the synthetic signals of the task.

The costs are 2, then 8, then 9 ms. slow-check costs 15 ms more, and 24 ms is more than 20 ms. Thus it does not fit, and it gets the marker "time budget".

width has the value 1280, draw-check has the marker "error: not available", and languages has "en". The list of worker differences is empty, because the two values agree. The payload must also carry the version of the build and the version of the remote configuration.

sources

  1. My model of the collector specification, the worker repeat, the remote configuration, and the data-protection record, 2026-11 (not public).