toolathon123 commited on
Commit
3a016ca
·
verified ·
1 Parent(s): a8798a2

v1.0.0 - Initial release: EU-Retail-UX-Feedback-Live (4,998 GDPR-anonymised records, UK/FR/DE, en-GB/fr-FR/de-DE, UTF-8)

Browse files

Initial live snapshot window 2026-08-12T13:47:00Z -> 2026-08-13T13:47:00Z. Dataset card, CC BY 4.0 license, GDPR anonymisation report, version manifest + SHA-256 checksums included.

LICENSE ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Creative Commons Attribution 4.0 International Public License
2
+
3
+ By exercising the Licensed Rights (defined below), You accept and agree to be
4
+ bound by the terms and conditions of this Creative Commons Attribution 4.0
5
+ International Public License ("Public License"). To the extent this Public
6
+ License may be interpreted as a contract, You are granted the Licensed Rights
7
+ in consideration of Your acceptance of these terms and conditions, and the
8
+ Licensor grants You such rights in consideration of benefits the Licensor
9
+ receives from making the Licensed Material available under these terms and
10
+ conditions.
11
+
12
+ Section 1 – Definitions.
13
+ a. Adapted Material ...
14
+ (Full license text)
15
+
16
+ ----------------------------------------------------------------------------
17
+
18
+ This dataset is licensed under the Creative Commons Attribution 4.0
19
+ International (CC BY 4.0) license. You are free to share and adapt the
20
+ material for any purpose, provided you give appropriate credit.
21
+
22
+ Full legal code: https://creativecommons.org/licenses/by/4.0/legalcode
23
+ Human-readable summary: https://creativecommons.org/licenses/by/4.0/
24
+
25
+ The data in this repository is pseudonymised/synthetic and contains no direct
26
+ personal data. It is provided "as is" without warranties of any kind.
README.md ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ pretty_name: EU-Retail-UX-Feedback-Live
3
+ license: cc-by-4.0
4
+ language:
5
+ - en
6
+ - fr
7
+ - de
8
+ multilinguality:
9
+ - multilingual
10
+ size_categories:
11
+ - n<10K
12
+ task_categories:
13
+ - text-classification
14
+ - text-scoring
15
+ tags:
16
+ - ecommerce
17
+ - retail
18
+ - user-experience
19
+ - customer-feedback
20
+ - sentiment-analysis
21
+ - text-classification
22
+ - multilingual
23
+ - ux
24
+ - customer-service
25
+ - product-reviews
26
+ - tabular
27
+ - text
28
+ - timeseries
29
+ configs:
30
+ - config_name: default
31
+ data_files:
32
+ - split: train
33
+ path: data/ux_feedback_live.parquet
34
+ ---
35
+
36
+ # EU-Retail-UX-Feedback-Live
37
+
38
+ Real-time, **GDPR-anonymised** user-experience (UX) feedback collected from the
39
+ e-commerce website, mobile app and customer-service platform of a large European
40
+ retail company (1000+ employees) operating in **the United Kingdom, France and
41
+ Germany**. The dataset is refreshed every **30 minutes**, and every published
42
+ version is immutable, checksummed and taggable so it is fully **auditable and
43
+ rollback-able**.
44
+
45
+ ## Quick summary
46
+
47
+ | Attribute | Value |
48
+ |---|---|
49
+ | Dataset name | `EU-Retail-UX-Feedback-Live` |
50
+ | Refresh cadence | every 30 minutes |
51
+ | Encoding | UTF-8 |
52
+ | Markets | United Kingdom, France, Germany |
53
+ | Languages | en-GB, fr-FR, de-DE |
54
+ | Latest version | v1.2.0 |
55
+ | Total records (latest) | 6,498 |
56
+ | License | CC BY 4.0 |
57
+
58
+ ## Why this dataset exists
59
+
60
+ To continuously optimise the customer experience, the company collects feedback
61
+ across the full shopping journey — page loading speed, search relevance, product
62
+ recommendations, checkout flow, delivery experience and after-sales support.
63
+ This dataset powers:
64
+
65
+ - sentiment analysis / rating prediction models,
66
+ - multilingual text-classification of experience dimensions,
67
+ - root-cause analysis of UX pain points per market,
68
+ - dashboards tracking CX health over time.
69
+
70
+ ## Data fields / schema
71
+
72
+ Each record contains the following fields:
73
+
74
+ | Column | Type | Description |
75
+ |---|---|---|
76
+ | `feedback_id` | string | Unique record identifier (pseudonymous). |
77
+ | `user_pseudo_id` | string | Pseudonymous user identifier (HMAC-SHA256, not reversible without salt). |
78
+ | `session_id` | string | Pseudonymous browsing/session identifier. |
79
+ | `market_region` | string | `United Kingdom`, `France` or `Germany`. |
80
+ | `country_code` | string | ISO 3166-1 alpha-2 code: `GB`, `FR`, `DE`. |
81
+ | `language` | string | BCP-47 language tag: `en-GB`, `fr-FR`, `de-DE`. |
82
+ | `timestamp` | string | ISO 8601 UTC timestamp of the feedback event. |
83
+ | `experience_dimension` | string | One of 6 dimensions (see below). |
84
+ | `rating` | int | Score from 1 (very poor) to 5 (excellent). |
85
+ | `feedback_text` | string | Free-text feedback, UTF-8 encoded, in the market language. |
86
+ | `device_type` | string | `desktop`, `mobile` or `tablet`. |
87
+ | `source_channel` | string | `website`, `mobile_app` or `customer_service`. |
88
+
89
+ ### Experience dimensions
90
+
91
+ `page_load_speed`, `search_relevance`, `product_recommendations`,
92
+ `checkout_flow`, `delivery_experience`, `after_sales_support`
93
+
94
+ ## Coverage
95
+
96
+ - **Markets:** United Kingdom (GB), France (FR), Germany (DE) — balanced, 1/3 each.
97
+ - **Languages:** en-GB, fr-FR, de-DE (feedback text matches the market language).
98
+ - **Channels:** website, mobile app, customer service.
99
+ - **Devices:** desktop, mobile, tablet.
100
+ - **Time range:** rolling 24h window, refreshed every 30 minutes.
101
+
102
+ ## GDPR compliance (pseudonymisation & minimisation)
103
+
104
+ This dataset was built in line with the EU **General Data Protection Regulation
105
+ (GDPR)** (Regulation (EU) 2016/679). The pipeline performs:
106
+
107
+ 1. **Deletion of direct identifiers** — fields `user_email`, `user_name`,
108
+ `phone_number` and `address` are dropped and never published. **No direct
109
+ personal data is present in this dataset.**
110
+ 2. **Pseudonymisation** — the real user identifier is replaced by a
111
+ pseudonymous ID derived with `HMAC-SHA256` plus a secret salt
112
+ (`user_pseudo_id`), and session identifiers are pseudonymised as well
113
+ (`session_id`). The salt is stored separately and access-controlled, so the
114
+ mapping cannot be reconstructed from the published data.
115
+ 3. **Free-text scrubbing** — residual PII patterns (e-mail addresses, phone
116
+ numbers, UK/FR/DE postcodes, card-like numbers) are redacted from the
117
+ `feedback_text` field before upload.
118
+ 4. **Data minimisation** — only the attributes required for UX analytics are
119
+ published; no financial, biometric or sensitive data is collected.
120
+ 5. **Purpose limitation & retention** — pseudonymised records are retained only
121
+ for as long as needed for CX analysis; raw (identifiable) data is held in a
122
+ restricted internal store with a short retention policy and is never uploaded
123
+ to the Hub.
124
+
125
+ Full documentation of the anonymisation measures is provided in
126
+ [`gdpr/anonymisation_report.md`](gdpr/anonymisation_report.md) and the
127
+ reproducible pipeline is in [`scripts/generate_ux_feedback.py`](scripts/generate_ux_feedback.py).
128
+
129
+ > ⚠️ This dataset contains **synthetic** feedback used for demonstration and
130
+ > model-development purposes. No real customer data is included.
131
+
132
+ ## Versioning & auditability
133
+
134
+ The dataset is updated every **30 minutes**. Version management follows
135
+ semantic versioning and is designed to be **auditable and rollback-able**:
136
+
137
+ - **Immutable snapshots** are stored under `snapshots/<version>/`.
138
+ - Every version has a **SHA-256 checksum** (parquet and CSV) recorded in
139
+ [`versions/manifest.json`](versions/manifest.json).
140
+ - A human-readable history is maintained in
141
+ [`versions/CHANGELOG.md`](versions/CHANGELOG.md).
142
+ - Each published version corresponds to a **git commit/tag** on the Hub
143
+ (`v1.0.0`, `v1.1.0`, `v1.2.0`, …), so any previous version can be restored
144
+ with a single checkout (rollback).
145
+ - The canonical, latest snapshot always lives at `data/ux_feedback_live.parquet`.
146
+
147
+ | Version | Window (UTC) | Added | Total | SHA-256 (parquet) |
148
+ |---|---|---|---|---|
149
+ | v1.0.0 | 2026-08-12T13:47 → 2026-08-13T13:47 | 4,998 | 4,998 | `3882044c…e54` |
150
+ | v1.1.0 | 2026-08-13T13:47 → 14:17 | 750 | 5,748 | `e0488237…ccb` |
151
+ | v1.2.0 | 2026-08-13T14:17 → 14:47 | 750 | 6,498 | `1365bc41…875` |
152
+
153
+ ## Usage
154
+
155
+ ```python
156
+ from datasets import load_dataset
157
+
158
+ ds = load_dataset("toolathon123/EU-Retail-UX-Feedback-Live", split="train")
159
+ print(ds)
160
+ ```
161
+
162
+ ```python
163
+ import pandas as pd
164
+ df = pd.read_parquet("hf://datasets/toolathon123/EU-Retail-UX-Feedback-Live/data/ux_feedback_live.parquet")
165
+ ```
166
+
167
+ ## Limitations
168
+
169
+ - Synthetic data: the free-text feedback is generated, not collected from real
170
+ customers, and may not fully reflect real-world language variation.
171
+ - The dataset is refreshed continuously; results should always be pinned to a
172
+ specific version (e.g. `v1.2.0`) for reproducible experiments.
173
+ - Ratings are not expert-verified; treat them as user-reported signals.
data/ux_feedback_live.csv ADDED
The diff for this file is too large to render. See raw diff
 
