Some checks failed
CI / Lint, Unit & Integration Tests (push) Has been cancelled
Replace the customers/data_request, customers/redact, and shop/redact stubs with real logic in app/services/gdpr.server.ts: compile a customer's Booking history, anonymize customerEmail/customerPhone on redact, and purge every shopDomain-scoped row on shop uninstall (Booking before Location, relying on Location's cascade for SlotTemplate/SlotOverride/BlackoutDate/Zone/Rate). Covered by a new tests/integration/gdpr.test.ts against live Postgres to verify the FK deletion order actually works, not just typechecks. Still commented out in shopify.app.toml pending Protected customer data access approval in the Partner Dashboard — unrelated to code readiness. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
23 lines
981 B
TypeScript
23 lines
981 B
TypeScript
import type { ActionFunctionArgs } from "@remix-run/node";
|
|
import { authenticate } from "../shopify.server";
|
|
import { compileCustomerData, type CustomerWebhookPayload } from "../services/gdpr.server";
|
|
|
|
// GDPR: a customer (or Shopify on their behalf) requesting their data.
|
|
// Shopify requires the app to make the data available to the merchant
|
|
// within 30 days; there's no response payload on the webhook itself, so we
|
|
// log the compiled records for the merchant to hand off (a self-serve
|
|
// export/notification is a Phase 9+ enhancement).
|
|
export const action = async ({ request }: ActionFunctionArgs) => {
|
|
const { shop, topic, payload } = await authenticate.webhook(request);
|
|
const { customer } = payload as CustomerWebhookPayload;
|
|
|
|
const bookings = await compileCustomerData(shop, customer);
|
|
|
|
console.log(
|
|
`[gdpr] ${topic} for ${shop}: customer ${customer?.id ?? "unknown"} — ${bookings.length} booking(s) found`,
|
|
bookings,
|
|
);
|
|
|
|
return new Response();
|
|
};
|