@curless/hotel-storefront 0.69.4 → 0.70.0
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/README.md +11 -0
- package/dist/account/index.d.ts +21 -0
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +63 -4
- package/dist/account/index.js.map +1 -1
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/huazhu/client.d.ts +3 -1
- package/dist/huazhu/client.d.ts.map +1 -1
- package/dist/huazhu/client.js +26 -0
- package/dist/huazhu/client.js.map +1 -1
- package/dist/otaless/backend.d.ts.map +1 -1
- package/dist/otaless/backend.js +4 -0
- package/dist/otaless/backend.js.map +1 -1
- package/dist/otaless/booking.d.ts +3 -2
- package/dist/otaless/booking.d.ts.map +1 -1
- package/dist/otaless/booking.js +8 -2
- package/dist/otaless/booking.js.map +1 -1
- package/dist/otaless/places.d.ts.map +1 -1
- package/dist/otaless/places.js +16 -2
- package/dist/otaless/places.js.map +1 -1
- package/dist/regions.d.ts.map +1 -1
- package/dist/regions.js +25 -2
- package/dist/regions.js.map +1 -1
- package/dist/server.d.ts +4 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +245 -8
- package/dist/server.js.map +1 -1
- package/dist/usage/boot.d.ts +32 -0
- package/dist/usage/boot.d.ts.map +1 -0
- package/dist/usage/boot.js +140 -0
- package/dist/usage/boot.js.map +1 -0
- package/dist/usage/geo.d.ts +48 -0
- package/dist/usage/geo.d.ts.map +1 -0
- package/dist/usage/geo.js +347 -0
- package/dist/usage/geo.js.map +1 -0
- package/dist/usage/maintain.d.ts +26 -0
- package/dist/usage/maintain.d.ts.map +1 -0
- package/dist/usage/maintain.js +177 -0
- package/dist/usage/maintain.js.map +1 -0
- package/dist/usage/platform.d.ts +69 -0
- package/dist/usage/platform.d.ts.map +1 -0
- package/dist/usage/platform.js +124 -0
- package/dist/usage/platform.js.map +1 -0
- package/dist/usage/pseudonym.d.ts +28 -0
- package/dist/usage/pseudonym.d.ts.map +1 -0
- package/dist/usage/pseudonym.js +73 -0
- package/dist/usage/pseudonym.js.map +1 -0
- package/dist/usage/range.d.ts +24 -0
- package/dist/usage/range.d.ts.map +1 -0
- package/dist/usage/range.js +102 -0
- package/dist/usage/range.js.map +1 -0
- package/dist/usage/recorder.d.ts +115 -0
- package/dist/usage/recorder.d.ts.map +1 -0
- package/dist/usage/recorder.js +227 -0
- package/dist/usage/recorder.js.map +1 -0
- package/dist/usage/report.d.ts +207 -0
- package/dist/usage/report.d.ts.map +1 -0
- package/dist/usage/report.js +730 -0
- package/dist/usage/report.js.map +1 -0
- package/dist/usage/shadow-import.d.ts +28 -0
- package/dist/usage/shadow-import.d.ts.map +1 -0
- package/dist/usage/shadow-import.js +107 -0
- package/dist/usage/shadow-import.js.map +1 -0
- package/dist/usage/store.d.ts +215 -0
- package/dist/usage/store.d.ts.map +1 -0
- package/dist/usage/store.js +430 -0
- package/dist/usage/store.js.map +1 -0
- package/dist/usage-cli.d.ts +3 -0
- package/dist/usage-cli.d.ts.map +1 -0
- package/dist/usage-cli.js +152 -0
- package/dist/usage-cli.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { geoFields, platformOf } from './platform.js';
|
|
2
|
+
/** The header Caddy is asked to copy the caller's own X-Forwarded-For into. */
|
|
3
|
+
export const CALLER_FORWARDED = 'x-caller-forwarded-for';
|
|
4
|
+
/** How long a conversation's facts are remembered for an account step finished on our own page. */
|
|
5
|
+
const KEY_TTL_MS = 30 * 60_000;
|
|
6
|
+
const KEYS_MAX = 5_000;
|
|
7
|
+
const REFS_MAX = 10_000;
|
|
8
|
+
/** A failure's category for the record: a short code, never free text. */
|
|
9
|
+
export const whyCode = (raw) => {
|
|
10
|
+
if (typeof raw !== 'string')
|
|
11
|
+
return undefined;
|
|
12
|
+
const w = raw
|
|
13
|
+
.toLowerCase()
|
|
14
|
+
.replace(/[^a-z0-9_-]+/g, '-')
|
|
15
|
+
.replace(/^-+|-+$/g, '')
|
|
16
|
+
.slice(0, 40);
|
|
17
|
+
return w || undefined;
|
|
18
|
+
};
|
|
19
|
+
/** What a client called itself, printable and at most 60 characters. */
|
|
20
|
+
export const clientLabel = (raw) => {
|
|
21
|
+
if (typeof raw !== 'string')
|
|
22
|
+
return undefined;
|
|
23
|
+
const v = raw
|
|
24
|
+
.replace(/[^\x20-\x7e]/g, '')
|
|
25
|
+
.trim()
|
|
26
|
+
.slice(0, 60);
|
|
27
|
+
return v || undefined;
|
|
28
|
+
};
|
|
29
|
+
/** A group's code as an event may carry it: `[a-z0-9-]`, the backend's own providerCode. */
|
|
30
|
+
export const shopCode = (raw) => typeof raw === 'string' && /^[a-z0-9][a-z0-9-]{0,39}$/.test(raw) ? raw : undefined;
|
|
31
|
+
export class UsageRecorder {
|
|
32
|
+
deps;
|
|
33
|
+
keys = new Map();
|
|
34
|
+
refs = new Set();
|
|
35
|
+
constructor(deps) {
|
|
36
|
+
this.deps = deps;
|
|
37
|
+
}
|
|
38
|
+
now() {
|
|
39
|
+
return (this.deps.now ?? Date.now)();
|
|
40
|
+
}
|
|
41
|
+
safe(what, fn) {
|
|
42
|
+
try {
|
|
43
|
+
fn();
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
this.deps.store.fault(what, err);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
emit(f, e, shop, extra = {}) {
|
|
50
|
+
const s = shopCode(shop);
|
|
51
|
+
this.deps.store.add({
|
|
52
|
+
v: 1,
|
|
53
|
+
t: new Date(this.now()).toISOString(),
|
|
54
|
+
d: this.deps.deployment,
|
|
55
|
+
...(s ? { shop: s } : {}),
|
|
56
|
+
e,
|
|
57
|
+
p: f.p,
|
|
58
|
+
...(f.u ? { u: f.u } : {}),
|
|
59
|
+
...(f.c ? { c: f.c } : {}),
|
|
60
|
+
...(f.k ? { k: f.k } : {}),
|
|
61
|
+
g: f.g,
|
|
62
|
+
...(f.n ? { n: f.n } : {}),
|
|
63
|
+
...extra,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Who and where, for this request. `connection` is the MCP session it came
|
|
68
|
+
* in on; `conversation` is the conversation it acts for - for a client that
|
|
69
|
+
* draws no card, carried across its connections (server.ts `own`), for a card,
|
|
70
|
+
* the conversation that drew it. `peer` is the address our proxy saw.
|
|
71
|
+
*/
|
|
72
|
+
facts(h, opts = {}) {
|
|
73
|
+
try {
|
|
74
|
+
const ua = h.get('user-agent') ?? undefined;
|
|
75
|
+
const oaiSession = h.get('x-openai-session')?.trim() || undefined;
|
|
76
|
+
const peer = opts.peer;
|
|
77
|
+
const p = platformOf({
|
|
78
|
+
client: opts.client,
|
|
79
|
+
userAgent: ua,
|
|
80
|
+
openaiSession: !!oaiSession,
|
|
81
|
+
peer,
|
|
82
|
+
});
|
|
83
|
+
const fromOpenAi = p === 'chatgpt' && this.deps.openai.has(peer);
|
|
84
|
+
const pseudo = this.deps.pseudo;
|
|
85
|
+
const u = fromOpenAi ? pseudo.user(h.get('x-openai-subject')) : undefined;
|
|
86
|
+
// The conversation: ChatGPT's own id, and nothing else for ChatGPT - its
|
|
87
|
+
// tool scan's MCP sessions are no one's conversation (总线程 11-13);
|
|
88
|
+
// everywhere else the conversation the call acts for - and none at
|
|
89
|
+
// `initialize`: which conversation a new connection serves is not known
|
|
90
|
+
// until it calls (claude.ai's card opens connections of its own, each of
|
|
91
|
+
// which would otherwise count as a conversation). The connection is `k`.
|
|
92
|
+
const k = pseudo.conversation('mcp', opts.connection);
|
|
93
|
+
const c = p === 'chatgpt'
|
|
94
|
+
? fromOpenAi && oaiSession
|
|
95
|
+
? pseudo.conversation('oai', oaiSession)
|
|
96
|
+
: undefined
|
|
97
|
+
: opts.conversation
|
|
98
|
+
? pseudo.conversation('mcp', opts.conversation)
|
|
99
|
+
: undefined;
|
|
100
|
+
// The caller's own X-Forwarded-For: Caddy's copy of it, or - should a
|
|
101
|
+
// proxy ever append instead of replace - the entries before the last.
|
|
102
|
+
const xff = h.get('x-forwarded-for')?.split(',') ?? [];
|
|
103
|
+
const forwarded = h.get(CALLER_FORWARDED)?.trim() || xff.slice(0, -1).join(',') || undefined;
|
|
104
|
+
const geo = geoFields(p, peer, forwarded, this.deps.openai, this.deps.geo());
|
|
105
|
+
return { p, ...(u ? { u } : {}), ...(c ? { c } : {}), ...(k ? { k } : {}), ...geo };
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
this.deps.store.fault('facts', err);
|
|
109
|
+
return { p: 'other', g: 'unknown' };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
init(f, x) {
|
|
113
|
+
this.safe('init', () => {
|
|
114
|
+
const client = clientLabel(x.client);
|
|
115
|
+
this.emit(f, 'init', undefined, { ...(client ? { client } : {}), cards: x.cards });
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
call(f, x) {
|
|
119
|
+
this.safe('call', () => {
|
|
120
|
+
const why = whyCode(x.why);
|
|
121
|
+
this.emit(f, 'call', x.shop, {
|
|
122
|
+
tool: x.tool,
|
|
123
|
+
r: this.deps.roleOf(x.tool),
|
|
124
|
+
ok: x.ok,
|
|
125
|
+
ms: Math.max(0, Math.round(x.ms)),
|
|
126
|
+
...(why && !x.ok ? { why } : {}),
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
/** Stays went into the trip: how many more lines it holds after the call. */
|
|
131
|
+
cartAdd(f, x) {
|
|
132
|
+
this.safe('cart', () => this.emit(f, 'cart_add', x.shop, { tool: x.tool, qty: x.added }));
|
|
133
|
+
}
|
|
134
|
+
/** A booking's reference, pseudonymised - and whether it was seen before (once per reference). */
|
|
135
|
+
ref(id) {
|
|
136
|
+
const ref = id ? this.deps.pseudo.ref(id) : undefined;
|
|
137
|
+
if (!ref)
|
|
138
|
+
return { again: false };
|
|
139
|
+
if (this.refs.has(ref))
|
|
140
|
+
return { ref, again: true };
|
|
141
|
+
this.refs.add(ref);
|
|
142
|
+
if (this.refs.size > REFS_MAX) {
|
|
143
|
+
const oldest = this.refs.values().next().value;
|
|
144
|
+
if (oldest !== undefined)
|
|
145
|
+
this.refs.delete(oldest);
|
|
146
|
+
}
|
|
147
|
+
return { ref, again: false };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A booking asked for, one stay of it: its outcome (`booking`) - and, made or
|
|
151
|
+
* being confirmed, the funnel's last step (`checkout`). Once per booking id:
|
|
152
|
+
* a booking asked again by the same words comes back as the one made before.
|
|
153
|
+
* Never an amount, a currency, a hotel or a confirmation code.
|
|
154
|
+
*/
|
|
155
|
+
booking(f, x) {
|
|
156
|
+
this.safe('booking', () => {
|
|
157
|
+
const { ref, again } = x.res === 'fail' ? { ref: undefined, again: false } : this.ref(x.id);
|
|
158
|
+
if (again)
|
|
159
|
+
return;
|
|
160
|
+
const why = whyCode(x.why);
|
|
161
|
+
const common = {
|
|
162
|
+
...(ref ? { ref } : {}),
|
|
163
|
+
kind: x.kind,
|
|
164
|
+
via: x.via,
|
|
165
|
+
...(x.signedIn !== undefined ? { signedIn: x.signedIn } : {}),
|
|
166
|
+
};
|
|
167
|
+
this.emit(f, 'booking', x.shop, {
|
|
168
|
+
res: x.res,
|
|
169
|
+
...common,
|
|
170
|
+
...(x.res === 'fail' && why ? { why } : {}),
|
|
171
|
+
});
|
|
172
|
+
if (x.res !== 'fail')
|
|
173
|
+
this.emit(f, 'checkout', x.shop, common);
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/** The guest's own account. `member` is the backend's member id - pseudonymised here, never kept as it came. */
|
|
177
|
+
account(f, x) {
|
|
178
|
+
this.safe('account', () => {
|
|
179
|
+
const s = x.member ? this.deps.pseudo.shopper(x.member) : undefined;
|
|
180
|
+
const why = whyCode(x.why);
|
|
181
|
+
this.emit(f, 'account', undefined, {
|
|
182
|
+
step: x.step,
|
|
183
|
+
...(s ? { s } : {}),
|
|
184
|
+
...(why ? { why } : {}),
|
|
185
|
+
...(x.signUp ? { signUp: true } : {}),
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
/** A hotel group's membership linked to the account: the group in `shop`, the account as `s`. */
|
|
190
|
+
member(f, x) {
|
|
191
|
+
this.safe('member', () => {
|
|
192
|
+
const s = x.member ? this.deps.pseudo.shopper(x.member) : undefined;
|
|
193
|
+
const why = whyCode(x.why);
|
|
194
|
+
this.emit(f, 'member', x.group, {
|
|
195
|
+
step: x.step,
|
|
196
|
+
...(s ? { s } : {}),
|
|
197
|
+
...(why ? { why } : {}),
|
|
198
|
+
...(x.signUp ? { signUp: true } : {}),
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Remember whose conversation `key` is, so an account step finished on our
|
|
204
|
+
* own page - a request from the guest's browser, not the platform - is
|
|
205
|
+
* counted against the conversation that began it.
|
|
206
|
+
*/
|
|
207
|
+
bindKey(key, f) {
|
|
208
|
+
if (!key)
|
|
209
|
+
return;
|
|
210
|
+
this.safe('bind', () => {
|
|
211
|
+
const at = this.now();
|
|
212
|
+
this.keys.delete(key);
|
|
213
|
+
this.keys.set(key, { facts: f, at });
|
|
214
|
+
for (const [k, v] of this.keys) {
|
|
215
|
+
if (this.keys.size <= KEYS_MAX && at - v.at < KEY_TTL_MS)
|
|
216
|
+
break;
|
|
217
|
+
this.keys.delete(k);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
/** The facts last bound to a conversation - or a platform unknown, nowhere. */
|
|
222
|
+
factsOf(key) {
|
|
223
|
+
const hit = this.keys.get(key);
|
|
224
|
+
return hit && this.now() - hit.at < KEY_TTL_MS ? hit.facts : { p: 'other', g: 'unknown' };
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rec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AC5F,CAAC;CACF"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { type Platform } from './platform.js';
|
|
2
|
+
import type { UsageEvent } from './store.js';
|
|
3
|
+
export declare const PLATFORM_LABEL: Record<Platform, string>;
|
|
4
|
+
export declare const geoLabel: (g: string) => string;
|
|
5
|
+
/** A fixed offset: China has no daylight saving. */
|
|
6
|
+
export type Tz = {
|
|
7
|
+
name: string;
|
|
8
|
+
offsetMin: number;
|
|
9
|
+
};
|
|
10
|
+
export declare const BEIJING: Tz;
|
|
11
|
+
export declare const UTC_TZ: Tz;
|
|
12
|
+
export declare const dayIn: (t: string | number, tz: Tz) => string;
|
|
13
|
+
export declare const addDays: (day: string, n: number) => string;
|
|
14
|
+
export type Row = {
|
|
15
|
+
users: number;
|
|
16
|
+
newUsers: number;
|
|
17
|
+
convs: number;
|
|
18
|
+
conns: number;
|
|
19
|
+
inits: number;
|
|
20
|
+
calls: number;
|
|
21
|
+
failed: number;
|
|
22
|
+
reqs: number;
|
|
23
|
+
cartAdds: number;
|
|
24
|
+
checkouts: number;
|
|
25
|
+
signIns: number;
|
|
26
|
+
shoppers: number;
|
|
27
|
+
};
|
|
28
|
+
export type GeoRow = Row & {
|
|
29
|
+
isp: number;
|
|
30
|
+
hosting: number;
|
|
31
|
+
};
|
|
32
|
+
export type Funnel = {
|
|
33
|
+
/** Conversations seen at all - on recorded days (imported ones carry no tool). */
|
|
34
|
+
connected: number;
|
|
35
|
+
/** …that looked at products (a browse or product tool). */
|
|
36
|
+
viewed: number;
|
|
37
|
+
/** …that put something in the cart. */
|
|
38
|
+
added: number;
|
|
39
|
+
/** …that were handed a checkout link. */
|
|
40
|
+
checkout: number;
|
|
41
|
+
};
|
|
42
|
+
export type AccountSummary = {
|
|
43
|
+
/** Sign-ins begun: a link handed out in words, or started in the card. */
|
|
44
|
+
begun: number;
|
|
45
|
+
links: number;
|
|
46
|
+
starts: number;
|
|
47
|
+
ok: number;
|
|
48
|
+
failed: number;
|
|
49
|
+
/** Failures by category. */
|
|
50
|
+
why: Record<string, number>;
|
|
51
|
+
signOuts: number;
|
|
52
|
+
orderReads: number;
|
|
53
|
+
/** Sign-ins that made the account first (注册). */
|
|
54
|
+
signUps: number;
|
|
55
|
+
/** Distinct shoppers signed in, and of those, first seen in this window. */
|
|
56
|
+
shoppers: number;
|
|
57
|
+
newShoppers: number;
|
|
58
|
+
returningShoppers: number;
|
|
59
|
+
/** Conversations signed in, of all conversations. */
|
|
60
|
+
signedInConvs: number;
|
|
61
|
+
allConvs: number;
|
|
62
|
+
/** Signed-in conversations later handed a checkout link. */
|
|
63
|
+
signedInCheckoutConvs: number;
|
|
64
|
+
};
|
|
65
|
+
/** Bookings asked for, by outcome - counts only, never an amount (robin 11-13). */
|
|
66
|
+
export type BookingSummary = {
|
|
67
|
+
ok: number;
|
|
68
|
+
fail: number;
|
|
69
|
+
checking: number;
|
|
70
|
+
/** Not made, by category. */
|
|
71
|
+
why: Record<string, number>;
|
|
72
|
+
};
|
|
73
|
+
type MemberCounts = {
|
|
74
|
+
links: number;
|
|
75
|
+
ok: number;
|
|
76
|
+
failed: number;
|
|
77
|
+
out: number;
|
|
78
|
+
};
|
|
79
|
+
/** Hotel groups' memberships linked to the account (Otaless), by step and group. */
|
|
80
|
+
export type MemberSummary = MemberCounts & {
|
|
81
|
+
/** Linked by making a new membership. */
|
|
82
|
+
signUps: number;
|
|
83
|
+
why: Record<string, number>;
|
|
84
|
+
byGroup: Record<string, MemberCounts>;
|
|
85
|
+
};
|
|
86
|
+
export type DayTotals = {
|
|
87
|
+
day: string;
|
|
88
|
+
total: Row;
|
|
89
|
+
byPlatform: Record<string, Row>;
|
|
90
|
+
byGeo: Record<string, GeoRow>;
|
|
91
|
+
/** `platform|geo` → row. */
|
|
92
|
+
rows: Record<string, Row>;
|
|
93
|
+
/** By group, in a deployment serving several (`shop`): Otaless. Empty elsewhere. */
|
|
94
|
+
byShop: Record<string, Row>;
|
|
95
|
+
account: AccountSummary;
|
|
96
|
+
booking: BookingSummary;
|
|
97
|
+
member: MemberSummary;
|
|
98
|
+
imported: boolean;
|
|
99
|
+
};
|
|
100
|
+
export type ToolRow = {
|
|
101
|
+
tool: string;
|
|
102
|
+
calls: number;
|
|
103
|
+
failed: number;
|
|
104
|
+
p50ms: number | null;
|
|
105
|
+
};
|
|
106
|
+
export type Report = {
|
|
107
|
+
v: 1;
|
|
108
|
+
deployment: string | null;
|
|
109
|
+
tz: string;
|
|
110
|
+
from: string;
|
|
111
|
+
to: string;
|
|
112
|
+
/** `exact`: from the event lines. `daily-sum`: from the days' totals - users summed per day. */
|
|
113
|
+
mode: 'exact' | 'daily-sum';
|
|
114
|
+
/** Why the days were summed: the window reaches past the kept lines, or holds too many to de-duplicate. */
|
|
115
|
+
reason?: 'past-13-months' | 'too-many';
|
|
116
|
+
days: DayTotals[];
|
|
117
|
+
total: Row & {
|
|
118
|
+
returningUsers: number;
|
|
119
|
+
};
|
|
120
|
+
byPlatform: Record<string, Row>;
|
|
121
|
+
byGeo: Record<string, GeoRow>;
|
|
122
|
+
byShop: Record<string, Row>;
|
|
123
|
+
tools: ToolRow[];
|
|
124
|
+
funnel: Funnel;
|
|
125
|
+
account: AccountSummary;
|
|
126
|
+
booking: BookingSummary;
|
|
127
|
+
member: MemberSummary;
|
|
128
|
+
/** Days with imported requests (no tool names) in the window. */
|
|
129
|
+
importedDays: string[];
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* When a pseudonym was first seen - the maintenance's index (maintain.ts), so
|
|
133
|
+
* a day's totals can say who is new without reading every earlier day again.
|
|
134
|
+
*/
|
|
135
|
+
export type SeenIndex = {
|
|
136
|
+
userFirst(u: string): string | undefined;
|
|
137
|
+
shopperFirst(s: string): string | undefined;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Sums events fed one at a time - so neither the maintenance nor the CLI ever
|
|
141
|
+
* holds a window's lines in memory, only its counts and distinct pseudonyms.
|
|
142
|
+
*
|
|
143
|
+
* Two passes over the same lines: `place` (who was where - see knownPlaces),
|
|
144
|
+
* then `add`. Lines before `from` only say who was seen before (new versus
|
|
145
|
+
* returning) - unless a `seen` index answers that instead.
|
|
146
|
+
*/
|
|
147
|
+
export declare class ReportBuilder {
|
|
148
|
+
private readonly from;
|
|
149
|
+
private readonly to;
|
|
150
|
+
private readonly deployment;
|
|
151
|
+
private readonly tz;
|
|
152
|
+
private readonly seen?;
|
|
153
|
+
private readonly tally;
|
|
154
|
+
private places;
|
|
155
|
+
private readonly seenUsers;
|
|
156
|
+
private readonly shoppersBefore;
|
|
157
|
+
private readonly days;
|
|
158
|
+
private readonly total;
|
|
159
|
+
private readonly byPlatform;
|
|
160
|
+
private readonly byGeo;
|
|
161
|
+
private readonly byShop;
|
|
162
|
+
private readonly booking;
|
|
163
|
+
private readonly member;
|
|
164
|
+
private readonly tools;
|
|
165
|
+
private readonly account;
|
|
166
|
+
private readonly imported;
|
|
167
|
+
private readonly funnel;
|
|
168
|
+
constructor(from: string, to: string, deployment?: string | null, tz?: Tz, seen?: SeenIndex | undefined);
|
|
169
|
+
/** How many distinct ids it holds - what a caller bounds its memory by. */
|
|
170
|
+
distinct(): number;
|
|
171
|
+
private mine;
|
|
172
|
+
/**
|
|
173
|
+
* First pass: where each user and conversation was seen, within the window.
|
|
174
|
+
* A request that said nothing of where is then counted where its user (or,
|
|
175
|
+
* with no user, its conversation) most often was - one request without an
|
|
176
|
+
* address does not put them in 「未知」 too (总线程 11-13: 5 ChatGPT users
|
|
177
|
+
* were in both).
|
|
178
|
+
*/
|
|
179
|
+
place(e: UsageEvent): void;
|
|
180
|
+
private placeOf;
|
|
181
|
+
/** Second pass: count it. */
|
|
182
|
+
add(raw: UsageEvent): void;
|
|
183
|
+
build(): Report;
|
|
184
|
+
}
|
|
185
|
+
/** The whole report from events in hand - tests, and small windows. */
|
|
186
|
+
export declare const buildReport: (events: Iterable<UsageEvent>, from: string, to: string, deployment?: string | null, tz?: Tz) => Report;
|
|
187
|
+
/** One day's totals as kept in daily/<day>.json - counts and tool names only. */
|
|
188
|
+
export type DailyTotals = DayTotals & {
|
|
189
|
+
v: 1;
|
|
190
|
+
deployment: string | null;
|
|
191
|
+
tz: string;
|
|
192
|
+
tools: ToolRow[];
|
|
193
|
+
funnel: Funnel;
|
|
194
|
+
};
|
|
195
|
+
export declare const dailyTotals: (r: Report, day: string) => DailyTotals | null;
|
|
196
|
+
/**
|
|
197
|
+
* The days' totals summed - for a window reaching past the 13 months of lines.
|
|
198
|
+
* Users are 「每天活跃之和」 and newUsers 「新用户累计」; conversations, the
|
|
199
|
+
* funnel and shoppers are per-day sums too.
|
|
200
|
+
*/
|
|
201
|
+
export declare const sumDays: (daily: DailyTotals[], from: string, to: string, deployment: string | null, tz: Tz, reason?: Report["reason"]) => Report;
|
|
202
|
+
/** The one line the daily check prints. */
|
|
203
|
+
export declare const summaryLine: (r: Report, name: string) => string;
|
|
204
|
+
/** The report as text, for a person at a terminal. */
|
|
205
|
+
export declare const reportText: (r: Report, name: string) => string;
|
|
206
|
+
export {};
|
|
207
|
+
//# sourceMappingURL=report.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../src/usage/report.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAMnD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,GAAG,MAAM,KAAG,MACmB,CAAC;AAEzD,oDAAoD;AACpD,MAAM,MAAM,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AACrD,eAAO,MAAM,OAAO,EAAE,EAA8C,CAAC;AACrE,eAAO,MAAM,MAAM,EAAE,EAAkC,CAAC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