Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] [ENTERPRISE] Engagement Dashboard #16960

Merged
merged 39 commits into from
Mar 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f364952
Add app module for engagement dashboard
tassoevan Dec 27, 2019
1b9aab5
Add naive component prototype
tassoevan Dec 27, 2019
2dbfa67
Fix broken import
tassoevan Feb 13, 2020
3d90358
[NEW] Engagement Dashboard - Layout prototype (#91)
tassoevan Feb 22, 2020
a036be5
Fix color transitions in growth symbols
tassoevan Feb 28, 2020
e06eaf7
[NEW] Engagement Dashboard - Client routes (#102)
tassoevan Mar 2, 2020
b91bc88
[NEW] Engagement Dashboard Backend (#98)
MarcosSpessatto Mar 2, 2020
b68d4ec
Fix some layout issues
tassoevan Mar 4, 2020
7b788b1
Add prototype of NewUsersSection
tassoevan Mar 4, 2020
49a629e
Feed data to a graph
tassoevan Mar 5, 2020
74eaed3
Add prototype of ActiveUsersSection
tassoevan Mar 5, 2020
439d313
Add prototype of UsersByTimeOfTheDaySection
tassoevan Mar 5, 2020
8256853
Embed heat map into UsersByTimeOfTheDaySection
tassoevan Mar 6, 2020
ceb70ca
Fix import paths
tassoevan Mar 21, 2020
11c7e8f
Add prototype of BusiestChatTimesSection
tassoevan Mar 7, 2020
22dd297
Enhance NewUsersSection
tassoevan Mar 7, 2020
ce76804
Enhance ActiveUsersSection
tassoevan Mar 7, 2020
c750428
Enhance UsersByTimeOfTheDaySection
tassoevan Mar 7, 2020
454e6fc
Rename some endpoints and change its response structures
MarcosSpessatto Mar 12, 2020
7367345
Update NewUsersSection
tassoevan Mar 12, 2020
c8059e0
Rename and improve endpoints
MarcosSpessatto Mar 13, 2020
940df43
Update endpoints
tassoevan Mar 14, 2020
3b86249
Add more chart adjustments
tassoevan Mar 16, 2020
74c1367
Fix tabs position
tassoevan Mar 17, 2020
40f2835
Inject data into some sections
tassoevan Mar 17, 2020
578b456
Fix some layout issues
tassoevan Mar 17, 2020
c13d817
Remove unused components
tassoevan Mar 17, 2020
13b10fa
Fix API route
tassoevan Mar 18, 2020
0c7aaf8
Add TableSection prototype
tassoevan Mar 18, 2020
d5e8558
Add pagination behavior
tassoevan Mar 18, 2020
6cb1750
Fix boolean condition
tassoevan Mar 21, 2020
c67f929
Add basic licensing support
tassoevan Mar 21, 2020
c666da6
Merge remote-tracking branch 'origin/develop' into feat/engagement-da…
rodrigok Mar 21, 2020
b60ea26
Add `engagement-dashboard` module to enterprise bundle
rodrigok Mar 21, 2020
35d057e
Add pagination support
MarcosSpessatto Mar 23, 2020
c57bd5c
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
ggazzo Mar 24, 2020
1bc60bf
added count channel page
ggazzo Mar 24, 2020
09c28bf
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into feat…
gabriellsh Mar 24, 2020
c920a04
Added missing translation keys
gabriellsh Mar 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ addDecorator(withKnobs);
configure([
require.context('../app', true, /\.stories\.js$/),
require.context('../client', true, /\.stories\.js$/),
require.context('../ee/app', true, /\.stories\.js$/),
], module);
11 changes: 11 additions & 0 deletions app/models/server/models/Analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Base } from './_Base';

export class Analytics extends Base {
constructor() {
super('analytics');
this.tryEnsureIndex({ date: 1 });
this.tryEnsureIndex({ 'room._id': 1, date: 1 }, { unique: true });
}
}

export default new Analytics();
145 changes: 145 additions & 0 deletions app/models/server/raw/Analytics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import { Random } from 'meteor/random';

import { BaseRaw } from './BaseRaw';
import Analytics from '../models/Analytics';

export class AnalyticsRaw extends BaseRaw {
saveMessageSent({ room, date }) {
return this.update({ date, 'room._id': room._id, type: 'messages' }, {
$set: {
room: { _id: room._id, name: room.fname || room.name, t: room.t, usernames: room.usernames || [] },
},
$setOnInsert: {
_id: Random.id(),
date,
type: 'messages',
},
$inc: { messages: 1 },
}, { upsert: true });
}

saveUserData({ date }) {
return this.update({ date, type: 'users' }, {
$setOnInsert: {
_id: Random.id(),
date,
type: 'users',
},
$inc: { users: 1 },
}, { upsert: true });
}

saveMessageDeleted({ room, date }) {
return this.update({ date, 'room._id': room._id }, {
$inc: { messages: -1 },
});
}

getMessagesSentTotalByDate({ start, end, options = {} }) {
const params = [
{
$match: {
type: 'messages',
date: { $gte: start, $lte: end },
},
},
{
$group: {
_id: '$date',
messages: { $sum: '$messages' },
},
},
];
if (options.sort) {
params.push({ $sort: options.sort });
}
if (options.count) {
params.push({ $limit: options.count });
}
return this.col.aggregate(params).toArray();
}

getMessagesOrigin({ start, end }) {
const params = [
{
$match: {
type: 'messages',
date: { $gte: start, $lte: end },
},
},
{
$group: {
_id: { t: '$room.t' },
messages: { $sum: '$messages' },
},
},
{
$project: {
_id: 0,
t: '$_id.t',
messages: 1,
},
},
];
return this.col.aggregate(params).toArray();
}

getMostPopularChannelsByMessagesSentQuantity({ start, end, options = {} }) {
const params = [
{
$match: {
type: 'messages',
date: { $gte: start, $lte: end },
},
},
{
$group: {
_id: { t: '$room.t', name: '$room.name', usernames: '$room.usernames' },
messages: { $sum: '$messages' },
},
},
{
$project: {
_id: 0,
t: '$_id.t',
name: '$_id.name',
usernames: '$_id.usernames',
messages: 1,
},
},
];
if (options.sort) {
params.push({ $sort: options.sort });
}
if (options.count) {
params.push({ $limit: options.count });
}
return this.col.aggregate(params).toArray();
}

getTotalOfRegisteredUsersByDate({ start, end, options = {} }) {
const params = [
{
$match: {
type: 'users',
date: { $gte: start, $lte: end },
},
},
{
$group: {
_id: '$date',
users: { $sum: '$users' },
},
},
];
if (options.sort) {
params.push({ $sort: options.sort });
}
if (options.count) {
params.push({ $limit: options.count });
}
return this.col.aggregate(params).toArray();
}
}

export default new AnalyticsRaw(Analytics.model.rawCollection());
103 changes: 103 additions & 0 deletions app/models/server/raw/Rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,107 @@ export class RoomsRaw extends BaseRaw {

return this.find(query, options);
}

findChannelsWithNumberOfMessagesBetweenDate({ start, end, startOfLastWeek, endOfLastWeek, onlyCount = false, options = {} }) {
const lookup = {
$lookup: {
from: 'rocketchat_analytics',
localField: '_id',
foreignField: 'room._id',
as: 'messages',
},
};
const messagesProject = {
$project: {
room: '$$ROOT',
messages: {
$filter: {
input: '$messages',
as: 'message',
cond: {
$and: [
{ $gte: ['$$message.date', start] },
{ $lte: ['$$message.date', end] },
],
},
},
},
lastWeekMessages: {
$filter: {
input: '$messages',
as: 'message',
cond: {
$and: [
{ $gte: ['$$message.date', startOfLastWeek] },
{ $lte: ['$$message.date', endOfLastWeek] },
],
},
},
},
},
};
const messagesUnwind = {
$unwind: {
path: '$messages',
preserveNullAndEmptyArrays: true,
},
};
const messagesGroup = {
$group: {
_id: {
_id: '$room._id',
},
room: { $first: '$room' },
messages: { $sum: '$messages.messages' },
lastWeekMessages: { $first: '$lastWeekMessages' },
},
};
const lastWeekMessagesUnwind = {
$unwind: {
path: '$lastWeekMessages',
preserveNullAndEmptyArrays: true,
},
};
const lastWeekMessagesGroup = {
$group: {
_id: {
_id: '$room._id',
},
room: { $first: '$room' },
messages: { $first: '$messages' },
lastWeekMessages: { $sum: '$lastWeekMessages.messages' },
},
};
const presentationProject = {
$project: {
_id: 0,
room: {
_id: '$_id._id',
name: { $ifNull: ['$room.name', '$room.fname'] },
ts: '$room.ts',
t: '$room.t',
_updatedAt: '$room._updatedAt',
usernames: '$room.usernames',
},
messages: '$messages',
lastWeekMessages: '$lastWeekMessages',
diffFromLastWeek: { $subtract: ['$messages', '$lastWeekMessages'] },
},
};
const firstParams = [lookup, messagesProject, messagesUnwind, messagesGroup, lastWeekMessagesUnwind, lastWeekMessagesGroup, presentationProject];
const sort = { $sort: options.sort || { messages: -1 } };
const params = [...firstParams, sort];
if (onlyCount) {
params.push({ $count: 'total' });
return this.col.aggregate(params);
}
if (options.offset) {
params.push({ $skip: options.offset });
}
if (options.count) {
params.push({ $limit: options.count });
}

return this.col.aggregate(params).toArray();
}
}
Loading