fix: Meta Ads muestra clics todos y clics enlace (y ambos CPC)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { isAgencyRole, userRole } from '@/lib/agency';
|
||||
import { AdDailyRow } from '@/lib/metrics';
|
||||
import {
|
||||
AdCreativeCard,
|
||||
fetchMetaAccountClickSplit,
|
||||
fetchMetaCreativeCards,
|
||||
} from '@/lib/ad-creatives-meta';
|
||||
import { fetchGoogleCreativeCards } from '@/lib/ad-creatives-google';
|
||||
@@ -66,16 +67,29 @@ export async function GET(req: NextRequest) {
|
||||
const warnings: string[] = [];
|
||||
let metaAds: AdCreativeCard[] = [];
|
||||
let googleAds: AdCreativeCard[] = [];
|
||||
let metaClickSplit: {
|
||||
clicks: number;
|
||||
linkClicks: number;
|
||||
spend: number;
|
||||
} | null = null;
|
||||
|
||||
if (platform === 'meta' || platform === 'all') {
|
||||
const meta = await fetchMetaCreativeCards({
|
||||
tenantId: ctx.tenantId,
|
||||
dailyRows: daily,
|
||||
since,
|
||||
until,
|
||||
limit: 16,
|
||||
});
|
||||
const [meta, clickSplit] = await Promise.all([
|
||||
fetchMetaCreativeCards({
|
||||
tenantId: ctx.tenantId,
|
||||
dailyRows: daily,
|
||||
since,
|
||||
until,
|
||||
limit: 16,
|
||||
}),
|
||||
fetchMetaAccountClickSplit({
|
||||
tenantId: ctx.tenantId,
|
||||
since,
|
||||
until,
|
||||
}),
|
||||
]);
|
||||
metaAds = meta.ads;
|
||||
metaClickSplit = clickSplit;
|
||||
if (meta.warning) warnings.push(meta.warning);
|
||||
}
|
||||
|
||||
@@ -99,6 +113,7 @@ export async function GET(req: NextRequest) {
|
||||
ads: [...metaAds, ...googleAds],
|
||||
metaCount: metaAds.length,
|
||||
googleCount: googleAds.length,
|
||||
metaClickSplit,
|
||||
warnings,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user