xite-reporting-sdk v7.3.1
xite-reporting-sdk
Reporting SDK for Typescript/JavaScript frontends
Install
yarn add XiteTV/xite-reporting-sdk#<tagname>
npm install XiteTV/xite-reporting-sdk#<tagname>
Example
yarn add XiteTV/xite-reporting-sdk#v0.0.6
will install git tag v0.0.6
How to use the SDK
Initialization
At the start of your app, when you get all of the parameters for reporting call the init
method of the reporting-sdk
import * as reportingSdk from 'xite-reporting-sdk';
reportingSdk.init({...initConfigParams}, {...initReportingParams});
This initializes the reporting-sdk with the configParams
needed to make the calls to reporting service
and the common reportingParams
that should be included in each report
Reporting
This sdk divides the reporting features based on the domain (eg: account reporting, session reporting, player reporting, etc) You can import specific reporting function in your code to make the specific report
import { accountReport, AccountMessage } from 'xite-reporting-sdk';
function handleProfileChange() {
// ... do the profile change magic
accountReport<accountReport.ChangeProfileType>(AccountMessage.changeProfile, {role: 'free_guest'});
}
Properly closing down the reporting SDK
The reporting-sdk might start timers and might contain unsent reports when it is time to close your app. So it is very important to close the reporting-sdk before the app exits.
You can close the reporting-sdk by calling the destroy
method. This method clears all the timers and
sends all of the unsent reports at that time.
import * as reportingService from 'xite-reporting-sdk';
function handleExit() {
reportingService.destroy();
}
Function and Constants documentation
init(configParams: InitConfigParams, reportingParams: InitReportingParams)
Parameters
configParams:
an object containing reportingUrl, batchTimeout, batchSize, headersreportingParams:
and object containing timestamp, ownerKey, deviceId, etc (check the types file for all the keys)
Return value
void
destroy()
Parameters
void
Return value
void
Constants
Check the constants file for all the available constants
ReportCategory:
The category the report belongs toScreenChangeMessage, SessionMessage, PlayerCoreMessage, PlayerAdditionalMessage, MenuMessage, AccountMessage, DeviceMessage, UserErrorMessage, VideoBeaconsMessage, AdBeaconsMessage:
Reporting messagesViewNames:
Name of the views that can be reported onscreen_change
or any other event
How to contribute
Build and watch
yarn dev
(you can smlink this package in development for easier workflow)
Build
yarn build
Test
yarn test
(always add unit tests! There is a coverage threshold which will disable git push if lowered)
Publish
npm version major | minor | patch
(this will increment the package.json version commit and create a tag)git push origin --tags
npm publish
(this will publish files inside thedist
directory to npm) Note: this will only work once XITE has private npm packages ;)