2014-12-13 2 views
1

У меня есть userVoice.jsИнтеграция UserVoice SDK с метеором

Meteor.startup(function() { 
    // 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/cOADa8czIXBWdvlpMDtTVg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})(); 

    // 
    // UserVoice Javascript SDK developer documentation: 
    // https://www.uservoice.com/o/javascript-sdk 
    // 

    //var feedbackEmail = Meteor.user().emails[0].address; 

    // Set colors 
    UserVoice.push(['set', { 
    accent_color: '#448dd6', 
    trigger_color: 'white', 
    trigger_background_color: 'rgba(46, 49, 51, 0.6)' 
    }]); 

    // Identify the user and pass traits 
    // To enable, replace sample data with actual user traits and uncomment the line 
    UserVoice.push(['identify', { 
    //email:  feedbackEmail, // User’s email address 
    //name:  'John Doe', // User’s real name 
    //created_at: 1364406966, // Unix timestamp for the date the user signed up 
    //id:   123, // Optional: Unique id of the user (if set, this should not change) 
    //type:  'Owner', // Optional: segment your users by type 
    //account: { 
    // id:   123, // Optional: associate multiple users with a single account 
    // name:   'Acme, Co.', // Account name 
    // created_at: 1364406966, // Unix timestamp for the date the account was created 
    // monthly_rate: 9.99, // Decimal; monthly rate of the account 
    // ltv:   1495.00, // Decimal; lifetime value of the account 
    // plan:   'Enhanced' // Plan name for the account 
    //} 
    }]); 

    // Add default trigger to the bottom-right corner of the window: 
    // UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-right' }]); 

    // Or, use your own custom trigger: 
    UserVoice.push(['addTrigger', '#submitFeedback', { mode: 'contact' }]); 

    // Autoprompt for Satisfaction and SmartVote (only displayed under certain conditions) 
    UserVoice.push(['autoprompt', {}]); 
}); 

Он работает иногда, но потом иногда я получаю ошибку клиента:

Uncaught TypeError: Cannot read property 'getAttribute' of null 

Хотите знать, если я бегу сценарий неправильно. Также не уверен, как дополнительные скрипты загружаются в Meteor и в каком порядке

ответ

1

Только что реализованный uservoice в моем приложении meteor, подобно вашей идее, но я думаю, что вы забыли раскомментировать информацию о пользователе.

Deps.autorun(function() { 
var user = Meteor.user(); 
if(user) { 
    //uservoice code 
} 

А теперь материал для indentify пользователя:

UserVoice.push(['identify', { 
    email:  user.profile.email, // User’s email address 
    name:  user.fullName(), // User’s real name 
    id:   user._id, // Optional: Unique id of the user (if set, this should not change) 
    type:  'user', // Optional: segment your users by type  
}]); 

Он работает до сих пор.

+0

спасибо! Я решил пойти с домофоном вместо uservoice – sdybskiy

Смежные вопросы