Skip to content

Commit

Permalink
Make the target for Feedback configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
rhainer authored Oct 26, 2018
1 parent 486fa58 commit d31b7bf
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 20 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,16 @@ sharing](tokbox.com/developer/guides/screen-sharing/).

#### Feedback

`ENABLE_FEEDBACK`: Enable the "Give Demo Feedback" form.
The app lets the developer POST feedback data to an endpoint on your HTTP server:

`FEEDBACK_URL`: The URL to send a POST request with feedback data. Leave this as an empty string or
undefined to disable issue reporting.

`REPORT_ISSUE_LEVEL`: The audio and video scores in the feedback form are between 1 (awful) and 5 (excellent). When the feedback form is submitted, if an audio or video score is less than or equal to the report issue level, the app calls `OT.reportIssue()`. This reports an issue, which you can view in OpenTok Inspector. (For more information, see [Reporting an issue](https://tokbox.com/developer/guides/debugging/js/#report-issue) in the OpenTok developer Guides.) The default value is 3, set to 0 to disable issue reporting.

```json
"Feedback": {
"enabled": true,
"url": "",
"reportIssueLevel": 0
},
```
Expand Down Expand Up @@ -431,7 +436,7 @@ endpoint sends a response with the HTTP status code set to 200 and the JSON like
```json
{
"name": "opentok-rtc",
"version": "4.1.0",
"version": "4.1.1",
"gitHash": "312903cd043d5267bc11639718c47a9b313c1663",
"opentok": true,
"firebase": true,
Expand Down Expand Up @@ -466,7 +471,7 @@ the HTTP status code set 400 and JSON like the following:
```json
{
"name": "opentok-rtc",
"version": "4.1.0",
"version": "4.1.1",
"git_hash": "312903cd043d5267bc11639718c47a9b313c1663",
"opentok": true,
"firebase": false,
Expand Down
2 changes: 1 addition & 1 deletion config/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
},
"Feedback":{
"enabled": false,
"url": "",
"reportIssueLevel": 0
},
"Screensharing":{
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opentok-rtc",
"version": "4.1.0",
"version": "4.1.1",
"description": "OpenTokRTC sample application to show off the OpenTok API and platform capabilities ",
"main": "server.js",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion server/serverConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ E.ENABLE_ARCHIVE_MANAGER = { envVar: 'ENABLE_ARCHIVE_MANAGER', jsonPath: 'Archiv
// Maximum time an empty room will keep it's history alive, in minutes.
E.EMPTY_ROOM_LIFETIME = { envVar: 'EMPTY_ROOM_LIFETIME', jsonPath: 'Archiving.archiveManager.emptyRoomMaxLifetime', defaultValue: 3 };

E.ENABLE_FEEDBACK = { envVar: 'ENABLE_FEEDBACK', jsonPath: 'Feedback.enabled', defaultValue: false, parser: parseBool };
E.FEEDBACK_URL = { envVar: 'FEEDBACK_URL', jsonPath: 'Feedback.url', defaultValue: '' };

E.REPORT_ISSUE_LEVEL = { envVar: 'REPORT_ISSUE_LEVEL', jsonPath: 'Feedback.reportIssueLevel', defaultValue: 3 };

Expand Down
6 changes: 3 additions & 3 deletions server/serverMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function ServerMethods(aLogLevel, aModules) {
var enableArchiveManager = enableArchiving && config.get(C.ENABLE_ARCHIVE_MANAGER);
var enableScreensharing = config.get(C.ENABLE_SCREENSHARING);
var enableAnnotations = enableScreensharing && config.get(C.ENABLE_ANNOTATIONS);
var enableFeedback = config.get(C.ENABLE_FEEDBACK);
var feedbackUrl = config.get(C.FEEDBACK_URL);
var reportIssueLevel = config.get(C.REPORT_ISSUE_LEVEL);

if (!firebaseConfigured && enableArchiveManager) {
Expand Down Expand Up @@ -179,7 +179,7 @@ function ServerMethods(aLogLevel, aModules) {
enableArchiveManager,
enableScreensharing,
enableAnnotations,
enableFeedback,
feedbackUrl,
enableSip,
opentokJsUrl,
showTos,
Expand Down Expand Up @@ -340,7 +340,7 @@ function ServerMethods(aLogLevel, aModules) {
enableArchiveManager: tbConfig.enableArchiveManager,
enableScreensharing: tbConfig.enableScreensharing,
enableAnnotation: tbConfig.enableAnnotations,
enableFeedback: tbConfig.enableFeedback,
feedbackUrl: tbConfig.feedbackUrl,
precallSessionId: testSession.sessionId,
apiKey: tbConfig.apiKey,
precallToken: tbConfig.otInstance.generateToken(testSession.sessionId, {
Expand Down
35 changes: 30 additions & 5 deletions test/unit/feedbackController_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,26 +51,51 @@ describe('FeedbackController', () => {
}));
});

// Fix
describe('#feedbackView:sendFeedback event', () => {
it('should send feedback event', sinon.test(function () {
var logEventStub = this.stub(window.OT.analytics, 'logEvent', (aLoggedEvent) => {});
var xhr = sinon.useFakeXMLHttpRequest();
var requests = this.requests = [];
var report = {
audioScore: 1,
videoScore: 2,
description: 'description',
};
window.dispatchEvent(new CustomEvent('feedbackView:sendFeedback', { detail: report }));
expect(logEventStub.calledOnce).to.be.true;
expect(logEventStub.calledWith({
var timestamp = new Date().getTime();
var sourceUrl = document.location.href;

xhr.onCreate = function (xhr) {
requests.push(xhr);
};

var expectedRequestBody = {
action: 'SessionQuality',
partnerId: fakeOTHelper.session.apiKey,
sessionId: fakeOTHelper.session.id,
connectionId: fakeOTHelper.session.connection.id,
publisherId: fakeOTHelper.publisherId,
clientSystemTime: timestamp,
source: sourceUrl,
audioScore: report.audioScore,
videoScore: report.videoScore,
description: report.description,
})).to.be.true;
};

window.dispatchEvent(new CustomEvent('feedbackView:sendFeedback', { detail: report }));
expect(requests.length).to.equal(1);
expect(requests[0].method).to.equal('POST');
var requestBodyObj = JSON.parse(requests[0].requestBody);
expect(requestBodyObj.action).to.equal('SessionQuality');
expect(requestBodyObj.partnerId).to.equal(fakeOTHelper.session.apiKey);
expect(requestBodyObj.sessionId).to.equal(fakeOTHelper.session.id);
expect(requestBodyObj.connectionId).to.equal(fakeOTHelper.session.connection.id);
expect(requestBodyObj.publisherId).to.equal(fakeOTHelper.publisherId);
expect(requestBodyObj.clientSystemTime).to.equal(timestamp);
expect(requestBodyObj.source).to.equal(sourceUrl);
expect(requestBodyObj.audioScore).to.equal(report.audioScore);
expect(requestBodyObj.videoScore).to.equal(report.videoScore);
expect(requestBodyObj.description).to.equal(report.description);
xhr.restore();
}));
});

Expand Down
2 changes: 1 addition & 1 deletion test/unit/roomView_spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
</div>
</section>

<% if (enableFeedback) { %>
<% if (feedbackUrl) { %>
<section class="feedbackButton">
<span id="showFeedback">Feedback / Report a Bug</span>
</section>
Expand Down
3 changes: 2 additions & 1 deletion views/room.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
window.precallToken='<%=precallToken%>';
window.showTos=<%=showTos%> && !sessionStorage.tosAccepted;
window.opentokJsUrl='<%=opentokJsUrl%>';
window.feedbackUrl = '<%=feedbackUrl%>';
var isMobile = function() { return typeof window.orientation !== 'undefined'; }
var mobileSettings = function() {
Expand Down Expand Up @@ -158,7 +159,7 @@
</div>
</section>

<% if (enableFeedback) { %>
<% if (feedbackUrl) { %>
<section class="feedbackButton">
<span id="showFeedback">Feedback / Report a Bug</span>
</section>
Expand Down
9 changes: 7 additions & 2 deletions web/js/feedbackController.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@
publisherId: otHelper.publisherId,
audioScore: report.audioScore,
videoScore: report.videoScore,
description: report.description
description: report.description,
clientSystemTime: new Date().getTime(),
source: document.location.href
};
OT.analytics.logEvent(loggedEvent);
var xhr = new XMLHttpRequest();
var url = window.feedbackUrl;
xhr.open('POST', url, true);
xhr.send(JSON.stringify(loggedEvent));
},
reportIssue: function () {
var loggedEvent = {
Expand Down

0 comments on commit d31b7bf

Please sign in to comment.