Skip to content
Snippets Groups Projects
Commit 4c0e50d4 authored by Diego Sampaio's avatar Diego Sampaio
Browse files

shows visitor's navigation history

parent 628ba2b3
No related branches found
No related tags found
No related merge requests found
......@@ -15,4 +15,4 @@
"Survey_instructions" : "Rate each question according to your satisfaction, 1 meaning you are completely unsatisfied and 5 meaning you are completely satisfied.",
"Thank_you_for_your_feedback" : "Thank you for your feedback",
"We_are_offline_Sorry_for_the_inconvenience" : "We are offline. Sorry for the inconvenience."
}
\ No newline at end of file
}
this.LivechatPageVisited = new Mongo.Collection('rocketchat_livechat_page_visited');
......@@ -440,7 +440,7 @@
.user-view {
li {
color: #7f7f7f;
color: @secondary-font-color;
line-height: 18px;
font-size: 12px;
font-weight: 300;
......@@ -462,3 +462,31 @@
.icon-chat-empty.status-away {
color: @status-away;
}
.visitor-navigation {
height: 130px;
overflow-y: auto;
border: 1px solid #E7E7E7;
border-radius: 4px;
padding: 4px;
margin-top: 4px;
ul {
li {
white-space: nowrap;
a {
text-overflow: ellipsis;
display: block;
overflow: hidden;
color: @secondary-font-color;
text-decoration: underline;
&:hover {
text-decoration: none;
}
}
}
}
}
......@@ -27,6 +27,20 @@
<nav>
<!-- <button class="button pvt-msg"><span><i class="icon-forward"></i> {{_ "Forward"}}</span></button> -->
</nav>
<h4>{{_ "Navigation_History_20_last_pages"}}</h4>
<div class="visitor-navigation">
{{#if loadingNavigation}}
{{_ "Loading..."}}
{{else}}
<ul>
{{#each pageVisited}}
<li><a href="{{page.location.href}}" target="_blank" title="{{accessDateTime}}">{{pageTitle}}</a></li>
{{/each}}
</ul>
{{/if}}
</div>
</div>
</div>
</template>
Template.visitorInfo.helpers({
user() {
var room = ChatRoom.findOne(Session.get('openedRoom'));
if (room && room.v && room.v.token) {
var user = Meteor.users.findOne({ "profile.token": room.v.token });
if (user && user.userAgent) {
var ua = new UAParser();
ua.setUA(user.userAgent);
user.os = ua.getOS().name + ' ' + ua.getOS().version;
if (['Mac OS', 'iOS'].indexOf(ua.getOS().name) !== -1) {
user.osIcon = 'icon-apple';
} else {
user.osIcon = 'icon-' + ua.getOS().name.toLowerCase();
}
user.browser = ua.getBrowser().name + ' ' + ua.getBrowser().version;
user.browserIcon = 'icon-' + ua.getBrowser().name.toLowerCase();
var user = Meteor.users.findOne({ "profile.token": Template.instance().visitorToken.get() });
if (user && user.userAgent) {
var ua = new UAParser();
ua.setUA(user.userAgent);
user.os = ua.getOS().name + ' ' + ua.getOS().version;
if (['Mac OS', 'iOS'].indexOf(ua.getOS().name) !== -1) {
user.osIcon = 'icon-apple';
} else {
user.osIcon = 'icon-' + ua.getOS().name.toLowerCase();
}
user.browser = ua.getBrowser().name + ' ' + ua.getBrowser().version;
user.browserIcon = 'icon-' + ua.getBrowser().name.toLowerCase();
}
return user;
},
loadingNavigation() {
return !Template.instance().pageVisited.ready();
},
pageVisited() {
return LivechatPageVisited.find({ token: Template.instance().visitorToken.get() }, { sort: { ts: -1 } });
},
pageTitle() {
return this.page.title || t('Empty_title');
},
accessDateTime() {
return moment(this.ts).format('L LTS');
},
return user;
createdAt() {
if (!this.createdAt) {
return '';
}
return moment(this.createdAt).format('L LTS');
},
lastLogin() {
if (!this.lastLogin) {
return '';
}
return moment(this.lastLogin).format('L LTS');
}
});
Template.visitorInfo.onCreated(function() {
this.autorun(() => {
this.subscribe('livechat:visitorInfo', Session.get('openedRoom'));
});
this.visitorToken = new ReactiveVar(null);
var currentData = Template.currentData();
if (currentData && currentData.rid) {
this.autorun(() => {
var room = ChatRoom.findOne(currentData.rid);
if (room && room.v && room.v.token) {
this.visitorToken.set(room.v.token);
} else {
this.visitorToken.set();
}
});
this.subscribe('livechat:visitorInfo', currentData.rid);
this.pageVisited = this.subscribe('livechat:visitorPageVisited', currentData.rid);
}
})
......@@ -15,6 +15,7 @@
"Departments" : "Departments",
"Description" : "Description",
"Edit_Department" : "Edit Department",
"Empty_title" : "Empty title",
"Enable" : "Enable",
"Enabled" : "Enabled",
"Enter_a_regex" : "Enter a regex",
......@@ -31,6 +32,7 @@
"Manager_added" : "Manager added",
"Manager_removed" : "Manager removed",
"Name_of_agent" : "Name of agent",
"Navigation_History_20_last_pages" : "Navigation History (20 last pages)",
"New_Department" : "New Department",
"Num_Agents" : "# Agents",
"Opened" : "Opened",
......@@ -53,4 +55,4 @@
"Username_not_found" : "Username not found",
"Visitor_page_URL" : "Visitor page URL",
"Visitor_time_on_site" : "Visitor time on site"
}
\ No newline at end of file
}
......@@ -44,6 +44,7 @@ Package.onUse(function(api) {
api.addFiles('client/collections/AgentUsers.js', 'client');
api.addFiles('client/collections/LivechatDepartment.js', 'client');
api.addFiles('client/collections/LivechatDepartmentAgents.js', 'client');
api.addFiles('client/collections/LivechatPageVisited.js', 'client');
api.addFiles('client/collections/LivechatTrigger.js', 'client');
// client views
......@@ -104,10 +105,11 @@ Package.onUse(function(api) {
api.addFiles('server/publications/availableDepartments.js', 'server');
api.addFiles('server/publications/departmentAgents.js', 'server');
api.addFiles('server/publications/livechatAgents.js', 'server');
api.addFiles('server/publications/livechatManagers.js', 'server');
api.addFiles('server/publications/livechatDepartments.js', 'server');
api.addFiles('server/publications/livechatManagers.js', 'server');
api.addFiles('server/publications/trigger.js', 'server');
api.addFiles('server/publications/visitorInfo.js', 'server');
api.addFiles('server/publications/visitorPageVisited.js', 'server');
api.addFiles('server/publications/visitorRoom.js', 'server');
// livechat app
......
......@@ -26,7 +26,7 @@ class LivechatPageVisitied extends RocketChat.models._Base {
}
findByToken(token) {
return this.find({ token: token });
return this.find({ token: token }, { sort : { ts: -1 }, limit: 20 });
}
keepHistoryForToken(token) {
......
Meteor.publish('livechat:visitorPageVisited', function(roomId) {
if (!this.userId) {
throw new Meteor.Error('not-authorized');
}
if (!RocketChat.authz.hasPermission(this.userId, 'view-l-room')) {
throw new Meteor.Error('not-authorized');
}
var room = RocketChat.models.Rooms.findOneById(roomId);
if (room && room.v && room.v.token) {
return RocketChat.models.LivechatPageVisitied.findByToken(room.v.token);
} else {
return this.ready();
}
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment