fix: previews Meta vía proxy y creatividades Google PMax/RSA
Las imágenes Meta dejan de romperse en el navegador; Google trae assets en vivo. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -36,6 +36,7 @@ export type AdCreativeCard = {
|
||||
headline: string;
|
||||
primaryText: string;
|
||||
status?: string;
|
||||
youtubeId?: string;
|
||||
};
|
||||
|
||||
type DailyAgg = {
|
||||
@@ -193,8 +194,9 @@ async function fetchMetaCreativeBundle(
|
||||
}, token);
|
||||
|
||||
let creative = (raw.creative || {}) as Record<string, unknown>;
|
||||
// Only hydrate creative detail when thumbnail/image missing
|
||||
const cid = str(creative.id);
|
||||
if (cid) {
|
||||
if (cid && !str(creative.thumbnail_url) && !str(creative.image_url)) {
|
||||
try {
|
||||
const detail = await graphGet<Record<string, unknown>>(
|
||||
cid,
|
||||
@@ -248,16 +250,16 @@ export async function fetchMetaCreativeCards(opts: {
|
||||
'meta',
|
||||
opts.since,
|
||||
opts.until
|
||||
).slice(0, opts.limit ?? 40);
|
||||
).slice(0, opts.limit ?? 16);
|
||||
|
||||
if (!aggs.length) {
|
||||
return { ads: [], warning: 'Sin ads Meta en ad_daily para este periodo' };
|
||||
}
|
||||
|
||||
const out: AdCreativeCard[] = [];
|
||||
// Sequential batches of 5 to respect rate limits
|
||||
for (let i = 0; i < aggs.length; i += 5) {
|
||||
const chunk = aggs.slice(i, i + 5);
|
||||
// Parallel batches of 8 — single Graph call per ad (thumbnail already in creative{})
|
||||
for (let i = 0; i < aggs.length; i += 8) {
|
||||
const chunk = aggs.slice(i, i + 8);
|
||||
const bundles = await Promise.all(
|
||||
chunk.map((a) => fetchMetaCreativeBundle(a.adId, token))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user