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(); };