gipity 1.1.37 → 1.1.38
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/commands/logs.js +91 -0
- package/dist/index.js +89 -0
- package/package.json +1 -1
package/dist/commands/logs.js
CHANGED
|
@@ -132,6 +132,12 @@ Examples:
|
|
|
132
132
|
const dur = d.duration_ms;
|
|
133
133
|
console.log(` ${muted(`${d.trigger_type} • ${dur ?? '?'}ms`)}${d.error_message ? muted(' • ') + clrError(String(d.error_message).slice(0, 200)) : ''}`);
|
|
134
134
|
}
|
|
135
|
+
if (e.kind === 'traffic') {
|
|
136
|
+
const where = [d.city, d.region, d.country].filter(Boolean).join(', ');
|
|
137
|
+
const bits = [where, d.referrer ? `from ${d.referrer}` : ''].filter(Boolean).join(' • ');
|
|
138
|
+
if (bits)
|
|
139
|
+
console.log(` ${muted(bits)}`);
|
|
140
|
+
}
|
|
135
141
|
if (e.kind === 'service') {
|
|
136
142
|
const dur = d.latency_ms;
|
|
137
143
|
console.log(` ${muted(`${d.service} (${d.provider ?? '?'}/${d.model ?? '?'}) • ${dur ?? '?'}ms`)}${d.error_message ? muted(' • ') + clrError(String(d.error_message).slice(0, 200)) : ''}`);
|
|
@@ -141,4 +147,89 @@ Examples:
|
|
|
141
147
|
console.log(`\n${muted(`(truncated at ${limit} entries: bump --limit or narrow --filter)`)}`);
|
|
142
148
|
}
|
|
143
149
|
}));
|
|
150
|
+
const TRAFFIC_RANGES = ['1h', '24h', '7d', '30d'];
|
|
151
|
+
logsCommand
|
|
152
|
+
.command('traffic')
|
|
153
|
+
.description('Visitor summary for this app: page views, sessions, and the top countries, cities, pages and referring sites')
|
|
154
|
+
.addOption(new Option('--range <window>', 'Time window').choices(TRAFFIC_RANGES).default('7d'))
|
|
155
|
+
.option('--country <code>', 'Only visitors from one country (ISO code, e.g. US)')
|
|
156
|
+
.option('--limit <n>', 'Rows per list', '10')
|
|
157
|
+
.option('--json', 'Output as JSON (parseable by agents / pipes)')
|
|
158
|
+
.addHelpText('after', `
|
|
159
|
+
Counts page views recorded by the Gipity tracker (gipity.js), on a Gipity app or
|
|
160
|
+
on any other site that loads it with this project's data-app. Country and city
|
|
161
|
+
come from each visitor's IP address when the view arrives; the address itself is
|
|
162
|
+
not stored.
|
|
163
|
+
|
|
164
|
+
Examples:
|
|
165
|
+
$ gipity logs traffic Last 7 days
|
|
166
|
+
$ gipity logs traffic --range 24h Last 24 hours
|
|
167
|
+
$ gipity logs traffic --country US US visitors only: their pages and cities
|
|
168
|
+
$ gipity logs traffic --json { pageviews, sessions, countries, cities, pages, referrers }
|
|
169
|
+
|
|
170
|
+
Page-by-page rows: gipity logs app --type traffic --since 1h
|
|
171
|
+
`)
|
|
172
|
+
.action((opts) => run('Traffic', async () => {
|
|
173
|
+
const config = requireConfig();
|
|
174
|
+
const limit = Math.min(Math.max(parseInt(opts.limit, 10) || 10, 1), 50);
|
|
175
|
+
const country = opts.country ? String(opts.country).trim().toUpperCase() : undefined;
|
|
176
|
+
if (country !== undefined && !/^[A-Z]{2}$/.test(country)) {
|
|
177
|
+
throw new Error(`--country takes a two-letter country code (e.g. US), not "${opts.country}"`);
|
|
178
|
+
}
|
|
179
|
+
const base = new URLSearchParams({ range: String(opts.range), app_guid: config.projectGuid });
|
|
180
|
+
const top = (signal) => {
|
|
181
|
+
const qs = new URLSearchParams(base);
|
|
182
|
+
qs.set('signal', signal);
|
|
183
|
+
qs.set('limit', String(limit));
|
|
184
|
+
if (country)
|
|
185
|
+
qs.set('country', country);
|
|
186
|
+
return get(`/account/logs/top?${qs.toString()}`).then((r) => r.data.items);
|
|
187
|
+
};
|
|
188
|
+
const [stats, sessions, countries, cities, pages, referrers] = await Promise.all([
|
|
189
|
+
get(`/account/logs/stats?${base.toString()}`),
|
|
190
|
+
get(`/account/logs/stats/sessions?${base.toString()}`),
|
|
191
|
+
top('country'), top('city'), top('path'), top('referrer_host'),
|
|
192
|
+
]);
|
|
193
|
+
const summary = {
|
|
194
|
+
range: String(opts.range),
|
|
195
|
+
country: country ?? null,
|
|
196
|
+
pageviews: stats.data.cards.traffic,
|
|
197
|
+
sessions: sessions.data.sessions,
|
|
198
|
+
live: sessions.data.live,
|
|
199
|
+
countries, cities, pages, referrers,
|
|
200
|
+
};
|
|
201
|
+
if (opts.json) {
|
|
202
|
+
console.log(JSON.stringify(summary));
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const scope = country ? `, visitors from ${country}` : '';
|
|
206
|
+
if (country) {
|
|
207
|
+
console.log(`${bold('Traffic')} ${muted(`(last ${summary.range}${scope})`)}\n`);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
console.log(`${bold('Traffic')} ${muted(`(last ${summary.range})`)}: ${summary.pageviews} page views, ${summary.sessions} sessions, ${summary.live} live now\n`);
|
|
211
|
+
}
|
|
212
|
+
const section = (title, items, label) => {
|
|
213
|
+
console.log(bold(title));
|
|
214
|
+
if (items.length === 0) {
|
|
215
|
+
console.log(` ${muted('none in this window')}\n`);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const width = Math.min(Math.max(...items.map((i) => label(i).length)), 48);
|
|
219
|
+
for (const i of items) {
|
|
220
|
+
const name = label(i);
|
|
221
|
+
const shown = name.length > 48 ? name.slice(0, 45) + '...' : name.padEnd(width);
|
|
222
|
+
const sess = typeof i.sessions === 'number' ? muted(` ${i.sessions} sessions`) : '';
|
|
223
|
+
console.log(` ${shown} ${String(i.count).padStart(6)} views${sess}`);
|
|
224
|
+
}
|
|
225
|
+
console.log('');
|
|
226
|
+
};
|
|
227
|
+
section('Countries', countries, (i) => i.key);
|
|
228
|
+
section('Cities', cities, (i) => [i.key, i.region, i.country].filter(Boolean).join(', '));
|
|
229
|
+
section('Pages', pages, (i) => i.key);
|
|
230
|
+
section('Referring sites', referrers, (i) => i.key);
|
|
231
|
+
if (countries.length === 0 && pages.length === 0) {
|
|
232
|
+
console.log(muted('No page views yet. Load gipity.js on the site with data-app="' + config.projectGuid + '" (gipity skill read app-debugging).'));
|
|
233
|
+
}
|
|
234
|
+
}));
|
|
144
235
|
//# sourceMappingURL=logs.js.map
|
package/dist/index.js
CHANGED
|
@@ -43436,6 +43436,11 @@ Examples:
|
|
|
43436
43436
|
const dur = d.duration_ms;
|
|
43437
43437
|
console.log(` ${muted(`${d.trigger_type} \u2022 ${dur ?? "?"}ms`)}${d.error_message ? muted(" \u2022 ") + error(String(d.error_message).slice(0, 200)) : ""}`);
|
|
43438
43438
|
}
|
|
43439
|
+
if (e.kind === "traffic") {
|
|
43440
|
+
const where = [d.city, d.region, d.country].filter(Boolean).join(", ");
|
|
43441
|
+
const bits = [where, d.referrer ? `from ${d.referrer}` : ""].filter(Boolean).join(" \u2022 ");
|
|
43442
|
+
if (bits) console.log(` ${muted(bits)}`);
|
|
43443
|
+
}
|
|
43439
43444
|
if (e.kind === "service") {
|
|
43440
43445
|
const dur = d.latency_ms;
|
|
43441
43446
|
console.log(` ${muted(`${d.service} (${d.provider ?? "?"}/${d.model ?? "?"}) \u2022 ${dur ?? "?"}ms`)}${d.error_message ? muted(" \u2022 ") + error(String(d.error_message).slice(0, 200)) : ""}`);
|
|
@@ -43446,6 +43451,90 @@ Examples:
|
|
|
43446
43451
|
${muted(`(truncated at ${limit} entries: bump --limit or narrow --filter)`)}`);
|
|
43447
43452
|
}
|
|
43448
43453
|
}));
|
|
43454
|
+
var TRAFFIC_RANGES = ["1h", "24h", "7d", "30d"];
|
|
43455
|
+
logsCommand.command("traffic").description("Visitor summary for this app: page views, sessions, and the top countries, cities, pages and referring sites").addOption(new Option("--range <window>", "Time window").choices(TRAFFIC_RANGES).default("7d")).option("--country <code>", "Only visitors from one country (ISO code, e.g. US)").option("--limit <n>", "Rows per list", "10").option("--json", "Output as JSON (parseable by agents / pipes)").addHelpText("after", `
|
|
43456
|
+
Counts page views recorded by the Gipity tracker (gipity.js), on a Gipity app or
|
|
43457
|
+
on any other site that loads it with this project's data-app. Country and city
|
|
43458
|
+
come from each visitor's IP address when the view arrives; the address itself is
|
|
43459
|
+
not stored.
|
|
43460
|
+
|
|
43461
|
+
Examples:
|
|
43462
|
+
$ gipity logs traffic Last 7 days
|
|
43463
|
+
$ gipity logs traffic --range 24h Last 24 hours
|
|
43464
|
+
$ gipity logs traffic --country US US visitors only: their pages and cities
|
|
43465
|
+
$ gipity logs traffic --json { pageviews, sessions, countries, cities, pages, referrers }
|
|
43466
|
+
|
|
43467
|
+
Page-by-page rows: gipity logs app --type traffic --since 1h
|
|
43468
|
+
`).action((opts) => run("Traffic", async () => {
|
|
43469
|
+
const config = requireConfig2();
|
|
43470
|
+
const limit = Math.min(Math.max(parseInt(opts.limit, 10) || 10, 1), 50);
|
|
43471
|
+
const country = opts.country ? String(opts.country).trim().toUpperCase() : void 0;
|
|
43472
|
+
if (country !== void 0 && !/^[A-Z]{2}$/.test(country)) {
|
|
43473
|
+
throw new Error(`--country takes a two-letter country code (e.g. US), not "${opts.country}"`);
|
|
43474
|
+
}
|
|
43475
|
+
const base = new URLSearchParams({ range: String(opts.range), app_guid: config.projectGuid });
|
|
43476
|
+
const top = (signal) => {
|
|
43477
|
+
const qs = new URLSearchParams(base);
|
|
43478
|
+
qs.set("signal", signal);
|
|
43479
|
+
qs.set("limit", String(limit));
|
|
43480
|
+
if (country) qs.set("country", country);
|
|
43481
|
+
return get(`/account/logs/top?${qs.toString()}`).then((r) => r.data.items);
|
|
43482
|
+
};
|
|
43483
|
+
const [stats, sessions, countries, cities, pages, referrers] = await Promise.all([
|
|
43484
|
+
get(`/account/logs/stats?${base.toString()}`),
|
|
43485
|
+
get(`/account/logs/stats/sessions?${base.toString()}`),
|
|
43486
|
+
top("country"),
|
|
43487
|
+
top("city"),
|
|
43488
|
+
top("path"),
|
|
43489
|
+
top("referrer_host")
|
|
43490
|
+
]);
|
|
43491
|
+
const summary = {
|
|
43492
|
+
range: String(opts.range),
|
|
43493
|
+
country: country ?? null,
|
|
43494
|
+
pageviews: stats.data.cards.traffic,
|
|
43495
|
+
sessions: sessions.data.sessions,
|
|
43496
|
+
live: sessions.data.live,
|
|
43497
|
+
countries,
|
|
43498
|
+
cities,
|
|
43499
|
+
pages,
|
|
43500
|
+
referrers
|
|
43501
|
+
};
|
|
43502
|
+
if (opts.json) {
|
|
43503
|
+
console.log(JSON.stringify(summary));
|
|
43504
|
+
return;
|
|
43505
|
+
}
|
|
43506
|
+
const scope = country ? `, visitors from ${country}` : "";
|
|
43507
|
+
if (country) {
|
|
43508
|
+
console.log(`${bold("Traffic")} ${muted(`(last ${summary.range}${scope})`)}
|
|
43509
|
+
`);
|
|
43510
|
+
} else {
|
|
43511
|
+
console.log(`${bold("Traffic")} ${muted(`(last ${summary.range})`)}: ${summary.pageviews} page views, ${summary.sessions} sessions, ${summary.live} live now
|
|
43512
|
+
`);
|
|
43513
|
+
}
|
|
43514
|
+
const section = (title, items, label2) => {
|
|
43515
|
+
console.log(bold(title));
|
|
43516
|
+
if (items.length === 0) {
|
|
43517
|
+
console.log(` ${muted("none in this window")}
|
|
43518
|
+
`);
|
|
43519
|
+
return;
|
|
43520
|
+
}
|
|
43521
|
+
const width = Math.min(Math.max(...items.map((i) => label2(i).length)), 48);
|
|
43522
|
+
for (const i of items) {
|
|
43523
|
+
const name = label2(i);
|
|
43524
|
+
const shown = name.length > 48 ? name.slice(0, 45) + "..." : name.padEnd(width);
|
|
43525
|
+
const sess = typeof i.sessions === "number" ? muted(` ${i.sessions} sessions`) : "";
|
|
43526
|
+
console.log(` ${shown} ${String(i.count).padStart(6)} views${sess}`);
|
|
43527
|
+
}
|
|
43528
|
+
console.log("");
|
|
43529
|
+
};
|
|
43530
|
+
section("Countries", countries, (i) => i.key);
|
|
43531
|
+
section("Cities", cities, (i) => [i.key, i.region, i.country].filter(Boolean).join(", "));
|
|
43532
|
+
section("Pages", pages, (i) => i.key);
|
|
43533
|
+
section("Referring sites", referrers, (i) => i.key);
|
|
43534
|
+
if (countries.length === 0 && pages.length === 0) {
|
|
43535
|
+
console.log(muted('No page views yet. Load gipity.js on the site with data-app="' + config.projectGuid + '" (gipity skill read app-debugging).'));
|
|
43536
|
+
}
|
|
43537
|
+
}));
|
|
43449
43538
|
|
|
43450
43539
|
// src/commands/page-test.ts
|
|
43451
43540
|
init_api();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gipity",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.38",
|
|
4
4
|
"description": "The full-stack platform tuned for AI agents. Database, storage, auth, functions, deploy, and drop-in kits - all agent-tuned. Pair with Claude Code or use standalone.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"gipity": "dist/updater/shim.js",
|