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
|
||||
|
||||
Reference in new issue
Block a user