Skip to content
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

feat: add support for startSurvey function #472

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ details.

`startTour()` Your intercom account needs to support product tours

`startSurvey()` Your intercom account needs to support surveys

### Events

Subscribe to events in your app with event listeners:
Expand Down
14 changes: 14 additions & 0 deletions addon/services/intercom.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ export default Service.extend(Evented, {
return this.get('api')('startTour', tourId);
},

/**
* If you would like to trigger a survey based on an action a user or visitor
* takes in your site or application, you can use this API method.
* You need to call this method with the id of the survey you wish to show.
* The id of the survey can be found in the “Additional ways to share your survey”
* section of the survey editor.
* @public
* @param {number} surveyId Survey ID to trigger
*/
startSurvey(surveyId) {
return this.get('api')('startSurvey', surveyId);
},


/**
* Private on hide
* @private
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/services/intercom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,9 @@ module('Unit | Service | intercom', function(hooks) {
service.startTour(123);
assert.equal(intercomStub.calledWith('startTour'), true, 'Intercom method called -- startTour');
sinon.assert.calledWith(intercomStub, 'startTour', 123);

service.startSurvey(456);
assert.equal(intercomStub.calledWith('startSurvey'), true, 'Intercom method called -- startSurvey');
sinon.assert.calledWith(intercomStub, 'startSurvey', 456);
});
});