feat: record own and trusted web traffic in its own classes instead of dropping it
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4143bf599e
commit
3511a7141c
18 files changed
+434
-17
No files matched your search
@@ -1579,6 +1579,31 @@
|
||||
var CLIENT_COLORS = { desktop: '--viz-1', mobile: '--viz-6', tablet: '--viz-5', bot: '--viz-3', tool: '--viz-7', unknown: '--viz-8', misc: '--viz-2' };
|
||||
var CLIENT_ORDER = ['desktop', 'mobile', 'tablet', 'bot', 'tool', 'unknown', 'misc'];
|
||||
var STATUS_TOKENS = ['--ok', '--info', '--warn', '--danger'];
|
||||
// Own infrastructure and trusted origins: counted apart, never analysed (s.own, s.totals.trusted/internal)
|
||||
function renderOwnTraffic(box, s) {
|
||||
var o = s.own || {}, T = s.totals || {}, tr = o.trusted || 0, inn = o.internal || 0, tot = tr + inn;
|
||||
ready(box); clear(box.body);
|
||||
if (!tot) { box.body.appendChild(empty(t('own.none'), t('own.noneBody'))); return; }
|
||||
var kp = h('div', 'kpi-row');
|
||||
kp.appendChild(stat(t('own.trusted'), nf(tr), t('own.sub.trusted'), 'neutral'));
|
||||
kp.appendChild(stat(t('own.internal'), nf(inn), t('own.sub.internal'), 'neutral'));
|
||||
kp.appendChild(stat(t('own.all'), nf(T.requests_all || (T.requests || 0) + tot), t('own.sub.all', { n: nf(T.requests || 0), o: nf(tot) }), 'neutral'));
|
||||
box.body.appendChild(kp);
|
||||
var ser = o.series || {};
|
||||
box.body.appendChild(charts.stackedArea([{ key: 'trusted', label: t('own.trusted'), values: ser.trusted || [] }, { key: 'internal', label: t('own.internal'), values: ser.internal || [] }], o.step, { start: o.start, colors: ['--viz-5', '--viz-8'], title: t('own.title') }));
|
||||
var cls = ['2xx', '3xx', '4xx', '5xx'];
|
||||
box.body.appendChild(charts.bars(cls.map(function (k, i) { return { key: k, label: t('traffic.status.' + k), value: (o.status || [])[i] || 0, color: STATUS_TOKENS[i] }; }), { title: t('traffic.status') }));
|
||||
var rows = o.origins || [], tb = el('table', { class: 'tbl' });
|
||||
tb.appendChild(h('thead', null, h('tr', null, h('th', null, t('own.col.origin')), h('th', null, t('own.col.class')), h('th', 'num', t('own.col.requests')))));
|
||||
var body = el('tbody');
|
||||
rows.forEach(function (r) { body.appendChild(h('tr', null, h('td', 'mono', r.key), h('td', null, t('own.' + pick(['trusted', 'internal'], r.label, 'internal'))), h('td', 'num', nf(r.n)))); });
|
||||
tb.appendChild(body);
|
||||
box.body.appendChild(h('h3', null, t('own.origins'))); box.body.appendChild(tb);
|
||||
var two = h('div', 'grid-12');
|
||||
var dm = h('div', 'span-6', h('h3', null, t('own.domains')), bars(o.domains || [], { mono: true }));
|
||||
var ph = h('div', 'span-6', h('h3', null, t('own.paths')), bars(o.paths || [], { mono: true }));
|
||||
two.appendChild(dm); two.appendChild(ph); box.body.appendChild(two);
|
||||
}
|
||||
var pTraffic = corePage({
|
||||
id: 'traffic', icon: ICONS.traffic, titleKey: 'nav.traffic', domain: true,
|
||||
build: function (root) {
|
||||
@@ -1594,19 +1619,22 @@
|
||||
v.browsers = panel({ title: t('traffic.browsers'), hint: t('traffic.browsers.hint'), loading: true });
|
||||
v.oses = panel({ title: t('traffic.oses'), hint: t('traffic.oses.hint'), loading: true });
|
||||
v.status = panel({ title: t('traffic.status'), hint: t('traffic.status.hint'), loading: true, help: 'term.status_class' });
|
||||
v.own = panel({ title: t('own.title'), hint: t('own.hint'), loading: true });
|
||||
v.privacy = sp(12, h('p', 'note', t('traffic.privacy')));
|
||||
g.appendChild(v.lead); g.appendChild(v.kpis); g.appendChild(sp(12, v.timeline)); g.appendChild(sp(12, v.map));
|
||||
g.appendChild(sp(4, v.client)); g.appendChild(sp(4, v.browsers)); g.appendChild(sp(4, v.oses));
|
||||
g.appendChild(sp(6, v.status)); g.appendChild(sp(6, v.bots));
|
||||
['pages', 'refs', 'cities'].forEach(function (k) { g.appendChild(sp(4, v[k])); });
|
||||
g.appendChild(sp(12, v.own));
|
||||
g.appendChild(v.privacy);
|
||||
root.appendChild(g);
|
||||
return v;
|
||||
},
|
||||
load: function (c) { return api('/api/v1/traffic', Object.assign({ host: c.host, domain: c.domain }, c.from !== null && c.from !== undefined ? { from: c.from, to: c.to } : { range: c.range })); },
|
||||
render: function (v, d) {
|
||||
render: function (v, d, c) {
|
||||
v.data = d;
|
||||
setDomains(d.domains || []);
|
||||
getSummary(c).then(function (s) { renderOwnTraffic(v.own, s); }, function () { ready(v.own); clear(v.own.body); v.own.body.appendChild(empty(t('own.none'), '')); });
|
||||
var hasData = d.requests > 0;
|
||||
clear(v.lead); v.lead.classList.remove('skeleton', 'lead-skel');
|
||||
v.lead.appendChild(hasData
|
||||
|
||||
@@ -321,6 +321,22 @@ window.URUTAU_I18N = {
|
||||
'traffic.browsers': 'Browsers',
|
||||
'traffic.oses': 'Operating systems',
|
||||
'traffic.status': 'Status codes',
|
||||
'own.title': 'Own infrastructure and trusted origins',
|
||||
'own.hint': 'Requests from --trusted origins and private networks. They are counted here and nowhere else: they never score an IP, enter threats, maps, visitors or the blocklist.',
|
||||
'own.none': 'No requests from own or trusted origins',
|
||||
'own.noneBody': 'Nothing came from --trusted or --ignore addresses in this range.',
|
||||
'own.trusted': 'Trusted origins',
|
||||
'own.internal': 'Internal networks',
|
||||
'own.all': 'All requests',
|
||||
'own.sub.trusted': 'addresses of --trusted',
|
||||
'own.sub.internal': 'private and --ignore ranges',
|
||||
'own.sub.all': '{n} external + {o} own',
|
||||
'own.origins': 'By origin',
|
||||
'own.domains': 'By domain',
|
||||
'own.paths': 'Top paths',
|
||||
'own.col.origin': 'Origin',
|
||||
'own.col.class': 'Class',
|
||||
'own.col.requests': 'Requests',
|
||||
'traffic.privacy': 'Visitors are counted with a daily rotating hash kept in memory only. No visitor IP is stored.',
|
||||
'traffic.sub.visitors': 'distinct, hash per day',
|
||||
'traffic.sub.requests': 'incl. assets and bots',
|
||||
@@ -857,6 +873,22 @@ window.URUTAU_I18N = {
|
||||
'traffic.browsers': 'Navegadores',
|
||||
'traffic.oses': 'Sistemas operacionais',
|
||||
'traffic.status': 'Códigos de status',
|
||||
'own.title': 'Infraestrutura própria e origens confiáveis',
|
||||
'own.hint': 'Requisições de origens --trusted e de redes privadas. Elas são contadas aqui e em mais nenhum lugar: nunca pontuam um IP, nem entram em ameaças, mapas, visitantes ou na lista de bloqueio.',
|
||||
'own.none': 'Nenhuma requisição de origens próprias ou confiáveis',
|
||||
'own.noneBody': 'Nada veio de endereços --trusted ou --ignore neste período.',
|
||||
'own.trusted': 'Origens confiáveis',
|
||||
'own.internal': 'Redes internas',
|
||||
'own.all': 'Todas as requisições',
|
||||
'own.sub.trusted': 'endereços de --trusted',
|
||||
'own.sub.internal': 'faixas privadas e --ignore',
|
||||
'own.sub.all': '{n} externas + {o} próprias',
|
||||
'own.origins': 'Por origem',
|
||||
'own.domains': 'Por domínio',
|
||||
'own.paths': 'Caminhos mais pedidos',
|
||||
'own.col.origin': 'Origem',
|
||||
'own.col.class': 'Classe',
|
||||
'own.col.requests': 'Requisições',
|
||||
'traffic.privacy': 'Visitantes são contados com um hash que muda todo dia e fica só na memória. Nenhum IP de visitante é guardado.',
|
||||
'traffic.sub.visitors': 'distintos, hash diário',
|
||||
'traffic.sub.requests': 'inclui recursos e bots',
|
||||
|
||||
Reference in new issue
Block a user