Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+15
-14
@@ -12,32 +12,33 @@
|
||||
*/
|
||||
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
import { runWithRlsContext } from "@hivegrid/db/rls-context.server";
|
||||
import { resolveEmailSequenceDeliveryRlsIdentity } from "@hivegrid/db/rls-resolvers.server";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { createScopedLogger } from "~/utils/logger.server";
|
||||
|
||||
const logger = createScopedLogger("marketing.tracking.open");
|
||||
|
||||
// 1x1 transparent GIF (43 bytes).
|
||||
const PIXEL = Buffer.from(
|
||||
"47494638396101000100800000FFFFFF00000021F90401000001002C00000000010001000002024401003B",
|
||||
"hex"
|
||||
);
|
||||
const PIXEL = Buffer.from("47494638396101000100800000FFFFFF00000021F90401000001002C00000000010001000002024401003B", "hex");
|
||||
|
||||
export async function loader({ params }: LoaderFunctionArgs): Promise<Response> {
|
||||
const deliveryId = params.deliveryId ?? "";
|
||||
if (deliveryId.length > 0) {
|
||||
try {
|
||||
// Use updateMany so a missing row is a soft no-op, not a P2025
|
||||
// exception; and only flip openedAt the FIRST time.
|
||||
await db.emailSequenceStepDelivery.updateMany({
|
||||
where: { id: deliveryId, openedAt: null },
|
||||
data: { openedAt: new Date() },
|
||||
});
|
||||
const identity = await resolveEmailSequenceDeliveryRlsIdentity(deliveryId);
|
||||
if (identity) {
|
||||
// Use updateMany so a missing row is a soft no-op, not a P2025
|
||||
// exception; and only flip openedAt the FIRST time.
|
||||
await runWithRlsContext({ tenantId: identity.tenantId }, () =>
|
||||
db.emailSequenceStepDelivery.updateMany({
|
||||
where: { id: identity.resourceId, openedAt: null },
|
||||
data: { openedAt: new Date() },
|
||||
})
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn(
|
||||
{ op: "marketing.tracking.open.error", deliveryId, errorName: (err as Error)?.name },
|
||||
"open tracker update failed"
|
||||
);
|
||||
logger.warn({ op: "marketing.tracking.open.error", deliveryId, errorName: (err as Error)?.name }, "open tracker update failed");
|
||||
}
|
||||
}
|
||||
return new Response(PIXEL, {
|
||||
|
||||
Reference in new issue
Block a user