Javascript library for SatisMeter API
Note: This library is experimental and not intended for production use.
npm install satismeter/satismeter-js
npm install satismeter/nps-widget
Configure SatisMeter client with your write key
var satismeter = require('satismeter-js');
var client = satismeter({
writeKey: 'ABCD'
});
Create a survey widget
var Widget = require('nps-widget');
var widget = new Widget();
Identify user and get information about survey
satismeter.survey({
userId: '007',
traits: {
name: 'James Bond',
email: '[email protected]',
createdAt: '1953-01-01T00:00:00.000Z'
}
}), function(err, survey) {
if (survey.visible) {
// visible flag says if the survey should be shown
widget.show();
}
});
Handle submit and dismiss events
widget.on('submit', function() {
survey.rating = widget.rating;
survey.feedback = widget.feedback;
survey.save();
});
widget.on('dismiss', function() {
survey.dismissed = true;
survey.save();
});