-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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] Send LiveChat visitor navigation history as messages #10091
Changes from 19 commits
2fb6d12
41e7cbd
089e15e
587ffda
460b76b
221c595
bc8c03d
5b4ec2a
57d0bf3
d86fb7b
cacc518
a25f9ea
632baf1
f4c62d8
d314565
2cc736b
bf90817
b2535ea
cb2274d
c086d6c
b350a0b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
this.LivechatMessage = new Mongo.Collection('rocketchat_message'); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
Meteor.methods({ | ||
'livechat:pageVisited'(token, pageInfo) { | ||
return RocketChat.Livechat.savePageHistory(token, pageInfo); | ||
'livechat:pageVisited'(token, room, pageInfo) { | ||
RocketChat.Livechat.savePageHistory(token, room, pageInfo); | ||
} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ Meteor.methods({ | |
}); | ||
|
||
// update visited page history to not expire | ||
RocketChat.models.LivechatPageVisited.keepHistoryForToken(token); | ||
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. we should keep this behavior. the idea is that page history of unregistered visitors can be deleted (expired), because we track visitor's navigation from the very first interaction.. but if that visitor sends a message then we want to keep his page history "forever" 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. There is a problem here.. I tried to keep this behavior, but currently we are sending and storing the navigation history as a message and we have a relation between message and room. 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.
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. to keep this behavior, as stated before, we'll have to use a new method to store navigations histories as messages. this new method will use |
||
RocketChat.models.Messages.keepHistoryForToken(token); | ||
|
||
return { | ||
userId | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ Meteor.methods({ | |
}); | ||
|
||
// update visited page history to not expire | ||
RocketChat.models.LivechatPageVisited.keepHistoryForToken(token); | ||
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. remember to add this back too =) |
||
RocketChat.models.Messages.keepHistoryForToken(token); | ||
|
||
return true; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
RocketChat.models.Messages.keepHistoryForToken = function(token) { | ||
return this.update({ | ||
'navigation.token': token, | ||
expireAt: { | ||
$exists: true | ||
} | ||
}, { | ||
$unset: { | ||
expireAt: 1 | ||
} | ||
}, { | ||
multi: true | ||
}); | ||
}; | ||
|
||
RocketChat.models.Messages.setRoomIdByToken = function(token, rid) { | ||
return this.update({ | ||
'navigation.token': token, | ||
rid: null | ||
}, { | ||
$set: { | ||
rid | ||
} | ||
}, { | ||
multi: true | ||
}); | ||
}; |
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.
you don't need to receive
roomId
here.. we can rely onRocketChat.models.Rooms.findOneOpenByVisitorToken
to get visitor's current room.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.
@sampaiodiego, the
RocketChat.models.Rooms.findOneOpenByVisitorToken
has aroomId
parameter, due to this I changed thesavePageHistory
to get this parameter.How can I call the
RocketChat.models.Rooms.findOneOpenByVisitorToken
method if I don't pass theroomId
parameter?I'm sorry if I'm making a mistake but I think this parameter is necessary.
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.
you're correct @renatobecker .. I didn't notice
RocketChat.models.Rooms.findOneOpenByVisitorToken
has aroomId
parameter as well. 😉I'll give this PR a whole review to see how we could still save visitor's navigation history without a room.