Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

small updates

Steven Teya8c61f46649a
diff --git a/apps/web/app/api/shopify/integration/webhook/customers-data-request.ts b/apps/web/app/api/shopify/integration/webhook/customers-data-request.ts
index d29b219c22..ad36d5ecde 100644
--- a/apps/web/app/api/shopify/integration/webhook/customers-data-request.ts
+++ b/apps/web/app/api/shopify/integration/webhook/customers-data-request.ts
@@ -19,22 +19,30 @@ export async function customersDataRequest({
workspaceId: string;
}) {
const {
- customer,
+ customer: { id: customerExternalId },
shop_domain: shopDomain,
orders_requested: ordersRequested,
} = schema.parse(event);
- const customerExternalId = customer.id.toString();
-
- const { userId } = await prisma.projectUsers.findFirstOrThrow({
- where: {
- projectId: workspaceId,
- role: "owner",
- },
- select: {
- userId: true,
- },
- });
+ const [user, customer] = await Promise.all([
+ prisma.projectUsers.findFirstOrThrow({
+ where: {
+ projectId: workspaceId,
+ role: "owner",
+ },
+ select: {
+ userId: true,
+ },
+ }),
+ prisma.customer.findUnique({
+ where: {
+ projectId_externalId: {
+ projectId: workspaceId,
+ externalId: customerExternalId.toString(),
+ },
+ },
+ }),
+ ]);
const rows = [
{
@@ -43,7 +51,15 @@ export async function customersDataRequest({
},
{
text: "Customer ID",
- value: customerExternalId,
+ value: customerExternalId.toString(),
+ },
+ {
+ text: "Customer name",
+ value: customer?.name ?? "N/A",
+ },
+ {
+ text: "Customer email",
+ value: customer?.email ?? "N/A",
},
...(ordersRequested.length > 0
? [{ text: "Orders requested", value: ordersRequested.join(", ") }]
@@ -52,7 +68,7 @@ export async function customersDataRequest({
waitUntil(
createPlainThread({
- userId,
+ userId: user.userId,
title: `Shopify - Customer data request received for ${shopDomain}`,
components: rows.map((row) => ({
componentRow: {
diff --git a/apps/web/app/api/shopify/integration/webhook/customers-redact.ts b/apps/web/app/api/shopify/integration/webhook/customers-redact.ts
index 6fd18ba8e9..2db29b9f41 100644
--- a/apps/web/app/api/shopify/integration/webhook/customers-redact.ts
+++ b/apps/web/app/api/shopify/integration/webhook/customers-redact.ts
@@ -1,3 +1,4 @@
+import { generateRandomName } from "@/lib/names";
import { createPlainThread } from "@/lib/plain";
import { prisma } from "@dub/prisma";
import { waitUntil } from "@vercel/functions";
@@ -36,8 +37,8 @@ export async function customersRedact({
},
},
data: {
- name: "Redacted",
- email: "Redacted",
+ name: generateRandomName(),
+ email: null,
},
});
} catch (error) {