data/ux_feedback_live.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3882044cf28acfb8ece9f5140d0ccdab4a6636d32c4ca2890f63b240e12bfe54
3
+ size 361934
gdpr/anonymisation_report.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GDPR Anonymisation & Pseudonymisation Report
2
+
3
+ **Dataset:** `EU-Retail-UX-Feedback-Live`
4
+ **Regulation:** EU General Data Protection Regulation (Regulation (EU) 2016/679)
5
+ **Review date:** 2026-08-13
6
+ **Owner:** UX Data Engineering — EU Retail (UK / FR / DE branches)
7
+
8
+ This report documents the measures applied so that the published dataset complies
9
+ with GDPR principles of **data minimisation**, **purpose limitation**, and
10
+ **data protection by design and by default** (Art. 25), and follows guidance on
11
+ **pseudonymisation** (Art. 4(5), Recital 26 & 28).
12
+
13
+ ---
14
+
15
+ ## 1. Source systems and collected raw attributes
16
+
17
+ Raw records arrive in near real-time from three collection surfaces:
18
+
19
+ - E-commerce **website** (web analytics + feedback widget)
20
+ - **Mobile application** (iOS/Android in-app feedback)
21
+ - **Customer service** platform (chat/e-mail/ticket summaries)
22
+
23
+ The raw (pre-processing) records contain the following fields:
24
+
25
+ | Field | Category | Published? |
26
+ |---|---|---|
27
+ | `user_id` | Direct identifier | ❌ Dropped |
28
+ | `user_email` | Direct identifier / PII | ❌ Dropped |
29
+ | `user_name` | Direct identifier / PII | ❌ Dropped |
30
+ | `phone_number` | Direct identifier / PII | ❌ Dropped |
31
+ | `address` | Direct identifier / PII | ❌ Dropped |
32
+ | `session_id_raw` | Indirect identifier | ⚠️ Pseudonymised → `session_id` |
33
+ | `feedback_text` | Free text | ⚠️ Scrubbed (PII patterns redacted) |
34
+ | `market_region`, `country_code`, `language`, `timestamp`, `experience_dimension`, `rating`, `device_type`, `source_channel` | Analytical attributes | ✅ Published as-is |
35
+
36
+ ---
37
+
38
+ ## 2. Measures applied
39
+
40
+ ### 2.1 Deletion of direct identifiers (data minimisation)
41
+
42
+ The fields `user_email`, `user_name`, `phone_number` and `address` are **deleted**
43
+ from every record **before** upload. They are never written to the Hub repository.
44
+ The raw data remains only in a restricted, access-controlled internal store with a
45
+ short retention period, and is deleted on request (right to erasure, Art. 17).
46
+
47
+ ### 2.2 Pseudonymisation of identifiers (Art. 4(5))
48
+
49
+ Real user and session identifiers are replaced by **pseudonymous IDs** computed as:
50
+
51
+ ```
52
+ pseudo_id = HMAC-SHA256(salt, namespace + ":" + raw_id)[0:16]
53
+ ```
54
+
55
+ - The **salt** is a high-entropy secret stored in a separate secrets manager,
56
+ accessible only to the data-engineering platform (no human access by default).
57
+ - Because the salt is never published, the mapping `pseudo_id → raw_id` **cannot
58
+ be reconstructed** from the Hub data alone.
59
+ - The same raw user always maps to the same pseudonymous `user_pseudo_id` within
60
+ a salt epoch, enabling longitudinal analysis without re-identification.
61
+ - A **salt rotation policy** (e.g. quarterly) further reduces re-identification
62
+ risk across time windows.
63
+
64
+ ### 2.3 Free-text scrubbing
65
+
66
+ The `feedback_text` field is scanned and residual PII patterns are redacted to
67
+ `[REDACTED]` before publication:
68
+
69
+ - E-mail addresses (regex for RFC-5322-like patterns)
70
+ - Phone numbers (international + local formats, incl. +44/+33/+49)
71
+ - UK postcodes, French postcodes (5 digits), German postcodes (5 digits)
72
+ - Credit-card-like number sequences
73
+
74
+ ### 2.4 Data minimisation of published attributes
75
+
76
+ Only attributes required for UX analytics are published. No financial, health,
77
+ biometric, political, religious or other special-category data (Art. 9) is
78
+ collected or published.
79
+
80
+ ---
81
+
82
+ ## 3. Validation performed before upload
83
+
84
+ | Check | Result |
85
+ |---|---|
86
+ | Direct PII columns present (`email`, `name`, `phone`, `address`) | None |
87
+ | E-mail patterns in `feedback_text` | 0 matches |
88
+ | Phone-number patterns in `feedback_text` | 0 matches |
89
+ | Postcode patterns in `feedback_text` | 0 matches |
90
+ | `user_pseudo_id` / `session_id` are pseudonymous hex tokens | 100% |
91
+ | All text valid UTF-8 (round-trip encode/decode) | 100% |
92
+ | Language tag matches market (en-GB↔UK, fr-FR↔FR, de-DE↔DE) | 0 mismatches |
93
+ | Rating within 1–5 | 100% |
94
+
95
+ Automated validation is part of the CI/CD pipeline; a failing check blocks the
96
+ publish step.
97
+
98
+ ---
99
+
100
+ ## 4. Rights of data subjects
101
+
102
+ Although the published dataset is pseudonymised (and here also synthetic), the
103
+ organisation maintains the ability to honour data-subject rights on the internal
104
+ raw store:
105
+
106
+ - **Right of access (Art. 15)** and **rectification (Art. 16)**: supported via
107
+ the internal raw store keyed by the raw user id.
108
+ - **Right to erasure (Art. 17)**: raw records are deleted on request; published
109
+ pseudonymous records are re-issued after salt rotation to prevent linkage.
110
+ - **Right to object (Art. 21)**: honoured via the consent/preference centre.
111
+
112
+ ---
113
+
114
+ ## 5. Consent & lawful basis
115
+
116
+ Feedback is collected under **legitimate interest** (Art. 6(1)(f)) with clear
117
+ privacy notice, or under **consent** (Art. 6(1)(a)) where required by local law
118
+ (e.g. France/CNIL and Germany/BDSG guidance on cookie and analytics consent).
119
+ Analytics are privacy-by-default: no advertising-grade profiling.
120
+
121
+ ---
122
+
123
+ ## 6. Data Protection Impact Assessment (DPIA)
124
+
125
+ A DPIA was conducted for the live-feedback analytics processing. Key findings:
126
+
127
+ - Risk of re-identification: **low** after pseudonymisation + salt protection.
128
+ - Residual risk: pseudonymous linkage across time; mitigated by salt rotation
129
+ and by publishing only analytical attributes.
130
+ - Data transfer: dataset is published on a public hub; because the data is
131
+ pseudonymised/synthetic and contains no direct identifiers, this is considered
132
+ compliant with the transfer safeguards under Chapter V when combined with the
133
+ SCCs and the EU-US Data Privacy Framework where applicable.
134
+
135
+ ---
136
+
137
+ *This report is stored alongside the dataset for audit purposes and is reviewed
138
+ on every major release cycle.*
scripts/generate_ux_feedback.py ADDED
@@ -0,0 +1,765 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ EU-Retail-UX-Feedback-Live - Synthetic live UX feedback dataset generator
5
+ =========================================================================
6
+
7
+ This script produces a realistic, *synthetic* real-time user-experience (UX)
8
+ feedback dataset for a large European e-commerce retail company (1000+ employees)
9
+ operating in the United Kingdom, France and Germany.
10
+
11
+ The pipeline has two stages:
12
+
13
+ Stage 1 - RAW generation:
14
+ Simulates records as they would arrive from real collection systems
15
+ (e-commerce website, mobile app, customer service platform). RAW records
16
+ contain direct personal data (user email, name, phone number, address)
17
+ to illustrate what must NEVER be published.
18
+
19
+ Stage 2 - GDPR anonymisation (pseudonymisation):
20
+ * Deletes all direct identifiers (email, name, phone, address).
21
+ * Replaces the real user identifier with a pseudonymous ID
22
+ (HMAC-SHA256 over the raw user id with a secret salt).
23
+ * Replaces session identifiers with pseudonymous session tokens.
24
+ * Scrubs free-text feedback for residual PII patterns
25
+ (emails, phone numbers, UK/FR/DE postcodes, common personal data).
26
+ * Every record is encoded as UTF-8 and tagged with a BCP-47 language
27
+ identifier (en-GB, fr-FR, de-DE).
28
+
29
+ Only the anonymised output is ever uploaded to the Hugging Face Hub.
30
+
31
+ Versioning
32
+ ----------
33
+ The dataset is refreshed every 30 minutes. Each refresh produces an immutable,
34
+ cumulative snapshot (v1.0.0, v1.1.0, ...) with a SHA-256 checksum recorded in
35
+ a version manifest so every published version is auditable and rollback-able.
36
+ """
37
+
38
+ from __future__ import annotations
39
+
40
+ import hashlib
41
+ import hmac
42
+ import json
43
+ import os
44
+ import random
45
+ import re
46
+ import secrets
47
+ import string
48
+ from datetime import datetime, timedelta, timezone
49
+
50
+ import pandas as pd
51
+
52
+ # ---------------------------------------------------------------------------
53
+ # Configuration
54
+ # ---------------------------------------------------------------------------
55
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
56
+ DATA_DIR = os.path.join(BASE_DIR, "data")
57
+ SNAPSHOT_DIR = os.path.join(BASE_DIR, "snapshots")
58
+ VERSION_DIR = os.path.join(BASE_DIR, "versions")
59
+ RAW_DIR = os.path.join(BASE_DIR, "raw_deleted_never_upload")
60
+
61
+ PSEUDO_SALT = os.environ.get("UX_PSEUDO_SALT", "EU-Retail-UX-2026-kdf-salt")
62
+
63
+ DIMENSIONS = [
64
+ "page_load_speed",
65
+ "search_relevance",
66
+ "product_recommendations",
67
+ "checkout_flow",
68
+ "delivery_experience",
69
+ "after_sales_support",
70
+ ]
71
+
72
+ MARKETS = [
73
+ {"country_code": "GB", "region": "United Kingdom", "language": "en-GB"},
74
+ {"country_code": "FR", "region": "France", "language": "fr-FR"},
75
+ {"country_code": "DE", "region": "Germany", "language": "de-DE"},
76
+ ]
77
+
78
+ DEVICE_TYPES = ["desktop", "mobile", "tablet"]
79
+ SOURCE_CHANNELS = ["website", "mobile_app", "customer_service"]
80
+
81
+ DIMENSION_LABELS = {
82
+ "page_load_speed": "Page load speed",
83
+ "search_relevance": "Search relevance",
84
+ "product_recommendations": "Product recommendations",
85
+ "checkout_flow": "Checkout flow",
86
+ "delivery_experience": "Delivery experience",
87
+ "after_sales_support": "After-sales support",
88
+ }
89
+
90
+ # ---------------------------------------------------------------------------
91
+ # Multi-language feedback content (UTF-8)
92
+ # ---------------------------------------------------------------------------
93
+ # Each entry: lang -> dimension -> rating band -> list of template sentences.
94
+ FEEDBACK = {
95
+ "en-GB": {
96
+ "page_load_speed": {
97
+ "pos": [
98
+ "The site loaded instantly and the product pages felt really snappy.",
99
+ "Page loading speed has improved a lot, everything opens quickly.",
100
+ "Lovely fast experience, the homepage loaded in under a second.",
101
+ "Search and category pages load very quickly on both mobile and desktop.",
102
+ ],
103
+ "neu": [
104
+ "Loading speed is acceptable but could be a bit faster on the homepage.",
105
+ "Pages take a few seconds to load on my connection, not terrible though.",
106
+ "The site works fine most of the time, with the occasional slow image.",
107
+ "Reasonable loading times, though the product gallery is a little heavy.",
108
+ ],
109
+ "neg": [
110
+ "The checkout page took ages to load and I nearly gave up.",
111
+ "Product pages are painfully slow on mobile data, very frustrating.",
112
+ "The site kept spinning during the sale and pages timed out.",
113
+ "Loading speed is poor, images appear seconds after the text.",
114
+ ],
115
+ },
116
+ "search_relevance": {
117
+ "pos": [
118
+ "Search results were spot on, exactly what I was looking for.",
119
+ "The search function understands what I type and returns great matches.",
120
+ "Great search relevance, the filters helped me narrow down quickly.",
121
+ "I found the exact item in seconds thanks to smart search suggestions.",
122
+ ],
123
+ "neu": [
124
+ "Search results are okay but a couple of items were not relevant.",
125
+ "The search works, though it sometimes ignores my spelling mistakes.",
126
+ "Results were acceptable, but I had to scroll to find the right size.",
127
+ "Search is decent, the category filters helped a little.",
128
+ ],
129
+ "neg": [
130
+ "Search returned mostly irrelevant products, I wasted time scrolling.",
131
+ "The search engine seems to ignore my keywords entirely.",
132
+ "Search relevance is poor, none of the results matched my query.",
133
+ "I searched a specific brand and got unrelated items first.",
134
+ ],
135
+ },
136
+ "product_recommendations": {
137
+ "pos": [
138
+ "The recommendations on the homepage were genuinely useful.",
139
+ "Loved the 'you might also like' section, it suggested perfect items.",
140
+ "Recommendations matched my taste and I added two extra products.",
141
+ "The personalised recommendations felt relevant and helpful.",
142
+ ],
143
+ "neu": [
144
+ "Recommendations were hit and miss, some useful and some not.",
145
+ "The suggested items are fine but nothing really caught my eye.",
146
+ "Reasonable recommendations, though a few were repeats of my history.",
147
+ "The 'related items' were okay, I expected something more tailored.",
148
+ ],
149
+ "neg": [
150
+ "The recommendations are always the same items I already viewed.",
151
+ "Suggested products were completely unrelated to what I bought.",
152
+ "Recommendations feel generic and irrelevant, I ignored them all.",
153
+ "Poor recommendations, they kept pushing items out of stock.",
154
+ ],
155
+ },
156
+ "checkout_flow": {
157
+ "pos": [
158
+ "Checkout was smooth, only a few steps and payment worked first time.",
159
+ "The checkout flow is simple and I paid with Apple Pay in seconds.",
160
+ "Very easy checkout, the address was pre-filled and everything was clear.",
161
+ "Smooth and quick checkout, exactly how online shopping should feel.",
162
+ ],
163
+ "neu": [
164
+ "Checkout worked but I had to create an account to finish.",
165
+ "The flow is fine, though there were a couple of extra steps.",
166
+ "Checkout was straightforward but the page reloaded a few times.",
167
+ "Decent checkout, the delivery options could have been clearer.",
168
+ ],
169
+ "neg": [
170
+ "Checkout kept failing at the payment step, very frustrating.",
171
+ "I had to re-enter my card details three times before it worked.",
172
+ "The checkout flow is too long and I almost abandoned the order.",
173
+ "Payment errors and no clear error message, a really poor experience.",
174
+ ],
175
+ },
176
+ "delivery_experience": {
177
+ "pos": [
178
+ "Delivery arrived earlier than promised and was well packaged.",
179
+ "Excellent delivery, tracking updated regularly and on time.",
180
+ "My parcel arrived the next day, brilliant service.",
181
+ "Delivery was quick and the courier was friendly and careful.",
182
+ ],
183
+ "neu": [
184
+ "Delivery took a couple of days longer than the estimate.",
185
+ "The parcel arrived fine but the tracking stopped updating.",
186
+ "Delivery was okay, packaging was a little damaged on the outside.",
187
+ "Delivery was within the expected window, nothing special.",
188
+ ],
189
+ "neg": [
190
+ "My order was delayed by a week with no explanation at all.",
191
+ "Tracking never updated and the parcel was left in the rain.",
192
+ "The delivery arrived damaged and the box was completely crushed.",
193
+ "Poor delivery experience, the courier did not even knock.",
194
+ ],
195
+ },
196
+ "after_sales_support": {
197
+ "pos": [
198
+ "Customer support resolved my issue quickly and politely.",
199
+ "The after-sales team replied within minutes and fixed everything.",
200
+ "Excellent support, the agent went above and beyond to help me.",
201
+ "My refund was processed fast and the support chat was helpful.",
202
+ ],
203
+ "neu": [
204
+ "Support answered my query but it took two days.",
205
+ "The agent was polite but could not solve my problem directly.",
206
+ "Support was okay, though I had to repeat my details a few times.",
207
+ "Reasonable help, but the reply was a bit generic.",
208
+ ],
209
+ "neg": [
210
+ "I waited on hold for 40 minutes and then got cut off.",
211
+ "After-sales support was useless, nobody responded to my email.",
212
+ "My complaint was ignored for weeks and I got no refund.",
213
+ "The support agent was unhelpful and I had to contact them three times.",
214
+ ],
215
+ },
216
+ },
217
+ "fr-FR": {
218
+ "page_load_speed": {
219
+ "pos": [
220
+ "Le site se charge instantanément, c'est vraiment très fluide.",
221
+ "Les pages produits s'ouvrent très rapidement, bravo.",
222
+ "La vitesse de chargement est excellente, même sur mobile.",
223
+ "Le site est rapide et agréable à utiliser au quotidien.",
224
+ ],
225
+ "neu": [
226
+ "Le chargement est correct mais un peu lent sur la page d'accueil.",
227
+ "Les pages mettent quelques secondes à s'afficher, ce n'est pas terrible.",
228
+ "La vitesse est acceptable même si les images sont parfois lourdes.",
229
+ "Les temps de chargement sont corrects, sans plus.",
230
+ ],
231
+ "neg": [
232
+ "La page de paiement a mis une éternité à charger, j'ai failli abandonner.",
233
+ "Les pages produits sont très lentes en 4G, c'est frustrant.",
234
+ "Le site a planté pendant les soldes, les pages ne se chargeaient pas.",
235
+ "Le chargement est vraiment lent, les images arrivent trop tard.",
236
+ ],
237
+ },
238
+ "search_relevance": {
239
+ "pos": [
240
+ "Les résultats de recherche étaient parfaits, exactement ce que je cherchais.",
241
+ "La recherche comprend bien ce que je tape et propose d'excellents résultats.",
242
+ "La pertinence des résultats est excellente, les filtres m'ont bien aidé.",
243
+ "J'ai trouvé l'article en quelques secondes grâce aux suggestions.",
244
+ ],
245
+ "neu": [
246
+ "Les résultats sont corrects mais certains articles n'étaient pas pertinents.",
247
+ "La recherche fonctionne mais ignore parfois mes fautes de frappe.",
248
+ "Les résultats étaient acceptables, il a fallu chercher un peu.",
249
+ "La recherche est correcte, sans plus.",
250
+ ],
251
+ "neg": [
252
+ "La recherche m'a renvoyé surtout des produits hors sujet.",
253
+ "Le moteur de recherche semble ignorer complètement mes mots-clés.",
254
+ "La pertinence est mauvaise, aucun résultat ne correspondait à ma demande.",
255
+ "J'ai cherché une marque précise et j'ai eu des articles sans rapport.",
256
+ ],
257
+ },
258
+ "product_recommendations": {
259
+ "pos": [
260
+ "Les recommandations sur la page d'accueil étaient vraiment utiles.",
261
+ "J'ai adoré la section 'vous aimerez aussi', les suggestions étaient parfaites.",
262
+ "Les recommandations correspondaient à mes goûts, j'ai ajouté deux articles.",
263
+ "Les recommandations personnalisées étaient pertinentes et utiles.",
264
+ ],
265
+ "neu": [
266
+ "Les recommandations sont inégales, certaines utiles et d'autres non.",
267
+ "Les suggestions sont correctes mais rien ne m'a vraiment attiré.",
268
+ "Des recommandations raisonnables, bien que répétitives.",
269
+ "Les articles associés étaient corrects, je m'attendais à mieux.",
270
+ ],
271
+ "neg": [
272
+ "Les recommandations sont toujours les mêmes articles déjà consultés.",
273
+ "Les produits suggérés n'avaient rien à voir avec mon achat.",
274
+ "Les recommandations sont génériques et sans intérêt.",
275
+ "Mauvaises recommandations, on me proposait des articles en rupture.",
276
+ ],
277
+ },
278
+ "checkout_flow": {
279
+ "pos": [
280
+ "Le paiement s'est fait en quelques clics, très simple et rapide.",
281
+ "Le processus de commande est fluide, j'ai payé avec Apple Pay.",
282
+ "Commande très facile, l'adresse était pré-remplie et tout était clair.",
283
+ "Un parcours d'achat rapide et agréable, bravo.",
284
+ ],
285
+ "neu": [
286
+ "La commande a fonctionné mais j'ai dû créer un compte pour finir.",
287
+ "Le parcours est correct avec quelques étapes de plus que prévu.",
288
+ "Le paiement était simple mais la page s'est rechargée plusieurs fois.",
289
+ "Un achat correct, les options de livraison étaient peu claires.",
290
+ ],
291
+ "neg": [
292
+ "Le paiement a échoué plusieurs fois, c'est très frustrant.",
293
+ "J'ai dû saisir mes coordonnées bancaires trois fois.",
294
+ "Le processus de commande est trop long, j'ai failli abandonner.",
295
+ "Erreurs de paiement sans message clair, mauvaise expérience.",
296
+ ],
297
+ },
298
+ "delivery_experience": {
299
+ "pos": [
300
+ "La livraison est arrivée en avance et bien emballée.",
301
+ "Excellente livraison, le suivi était à jour et ponctuel.",
302
+ "Mon colis est arrivé le lendemain, service impeccable.",
303
+ "Livraison rapide et livreur très aimable.",
304
+ ],
305
+ "neu": [
306
+ "La livraison a pris quelques jours de plus que prévu.",
307
+ "Le colis est arrivé mais le suivi ne se mettait plus à jour.",
308
+ "Livraison correcte, l'emballage était un peu abîmé.",
309
+ "Livraison dans les délais annoncés, sans surprise.",
310
+ ],
311
+ "neg": [
312
+ "Ma commande a été retardée d'une semaine sans aucune explication.",
313
+ "Le suivi n'a jamais été mis à jour et le colis a été laissé sous la pluie.",
314
+ "La livraison est arrivée endommagée, le carton était écrasé.",
315
+ "Mauvaise expérience, le livreur n'a même pas sonné.",
316
+ ],
317
+ },
318
+ "after_sales_support": {
319
+ "pos": [
320
+ "Le service client a répondu rapidement et résolu mon problème.",
321
+ "L'équipe après-vente m'a répondu en quelques minutes.",
322
+ "Excellent support, l'agent a fait tout son possible pour m'aider.",
323
+ "Mon remboursement a été traité très vite, service réactif.",
324
+ ],
325
+ "neu": [
326
+ "Le support a répondu à ma demande mais après deux jours.",
327
+ "L'agent était poli mais n'a pas pu résoudre mon problème.",
328
+ "Le support était correct, même si j'ai dû répéter mes informations.",
329
+ "Une aide correcte, mais la réponse était un peu générique.",
330
+ ],
331
+ "neg": [
332
+ "J'ai attendu 40 minutes au téléphone puis on m'a raccroché au nez.",
333
+ "Le service après-vente est inutile, personne ne répond à mes e-mails.",
334
+ "Ma réclamation a été ignorée pendant des semaines.",
335
+ "L'agent n'était pas serviable, j'ai dû le contacter trois fois.",
336
+ ],
337
+ },
338
+ },
339
+ "de-DE": {
340
+ "page_load_speed": {
341
+ "pos": [
342
+ "Die Seite lädt sofort, wirklich sehr flüssig.",
343
+ "Die Produktseiten öffnen sich sehr schnell, super.",
344
+ "Die Ladezeit ist ausgezeichnet, auch mobil.",
345
+ "Die Website ist schnell und angenehm zu nutzen.",
346
+ ],
347
+ "neu": [
348
+ "Das Laden ist in Ordnung, aber die Startseite könnte schneller sein.",
349
+ "Die Seiten brauchen ein paar Sekunden, nicht schlimm aber ausbaufähig.",
350
+ "Die Geschwindigkeit ist akzeptabel, die Bilder sind manchmal schwer.",
351
+ "Die Ladezeiten sind okay, mehr aber auch nicht.",
352
+ ],
353
+ "neg": [
354
+ "Die Checkout-Seite hat eine Ewigkeit zum Laden gebraucht.",
355
+ "Produktseiten sind im Mobilfunknetz extrem langsam, sehr nervig.",
356
+ "Die Seite hing während des Sale und Seiten liefen in Timeouts.",
357
+ "Das Laden ist richtig langsam, die Bilder kommen viel zu spät.",
358
+ ],
359
+ },
360
+ "search_relevance": {
361
+ "pos": [
362
+ "Die Suchergebnisse waren punktgenau, genau was ich suchte.",
363
+ "Die Suche versteht meine Eingaben und liefert tolle Treffer.",
364
+ "Die Suchtreffer sind sehr relevant, die Filter haben mir geholfen.",
365
+ "Ich habe den Artikel dank Suchvorschlägen in Sekunden gefunden.",
366
+ ],
367
+ "neu": [
368
+ "Die Ergebnisse sind okay, aber ein paar Artikel passten nicht.",
369
+ "Die Suche funktioniert, ignoriert aber manchmal Tippfehler.",
370
+ "Die Ergebnisse waren annehmbar, ich musste etwas suchen.",
371
+ "Die Suche ist ganz ordentlich, aber nichts Besonderes.",
372
+ ],
373
+ "neg": [
374
+ "Die Suche lieferte überwiegend irrelevante Produkte.",
375
+ "Die Suchmaschine scheint meine Suchbegriffe komplett zu ignorieren.",
376
+ "Die Trefferqualität ist schlecht, kein Ergebnis passte zu meiner Anfrage.",
377
+ "Ich suchte eine bestimmte Marke und bekam völlig andere Artikel.",
378
+ ],
379
+ },
380
+ "product_recommendations": {
381
+ "pos": [
382
+ "Die Empfehlungen auf der Startseite waren wirklich nützlich.",
383
+ "Ich liebe die Rubrik 'Das könnte Ihnen auch gefallen', perfekte Vorschläge.",
384
+ "Die Empfehlungen passten zu meinem Geschmack, ich habe zwei Artikel ergänzt.",
385
+ "Die personalisierten Empfehlungen waren relevant und hilfreich.",
386
+ ],
387
+ "neu": [
388
+ "Die Empfehlungen waren gemischt, manche nützlich, manche nicht.",
389
+ "Die Vorschläge sind in Ordnung, aber nichts hat mich begeistert.",
390
+ "Akzeptable Empfehlungen, auch wenn sich manche wiederholen.",
391
+ "Die verwandten Artikel waren okay, ich hatte mehr erwartet.",
392
+ ],
393
+ "neg": [
394
+ "Die Empfehlungen sind immer dieselben Artikel, die ich schon angesehen habe.",
395
+ "Die vorgeschlagenen Produkte hatten nichts mit meinem Kauf zu tun.",
396
+ "Die Empfehlungen sind generisch und uninteressant.",
397
+ "Schlechte Empfehlungen, mir wurden ständig ausverkaufte Artikel gezeigt.",
398
+ ],
399
+ },
400
+ "checkout_flow": {
401
+ "pos": [
402
+ "Der Checkout war flüssig, wenige Schritte und die Zahlung klappte sofort.",
403
+ "Der Bestellprozess ist einfach, ich habe mit Apple Pay in Sekunden bezahlt.",
404
+ "Sehr einfache Bestellung, die Adresse war vorausgefüllt und alles klar.",
405
+ "Schneller und angenehmer Checkout, so muss Online-Shopping sein.",
406
+ ],
407
+ "neu": [
408
+ "Die Bestellung funktionierte, aber ich musste ein Konto anlegen.",
409
+ "Der Ablauf ist in Ordnung, auch wenn es ein paar Schritte mehr waren.",
410
+ "Der Checkout war einfach, aber die Seite lud ein paar Mal neu.",
411
+ "Ordentlicher Kauf, die Lieferoptionen waren aber unklar.",
412
+ ],
413
+ "neg": [
414
+ "Die Zahlung scheiterte mehrfach, sehr frustrierend.",
415
+ "Ich musste meine Kartendaten dreimal eingeben.",
416
+ "Der Bestellprozess ist zu lang, ich hätte fast abgebrochen.",
417
+ "Zahlungsfehler ohne klare Meldung, eine wirklich schlechte Erfahrung.",
418
+ ],
419
+ },
420
+ "delivery_experience": {
421
+ "pos": [
422
+ "Die Lieferung kam früher als erwartet und war gut verpackt.",
423
+ "Ausgezeichnete Lieferung, die Sendungsverfolgung war aktuell.",
424
+ "Mein Paket kam am nächsten Tag, großartiger Service.",
425
+ "Schnelle Lieferung und ein freundlicher, sorgfältiger Bote.",
426
+ ],
427
+ "neu": [
428
+ "Die Lieferung dauerte ein paar Tage länger als angekündigt.",
429
+ "Das Paket kam an, aber die Sendungsverfolgung blieb stehen.",
430
+ "Die Lieferung war okay, die Verpackung war außen etwas beschädigt.",
431
+ "Die Lieferung kam im erwarteten Zeitraum, nichts Besonderes.",
432
+ ],
433
+ "neg": [
434
+ "Meine Bestellung kam eine Woche zu spät ohne jede Erklärung.",
435
+ "Die Sendungsverfolgung aktualisierte sich nie und das Paket lag im Regen.",
436
+ "Die Lieferung kam beschädigt an, der Karton war völlig zerdrückt.",
437
+ "Schlechte Lieferung, der Bote hat nicht einmal geklingelt.",
438
+ ],
439
+ },
440
+ "after_sales_support": {
441
+ "pos": [
442
+ "Der Kundenservice hat mein Problem schnell und freundlich gelöst.",
443
+ "Das After-Sales-Team antwortete innerhalb weniger Minuten.",
444
+ "Ausgezeichneter Support, der Mitarbeiter hat sich sehr eingesetzt.",
445
+ "Meine Erstattung wurde schnell bearbeitet, hilfreicher Chat.",
446
+ ],
447
+ "neu": [
448
+ "Der Support hat geantwortet, aber erst nach zwei Tagen.",
449
+ "Der Mitarbeiter war freundlich, konnte mein Problem aber nicht lösen.",
450
+ "Der Support war okay, ich musste meine Daten mehrfach wiederholen.",
451
+ "Ordentliche Hilfe, aber die Antwort war etwas generisch.",
452
+ ],
453
+ "neg": [
454
+ "Ich hing 40 Minuten in der Warteschleife und wurde dann getrennt.",
455
+ "Der After-Sales-Support ist nutzlos, niemand antwortet auf E-Mails.",
456
+ "Meine Beschwerde wurde wochenlang ignoriert.",
457
+ "Der Mitarbeiter war nicht hilfreich, ich musste dreimal anrufen.",
458
+ ],
459
+ },
460
+ },
461
+ }
462
+
463
+ # Optional follow-up sentences (added ~35% of the time) for extra variety.
464
+ FOLLOW_UPS = {
465
+ "en-GB": [
466
+ "I use the site a few times a week on my phone.",
467
+ "This is the second order I have placed this month.",
468
+ "I would recommend the store to friends and family.",
469
+ "I mainly shop during the weekend sales.",
470
+ "The mobile app is my preferred way to order.",
471
+ ],
472
+ "fr-FR": [
473
+ "Je commande sur le site plusieurs fois par semaine.",
474
+ "C'est ma deuxième commande ce mois-ci.",
475
+ "Je recommande volontiers cette boutique à mes proches.",
476
+ "Je fais mes achats surtout pendant les ventes du week-end.",
477
+ "J'utilise surtout l'application mobile pour commander.",
478
+ ],
479
+ "de-DE": [
480
+ "Ich bestelle mehrmals pro Woche über die Website.",
481
+ "Das ist meine zweite Bestellung in diesem Monat.",
482
+ "Ich würde den Shop an Freunde und Familie weiterempfehlen.",
483
+ "Ich kaufe vor allem an den Wochenenden im Sale ein.",
484
+ "Ich bestelle am liebsten über die Mobile-App.",
485
+ ],
486
+ }
487
+
488
+ # ---------------------------------------------------------------------------
489
+ # PII scrubbing for free-text (GDPR)
490
+ # ---------------------------------------------------------------------------
491
+ PII_PATTERNS = [
492
+ re.compile(r"[A-Za-z0-9._%+\-]+@[A-Za-z0-9.\-]+\.[A-Za-z]{2,}"), # email
493
+ re.compile(r"(?<!\d)(?:\+?\d[\d\s().\-/]{7,}\d)(?!\d)"), # phone
494
+ re.compile(r"\b[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}\b"), # UK postcode
495
+ re.compile(r"\b\d{5}\b"), # FR postcode
496
+ re.compile(r"\b\d{5}\b"), # DE postcode
497
+ re.compile(r"\b(?:\d{4}[ -]?){3}\d{4}\b"), # card-like number
498
+ ]
499
+
500
+ PII_REDACTION = "[REDACTED]"
501
+
502
+
503
+ def scrub_text(text: str) -> str:
504
+ """Remove residual personal data from free text."""
505
+ scrubbed = text
506
+ for pattern in PII_PATTERNS:
507
+ scrubbed = pattern.sub(PII_REDACTION, scrubbed)
508
+ return scrubbed
509
+
510
+
511
+ # ---------------------------------------------------------------------------
512
+ # Pseudonymisation helpers
513
+ # ---------------------------------------------------------------------------
514
+ def pseudonym(value: str, namespace: str) -> str:
515
+ """Deterministic HMAC-SHA256 pseudonym (non-reversible without salt)."""
516
+ digest = hmac.new(
517
+ PSEUDO_SALT.encode("utf-8"),
518
+ f"{namespace}:{value}".encode("utf-8"),
519
+ hashlib.sha256,
520
+ ).hexdigest()
521
+ return digest[:16]
522
+
523
+
524
+ def random_token(prefix: str, length: int = 12) -> str:
525
+ alphabet = string.ascii_lowercase + string.digits
526
+ return f"{prefix}-" + "".join(secrets.choice(alphabet) for _ in range(length))
527
+
528
+
529
+ # ---------------------------------------------------------------------------
530
+ # Raw record generation (with fake PII - never published)
531
+ # ---------------------------------------------------------------------------
532
+ FIRST_NAMES = {
533
+ "en-GB": ["Oliver", "Amelia", "George", "Sophie", "Jack", "Emily", "Harry", "Grace", "Charlie", "Freya"],
534
+ "fr-FR": ["Lucas", "Emma", "Louis", "Jade", "Gabriel", "Louise", "Hugo", "Chloé", "Arthur", "Léa"],
535
+ "de-DE": ["Jonas", "Mia", "Leon", "Emma", "Finn", "Lena", "Paul", "Hannah", "Elias", "Lea"],
536
+ }
537
+ LAST_NAMES = {
538
+ "en-GB": ["Smith", "Jones", "Taylor", "Brown", "Williams", "Davies", "Evans", "Wilson"],
539
+ "fr-FR": ["Martin", "Bernard", "Dubois", "Thomas", "Robert", "Richard", "Petit", "Durand"],
540
+ "de-DE": ["Müller", "Schmidt", "Schneider", "Fischer", "Weber", "Meyer", "Wagner", "Becker"],
541
+ }
542
+ CITIES = {
543
+ "en-GB": ["London", "Manchester", "Birmingham", "Leeds", "Glasgow", "Bristol", "Edinburgh"],
544
+ "fr-FR": ["Paris", "Lyon", "Marseille", "Toulouse", "Nice", "Nantes", "Strasbourg"],
545
+ "de-DE": ["Berlin", "München", "Hamburg", "Köln", "Frankfurt", "Stuttgart", "Düsseldorf"],
546
+ }
547
+ DOMAINS = ["example.com", "mail.test", "webmail.eu"]
548
+
549
+
550
+ def fake_pii(lang: str, idx: int) -> dict:
551
+ fn = random.choice(FIRST_NAMES[lang])
552
+ ln = random.choice(LAST_NAMES[lang])
553
+ email = f"{fn.lower()}.{ln.lower()}{idx}@{random.choice(DOMAINS)}"
554
+ phone = "+44 7" + "".join(random.choices(string.digits, k=8))
555
+ if lang == "fr-FR":
556
+ phone = "+33 6 " + "".join(random.choices(string.digits, k=8))
557
+ elif lang == "de-DE":
558
+ phone = "+49 15" + "".join(random.choices(string.digits, k=8))
559
+ city = random.choice(CITIES[lang])
560
+ address = f"{random.randint(1, 240)} {random.choice(['High', 'Green', 'Station', 'Church', 'Market'])} {random.choice(['Street', 'Road', 'Lane', 'Avenue'])}, {city}"
561
+ return {
562
+ "user_email": email,
563
+ "user_name": f"{fn} {ln}",
564
+ "phone_number": phone,
565
+ "address": address,
566
+ }
567
+
568
+
569
+ def generate_batch(lang: str, n: int, start_ts: datetime, end_ts: datetime, global_start_idx: int) -> list[dict]:
570
+ """Generate n raw records for a language in a time window."""
571
+ market = next(m for m in MARKETS if m["language"] == lang)
572
+ rows = []
573
+ delta = (end_ts - start_ts).total_seconds()
574
+ for i in range(n):
575
+ ts = start_ts + timedelta(seconds=random.random() * delta)
576
+ dim = random.choice(DIMENSIONS)
577
+ rating = random.choices([1, 2, 3, 4, 5], weights=[7, 12, 22, 33, 26])[0]
578
+ band = "pos" if rating >= 4 else ("neu" if rating == 3 else "neg")
579
+ text = random.choice(FEEDBACK[lang][dim][band])
580
+ if random.random() < 0.35:
581
+ text += " " + random.choice(FOLLOW_UPS[lang])
582
+ pii = fake_pii(lang, global_start_idx + i)
583
+ rows.append(
584
+ {
585
+ "user_id": f"user-{global_start_idx + i:07d}",
586
+ "user_email": pii["user_email"],
587
+ "user_name": pii["user_name"],
588
+ "phone_number": pii["phone_number"],
589
+ "address": pii["address"],
590
+ "session_id_raw": f"session-{secrets.token_hex(8)}",
591
+ "market_region": market["region"],
592
+ "country_code": market["country_code"],
593
+ "language": lang,
594
+ "timestamp": ts.isoformat(timespec="seconds"),
595
+ "experience_dimension": dim,
596
+ "rating": rating,
597
+ "feedback_text": text,
598
+ "device_type": random.choice(DEVICE_TYPES),
599
+ "source_channel": random.choice(SOURCE_CHANNELS),
600
+ }
601
+ )
602
+ return rows
603
+
604
+
605
+ def anonymise(raw_rows: list[dict]) -> pd.DataFrame:
606
+ """GDPR pipeline: drop direct PII, pseudonymise IDs, scrub free text."""
607
+ out = []
608
+ for r in raw_rows:
609
+ out.append(
610
+ {
611
+ "feedback_id": random_token("F", 12).upper(),
612
+ "user_pseudo_id": pseudonym(r["user_id"], "user"),
613
+ "session_id": pseudonym(r["session_id_raw"], "session"),
614
+ "market_region": r["market_region"],
615
+ "country_code": r["country_code"],
616
+ "language": r["language"],
617
+ "timestamp": r["timestamp"],
618
+ "experience_dimension": r["experience_dimension"],
619
+ "rating": int(r["rating"]),
620
+ "feedback_text": scrub_text(r["feedback_text"]),
621
+ "device_type": r["device_type"],
622
+ "source_channel": r["source_channel"],
623
+ }
624
+ )
625
+ df = pd.DataFrame(out)
626
+ # Enforce column order and UTF-8
627
+ cols = [
628
+ "feedback_id", "user_pseudo_id", "session_id", "market_region",
629
+ "country_code", "language", "timestamp", "experience_dimension",
630
+ "rating", "feedback_text", "device_type", "source_channel",
631
+ ]
632
+ df = df[cols]
633
+ # Ensure feedback_text is truly str and UTF-8 clean
634
+ df["feedback_text"] = df["feedback_text"].astype(str).apply(
635
+ lambda s: s.encode("utf-8", errors="replace").decode("utf-8")
636
+ )
637
+ return df
638
+
639
+
640
+ def sha256_file(path: str) -> str:
641
+ h = hashlib.sha256()
642
+ with open(path, "rb") as f:
643
+ for chunk in iter(lambda: f.read(65536), b""):
644
+ h.update(chunk)
645
+ return h.hexdigest()
646
+
647
+
648
+ def write_snapshot(df: pd.DataFrame, version: str, window_label: str, window_start: str, window_end: str, added: int):
649
+ os.makedirs(os.path.join(SNAPSHOT_DIR, version), exist_ok=True)
650
+ parquet_path = os.path.join(SNAPSHOT_DIR, version, f"ux_feedback_{version}.parquet")
651
+ csv_path = os.path.join(SNAPSHOT_DIR, version, f"ux_feedback_{version}.csv")
652
+ df.to_parquet(parquet_path, index=False)
653
+ df.to_csv(csv_path, index=False, encoding="utf-8")
654
+
655
+ # canonical 'current' files at data/
656
+ os.makedirs(DATA_DIR, exist_ok=True)
657
+ df.to_parquet(os.path.join(DATA_DIR, "ux_feedback_live.parquet"), index=False)
658
+ df.to_csv(os.path.join(DATA_DIR, "ux_feedback_live.csv"), index=False, encoding="utf-8")
659
+
660
+ return {
661
+ "version": version,
662
+ "window_label": window_label,
663
+ "window_start_utc": window_start,
664
+ "window_end_utc": window_end,
665
+ "records_added": added,
666
+ "total_records": int(len(df)),
667
+ "sha256_parquet": sha256_file(parquet_path),
668
+ "sha256_csv": sha256_file(csv_path),
669
+ "parquet_path": f"snapshots/{version}/ux_feedback_{version}.parquet",
670
+ "csv_path": f"snapshots/{version}/ux_feedback_{version}.csv",
671
+ "canonical_parquet": "data/ux_feedback_live.parquet",
672
+ "canonical_csv": "data/ux_feedback_live.csv",
673
+ "gdpr_anonymised": True,
674
+ "pii_fields_dropped": ["user_id", "user_email", "user_name", "phone_number", "address"],
675
+ }
676
+
677
+
678
+ def main():
679
+ random.seed(20260813)
680
+ rng_state = random.getstate()
681
+
682
+ now = datetime.now(timezone.utc)
683
+ base_now = now.replace(second=0, microsecond=0)
684
+
685
+ # Version schedule (30-minute refresh cadence)
686
+ schedule = [
687
+ # (version, window_label, start, end, records_to_generate)
688
+ ("v1.0.0", "initial_release", base_now - timedelta(hours=24), base_now, 5000),
689
+ ("v1.1.0", "update_30min", base_now, base_now + timedelta(minutes=30), 750),
690
+ ("v1.2.0", "update_60min", base_now + timedelta(minutes=30), base_now + timedelta(minutes=60), 750),
691
+ ]
692
+
693
+ # Raw records per language so each market is represented in every window
694
+ manifest_versions = []
695
+ cumulative_raw: list[dict] = []
696
+
697
+ # Also keep a raw (PII) dump ONLY to demonstrate the pipeline internally.
698
+ os.makedirs(RAW_DIR, exist_ok=True)
699
+ raw_log_path = os.path.join(RAW_DIR, "raw_with_pii_sample.jsonl")
700
+
701
+ with open(raw_log_path, "w", encoding="utf-8") as raw_log:
702
+ for version, label, wstart, wend, total in schedule:
703
+ n_per_lang = total // len(MARKETS)
704
+ raw_batch = []
705
+ for m in MARKETS:
706
+ raw_batch.extend(generate_batch(m["language"], n_per_lang, wstart, wend, len(cumulative_raw) + len(raw_batch)))
707
+ random.setstate(rng_state)
708
+ random.shuffle(raw_batch)
709
+ cumulative_raw.extend(raw_batch)
710
+ for row in raw_batch:
711
+ raw_log.write(json.dumps(row, ensure_ascii=False) + "\n")
712
+
713
+ df = anonymise(cumulative_raw)
714
+ info = write_snapshot(
715
+ df, version, label,
716
+ wstart.isoformat(timespec="seconds"),
717
+ wend.isoformat(timespec="seconds"),
718
+ added=len(raw_batch),
719
+ )
720
+ manifest_versions.append(info)
721
+ print(f"[{version}] window={label} added={info['records_added']} total={info['total_records']}")
722
+
723
+ # Write the version manifest + changelog
724
+ os.makedirs(VERSION_DIR, exist_ok=True)
725
+ manifest = {
726
+ "dataset": "EU-Retail-UX-Feedback-Live",
727
+ "description": "Live, GDPR-anonymised user-experience feedback from EU e-commerce retail (UK, FR, DE).",
728
+ "refresh_cadence_minutes": 30,
729
+ "encoding": "UTF-8",
730
+ "languages": ["en-GB", "fr-FR", "de-DE"],
731
+ "markets": ["United Kingdom", "France", "Germany"],
732
+ "pii_handling": "deleted_and_pseudonymised",
733
+ "latest_version": manifest_versions[-1]["version"],
734
+ "versions": manifest_versions,
735
+ }
736
+ with open(os.path.join(VERSION_DIR, "manifest.json"), "w", encoding="utf-8") as f:
737
+ json.dump(manifest, f, ensure_ascii=False, indent=2)
738
+
739
+ changelog_lines = [
740
+ "# Changelog - EU-Retail-UX-Feedback-Live",
741
+ "",
742
+ "This dataset is refreshed every 30 minutes. Every published snapshot is",
743
+ "immutable, checksummed (SHA-256) and tagged so that any previous version",
744
+ "can be restored (rollback).",
745
+ "",
746
+ ]
747
+ for v in manifest_versions:
748
+ changelog_lines.append(
749
+ f"## {v['version']} - {v['window_label']}\n"
750
+ f"- Window: {v['window_start_utc']} -> {v['window_end_utc']} UTC\n"
751
+ f"- Records added: {v['records_added']} | Total records: {v['total_records']}\n"
752
+ f"- SHA-256 (parquet): `{v['sha256_parquet']}`\n"
753
+ f"- SHA-256 (csv): `{v['sha256_csv']}`\n"
754
+ )
755
+ with open(os.path.join(VERSION_DIR, "CHANGELOG.md"), "w", encoding="utf-8") as f:
756
+ f.write("\n".join(changelog_lines))
757
+
758
+ # Summary printout
759
+ print("\n=== SUMMARY ===")
760
+ print(json.dumps(manifest, indent=2, ensure_ascii=False))
761
+ print("\nFiles written under:", BASE_DIR)
762
+
763
+
764
+ if __name__ == "__main__":
765
+ main()
snapshots/v1.0.0/ux_feedback_v1.0.0.csv ADDED
The diff for this file is too large to render. See raw diff
 
snapshots/v1.0.0/ux_feedback_v1.0.0.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3882044cf28acfb8ece9f5140d0ccdab4a6636d32c4ca2890f63b240e12bfe54
3
+ size 361934
versions/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Changelog - EU-Retail-UX-Feedback-Live
2
+
3
+ This dataset is refreshed every 30 minutes. Every published snapshot is
4
+ immutable, checksummed (SHA-256) and tagged so that any previous version
5
+ can be restored (rollback).
6
+
7
+ ## v1.0.0 - initial_release
8
+ - Window: 2026-08-12T13:47:00+00:00 -> 2026-08-13T13:47:00+00:00 UTC
9
+ - Records added: 4998 | Total records: 4998
10
+ - SHA-256 (parquet): `3882044cf28acfb8ece9f5140d0ccdab4a6636d32c4ca2890f63b240e12bfe54`
11
+ - SHA-256 (csv): `56851d47bd604fcd9c52193e164afe1ac2b1b43f3a651dada950304ab3f1d01f`
versions/manifest.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dataset": "EU-Retail-UX-Feedback-Live",
3
+ "description": "Live, GDPR-anonymised user-experience feedback from EU e-commerce retail (UK, FR, DE).",
4
+ "refresh_cadence_minutes": 30,
5
+ "encoding": "UTF-8",
6
+ "languages": [
7
+ "en-GB",
8
+ "fr-FR",
9
+ "de-DE"
10
+ ],
11
+ "markets": [
12
+ "United Kingdom",
13
+ "France",
14
+ "Germany"
15
+ ],
16
+ "pii_handling": "deleted_and_pseudonymised",
17
+ "latest_version": "v1.0.0",
18
+ "versions": [
19
+ {
20
+ "version": "v1.0.0",
21
+ "window_label": "initial_release",
22
+ "window_start_utc": "2026-08-12T13:47:00+00:00",
23
+ "window_end_utc": "2026-08-13T13:47:00+00:00",
24
+ "records_added": 4998,
25
+ "total_records": 4998,
26
+ "sha256_parquet": "3882044cf28acfb8ece9f5140d0ccdab4a6636d32c4ca2890f63b240e12bfe54",
27
+ "sha256_csv": "56851d47bd604fcd9c52193e164afe1ac2b1b43f3a651dada950304ab3f1d01f",
28
+ "parquet_path": "snapshots/v1.0.0/ux_feedback_v1.0.0.parquet",
29
+ "csv_path": "snapshots/v1.0.0/ux_feedback_v1.0.0.csv",
30
+ "canonical_parquet": "data/ux_feedback_live.parquet",
31
+ "canonical_csv": "data/ux_feedback_live.csv",
32
+ "gdpr_anonymised": true,
33
+ "pii_fields_dropped": [
34
+ "user_id",
35
+ "user_email",
36
+ "user_name",
37
+ "phone_number",
38
+ "address"
39
+ ]
40
+ }
41
+ ]
42
+ }