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-10615): support sending Kava beacons as POST #86

Merged
merged 2 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 docs/configuration-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Type: [Object][41]
### Properties

- `serviceUrl` **[string][42]?** The Kaltura API server.
- `requestMethod` **[string][42]?** The http method to be used for sending the beacons, GET or POST, the default is GET.
- `viewEventCountdown` **[number][43]?** The interval in seconds that VIEW event will be sent.
- `resetSessionCountdown` **[number][43]?** The interval in seconds that Kava session will be reset.
- `dvrThreshold` **[number][43]?** Threshold in seconds from the live edge.
Expand All @@ -68,6 +69,7 @@ Type: [Object][41]
// Default config
{
serviceUrl: '//analytics.kaltura.com/api_v3/index.php',
requestMethod: 'GET',
viewEventCountdown: 30,
resetSessionCountdown: 30,
dvrThreshold: 120,
Expand Down
3 changes: 2 additions & 1 deletion src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Kava extends BasePlugin {
*/
static defaultConfig: Object = {
serviceUrl: `${Utils.Http.protocol}//analytics.kaltura.com/api_v3/index.php`,
requestMethod: 'GET',
viewEventCountdown: 10,
resetSessionCountdown: 30,
dvrThreshold: 120,
Expand Down Expand Up @@ -206,7 +207,7 @@ class Kava extends BasePlugin {
*/
sendAnalytics(model: Object): Promise<*> {
return new Promise((resolve, reject) => {
OVPAnalyticsService.trackEvent(this.config.serviceUrl, model)
OVPAnalyticsService.trackEvent(this.config.serviceUrl, model, this.config.requestMethod)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yairans does the service is case sensitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to add toUpper... and not to force it.
Seems reasonable to pass also get/post.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use an enum and expose it

.doHttpRequest()
.then(
response => {
Expand Down
21 changes: 20 additions & 1 deletion test/src/kava.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,11 @@ describe('KavaPlugin', function () {
})
);
player.dispatchEvent(
new FakeEvent(CustomEventType.FRAG_LOADED, {miliSeconds: FRAG2_DOWNLOAD_TIME, bytes: FRAG2_BYTES, url: 'http://www.somesite.com/movie2.ts'})
new FakeEvent(CustomEventType.FRAG_LOADED, {
miliSeconds: FRAG2_DOWNLOAD_TIME,
bytes: FRAG2_BYTES,
url: 'http://www.somesite.com/movie2.ts'
})
);
let performanceOverserList = {};
performanceOverserList.getEntries = () => {
Expand Down Expand Up @@ -1068,6 +1072,21 @@ describe('KavaPlugin', function () {
kava = getKavaPlugin();
kava._onPlaybackRateChanged();
});

it('should send IMPRESSION event as POST', done => {
sandbox.stub(OVPAnalyticsService, 'trackEvent').callsFake((serviceUrl, params, requestMethod) => {
try {
requestMethod.should.be.equal('POST');
done();
} catch (e) {
done(e);
}
});
config.plugins.kava.requestMethod = 'POST';
setupPlayer(config);
kava = getKavaPlugin();
player.play();
});
});

describe('Server Response', () => {
Expand Down