Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(api): add scrape_id and team_id to branding Sentry errors, respect ZDR (#3196)

Abimael Martellb85d52fd3452
diff --git a/apps/api/src/lib/branding/llm.ts b/apps/api/src/lib/branding/llm.ts
index 4748e3ac3..82005f398 100644
--- a/apps/api/src/lib/branding/llm.ts
+++ b/apps/api/src/lib/branding/llm.ts
@@ -1,11 +1,11 @@
import { generateObject } from "ai";
-import * as Sentry from "@sentry/node";
import { logger } from "../logger";
import { config } from "../../config";
import { BrandingEnhancement, getBrandingEnhancementSchema } from "./schema";
import { buildBrandingPrompt } from "./prompt";
import { BrandingLLMInput } from "./types";
import { getModel } from "../generic-ai";
+import { captureExceptionWithZdrCheck } from "../../services/sentry";
function isDebugBrandingEnabled(input: BrandingLLMInput): boolean {
return (
@@ -192,17 +192,21 @@ export async function enhanceBrandingWithLLM(
},
);
} else {
- Sentry.withScope(scope => {
- scope.setTag("feature", "branding-llm");
- scope.setTag("model", modelName);
- scope.setContext("branding_llm", {
+ captureExceptionWithZdrCheck(error, {
+ tags: {
+ feature: "branding-llm",
+ model: modelName,
+ ...(input.scrapeId ? { scrape_id: input.scrapeId } : {}),
+ ...(input.teamId ? { team_id: input.teamId } : {}),
+ },
+ extra: {
url: input.url,
buttonsCount: input.buttons?.length || 0,
logoCandidatesCount: input.logoCandidates?.length || 0,
promptLength: prompt.length,
hasScreenshot: !!input.screenshot,
- });
- Sentry.captureException(error);
+ },
+ zeroDataRetention: input.zeroDataRetention,
});
logger.error("LLM branding enhancement failed", {
error,
diff --git a/apps/api/src/lib/branding/transformer.ts b/apps/api/src/lib/branding/transformer.ts
index 7389450bd..a9e7adfe4 100644
--- a/apps/api/src/lib/branding/transformer.ts
+++ b/apps/api/src/lib/branding/transformer.ts
@@ -193,6 +193,8 @@ export async function brandingTransformer(
ogImage: brandingProfile.images?.ogImage ?? undefined,
heuristicLogoPick,
teamId: meta.internalOptions.teamId,
+ scrapeId: meta.id,
+ zeroDataRetention: meta.internalOptions.zeroDataRetention,
teamFlags: meta.internalOptions.teamFlags,
});
diff --git a/apps/api/src/lib/branding/types.ts b/apps/api/src/lib/branding/types.ts
index ef7ad7aa4..13c394897 100644
--- a/apps/api/src/lib/branding/types.ts
+++ b/apps/api/src/lib/branding/types.ts
@@ -91,6 +91,8 @@ export interface BrandingLLMInput {
reasoning: string;
};
teamId?: string;
+ scrapeId?: string;
+ zeroDataRetention?: boolean;
teamFlags?: { debugBranding?: boolean } | null;
}