-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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] Livechat Analytics and Reports #11238
Changes from 10 commits
eb932a8
f09ad74
7b30300
f91824e
b7b47c9
c788bfa
3b63557
8777c0d
61a3920
82dbdd0
3b38fca
eae93a8
97b3c56
97947fb
39ce22d
e3b09bd
529f543
b0d3ca7
433b5ba
f569b84
9c44791
71e4d67
b92bb6b
4ad9db3
56f9c76
7e6f55a
7207a52
de07653
0a43128
91e3bef
d4d4810
b73ddb4
2968549
b024e66
35c3d79
30cc972
cfa500d
c06b691
b27839e
30024db
bbcb319
47ecb6a
4cca087
4b178a7
8465f9b
bb5420a
580f4de
01276ce
d05a559
8459ab4
be37a29
e986dfd
073a5d3
4212b80
9f6f001
f5349b8
755645e
32688af
0857584
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -561,9 +561,9 @@ class ModelRooms extends RocketChat.models._Base { | |
return this.update(query, update); | ||
} | ||
|
||
incMsgCountAndSetLastMessageById(_id, inc, lastMessageTimestamp, lastMessage) { | ||
incMsgCountAndSetLastMessageById(room, token, inc, lastMessageTimestamp, lastMessage) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I'm not wrong, your implementation here is not related to In addition: You can use the |
||
if (inc == null) { inc = 1; } | ||
const query = {_id}; | ||
const query = {_id: room._id}; | ||
|
||
const update = { | ||
$set: { | ||
|
@@ -574,6 +574,20 @@ class ModelRooms extends RocketChat.models._Base { | |
} | ||
}; | ||
|
||
// livechat analytics : update last message timestamps | ||
if (room.t === 'l') { | ||
const visitorLastMessage = (room.metrics && room.metrics.v) ? room.metrics.v.lq : room.ts; | ||
const agentLastMessage = (room.metrics && room.metrics.servedBy) ? room.metrics.servedBy.lr : room.ts; | ||
|
||
if (token) { // update visitor timestamp, only if its new inquiry and not continuing message | ||
if (agentLastMessage >= visitorLastMessage) { // if first query, not continuing query from visitor | ||
update.$set['metrics.v.lq'] = lastMessageTimestamp; | ||
} | ||
} else if (visitorLastMessage > agentLastMessage) { // update agent timestamp, if first response, not continuing | ||
update.$set['metrics.servedBy.lr'] = lastMessageTimestamp; | ||
} | ||
} | ||
|
||
if (lastMessage) { | ||
update.$set.lastMessage = lastMessage; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said below, you don't need to change the method
incMsgCountAndSetLastMessageById
to implement your code.You have created a new file listening
afterSaveMessage
callback, why didn't you implement the code there?https://github.com/RocketChat/Rocket.Chat/pull/11238/files#diff-9943cbbd0d16d3c0c7306a507793042dR1