mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 01:34:13 +08:00
14b436923c
### UI changes
All of the UI changes described are gated behind the `use_legacy_pageviews`
site setting.
This commit changes the admin dashboard pageviews report to
use the "Consolidated Pageviews with Browser Detection" report
introduced in 2f2da72747
with
the following changes:
* The report name is changed to "Site traffic"
* The pageview count on the dashboard is counting only using the new method
* The old "Consolidated Pageviews" report is renamed as "Consolidated Legacy Pageviews"
* By default "known crawlers" and "other" sources of pageviews are hidden on the report
When `use_legacy_pageviews` is `true`, we do not show or allow running
the "Site traffic" report for admins. When `use_legacy_pageviews` is `false`,
we do not show or allow running the following legacy reports:
* consolidated_page_views
* consolidated_page_views_browser_detection
* page_view_anon_reqs
* page_view_logged_in_reqs
### Historical data changes
Also part of this change is that, since we introduced our new "Consolidated
Pageviews with Browser Detection" report, some admins are confused at either:
* The lack of data before a certain date , which didn’t exist before
we started collecting it
* Comparing this and the current "Consolidated Pageviews" report data,
which rolls up "Other Pageviews" into "Anonymous Browser" and so it
appears inaccurate
All pageview data in the new report before the date where the _first_
anon or logged in browser pageview was recorded is now hidden.
171 lines
4.3 KiB
JavaScript
171 lines
4.3 KiB
JavaScript
import { inject as controller } from "@ember/controller";
|
|
import { computed } from "@ember/object";
|
|
import { service } from "@ember/service";
|
|
import { setting } from "discourse/lib/computed";
|
|
import getURL from "discourse-common/lib/get-url";
|
|
import { makeArray } from "discourse-common/lib/helpers";
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
import I18n from "discourse-i18n";
|
|
import AdminDashboard from "admin/models/admin-dashboard";
|
|
import Report from "admin/models/report";
|
|
import AdminDashboardTabController from "./admin-dashboard-tab";
|
|
|
|
function staticReport(reportType) {
|
|
return computed("reports.[]", function () {
|
|
return makeArray(this.reports).find((report) => report.type === reportType);
|
|
});
|
|
}
|
|
|
|
export default class AdminDashboardGeneralController extends AdminDashboardTabController {
|
|
@service router;
|
|
@service siteSettings;
|
|
@controller("exception") exceptionController;
|
|
|
|
isLoading = false;
|
|
dashboardFetchedAt = null;
|
|
|
|
@setting("log_search_queries") logSearchQueriesEnabled;
|
|
|
|
@staticReport("users_by_type") usersByTypeReport;
|
|
@staticReport("users_by_trust_level") usersByTrustLevelReport;
|
|
@staticReport("storage_report") storageReport;
|
|
|
|
@discourseComputed("siteSettings.dashboard_general_tab_activity_metrics")
|
|
activityMetrics(metrics) {
|
|
return (metrics || "").split("|").filter(Boolean);
|
|
}
|
|
|
|
@computed("siteSettings.dashboard_hidden_reports")
|
|
get hiddenReports() {
|
|
return (this.siteSettings.dashboard_hidden_reports || "")
|
|
.split("|")
|
|
.filter(Boolean);
|
|
}
|
|
|
|
@computed("activityMetrics", "hiddenReports")
|
|
get isActivityMetricsVisible() {
|
|
return (
|
|
this.activityMetrics.length &&
|
|
this.activityMetrics.some((x) => !this.hiddenReports.includes(x))
|
|
);
|
|
}
|
|
|
|
@computed("hiddenReports")
|
|
get isSearchReportsVisible() {
|
|
return ["top_referred_topics", "trending_search"].some(
|
|
(x) => !this.hiddenReports.includes(x)
|
|
);
|
|
}
|
|
|
|
@computed("hiddenReports")
|
|
get isCommunityHealthVisible() {
|
|
return [
|
|
"consolidated_page_views",
|
|
"site_traffic",
|
|
"signups",
|
|
"topics",
|
|
"posts",
|
|
"dau_by_mau",
|
|
"daily_engaged_users",
|
|
"new_contributors",
|
|
].some((x) => !this.hiddenReports.includes(x));
|
|
}
|
|
|
|
@discourseComputed
|
|
today() {
|
|
return moment().locale("en").utc().endOf("day");
|
|
}
|
|
|
|
@computed("startDate", "endDate")
|
|
get filters() {
|
|
return { startDate: this.startDate, endDate: this.endDate };
|
|
}
|
|
|
|
@discourseComputed
|
|
activityMetricsFilters() {
|
|
const lastMonth = moment()
|
|
.locale("en")
|
|
.utc()
|
|
.startOf("day")
|
|
.subtract(1, "month");
|
|
|
|
return {
|
|
startDate: lastMonth,
|
|
endDate: this.today,
|
|
};
|
|
}
|
|
|
|
@discourseComputed
|
|
topReferredTopicsOptions() {
|
|
return {
|
|
table: { total: false, limit: 8 },
|
|
};
|
|
}
|
|
|
|
@discourseComputed
|
|
siteTrafficOptions() {
|
|
return {
|
|
stackedChart: { hiddenLabels: ["page_view_other", "page_view_crawler"] },
|
|
};
|
|
}
|
|
|
|
@discourseComputed
|
|
topReferredTopicsFilters() {
|
|
return {
|
|
startDate: moment().subtract(6, "days").startOf("day"),
|
|
endDate: this.today,
|
|
};
|
|
}
|
|
|
|
@discourseComputed
|
|
trendingSearchFilters() {
|
|
return {
|
|
startDate: moment().subtract(1, "month").startOf("day"),
|
|
endDate: this.today,
|
|
};
|
|
}
|
|
|
|
@discourseComputed
|
|
trendingSearchOptions() {
|
|
return {
|
|
table: { total: false, limit: 8 },
|
|
};
|
|
}
|
|
|
|
@discourseComputed
|
|
trendingSearchDisabledLabel() {
|
|
return I18n.t("admin.dashboard.reports.trending_search.disabled", {
|
|
basePath: getURL(""),
|
|
});
|
|
}
|
|
|
|
fetchDashboard() {
|
|
if (this.isLoading) {
|
|
return;
|
|
}
|
|
|
|
if (
|
|
!this.dashboardFetchedAt ||
|
|
moment().subtract(30, "minutes").toDate() > this.dashboardFetchedAt
|
|
) {
|
|
this.set("isLoading", true);
|
|
|
|
AdminDashboard.fetchGeneral()
|
|
.then((adminDashboardModel) => {
|
|
this.setProperties({
|
|
dashboardFetchedAt: new Date(),
|
|
model: adminDashboardModel,
|
|
reports: makeArray(adminDashboardModel.reports).map((x) =>
|
|
Report.create(x)
|
|
),
|
|
});
|
|
})
|
|
.catch((e) => {
|
|
this.exceptionController.set("thrown", e.jqXHR);
|
|
this.router.replaceWith("exception");
|
|
})
|
|
.finally(() => this.set("isLoading", false));
|
|
}
|
|
}
|
|
}
|