-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(FEC-8629): add hooks to kava to enable analytics event tampering…
… and sending custom events (#26) Add tamperAnalyticsHandler config option and expose sendAnalytics API. Read more from the docs.
- Loading branch information
Dan Ziv
authored
Nov 1, 2018
1 parent
a62f074
commit fdcc08d
Showing
12 changed files
with
1,759 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Configuration & API | ||
|
||
### Table of Contents | ||
|
||
- [KavaConfigObject](#kavaconfigobject) | ||
- [tamperAnalyticsHandler](#tamperanalyticshandler) | ||
- [Kava](#kava) | ||
- [destroy](#destroy) | ||
- [reset](#reset) | ||
- [sendAnalytics](#sendanalytics) | ||
- [defaultConfig](#defaultconfig) | ||
- [isValid](#isvalid) | ||
|
||
## KavaConfigObject | ||
|
||
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
|
||
**Properties** | ||
|
||
- `serviceUrl` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** The Kaltura API server. | ||
- `viewEventCountdown` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** The interval in seconds that VIEW event will be sent. | ||
- `resetSessionCountdown` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** The interval in seconds that Kava session will be reset. | ||
- `dvrThreshold` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Threshold in seconds from the live edge. | ||
- `applicationVersion` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Used to send the application version from which the user is playing the entry. | ||
- `playbackContext` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Used to send the id of the category from which the user is playing the entry. | ||
- `tamperAnalyticsHandler` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** 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](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Custom objects field. | ||
- `customVar2` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Custom objects field. | ||
- `customVar3` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Custom objects field. | ||
|
||
**Examples** | ||
|
||
```javascript | ||
// Default config | ||
{ | ||
serviceUrl: '//analytics.kaltura.com/api_v3/index.php', | ||
viewEventCountdown: 30, | ||
resetSessionCountdown: 30, | ||
dvrThreshold: 120, | ||
applicationVersion: '', | ||
playbackContext: '' | ||
} | ||
``` | ||
|
||
### tamperAnalyticsHandler | ||
|
||
**Parameters** | ||
|
||
- `model` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Event model | ||
|
||
**Examples** | ||
|
||
```javascript | ||
tamperAnalyticsHandler: function (model) { | ||
// Always add myCustomFlag but don't send the request if the event type equals to 2 | ||
model.myCustomFlag = true; | ||
if (model.eventType !== 2) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
``` | ||
|
||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Should send the request or not. | ||
|
||
## Kava | ||
|
||
**Extends BasePlugin** | ||
|
||
**Parameters** | ||
|
||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The plugin name. | ||
- `player` **Player** The player instance. | ||
- `config` **[KavaConfigObject](#kavaconfigobject)** The plugin config. | ||
|
||
### destroy | ||
|
||
Destroys the plugin. | ||
|
||
Returns **void** | ||
|
||
### reset | ||
|
||
Reset the plugin. | ||
|
||
Returns **void** | ||
|
||
### sendAnalytics | ||
|
||
Sends KAVA analytics event to analytics service. | ||
|
||
**Parameters** | ||
|
||
- `model` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Event model. | ||
|
||
Returns **void** | ||
|
||
### defaultConfig | ||
|
||
Default config of the plugin. | ||
|
||
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) | ||
|
||
### isValid | ||
|
||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether the plugin is valid in the current environment. |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// @flow | ||
|
||
/** | ||
* @typedef {Object} KavaConfigObject | ||
* @property {string} [serviceUrl] - The Kaltura API server. | ||
* @property {number} [viewEventCountdown] - The interval in seconds that VIEW event will be sent. | ||
* @property {number} [resetSessionCountdown] - The interval in seconds that Kava session will be reset. | ||
* @property {number} [dvrThreshold] - Threshold in seconds from the live edge. | ||
* @property {string} [applicationVersion] - Used to send the application version from which the user is playing the entry. | ||
* @property {string} [playbackContext] - Used to send the id of the category from which the user is playing the entry. | ||
* @property {Function} [tamperAnalyticsHandler] - An optional handler to implement. Can be used to manipulate the model data before analytics event sent, or to cancel a certain analytics request. | ||
* @property {Object} [customVar1] - Custom objects field. | ||
* @property {Object} [customVar2] - Custom objects field. | ||
* @property {Object} [customVar3] - Custom objects field. | ||
* @example | ||
* // Default config | ||
* { | ||
* serviceUrl: '//analytics.kaltura.com/api_v3/index.php', | ||
* viewEventCountdown: 30, | ||
* resetSessionCountdown: 30, | ||
* dvrThreshold: 120, | ||
* applicationVersion: '', | ||
* playbackContext: '' | ||
* } | ||
*/ | ||
type _KavaConfigObject = { | ||
serviceUrl?: string, | ||
viewEventCountdown?: number, | ||
resetSessionCountdown?: number, | ||
dvrThreshold?: number, | ||
customVar1?: Object, | ||
customVar2?: Object, | ||
customVar3?: Object, | ||
applicationVersion?: string, | ||
playbackContext?: string, | ||
tamperAnalyticsHandler?: Function | ||
}; | ||
|
||
/** | ||
* @function tamperAnalyticsHandler | ||
* @param {Object} model - Event model | ||
* @memberof KavaConfigObject | ||
* @returns {boolean} - Should send the request or not. | ||
* @example | ||
* tamperAnalyticsHandler: function (model) { | ||
* // Always add myCustomFlag but don't send the request if the event type equals to 2 | ||
* model.myCustomFlag = true; | ||
* if (model.eventType !== 2) { | ||
* return true; | ||
* } | ||
* return false; | ||
* } | ||
*/ | ||
declare type KavaConfigObject = _KavaConfigObject; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.