Data and consent rules
What guest data we collect, what we never collect, how consent is logged, and who owns the data.
Not legal advice
Law 2004-63 and the INPDP apply. We are not lawyers. A lawyer checks the consent wording and hosting before the first pilot.
Ownership
- The hotel owns the guest data. We only process it, and the contract says so.
- Data is stored in our database, per hotel, so our AI can learn from it later.
- We never sell or reuse a raw guest list.
- Anonymous combined stats are ours to use.
- The hotel can export and delete at any time, per guest and per hotel.
Data tiers
| Tier | Fields |
|---|---|
| Must have | Name, phone, language, consent |
| Optional | Birthday, email |
| Optional with consent | Origin (country, city), stay dates, length of stay, where they go next, survey answers |
| Never | Continuous phone location, passport or ID numbers, payment cards |
Every extra question lowers the number of guests who finish the form, and every field is something we must protect. Do not add a field the hotel would never use.
Consent
- Consent is logged per channel: email, WhatsApp, and later SMS.
- Each entry records the timestamp, the source, and the wording version.
- When signed-in staff make the change (adding a guest, a CSV import, a consent switch), the entry also keeps their user id (
consent_events.staff_user_id). It stays empty for the guest's own answers (QR, unsubscribe, STOP) and is cleared if the staff account is deleted. It is not part of the guest export. - The log is append only. A change of mind is a new entry, never an edit. See consent log is append only.
- WhatsApp and email have separate toggles on the capture page, both off by default, each with the exact logged wording under it.
- Every message carries an unsubscribe link or STOP. Messaging builds them with
packages/common/src/unsubscribe.ts:signUnsubscribeToken,unsubscribePageUrl,listUnsubscribeHeaders(RFC 8058 one tap, for email) andunsubscribeFooter(the line every message ends with). The link opens/u/<token>on the web app (en, fr, ar, the hotel's branding): one switch per channel and one tap to stop everything. Each change is a consent event with sourceunsubscribe_link. Email clients that show their own button POST to/unsubscribe/<token>on the api. - An inbound WhatsApp message is checked with
isStopKeyword(the whole message must be STOP, arrêt, توقف and the like). The webhook then callsapplyStopReply, which withdraws WhatsApp consent with sourcestop_reply. See unsubscribe links are signed tokens. - The consent text lives in one place so it can change after legal review:
packages/common/src/consent.ts(CONSENT_WORDINGin en, fr and ar, andCONSENT_WORDING_VERSION, bumped on every change). /privacyand/terms(en, fr, ar) are short plain-language drafts inapps/web, not yet reviewed by a lawyer; the privacy page prints the liveCONSENT_WORDING, so it can never drift from what the capture page shows.
Changing the wording
- Edit
CONSENT_WORDINGinpackages/common/src/consent.tsonly. Never copy the text into a component or a translation file. - Bump
CONSENT_WORDING_VERSION(YYYY-MM-<label>-<n>) in the same change, for any edit, even a typo in one language. Every consent event stores the version the guest saw, so old events stay true. - Adding a channel or a language is also a bump. Old events are never rewritten.
The QR capture page
- Guest pages (
/h/...,/u/,/s/,/o/and/r/<token>, inapps/web/app/(guest)) shareGuestShelland ship none of the site chrome (no analytics, consent banner, feedback button or background art) and almost no client code: native toggles, a native<details>for the optional part. One small client component holds the form. The header is the hotel's logo (or its initials) and name on a flat tint of its primary color, the perk card uses its accent color, and Ritorno only shows as a "Powered by" line in the footer. A language switcher (en, fr, ar) sits at the inline end and sets?lang=; the unsubscribe page has none, because the consent log stores the wording in the guest's language. When a hotel color is under 3:1 on white the focus ring stays ink. Every guest page has the same loading skeleton, error boundary (with retry) and a not valid or expired state. - Fields: name, phone (searchable list of every country, +216 by default), an optional "when do you leave?" (tomorrow, 2, 3 or 7 nights, or a date up to 90 days ahead, refused outside that range by the api too) with its own
profiletoggle that only shows once a date is chosen, the WhatsApp and email consent toggles (always off at first, the email field opens right under the email toggle), then an "optional" section with the birthday. The Join button sits after all of it and is never sticky, so a guest cannot join without passing the consent toggles, and the keyboard's enter key does not submit. There is no separate message language question: the language the guest reads the page in is the language stored for their messages and consent wording. Name and phone are checked on blur, so a wrong phone number rarely reaches the api. When the api refuses a sign-up, the error shows on the field it names. - The button shows a sending state, and success (animated check, the perk, what to do at the front desk) shows only after the api says ok. If the api refuses (invalid, rate limit) or the request never arrives (offline, api down), the form stays with the guest's answers, an error and the button to retry.
- Route
apps/web/app/(guest)/h/[hotelSlug]?src=room|table|desk&loc=<spot>&lang=en|fr|ar.srcbecomes the guest source (qr_room,qr_table,qr_front_desk),locis stored asguests.capture_location. - Branding comes from
hotel_settingsthroughpublic.hotel, which returns only the display name, two colors, logo url, default language and slug. Everything else stays behind a session. public.captureis the one public write. It is scoped by the hotel slug, recordsprofileconsent only when the guest chose a departure date and switched its toggle on, and goes through the sameupsertGuestas staff and CSV, so a known phone merges and every answer lands in the consent log with the wording version.- The page loads in the language of
?lang, else the phone'sAccept-Language, else the hotel's default, with a link switcher (no JS needed) in a compact header. It isnoindex, and skips the site chrome (feedback button, consent banner, analytics) to stay small on a weak connection. - Abuse protection on
public.capture: 60 sign-ups per ip and hotel per 10 minutes (everyone on the hotel wifi shares one ip) and 200 per hotel per hour (429 over that; survey answers are counted apart, 60 per ip per 10 minutes), a hiddenwebsitehoneypot, and names that are links. A bot caught by the honeypot or a link name gets a normal "ok", nothing is stored, and acapture discardedlog line records the hotel id and the reason. There is no minimum fill time: autofill makes real guests fast. Only the ip and the hotel id are used as keys, never a phone, email or name. The web app forwards the guest'sx-forwarded-forso the limit is per guest, not per web server. The ip is the first hop of that header, so the api must sit behind a proxy that sets it (Dokploy, Vercel, Cloudflare do). A client that sends its own header can pick a fresh ip each time, so the per-hotel cap is the real ceiling. - Welcomes from
public.capture(enqueuePublicWelcome) are capped so a stranger can't spend a hotel's WhatsApp balance: no new welcome when the guest (one per phone and hotel) got one in the last 30 days, and at most 60 per hotel per hour. A skip is logged with the hotel id only, the sign-up still succeeds. - QR codes: the dashboard page
/qr-codesprints one code per room, table or front desk (hotel.qrCodes, printing). Apreview=1try-out of the page saves nothing. Each code is a short link,/q/<code>, that leads to/h/<slug>?src=<room|table|desk>&loc=<spot>(short links). The link table holds no guest data and no scan is logged. The source is the guest'ssourceand the spot isguests.capture_location, set when the guest is first created.hotel.captureStatscounts guests per source and spot so a hotel sees which code works. Staff add the spots (101-120,T1, T2). Room and table names are saved per hotel (capture_spots) so they can be printed again, see rooms and tables. They are not guest data. - Continue on WhatsApp on the same page opens a chat with Ritorno's shared number. Sending that message is not a consent: see scan to WhatsApp for what is kept and for how long.
- Known limit: a phone number is not verified, so someone could sign up another person's number. Consent is per channel and withdrawable with STOP or the unsubscribe link.
How it is stored
guestsis unique per hotel and phone (hotel_id,phone_e164). Every row carrieshotel_id, and the consent tables point at(guest_id, hotel_id)so a row can never reference another hotel's guest.guest_consentsholds the current answer per guest and channel.consent_eventsholds every change: channel, granted or not, time, source, wording version, optional ip hash. A first "no" is logged too, an unchanged answer is not.guest_visitsholds one row per visit, at most one per guest per day on the hotel's clock (recordVisitinpackages/orpc/src/lib/guests.ts). It only feeds recognition (visit count, returning badge and filter, first and last visit), never points or tiers. Deleted with the guest. A visit is counted when:- a guest signs up or scans the QR again. The public answer is the same for a new and a known phone
- staff add a guest, also with a phone that is already known
- staff tap "Mark visit" in the guest finder at the top of the dashboard home, on the guest page, or in quick add once the typed phone is known (source
staff) - a guest's offer code is redeemed (source
staff). A promo code belongs to no guest and counts nothing
- Imports by csv count no visit. A wrong tap can be taken back for 10 minutes: "Undo" on the "Visit saved" toast (
guests.undoVisit), or "Undo" on the redeem result (offers.undoRedeem, which also removes the visit that redemption counted). - Adding a phone that is already known shows whose it is while staff type. After saving it lists what was updated and what was kept: name, email, birthday, country and city only fill gaps.
- Channels are
email,whatsappandprofile.profileis the consent for the optional tier (country, city, stay dates, next destination): those fields are refused without it and cleared when it is withdrawn. On the capture page theprofiletoggle only shows once the guest answers the optional "when do you leave?". The page only collects the departure date, but switching the toggle on grants the wholeprofilechannel, so staff can then record the other details too. With the toggle off, the date is not stored and no consent is granted. - Deleting a guest is a hard delete: the guest, its consents and its events go together, and the staff notes on their feedback cases are erased in the same transaction, so nothing personal is left. The audit log keeps only a row without personal data:
guest.deletewith the SHA-256 of the guest id (hashGuestId) and the hotel id. Earlier audit rows (export, consent change) keep the opaque guest id, which names nobody once the guest row is gone. See guest delete is a hard delete. - Staff can record arrival and departure dates in quick add, guest edit and csv import, always under
profile: quick add has its own unchecked box, edit needs the consent already on. In a csv, dates are saved only when the row's own stay consent column says yes and the hotel confirms; the email and WhatsApp consent columns never count. Departure can't be before arrival. - When staff or a csv give new dates, a stored date that would put arrival after departure is dropped. A csv row older than the stored departure changes no date, and a withdrawn
profileconsent stays withdrawn with its dates. - A campaign's "last stay" window takes the later of the departure date and the last visit, on the hotel's clock. Guests with neither are not reached, and the audience card says how many.
- Export and delete, per guest and per hotel, are in the dashboard under Guest data (owner and manager only, staff cannot). Export is JSON (every field, the full consent log and the feedback follow-up with its notes,
guests.export,guests.exportAll) or CSV (one row per guest, feedback follow-up infeedback_follow_up, consent log in the last column,guests.exportCsv; cells starting with=,+,-,@are neutralised against spreadsheet formulas). Delete all (guests.removeAll) needs the exact guest count, so a stale screen can't delete guests added since. Every export and delete writes an audit entry.
Phone numbers and duplicates
- Phones are stored as E.164 (
+21620123456).parsePhoneinpackages/common/src/phone.tsaccepts the Tunisian local 8 digits,+216…,00216…, other international numbers, separators and Arabic-Indic digits. Tunisian landlines (starting 3, 7, 8) are valid but can't take WhatsApp, so a WhatsApp consent is refused for them. - The phone field (
PhoneInput,packages/common/src/dial.ts) reads a leading+or00, typed or pasted, and switches the country. The default is always +216 and the country changes only when it is picked from the list or typed with+or00. The browser locale is deliberately not used: it says how a phone is set up, not whose number is typed, and a Tunisian mobile read under a foreign code (20123456under +49) can be a valid number belonging to a stranger, who would then be messaged. It is used by the capture page, the demo form and staff quick add, which returns to +216 after each guest. Guest search ignores a leading0or00, so06 12…finds+336 12…. CSV import reads numbers without a country code as Tunisian. - Same hotel and same phone is the same guest. A second capture (
guests.create) merges into the existing guest: name, email, birthday, country and city only fill gaps, language and stay details take the latest value. A rescan of the public form is the exception: it never changes a check-out that is today or later (staff may have set it), and never sets one earlier than the check-in. - Merging only adds consent and fills gaps. A "no" from any source, a QR rescan included, never withdraws an existing "yes" and never clears the optional details, since anyone who knows a phone can rescan the public form. Withdrawal goes through the unsubscribe link, a STOP reply or a staff consent change (
guests.setConsent), each logged. - Staff can change a guest's number on the edit page (
guests.updatewithphone). A number another guest of the same hotel has is refused (CONFLICTwith that guest's id), never merged; other hotels do not count. WhatsApp consent was given for the old number, so a change turns it off, logged as a staff consent event, even when it was only a typo. Staff turn it back on after asking the guest. Email and stay details consent stay. QR scans kept for the old number are deleted in the same transaction. Messages created before the change (guests.phone_changed_at) went to the old number, so a STOP never uses them to pick a hotel or to find the sender of a hidden-number reply. The change writes aguest.phone-changeaudit entry without either number. - A CSV import never re-grants a withdrawn channel. When a guest said yes to a channel and later withdrew it (unsubscribe, STOP or staff), a "yes" in an imported row is ignored for that channel and nothing is added to the consent log: an old list must not override a withdrawal. The import summary counts these rows (
consentKept). The guest can opt in again from the QR page or the unsubscribe page, and staff can grant it back on the guest page (logged with the staff source).
Isolation
- Every guest row and every query is scoped by hotel id. See hotel is an organization.
- Guests are not auth users. See guests are not auth users.
- Files live in one bucket with a prefix per hotel. See one bucket, prefix per hotel.
Logging and non-production
- Never log a phone, email or name in plain text. Use the logger redaction.
- Previews, tests, local and staging never send real messages. Providers are log-only there.
- Seeds, previews and tests use fake data only, never real guests.
Parked: location tracking
Dawarich or any location tracking is parked. If it ever returns it is opt in, one time, on guest request, and only after a legal check.