Skip to content

Commit

Permalink
fix(FEC-9247): add userId to kava reports (#45)
Browse files Browse the repository at this point in the history
add userId to report from kava config
  • Loading branch information
Yuvalke authored Jul 25, 2019
1 parent cab2327 commit cda7469
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 104 deletions.
143 changes: 76 additions & 67 deletions docs/configuration-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,32 +32,34 @@
- [Parameters][28]
- [destroy][29]
- [reset][30]
- [getEventModel][31]
- [Parameters][32]
- [Examples][33]
- [EventType][34]
- [sendAnalytics][35]
- [Parameters][36]
- [Examples][37]
- [defaultConfig][38]
- [isValid][39]
- [loadMedia][31]
- [getEventModel][32]
- [Parameters][33]
- [Examples][34]
- [EventType][35]
- [sendAnalytics][36]
- [Parameters][37]
- [Examples][38]
- [defaultConfig][39]
- [isValid][40]

## KavaConfigObject

Type: [Object][40]
Type: [Object][41]

### Properties

- `serviceUrl` **[string][41]?** The Kaltura API server.
- `viewEventCountdown` **[number][42]?** The interval in seconds that VIEW event will be sent.
- `resetSessionCountdown` **[number][42]?** The interval in seconds that Kava session will be reset.
- `dvrThreshold` **[number][42]?** Threshold in seconds from the live edge.
- `applicationVersion` **[string][41]?** Used to send the application version from which the user is playing the entry.
- `playbackContext` **[string][41]?** Used to send the id of the category from which the user is playing the entry.
- `tamperAnalyticsHandler` **[Function][43]?** An optional handler to implement. Can be used to manipulate the model data before analytics event sent, or to cancel a certain analytics request.
- `customVar1` **[Object][40]?** Custom objects field.
- `customVar2` **[Object][40]?** Custom objects field.
- `customVar3` **[Object][40]?** Custom objects field.
- `serviceUrl` **[string][42]?** The Kaltura API server.
- `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.
- `applicationVersion` **[string][42]?** Used to send the application version from which the user is playing the entry.
- `playbackContext` **[string][42]?** Used to send the id of the category from which the user is playing the entry.
- `tamperAnalyticsHandler` **[Function][44]?** An optional handler to implement. Can be used to manipulate the model data before analytics event sent, or to cancel a certain analytics request.
- `customVar1` **[Object][41]?** Custom objects field.
- `customVar2` **[Object][41]?** Custom objects field.
- `customVar3` **[Object][41]?** Custom objects field.
- `userId` **[string][42]?** custom user id .

### Examples

Expand All @@ -77,7 +79,7 @@ Type: [Object][40]

#### Parameters

- `model` **[Object][40]** Event model
- `model` **[Object][41]** Event model

#### Examples

Expand All @@ -92,95 +94,95 @@ tamperAnalyticsHandler: function (model) {
}
```

Returns **[boolean][44]** Should send the request or not.
Returns **[boolean][45]** Should send the request or not.

## KavaEventType

### VIEW

Type: [string][41]
Type: [string][42]

### IMPRESSION

Type: [string][41]
Type: [string][42]

### PLAY_REQUEST

Type: [string][41]
Type: [string][42]

### PLAY

Type: [string][41]
Type: [string][42]

### RESUME

Type: [string][41]
Type: [string][42]

### PAUSE

Type: [string][41]
Type: [string][42]

### BUFFER_START

Type: [string][41]
Type: [string][42]

### BUFFER_END

Type: [string][41]
Type: [string][42]

### REPLAY

Type: [string][41]
Type: [string][42]

### SEEK

Type: [string][41]
Type: [string][42]

### PLAY_REACHED_25_PERCENT

Type: [string][41]
Type: [string][42]

### PLAY_REACHED_50_PERCENT

Type: [string][41]
Type: [string][42]

### PLAY_REACHED_75_PERCENT

Type: [string][41]
Type: [string][42]

### PLAY_REACHED_100_PERCENT

Type: [string][41]
Type: [string][42]

### SOURCE_SELECTED

Type: [string][41]
Type: [string][42]

### AUDIO_SELECTED

Type: [string][41]
Type: [string][42]

### FLAVOR_SWITCH

Type: [string][41]
Type: [string][42]

### CAPTIONS

Type: [string][41]
Type: [string][42]

### ERROR

Type: [string][41]
Type: [string][42]

## Kava

Kaltura Advanced Analytics plugin.

### Parameters

- `name` **[string][41]** The plugin name.
- `name` **[string][42]** The plugin name.
- `player` **Player** The player instance.
- `config` **[KavaConfigObject][45]** The plugin config.
- `config` **[KavaConfigObject][46]** The plugin config.

### destroy

Expand All @@ -194,13 +196,19 @@ Reset the plugin.

Returns **void**

### loadMedia

loadMedia of the plugin.

Returns **void**

### getEventModel

Gets the model object for a certain event.

#### Parameters

- `event` **[string][41]** Event name.
- `event` **[string][42]** Event name.

#### Examples

Expand All @@ -210,19 +218,19 @@ const viewModel = kava.getEventModel(kava.EventType.VIEW);
kava.sendAnalytics(viewModel);
```

Returns **[Object][40]** Model object.
Returns **[Object][41]** Model object.

### EventType

Returns **[KavaEventType][46]** The kava events list.
Returns **[KavaEventType][47]** The kava events list.

### sendAnalytics

Sends KAVA analytics event to analytics service.

#### Parameters

- `model` **[Object][40]** Event model.
- `model` **[Object][41]** Event model.

#### Examples

Expand All @@ -236,17 +244,17 @@ player.plugins.kava.sendAnalytics({...})
});
```

Returns **[Promise][47]** Promise to indicate request succeed or failed.
Returns **[Promise][48]** Promise to indicate request succeed or failed.

### defaultConfig

Default config of the plugin.

Type: [Object][40]
Type: [Object][41]

### isValid

Returns **[boolean][44]** Whether the plugin is valid in the current environment.
Returns **[boolean][45]** Whether the plugin is valid in the current environment.

[1]: #kavaconfigobject
[2]: #properties
Expand Down Expand Up @@ -278,20 +286,21 @@ Returns **[boolean][44]** Whether the plugin is valid in the current environment
[28]: #parameters-1
[29]: #destroy
[30]: #reset
[31]: #geteventmodel
[32]: #parameters-2
[33]: #examples-2
[34]: #eventtype
[35]: #sendanalytics
[36]: #parameters-3
[37]: #examples-3
[38]: #defaultconfig
[39]: #isvalid
[40]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[41]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[42]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[43]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[44]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[45]: #kavaconfigobject
[46]: #kavaeventtype
[47]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
[31]: #loadmedia
[32]: #geteventmodel
[33]: #parameters-2
[34]: #examples-2
[35]: #eventtype
[36]: #sendanalytics
[37]: #parameters-3
[38]: #examples-3
[39]: #defaultconfig
[40]: #isvalid
[41]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[42]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[43]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[44]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[45]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[46]: #kavaconfigobject
[47]: #kavaeventtype
[48]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
4 changes: 3 additions & 1 deletion flow-typed/types/kava-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* @property {Object} [customVar1] - Custom objects field.
* @property {Object} [customVar2] - Custom objects field.
* @property {Object} [customVar3] - Custom objects field.
* @property {string} [userId] - custom user id .
* @example
* // Default config
* {
Expand All @@ -25,6 +26,7 @@
*/
type _KavaConfigObject = {
serviceUrl?: string,
tamperAnalyticsHandler?: Function,
viewEventCountdown?: number,
resetSessionCountdown?: number,
dvrThreshold?: number,
Expand All @@ -33,7 +35,7 @@ type _KavaConfigObject = {
customVar3?: Object,
applicationVersion?: string,
playbackContext?: string,
tamperAnalyticsHandler?: Function
userId?: string
};

/**
Expand Down
3 changes: 3 additions & 0 deletions src/kava-event-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,9 @@ export function getEventModel(eventObj: KavaEvent, model: KavaModel): Object {
if (model.getApplicationVersion()) {
commonModel.applicationVersion = model.getApplicationVersion();
}
if (model.getUserId()) {
commonModel.userId = model.getUserId();
}
const eventModel = eventObj.getEventModel(model);
return Object.assign(eventModel, commonModel);
}
1 change: 1 addition & 0 deletions src/kava-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class KavaModel {
getPlaybackType: Function;
getPlaybackContext: Function;
getApplicationVersion: Function;
getUserId: Function;
getCanPlayTime: Function;

constructor(model?: Object) {
Expand Down
1 change: 1 addition & 0 deletions src/kava.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,7 @@ class Kava extends BasePlugin {
this._model.getPlaybackType = () => this._getPlaybackType();
this._model.getPlaybackContext = () => this.config.playbackContext;
this._model.getApplicationVersion = () => this.config.applicationVersion;
this._model.getUserId = () => this.config.userId;
}

_getPosition(): number {
Expand Down
7 changes: 5 additions & 2 deletions test/src/kava-model.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const ab = 3,
jt = 1213,
tp = '12',
pc = 'pc',
av = 'av';
av = 'av',
usi = '1234';

describe('KavaModel', () => {
let model;
Expand Down Expand Up @@ -79,6 +80,7 @@ describe('KavaModel', () => {
model.getPlaybackType = () => pback;
model.getPlaybackContext = () => pc;
model.getApplicationVersion = () => av;
model.getUserId = () => usi;
});

it('should update the model', function() {
Expand Down Expand Up @@ -111,7 +113,8 @@ describe('KavaModel', () => {
sessionStartTime: sst,
customVar2: cv2,
playbackContext: pc,
applicationVersion: av
applicationVersion: av,
userId: usi
});
});
});
Loading

0 comments on commit cda7469

Please sign in to comment.