further fixed uservoice to identify user

This commit is contained in:
Connor Turland 2014-10-07 15:39:11 -04:00
parent 6eec187eee
commit 9ba6daec90
3 changed files with 9 additions and 6 deletions

View file

@ -3,7 +3,7 @@ if(USERVOICE == undefined) {
USERVOICE = {};
}
USERVOICE.load = function (sso_token) {
USERVOICE.load = function (name, id, email, sso_token) {
// Include the UserVoice JavaScript SDK (only needed once on a page)
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/wybK0nSMNuhlWkIKzTyWg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();
@ -21,8 +21,13 @@ UserVoice.push(['set', {
// Identify the user and pass traits
// To enable, replace sample data with actual user traits and uncomment the line
if (sso_token) {
if (name) {
UserVoice.push(['setSSO', sso_token]);
UserVoice.push(['identify', {
'email': email, // Users email address
'name': name, // Users real name
'id': id, // Optional: Unique id of the user
}]);
}
// Add default trigger to the bottom-left corner of the window:

View file

@ -90,7 +90,7 @@
// set up uservoice with signed in user
<% if authenticated? %>
USERVOICE.load("<%= current_sso_token %>");
USERVOICE.load(Metamaps.Active.Mapper.name, Metamaps.Active.Mapper.id, "<%= user.email %>", "<%= current_sso_token %>");
<% else %>
USERVOICE.load();
<% end %>

View file

@ -1,9 +1,7 @@
require 'uservoice-ruby'
SSO_KEY = '3f0d5e3bbaff5ea7c95e549f75ebba8c'
def current_sso_token
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', SSO_KEY, {
@current_sso_token ||= UserVoice.generate_sso_token('metamapscc', ENV['SSO_KEY'], {
:email => current_user.email
}, 300) # Default expiry time is 5 minutes = 300 seconds
end