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(FEC-9345): send view event on first play #61

Merged
merged 3 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions docs/kava-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Here we will see some explanation about each event. When does it sent and what p
- [`networkConnectionType`](./kava-parameters.md#networkConnectionType)
- [`networkConnectionOverhead`](./kava-parameters.md#networkConnectionOverhead)
- [`flavorParamsId`](./kava-parameters.md#flavorParamsId)
- Sent every 10 second of active playback (when player is paused, view timer should be paused/stopped).
- Sent on first play and every 10 seconds of active playback (when player is paused, view timer should be paused/stopped).
- 30 seconds without VIEW event will reset KAVA session, so all the VIEW [specific parameters](#endSessionResetParams) should be reset also.
- Server may notify Kava (via response field ["viewEventsEnabled" = false](#serverResponse)) to shut down VIEW events. When it happens, VIEW events should be blocked from sending until server decides to enable VIEW events again.

Expand All @@ -56,7 +56,7 @@ Here we will see some explanation about each event. When does it sent and what p

- Event ID: `1`
- Player Event: `SOURCE_SELECTED`
- Event Parameters:
- Event Parameters:
- [`COMMON_PARAMS`](./kava-parameters.md#common_params)
- [`playerJSLoadTime`](./kava-parameters.md#playerJSLoadTime)

Expand Down
1 change: 1 addition & 0 deletions src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ class Kava extends BasePlugin {
joinTime: Kava._getTimeDifferenceInSeconds(this._firstPlayRequestTime)
});
this._sendAnalytics(KavaEventModel.PLAY);
this._onReport();
} else if (this._isEnded) {
this._timer.start();
this._isEnded = false;
Expand Down
16 changes: 15 additions & 1 deletion test/src/kava.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ describe('KavaPlugin', function() {
player.play();
});

it('should send VIEW event with manifest download time, segment download time, bandwidth, networkConnectionOverhead', done => {
it('should send first VIEW event with manifest download time, segment download time, bandwidth, networkConnectionOverhead', done => {
const DUMMY_MANIFEST_DOWNLOAD_TIME = 57;
const FRAG1_DOWNLOAD_TIME = 100;
const FRAG2_DOWNLOAD_TIME = 20;
Expand All @@ -541,6 +541,7 @@ describe('KavaPlugin', function() {
params.segmentDownloadTime.should.equal(FRAG1_DOWNLOAD_TIME / 1000);
params.networkConnectionOverhead.should.equal(0.1);
params.flavorParamsId.should.equal(36);
params.position.should.equal(0);
done();
}
return new RequestBuilder();
Expand Down Expand Up @@ -620,6 +621,19 @@ describe('KavaPlugin', function() {
player.volume = 0;
});

it('should send timed VIEW event after 10 secs', done => {
sandbox.stub(OVPAnalyticsService, 'trackEvent').callsFake((serviceUrl, params) => {
if (params.eventType === KavaEventModel.VIEW.index) {
params.position.should.gt(config.plugins.kava.viewEventCountdown);
done();
}
return new RequestBuilder();
});
setupPlayer(config);
kava = getKavaPlugin();
player.play();
});

it('should send VIEW event with sound muted', done => {
sandbox.stub(OVPAnalyticsService, 'trackEvent').callsFake((serviceUrl, params) => {
if (params.eventType === KavaEventModel.VIEW.index) {
Expand Down