GDPR 合规 是做什么的?
规则
- 实现数据删除端点(被遗忘权):根据请求删除或匿名化所有用户 PII
- 使用时间戳追踪明确同意:记录用户同意内容、时间及政策版本
- 在分析和日志中匿名化 PII:使用不透明 ID,绝不使用原始电子邮件或姓名
- 实现数据导出端点(可移植性):以 JSON 或 CSV 格式返回所有用户数据
- 显示 Cookie 同意横幅:在用户选择加入之前,不加载任何跟踪脚本
- 在每个包含数据收集表单的页面上链接到隐私政策
- 维护 PII 访问审计日志:记录谁查看了哪些个人数据以及查看时间
- 72 小时违规通知:准备记录在案的处理流程和联系人名单
app.delete("/api/user/data", requireAuth, async (req, res) => {
const userId = req.user.id;
await db.transaction(async (tx) => {
await tx.delete(userProfiles).where(eq(userProfiles.userId, userId));
await tx.delete(userSessions).where(eq(userSessions.userId, userId));
await tx.update(users).set({
email: `deleted_${userId}@anonymized.local`,
name: "Deleted User",
deletedAt: new Date(),
}).where(eq(users.id, userId));
});
await auditLog("user_data_deleted", { userId, requestedBy: userId });
res.json({ success: true });
});
const consentSchema = z.object({
marketing: z.boolean(),
analytics: z.boolean(),
policyVersion: z.string(),
});
app.post("/api/consent", requireAuth, async (req, res) => {
const consent = consentSchema.parse(req.body);
await db.insert(consentRecords).values({
userId: req.user.id,
...consent,
consentedAt: new Date(),
ipAddress: req.ip,
});
res.json({ success: true });
});
避免
- 软删除用户数据而不实际移除 PII —— “已删除”用户的电子邮件仍留在数据库中
- 在获得 Cookie 同意之前加载 Google Analytics 或跟踪像素
- 在分析事件或应用程序日志中存储原始电子邮件
- 没有数据导出机制 —— 用户对其数据拥有合法权利
- 假设 GDPR 仅适用于欧盟公司 —— 它适用于任何为欧盟用户服务的应用程序