@adkit/cli 1.12.11 → 1.12.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +62 -43
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1380,28 +1380,30 @@ function readMediaFormatFlag(value) {
|
|
|
1380
1380
|
throw new CliError("INVALID_VALUE", `Invalid --media-format: ${value}`, "Use one of: default, square, vertical, horizontal.");
|
|
1381
1381
|
}
|
|
1382
1382
|
async function listResults(client, args, flags) {
|
|
1383
|
-
validateFlags(flags, ["campaign", "adset", "ad", "
|
|
1383
|
+
validateFlags(flags, ["account", "campaign-ids", "adset-ids", "ad-ids", "statuses", "period", "from", "to", "fields", "conversion-event-keys", "attribution-window", "breakdowns", "sort", "sort-direction", "limit", "offset", "confirm", "raw"], "manage meta results");
|
|
1384
1384
|
const accountId = typeof flags.account === "string" ? flags.account : void 0;
|
|
1385
1385
|
const level = parseResultsLevel(args);
|
|
1386
1386
|
warnIgnoredResultsArgs(args);
|
|
1387
|
-
const
|
|
1388
|
-
const
|
|
1389
|
-
const
|
|
1390
|
-
const
|
|
1387
|
+
const campaignIds = typeof flags["campaign-ids"] === "string" ? flags["campaign-ids"] : void 0;
|
|
1388
|
+
const adsetIds = typeof flags["adset-ids"] === "string" ? flags["adset-ids"] : void 0;
|
|
1389
|
+
const adIds = typeof flags["ad-ids"] === "string" ? flags["ad-ids"] : void 0;
|
|
1390
|
+
const statuses = typeof flags.statuses === "string" ? flags.statuses : void 0;
|
|
1391
1391
|
const period = typeof flags.period === "string" ? flags.period : void 0;
|
|
1392
1392
|
const from = typeof flags.from === "string" ? flags.from : void 0;
|
|
1393
1393
|
const to = typeof flags.to === "string" ? flags.to : void 0;
|
|
1394
|
-
const
|
|
1395
|
-
const
|
|
1394
|
+
const fields = typeof flags.fields === "string" ? flags.fields : void 0;
|
|
1395
|
+
const conversionEventKeys = typeof flags["conversion-event-keys"] === "string" ? flags["conversion-event-keys"] : void 0;
|
|
1396
1396
|
const attributionWindow = typeof flags["attribution-window"] === "string" ? flags["attribution-window"] : void 0;
|
|
1397
|
-
const
|
|
1397
|
+
const breakdowns = typeof flags.breakdowns === "string" ? flags.breakdowns : void 0;
|
|
1398
1398
|
const sort = typeof flags.sort === "string" ? flags.sort : void 0;
|
|
1399
|
+
const sortDirection = typeof flags["sort-direction"] === "string" ? flags["sort-direction"] : void 0;
|
|
1399
1400
|
const limit = typeof flags.limit === "string" ? flags.limit : void 0;
|
|
1401
|
+
const offset = typeof flags.offset === "string" ? flags.offset : void 0;
|
|
1400
1402
|
const confirm = flags.confirm === true ? "true" : void 0;
|
|
1401
1403
|
const raw = flags.raw === true ? "true" : void 0;
|
|
1402
|
-
const hasTimeBreakdown =
|
|
1404
|
+
const hasTimeBreakdown = breakdowns?.split(",").some((b) => b === "day" || b === "week" || b === "month");
|
|
1403
1405
|
if (period === "maximum" && hasTimeBreakdown && !confirm) throw new CliError("INVALID_VALUE", "maximum date range with time breakdowns (day/week/month) can produce very large result sets. Add --confirm to proceed.");
|
|
1404
|
-
const qs = queryString({ accountId, level,
|
|
1406
|
+
const qs = queryString({ accountId, level, campaignIds, adsetIds, adIds, statuses, period, from, to, fields, conversionEventKeys, attributionWindow, breakdowns, sort, sortDirection, limit, offset, confirm, raw });
|
|
1405
1407
|
return client.get(`/manage/meta/results${qs}`);
|
|
1406
1408
|
}
|
|
1407
1409
|
async function createAd(client, _args, flags) {
|
|
@@ -4388,20 +4390,22 @@ var RESULTS_HELP = `adkit manage meta results \u2014 Meta performance insights
|
|
|
4388
4390
|
[campaigns|adsets|ads] Optional level positional arg (default: campaigns)
|
|
4389
4391
|
|
|
4390
4392
|
Flags:
|
|
4391
|
-
--campaign <ids>
|
|
4392
|
-
--adset <ids>
|
|
4393
|
-
--ad <ids>
|
|
4394
|
-
--
|
|
4393
|
+
--campaign-ids <ids> Comma-separated campaign IDs
|
|
4394
|
+
--adset-ids <ids> Comma-separated ad set IDs
|
|
4395
|
+
--ad-ids <ids> Comma-separated ad IDs
|
|
4396
|
+
--statuses <s> active, paused (filter by entity status)
|
|
4395
4397
|
--period <range> Relative range like 7d or preset: today, yesterday, this_month, last_month, this_quarter, last_quarter, this_year, last_year, maximum (default: 30d)
|
|
4396
4398
|
--from <date> Start date, YYYY-MM-DD
|
|
4397
4399
|
--to <date> End date, YYYY-MM-DD
|
|
4398
|
-
--
|
|
4399
|
-
--
|
|
4400
|
+
--fields <list> Normalized fields, e.g. spend, impressions, clicks, conversionEvents, etc
|
|
4401
|
+
--conversion-event-keys <list> purchase,lead or all
|
|
4400
4402
|
--attribution-window <w> 1d_click, 7d_click, 1d_view, 7d_click_1d_view, 28d_click_1d_view
|
|
4401
|
-
--
|
|
4403
|
+
--breakdowns <list> day, week, month, age, gender, country, region, device_platform, publisher_platform, platform_position, impression_device
|
|
4402
4404
|
--confirm Required with --period maximum plus any breakdown
|
|
4403
4405
|
--sort <field> spend = descending, +spend = ascending
|
|
4406
|
+
--sort-direction <d> asc or desc
|
|
4404
4407
|
--limit <n> Limit rows after sorting
|
|
4408
|
+
--offset <n> Skip rows after sorting
|
|
4405
4409
|
--raw Return Meta's paginated response without conversion
|
|
4406
4410
|
|
|
4407
4411
|
Output: always JSON, even in TTY mode.
|
|
@@ -4410,15 +4414,15 @@ Examples:
|
|
|
4410
4414
|
# Campaign overview (default: last 30 days)
|
|
4411
4415
|
adkit manage meta results
|
|
4412
4416
|
# Top-spending ads for a campaign
|
|
4413
|
-
adkit manage meta results ads --campaign 123 --sort spend --limit 10
|
|
4417
|
+
adkit manage meta results ads --campaign-ids 123 --sort spend --limit 10
|
|
4414
4418
|
# Daily performance by age group
|
|
4415
|
-
adkit manage meta results adsets --period 7d --
|
|
4419
|
+
adkit manage meta results adsets --period 7d --breakdowns day,age
|
|
4416
4420
|
# Country breakdown for all time
|
|
4417
|
-
adkit manage meta results ads --period maximum --
|
|
4421
|
+
adkit manage meta results ads --period maximum --breakdowns country --confirm
|
|
4418
4422
|
# Conversion data for a campaign
|
|
4419
|
-
adkit manage meta results --campaign 123 --
|
|
4423
|
+
adkit manage meta results --campaign-ids 123 --conversion-event-keys purchase,lead
|
|
4420
4424
|
# Raw API response with custom metrics
|
|
4421
|
-
adkit manage meta results --campaign 123 --raw --
|
|
4425
|
+
adkit manage meta results --campaign-ids 123 --raw --fields spend,impressions,conversionEvents`.trim();
|
|
4422
4426
|
var CREATIVE_HELP = `adkit manage meta creatives \u2014 Meta ad creatives
|
|
4423
4427
|
|
|
4424
4428
|
Prefer using "ads create --media" which handles creative creation automatically.
|
|
@@ -5913,11 +5917,11 @@ function printResultsCard(data) {
|
|
|
5913
5917
|
const parts = [];
|
|
5914
5918
|
const reportCurrency = str(report, "currency");
|
|
5915
5919
|
const timezone = str(report, "timezone");
|
|
5916
|
-
const attrWindow = str(report, "attribution_window");
|
|
5920
|
+
const attrWindow = str(report, "attributionWindow") ?? str(report, "attribution_window");
|
|
5917
5921
|
if (reportCurrency) parts.push(reportCurrency);
|
|
5918
5922
|
if (timezone) parts.push(timezone);
|
|
5919
5923
|
if (attrWindow) parts.push(attrWindow);
|
|
5920
|
-
const dr = nested(report, "date_range");
|
|
5924
|
+
const dr = nested(report, "dateRange") ?? nested(report, "date_range");
|
|
5921
5925
|
if (dr) {
|
|
5922
5926
|
const from = str(dr, "from");
|
|
5923
5927
|
const to = str(dr, "to");
|
|
@@ -5925,7 +5929,7 @@ function printResultsCard(data) {
|
|
|
5925
5929
|
}
|
|
5926
5930
|
if (parts.length > 0) console.log(parts.join(" \xB7 "));
|
|
5927
5931
|
}
|
|
5928
|
-
const results = data.results;
|
|
5932
|
+
const results = Array.isArray(data.rows) ? data.rows : data.results;
|
|
5929
5933
|
if (!Array.isArray(results) || results.length === 0) {
|
|
5930
5934
|
console.log("\nNo results for this period.");
|
|
5931
5935
|
printWarnings(data.warnings);
|
|
@@ -5933,40 +5937,43 @@ function printResultsCard(data) {
|
|
|
5933
5937
|
}
|
|
5934
5938
|
for (const row of results) {
|
|
5935
5939
|
if (!isObject(row)) continue;
|
|
5936
|
-
const
|
|
5940
|
+
const entity = nested(row, "entity");
|
|
5941
|
+
const metrics = nested(row, "metrics");
|
|
5942
|
+
const breakdown = nested(row, "breakdown");
|
|
5943
|
+
const name = (entity ? str(entity, "name") : void 0) || str(row, "campaign_name") || str(row, "adset_name") || str(row, "ad_name") || "Unknown";
|
|
5937
5944
|
const titleParts = [name];
|
|
5938
|
-
const status2 = str(row, "status");
|
|
5939
|
-
const spend = num(row, "spend");
|
|
5945
|
+
const status2 = (entity ? str(entity, "status") : void 0) || str(row, "status");
|
|
5946
|
+
const spend = (metrics ? num(metrics, "spend") : void 0) ?? num(row, "spend");
|
|
5940
5947
|
if (status2) titleParts.push(status2);
|
|
5941
5948
|
if (spend !== void 0) titleParts.push(`${fmtCurrency(spend, currency)} spent`);
|
|
5942
|
-
const dateStart = str(row, "date_start");
|
|
5943
|
-
const dateStop = str(row, "date_stop");
|
|
5949
|
+
const dateStart = (breakdown ? str(breakdown, "day") ?? str(breakdown, "week") ?? str(breakdown, "month") ?? str(breakdown, "dateStart") : void 0) ?? str(row, "date_start");
|
|
5950
|
+
const dateStop = (breakdown ? str(breakdown, "dateStop") : void 0) ?? str(row, "date_stop");
|
|
5944
5951
|
if (dateStart && dateStop) titleParts.push(`${fmtShortDate(dateStart)} \u2013 ${fmtShortDate(dateStop)}`);
|
|
5945
5952
|
else if (dateStart) titleParts.push(fmtShortDate(dateStart));
|
|
5946
5953
|
else if (dateStop) titleParts.push(fmtShortDate(dateStop));
|
|
5947
|
-
const age = str(row, "age");
|
|
5954
|
+
const age = (breakdown ? str(breakdown, "age") : void 0) ?? str(row, "age");
|
|
5948
5955
|
if (age) titleParts.push(age);
|
|
5949
|
-
const gender = str(row, "gender");
|
|
5956
|
+
const gender = (breakdown ? str(breakdown, "gender") : void 0) ?? str(row, "gender");
|
|
5950
5957
|
if (gender) titleParts.push(gender);
|
|
5951
|
-
const country = str(row, "country");
|
|
5958
|
+
const country = (breakdown ? str(breakdown, "country") : void 0) ?? str(row, "country");
|
|
5952
5959
|
if (country) titleParts.push(country);
|
|
5953
|
-
const region = str(row, "region");
|
|
5960
|
+
const region = (breakdown ? str(breakdown, "region") : void 0) ?? str(row, "region");
|
|
5954
5961
|
if (region) titleParts.push(region);
|
|
5955
|
-
const devicePlatform = str(row, "device_platform");
|
|
5962
|
+
const devicePlatform = (breakdown ? str(breakdown, "devicePlatform") : void 0) ?? str(row, "device_platform");
|
|
5956
5963
|
if (devicePlatform) titleParts.push(devicePlatform);
|
|
5957
|
-
const publisherPlatform = str(row, "publisher_platform");
|
|
5964
|
+
const publisherPlatform = (breakdown ? str(breakdown, "publisherPlatform") : void 0) ?? str(row, "publisher_platform");
|
|
5958
5965
|
if (publisherPlatform) titleParts.push(publisherPlatform);
|
|
5959
|
-
const platformPosition = str(row, "platform_position");
|
|
5966
|
+
const platformPosition = (breakdown ? str(breakdown, "platformPosition") : void 0) ?? str(row, "platform_position");
|
|
5960
5967
|
if (platformPosition) titleParts.push(platformPosition);
|
|
5961
|
-
const impressionDevice = str(row, "impression_device");
|
|
5968
|
+
const impressionDevice = (breakdown ? str(breakdown, "impressionDevice") : void 0) ?? str(row, "impression_device");
|
|
5962
5969
|
if (impressionDevice) titleParts.push(impressionDevice);
|
|
5963
5970
|
console.log(`
|
|
5964
5971
|
${titleParts.join(" \xB7 ")}`);
|
|
5965
|
-
const impressions = num(row, "impressions");
|
|
5972
|
+
const impressions = (metrics ? num(metrics, "impressions") : void 0) ?? num(row, "impressions");
|
|
5966
5973
|
if (impressions !== void 0) console.log(` Impressions ${fmtNum(impressions)}`);
|
|
5967
|
-
const reach = num(row, "reach");
|
|
5974
|
+
const reach = (metrics ? num(metrics, "reach") : void 0) ?? num(row, "reach");
|
|
5968
5975
|
if (reach !== void 0) {
|
|
5969
|
-
const freq = num(row, "frequency");
|
|
5976
|
+
const freq = (metrics ? num(metrics, "frequency") : void 0) ?? num(row, "frequency");
|
|
5970
5977
|
const freqStr = freq !== void 0 ? ` (${fmtPct(freq)} freq)` : "";
|
|
5971
5978
|
console.log(` Reach ${fmtNum(reach)}${freqStr}`);
|
|
5972
5979
|
}
|
|
@@ -5976,14 +5983,17 @@ ${titleParts.join(" \xB7 ")}`);
|
|
|
5976
5983
|
if (all) printClickLine("Clicks", all, currency);
|
|
5977
5984
|
const outbound = nested(clicks, "outbound");
|
|
5978
5985
|
if (outbound) printClickLine("Outbound", outbound, currency);
|
|
5986
|
+
} else if (metrics) {
|
|
5987
|
+
printClickLine("Clicks", { count: metrics.clicks, ctr: metrics.ctr, cpc: metrics.cpc }, currency);
|
|
5988
|
+
printClickLine("Outbound", { count: metrics.outboundClicks, ctr: metrics.outboundCtr, cpc: metrics.costPerOutboundClick }, currency);
|
|
5979
5989
|
}
|
|
5980
|
-
const actions = nested(row, "actions");
|
|
5990
|
+
const actions = nested(row, "conversionEvents") ?? nested(row, "actions");
|
|
5981
5991
|
if (actions) {
|
|
5982
5992
|
for (const [key, val] of Object.entries(actions)) {
|
|
5983
5993
|
if (!isObject(val)) continue;
|
|
5984
5994
|
const parts = [];
|
|
5985
5995
|
const count = num(val, "count");
|
|
5986
|
-
const cost = num(val, "cost");
|
|
5996
|
+
const cost = num(val, "costPerResult") ?? num(val, "cost");
|
|
5987
5997
|
if (count !== void 0) parts.push(fmtNum(count));
|
|
5988
5998
|
if (cost !== void 0) parts.push(`${fmtCurrency(cost, currency)} each`);
|
|
5989
5999
|
if (parts.length > 0) console.log(` ${humanizeAction(key).padEnd(14)}${parts.join(" \xB7 ")}`);
|
|
@@ -5997,6 +6007,15 @@ ${titleParts.join(" \xB7 ")}`);
|
|
|
5997
6007
|
for (const [key, val] of Object.entries(aq)) if (typeof val === "string" && val !== "UNKNOWN") parts.push(`${humanizeAction(key)}: ${val}`);
|
|
5998
6008
|
if (parts.length > 0) console.log(` Ad Quality ${parts.join(" \xB7 ")}`);
|
|
5999
6009
|
}
|
|
6010
|
+
} else if (metrics) {
|
|
6011
|
+
const parts = [];
|
|
6012
|
+
const qualityRanking = str(metrics, "qualityRanking");
|
|
6013
|
+
const engagementRateRanking = str(metrics, "engagementRateRanking");
|
|
6014
|
+
const conversionRateRanking = str(metrics, "conversionRateRanking");
|
|
6015
|
+
if (qualityRanking && qualityRanking !== "UNKNOWN") parts.push(`quality: ${qualityRanking}`);
|
|
6016
|
+
if (engagementRateRanking && engagementRateRanking !== "UNKNOWN") parts.push(`engagement rate: ${engagementRateRanking}`);
|
|
6017
|
+
if (conversionRateRanking && conversionRateRanking !== "UNKNOWN") parts.push(`conversion rate: ${conversionRateRanking}`);
|
|
6018
|
+
if (parts.length > 0) console.log(` Ad Quality ${parts.join(" \xB7 ")}`);
|
|
6000
6019
|
}
|
|
6001
6020
|
}
|
|
6002
6021
|
printWarnings(data.warnings);
|
package/package.json
CHANGED