Skip to content

Commit

Permalink
[MM-14720] Add bot post counts per day to System Analytics (mattermos…
Browse files Browse the repository at this point in the history
…t#3018)

* Add Bot Posts per day analytics

* Remove botPostCountsDay from team analytics. This is causing an
linting error and not currently requested for teams

* Add Total Posts from Bots

* Correctly place alphabetically in sorted fields
  • Loading branch information
jfrerich authored and crspeller committed Jul 8, 2019
1 parent f4130ac commit 9fb904a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions actions/admin_actions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ export async function getAdvancedAnalytics(teamId) {
await AdminActions.getAdvancedAnalytics(teamId)(dispatch, getState);
}

export async function getBotPostsPerDayAnalytics(teamId) {
await AdminActions.getBotPostsPerDayAnalytics(teamId)(dispatch, getState);
}

export async function getPostsPerDayAnalytics(teamId) {
await AdminActions.getPostsPerDayAnalytics(teamId)(dispatch, getState);
}
Expand Down
20 changes: 20 additions & 0 deletions components/analytics/system_analytics/system_analytics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export default class SystemAnalytics extends React.PureComponent {
componentDidMount() {
AdminActions.getStandardAnalytics();
AdminActions.getPostsPerDayAnalytics();
AdminActions.getBotPostsPerDayAnalytics();
AdminActions.getUsersPerDayAnalytics();

if (this.props.isLicensed) {
Expand All @@ -46,11 +47,13 @@ export default class SystemAnalytics extends React.PureComponent {
const isLicensed = this.props.isLicensed;
const skippedIntensiveQueries = stats[StatTypes.TOTAL_POSTS] === -1;
const postCountsDay = formatPostsPerDayData(stats[StatTypes.POST_PER_DAY]);
const botPostCountsDay = formatPostsPerDayData(stats[StatTypes.BOT_POST_PER_DAY]);
const userCountsWithPostsDay = formatUsersWithPostsPerDayData(stats[StatTypes.USERS_WITH_POSTS_PER_DAY]);

let banner;
let postCount;
let postTotalGraph;
let botPostTotalGraph;
let activeUserGraph;
if (skippedIntensiveQueries) {
banner = (
Expand All @@ -77,6 +80,22 @@ export default class SystemAnalytics extends React.PureComponent {
/>
);

botPostTotalGraph = (
<div className='row'>
<LineChart
title={
<FormattedMessage
id='analytics.system.totalBotPosts'
defaultMessage='Total Posts from Bots'
/>
}
data={botPostCountsDay}
width={740}
height={225}
/>
</div>
);

postTotalGraph = (
<div className='row'>
<LineChart
Expand Down Expand Up @@ -379,6 +398,7 @@ export default class SystemAnalytics extends React.PureComponent {
</div>
{advancedGraphs}
{postTotalGraph}
{botPostTotalGraph}
{activeUserGraph}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions components/analytics/team_analytics/team_analytics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export default class TeamAnalytics extends React.Component {
getData = async (id) => {
AdminActions.getStandardAnalytics(id);
AdminActions.getPostsPerDayAnalytics(id);
AdminActions.getBotPostsPerDayAnalytics(id);
AdminActions.getUsersPerDayAnalytics(id);
const {data: recentlyActiveUsers} = await this.props.actions.getProfilesInTeam(id, 0, General.PROFILE_CHUNK_SIZE, 'last_activity_at');
const {data: newUsers} = await this.props.actions.getProfilesInTeam(id, 0, General.PROFILE_CHUNK_SIZE, 'create_at');
Expand Down
1 change: 1 addition & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1585,6 +1585,7 @@
"analytics.system.skippedIntensiveQueries": "To maximize performance, some statistics are disabled. You can [re-enable them in config.json](!https://docs.mattermost.com/administration/statistics.html).",
"analytics.system.textPosts": "Posts with Text-only",
"analytics.system.title": "System Statistics",
"analytics.system.totalBotPosts": "Total Posts from Bots",
"analytics.system.totalChannels": "Total Channels",
"analytics.system.totalCommands": "Total Commands",
"analytics.system.totalFilePosts": "Posts with Files",
Expand Down
1 change: 1 addition & 0 deletions utils/constants.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ export const StatTypes = keyMirror({
TOTAL_COMMANDS: null,
TOTAL_SESSIONS: null,
POST_PER_DAY: null,
BOT_POST_PER_DAY: null,
USERS_WITH_POSTS_PER_DAY: null,
RECENTLY_ACTIVE_USERS: null,
NEWLY_CREATED_USERS: null,
Expand Down

0 comments on commit 9fb904a

Please sign in to comment.