mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
This commit is contained in:
@@ -65,6 +65,9 @@
|
|||||||
"high-presence-topics": "High Presence Topics",
|
"high-presence-topics": "High Presence Topics",
|
||||||
|
|
||||||
"graphs.page-views": "Page Views",
|
"graphs.page-views": "Page Views",
|
||||||
|
"graphs.page-views-registered": "Page Views Registered",
|
||||||
|
"graphs.page-views-guest": "Page Views Guest",
|
||||||
|
"graphs.page-views-bot": "Page Views Bot",
|
||||||
"graphs.unique-visitors": "Unique Visitors",
|
"graphs.unique-visitors": "Unique Visitors",
|
||||||
"graphs.registered-users": "Registered Users",
|
"graphs.registered-users": "Registered Users",
|
||||||
"graphs.anonymous-users": "Anonymous Users",
|
"graphs.anonymous-users": "Anonymous Users",
|
||||||
|
|||||||
@@ -145,6 +145,9 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator', 'benchpress'
|
|||||||
var t = translator.Translator.create();
|
var t = translator.Translator.create();
|
||||||
Promise.all([
|
Promise.all([
|
||||||
t.translateKey('admin/general/dashboard:graphs.page-views', []),
|
t.translateKey('admin/general/dashboard:graphs.page-views', []),
|
||||||
|
t.translateKey('admin/general/dashboard:graphs.page-views-registered', []),
|
||||||
|
t.translateKey('admin/general/dashboard:graphs.page-views-guest', []),
|
||||||
|
t.translateKey('admin/general/dashboard:graphs.page-views-bot', []),
|
||||||
t.translateKey('admin/general/dashboard:graphs.unique-visitors', []),
|
t.translateKey('admin/general/dashboard:graphs.unique-visitors', []),
|
||||||
t.translateKey('admin/general/dashboard:graphs.registered-users', []),
|
t.translateKey('admin/general/dashboard:graphs.registered-users', []),
|
||||||
t.translateKey('admin/general/dashboard:graphs.anonymous-users', []),
|
t.translateKey('admin/general/dashboard:graphs.anonymous-users', []),
|
||||||
@@ -169,6 +172,36 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator', 'benchpress'
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: translations[1],
|
label: translations[1],
|
||||||
|
backgroundColor: 'rgba(220,110,110,0.2)',
|
||||||
|
borderColor: 'rgba(220,110,110,1)',
|
||||||
|
pointBackgroundColor: 'rgba(220,110,110,1)',
|
||||||
|
pointHoverBackgroundColor: '#fff',
|
||||||
|
pointBorderColor: '#fff',
|
||||||
|
pointHoverBorderColor: 'rgba(220,220,220,1)',
|
||||||
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: translations[2],
|
||||||
|
backgroundColor: 'rgba(220,220,220,0.2)',
|
||||||
|
borderColor: 'rgba(220,220,220,1)',
|
||||||
|
pointBackgroundColor: 'rgba(220,220,220,1)',
|
||||||
|
pointHoverBackgroundColor: '#fff',
|
||||||
|
pointBorderColor: '#fff',
|
||||||
|
pointHoverBorderColor: 'rgba(220,220,220,1)',
|
||||||
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: translations[3],
|
||||||
|
backgroundColor: 'rgba(220,220,220,0.2)',
|
||||||
|
borderColor: 'rgba(220,220,220,1)',
|
||||||
|
pointBackgroundColor: 'rgba(220,220,220,1)',
|
||||||
|
pointHoverBackgroundColor: '#fff',
|
||||||
|
pointBorderColor: '#fff',
|
||||||
|
pointHoverBorderColor: 'rgba(220,220,220,1)',
|
||||||
|
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: translations[4],
|
||||||
backgroundColor: 'rgba(151,187,205,0.2)',
|
backgroundColor: 'rgba(151,187,205,0.2)',
|
||||||
borderColor: 'rgba(151,187,205,1)',
|
borderColor: 'rgba(151,187,205,1)',
|
||||||
pointBackgroundColor: 'rgba(151,187,205,1)',
|
pointBackgroundColor: 'rgba(151,187,205,1)',
|
||||||
@@ -215,7 +248,7 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator', 'benchpress'
|
|||||||
position: 'right',
|
position: 'right',
|
||||||
scaleLabel: {
|
scaleLabel: {
|
||||||
display: true,
|
display: true,
|
||||||
labelString: translations[1],
|
labelString: translations[4],
|
||||||
},
|
},
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
@@ -415,7 +448,10 @@ define('admin/general/dashboard', ['semver', 'Chart', 'translator', 'benchpress'
|
|||||||
}
|
}
|
||||||
|
|
||||||
graphs.traffic.data.datasets[0].data = data.pageviews;
|
graphs.traffic.data.datasets[0].data = data.pageviews;
|
||||||
graphs.traffic.data.datasets[1].data = data.uniqueVisitors;
|
graphs.traffic.data.datasets[1].data = data.pageviewsRegistered;
|
||||||
|
graphs.traffic.data.datasets[2].data = data.pageViewsGuest;
|
||||||
|
graphs.traffic.data.datasets[3].data = data.pageViewsBot;
|
||||||
|
graphs.traffic.data.datasets[4].data = data.uniqueVisitors;
|
||||||
graphs.traffic.data.labels = graphs.traffic.data.xLabels;
|
graphs.traffic.data.labels = graphs.traffic.data.xLabels;
|
||||||
|
|
||||||
graphs.traffic.update();
|
graphs.traffic.update();
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ var Analytics = module.exports;
|
|||||||
var counters = {};
|
var counters = {};
|
||||||
|
|
||||||
var pageViews = 0;
|
var pageViews = 0;
|
||||||
|
var pageViewsRegistered = 0;
|
||||||
|
var pageViewsGuest = 0;
|
||||||
|
var pageViewsBot = 0;
|
||||||
var uniqueIPCount = 0;
|
var uniqueIPCount = 0;
|
||||||
var uniquevisitors = 0;
|
var uniquevisitors = 0;
|
||||||
|
|
||||||
@@ -51,6 +54,14 @@ Analytics.increment = function (keys, callback) {
|
|||||||
Analytics.pageView = function (payload) {
|
Analytics.pageView = function (payload) {
|
||||||
pageViews += 1;
|
pageViews += 1;
|
||||||
|
|
||||||
|
if (payload.uid > 0) {
|
||||||
|
pageViewsRegistered += 1;
|
||||||
|
} else if (payload.uid < 0) {
|
||||||
|
pageViewsBot += 1;
|
||||||
|
} else {
|
||||||
|
pageViewsGuest += 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (payload.ip) {
|
if (payload.ip) {
|
||||||
// Retrieve hash or calculate if not present
|
// Retrieve hash or calculate if not present
|
||||||
let hash = ipCache.get(payload.ip + nconf.get('secret'));
|
let hash = ipCache.get(payload.ip + nconf.get('secret'));
|
||||||
@@ -92,6 +103,24 @@ Analytics.writeData = function (callback) {
|
|||||||
pageViews = 0;
|
pageViews = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pageViewsRegistered > 0) {
|
||||||
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:pageviews:registered', pageViewsRegistered, today.getTime()));
|
||||||
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:pageviews:month:registered', pageViewsRegistered, month.getTime()));
|
||||||
|
pageViewsRegistered = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageViewsGuest > 0) {
|
||||||
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:pageviews:guest', pageViewsGuest, today.getTime()));
|
||||||
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:pageviews:month:guest', pageViewsGuest, month.getTime()));
|
||||||
|
pageViewsGuest = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pageViewsBot > 0) {
|
||||||
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:pageviews:bot', pageViewsBot, today.getTime()));
|
||||||
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:pageviews:month:bot', pageViewsBot, month.getTime()));
|
||||||
|
pageViewsBot = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (uniquevisitors > 0) {
|
if (uniquevisitors > 0) {
|
||||||
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:uniquevisitors', uniquevisitors, today.getTime()));
|
dbQueue.push(async.apply(db.sortedSetIncrBy, 'analytics:uniquevisitors', uniquevisitors, today.getTime()));
|
||||||
uniquevisitors = 0;
|
uniquevisitors = 0;
|
||||||
|
|||||||
@@ -291,22 +291,23 @@ SocketAdmin.analytics.get = function (socket, data, callback) {
|
|||||||
data.amount = 24;
|
data.amount = 24;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const getStats = data.units === 'days' ? analytics.getDailyStatsForSet : analytics.getHourlyStatsForSet;
|
||||||
if (data.graph === 'traffic') {
|
if (data.graph === 'traffic') {
|
||||||
async.parallel({
|
async.parallel({
|
||||||
uniqueVisitors: function (next) {
|
uniqueVisitors: function (next) {
|
||||||
if (data.units === 'days') {
|
getStats('analytics:uniquevisitors', data.until || Date.now(), data.amount, next);
|
||||||
analytics.getDailyStatsForSet('analytics:uniquevisitors', data.until || Date.now(), data.amount, next);
|
|
||||||
} else {
|
|
||||||
analytics.getHourlyStatsForSet('analytics:uniquevisitors', data.until || Date.now(), data.amount, next);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
pageviews: function (next) {
|
pageviews: function (next) {
|
||||||
if (data.units === 'days') {
|
getStats('analytics:pageviews', data.until || Date.now(), data.amount, next);
|
||||||
analytics.getDailyStatsForSet('analytics:pageviews', data.until || Date.now(), data.amount, next);
|
},
|
||||||
} else {
|
pageViewsRegistered: function (next) {
|
||||||
analytics.getHourlyStatsForSet('analytics:pageviews', data.until || Date.now(), data.amount, next);
|
getStats('analytics:pageviews:registered', data.until || Date.now(), data.amount, next);
|
||||||
}
|
},
|
||||||
|
pageViewsGuest: function (next) {
|
||||||
|
getStats('analytics:pageviews:guest', data.until || Date.now(), data.amount, next);
|
||||||
|
},
|
||||||
|
pageViewsBot: function (next) {
|
||||||
|
getStats('analytics:pageviews:bot', data.until || Date.now(), data.amount, next);
|
||||||
},
|
},
|
||||||
summary: function (next) {
|
summary: function (next) {
|
||||||
analytics.getSummary(next);
|
analytics.getSummary(next);
|
||||||
|
|||||||
Reference in New Issue
Block a user