@temps-sdk/cli 0.1.19 → 0.1.20
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/index.js +40 -62
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -96806,30 +96806,44 @@ async function previewFunnelMetricsAction(options) {
|
|
|
96806
96806
|
init_source();
|
|
96807
96807
|
init_sdk_gen();
|
|
96808
96808
|
init_output();
|
|
96809
|
+
|
|
96810
|
+
// src/commands/analytics/period.ts
|
|
96809
96811
|
function parsePeriod(period) {
|
|
96810
96812
|
const now2 = new Date;
|
|
96811
96813
|
const endDate = now2.toISOString();
|
|
96814
|
+
if (period === "today") {
|
|
96815
|
+
const start2 = new Date(now2.getFullYear(), now2.getMonth(), now2.getDate());
|
|
96816
|
+
return { startDate: start2.toISOString(), endDate, label: "today" };
|
|
96817
|
+
}
|
|
96818
|
+
const match = period.match(/^(\d+)(h|d|m)$/);
|
|
96819
|
+
if (!match) {
|
|
96820
|
+
throw new Error(`Invalid period "${period}". Use: today, <n>h (hours), <n>d (days), <n>m (months). Examples: 1h, 6h, 24h, 7d, 30d, 3m`);
|
|
96821
|
+
}
|
|
96822
|
+
const n = parseInt(match[1], 10);
|
|
96823
|
+
const unit = match[2];
|
|
96812
96824
|
let start;
|
|
96813
|
-
|
|
96814
|
-
|
|
96815
|
-
|
|
96816
|
-
|
|
96817
|
-
|
|
96818
|
-
|
|
96819
|
-
|
|
96820
|
-
|
|
96821
|
-
|
|
96822
|
-
|
|
96823
|
-
case "
|
|
96824
|
-
start = new Date(now2
|
|
96825
|
-
|
|
96826
|
-
|
|
96827
|
-
|
|
96828
|
-
return { startDate: start.toISOString(), endDate, label: "last 90 days" };
|
|
96825
|
+
let label;
|
|
96826
|
+
switch (unit) {
|
|
96827
|
+
case "h":
|
|
96828
|
+
start = new Date(now2.getTime() - n * 60 * 60 * 1000);
|
|
96829
|
+
label = n === 1 ? "last hour" : `last ${n} hours`;
|
|
96830
|
+
break;
|
|
96831
|
+
case "d":
|
|
96832
|
+
start = new Date(now2.getTime() - n * 24 * 60 * 60 * 1000);
|
|
96833
|
+
label = n === 1 ? "last day" : `last ${n} days`;
|
|
96834
|
+
break;
|
|
96835
|
+
case "m":
|
|
96836
|
+
start = new Date(now2);
|
|
96837
|
+
start.setMonth(start.getMonth() - n);
|
|
96838
|
+
label = n === 1 ? "last month" : `last ${n} months`;
|
|
96839
|
+
break;
|
|
96829
96840
|
default:
|
|
96830
|
-
throw new Error(`
|
|
96841
|
+
throw new Error(`Unknown unit "${unit}"`);
|
|
96831
96842
|
}
|
|
96843
|
+
return { startDate: start.toISOString(), endDate, label };
|
|
96832
96844
|
}
|
|
96845
|
+
|
|
96846
|
+
// src/commands/analytics/overview.ts
|
|
96833
96847
|
function formatNumber(n) {
|
|
96834
96848
|
return n.toLocaleString("en-US");
|
|
96835
96849
|
}
|
|
@@ -97002,20 +97016,6 @@ async function overview(options) {
|
|
|
97002
97016
|
init_source();
|
|
97003
97017
|
init_sdk_gen();
|
|
97004
97018
|
init_output();
|
|
97005
|
-
var VALID_DIMENSIONS = [
|
|
97006
|
-
"pages",
|
|
97007
|
-
"referrers",
|
|
97008
|
-
"browsers",
|
|
97009
|
-
"os",
|
|
97010
|
-
"devices",
|
|
97011
|
-
"countries",
|
|
97012
|
-
"channels",
|
|
97013
|
-
"events",
|
|
97014
|
-
"languages",
|
|
97015
|
-
"utm_source",
|
|
97016
|
-
"utm_medium",
|
|
97017
|
-
"utm_campaign"
|
|
97018
|
-
];
|
|
97019
97019
|
var DIMENSION_MAP = {
|
|
97020
97020
|
pages: { groupBy: "page_path", label: "Top Pages" },
|
|
97021
97021
|
referrers: { groupBy: "referrer_hostname", label: "Top Referrers" },
|
|
@@ -97023,6 +97023,8 @@ var DIMENSION_MAP = {
|
|
|
97023
97023
|
os: { groupBy: "operating_system", label: "Operating Systems" },
|
|
97024
97024
|
devices: { groupBy: "device_type", label: "Devices" },
|
|
97025
97025
|
countries: { groupBy: "country", label: "Countries" },
|
|
97026
|
+
regions: { groupBy: "region", label: "Regions" },
|
|
97027
|
+
cities: { groupBy: "city", label: "Cities" },
|
|
97026
97028
|
channels: { groupBy: "channel", label: "Channels" },
|
|
97027
97029
|
events: { groupBy: "event_name", label: "Events" },
|
|
97028
97030
|
languages: { groupBy: "language", label: "Languages" },
|
|
@@ -97030,44 +97032,20 @@ var DIMENSION_MAP = {
|
|
|
97030
97032
|
utm_medium: { groupBy: "utm_medium", label: "UTM Mediums" },
|
|
97031
97033
|
utm_campaign: { groupBy: "utm_campaign", label: "UTM Campaigns" }
|
|
97032
97034
|
};
|
|
97033
|
-
function parsePeriod2(period) {
|
|
97034
|
-
const now2 = new Date;
|
|
97035
|
-
const endDate = now2.toISOString();
|
|
97036
|
-
let start;
|
|
97037
|
-
switch (period) {
|
|
97038
|
-
case "today":
|
|
97039
|
-
start = new Date(now2.getFullYear(), now2.getMonth(), now2.getDate());
|
|
97040
|
-
return { startDate: start.toISOString(), endDate, label: "today" };
|
|
97041
|
-
case "24h":
|
|
97042
|
-
start = new Date(now2.getTime() - 24 * 60 * 60 * 1000);
|
|
97043
|
-
return { startDate: start.toISOString(), endDate, label: "last 24 hours" };
|
|
97044
|
-
case "7d":
|
|
97045
|
-
start = new Date(now2.getTime() - 7 * 24 * 60 * 60 * 1000);
|
|
97046
|
-
return { startDate: start.toISOString(), endDate, label: "last 7 days" };
|
|
97047
|
-
case "30d":
|
|
97048
|
-
start = new Date(now2.getTime() - 30 * 24 * 60 * 60 * 1000);
|
|
97049
|
-
return { startDate: start.toISOString(), endDate, label: "last 30 days" };
|
|
97050
|
-
case "90d":
|
|
97051
|
-
start = new Date(now2.getTime() - 90 * 24 * 60 * 60 * 1000);
|
|
97052
|
-
return { startDate: start.toISOString(), endDate, label: "last 90 days" };
|
|
97053
|
-
default:
|
|
97054
|
-
throw new Error(`Invalid period "${period}". Use: today, 24h, 7d, 30d, 90d`);
|
|
97055
|
-
}
|
|
97056
|
-
}
|
|
97057
97035
|
function formatNumber2(n) {
|
|
97058
97036
|
return n.toLocaleString("en-US");
|
|
97059
97037
|
}
|
|
97060
97038
|
async function breakdown(dimension, options) {
|
|
97061
97039
|
const dim2 = DIMENSION_MAP[dimension];
|
|
97062
97040
|
if (!dim2) {
|
|
97063
|
-
const valid =
|
|
97041
|
+
const valid = Object.keys(DIMENSION_MAP).join(", ");
|
|
97064
97042
|
throw new Error(`Unknown dimension "${dimension}". Available: ${valid}`);
|
|
97065
97043
|
}
|
|
97066
97044
|
await requireAuth();
|
|
97067
97045
|
await setupClient();
|
|
97068
97046
|
const period = options.period ?? "24h";
|
|
97069
97047
|
const limit = options.limit ? parseInt(options.limit, 10) : 20;
|
|
97070
|
-
const { startDate, endDate, label } =
|
|
97048
|
+
const { startDate, endDate, label } = parsePeriod(period);
|
|
97071
97049
|
const resolved = await requireProjectSlug(options.project);
|
|
97072
97050
|
if (resolved.source !== "flag") {
|
|
97073
97051
|
info(`Using project ${colors.bold(resolved.slug)} (from ${resolved.source})`);
|
|
@@ -97140,16 +97118,16 @@ async function breakdown(dimension, options) {
|
|
|
97140
97118
|
// src/commands/analytics/index.ts
|
|
97141
97119
|
function registerAnalyticsCommands(program2) {
|
|
97142
97120
|
const analytics = program2.command("analytics").alias("stats").description("View project analytics");
|
|
97143
|
-
analytics.command("overview").alias("o").description("Show analytics dashboard overview").option("-p, --project <project>", "Project slug or ID").option("--period <period>", "Time period: today,
|
|
97144
|
-
analytics.command("top <dimension>").description("Show breakdown by dimension: pages, referrers, browsers, os, devices, countries, channels, events, languages, utm_source, utm_medium, utm_campaign").option("-p, --project <project>", "Project slug or ID").option("--period <period>", "Time period: today,
|
|
97121
|
+
analytics.command("overview").alias("o").description("Show analytics dashboard overview").option("-p, --project <project>", "Project slug or ID").option("--period <period>", "Time period: today, <n>h, <n>d, <n>m (e.g. 1h, 6h, 48h, 7d, 30d, 3m)", "24h").option("--json", "Output in JSON format").action(overview);
|
|
97122
|
+
analytics.command("top <dimension>").description("Show breakdown by dimension: pages, referrers, browsers, os, devices, countries, regions, cities, channels, events, languages, utm_source, utm_medium, utm_campaign").option("-p, --project <project>", "Project slug or ID").option("--period <period>", "Time period: today, <n>h, <n>d, <n>m (e.g. 1h, 6h, 48h, 7d, 30d, 3m)", "24h").option("--limit <n>", "Number of results (default: 20, max: 100)").option("--json", "Output in JSON format").action(breakdown);
|
|
97145
97123
|
analytics.addHelpText("after", `
|
|
97146
97124
|
Examples:
|
|
97147
97125
|
$ temps analytics Show overview (last 24h)
|
|
97148
97126
|
$ temps analytics overview -p my-app --period 7d
|
|
97149
97127
|
$ temps analytics top pages -p my-app --period 30d
|
|
97150
|
-
$ temps analytics top referrers --period
|
|
97151
|
-
$ temps analytics top browsers --json
|
|
97152
|
-
$ temps analytics top countries --period
|
|
97128
|
+
$ temps analytics top referrers --period 1h
|
|
97129
|
+
$ temps analytics top browsers --period 48h --json
|
|
97130
|
+
$ temps analytics top countries --period 3m --limit 50`);
|
|
97153
97131
|
}
|
|
97154
97132
|
|
|
97155
97133
|
// src/commands/notification-preferences/index.ts
|