{"id":18498045,"url":"https://github.com/apivideo/api.video-player-analytics","last_synced_at":"2025-04-09T00:30:53.393Z","repository":{"id":43728445,"uuid":"350784939","full_name":"apivideo/api.video-player-analytics","owner":"apivideo","description":"api.video player analytics module","archived":false,"fork":false,"pushed_at":"2024-07-30T13:08:25.000Z","size":311,"stargazers_count":18,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T19:44:53.828Z","etag":null,"topics":["javascript","library","player","video","video-analytics"],"latest_commit_sha":null,"homepage":"https://api.video","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apivideo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-23T16:38:45.000Z","updated_at":"2025-03-15T10:17:14.000Z","dependencies_parsed_at":"2024-11-06T18:16:47.269Z","dependency_job_id":null,"html_url":"https://github.com/apivideo/api.video-player-analytics","commit_stats":{"total_commits":27,"total_committers":6,"mean_commits":4.5,"dds":0.4814814814814815,"last_synced_commit":"bf26a946015bed2d918ad540f12aad384b6d2656"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-player-analytics","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-player-analytics/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-player-analytics/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apivideo%2Fapi.video-player-analytics/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apivideo","download_url":"https://codeload.github.com/apivideo/api.video-player-analytics/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247949730,"owners_count":21023375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","library","player","video","video-analytics"],"created_at":"2024-11-06T13:37:20.736Z","updated_at":"2025-04-09T00:30:51.917Z","avatar_url":"https://github.com/apivideo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\u003cdocumentation_excluded\u003e--\u003e\n[![badge](https://img.shields.io/twitter/follow/api_video?style=social)](https://twitter.com/intent/follow?screen_name=api_video) \u0026nbsp; [![badge](https://img.shields.io/github/stars/apivideo/api.video-player-analytics?style=social)](https://github.com/apivideo/api.video-player-analytics) \u0026nbsp; [![badge](https://img.shields.io/discourse/topics?server=https%3A%2F%2Fcommunity.api.video)](https://community.api.video)\n![](https://github.com/apivideo/.github/blob/main/assets/apivideo_banner.png)\n![npm](https://img.shields.io/npm/v/@api.video/player-analytics) ![ts](https://badgen.net/badge/-/TypeScript/blue?icon=typescript\u0026label)\n\u003ch1 align=\"center\"\u003eapi.video player analytics module\u003c/h1\u003e\n\n[api.video](https://api.video) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand \u0026 low latency live streaming features in your app.\n\n## Table of contents\n\n- [Table of contents](#table-of-contents)\n- [Project description](#project-description)\n- [Getting started](#getting-started)\n  - [Installation](#installation)\n    - [Method #1: requirejs](#method-1-requirejs)\n    - [Method #2: typescript](#method-2-typescript)\n    - [Method #3: imple include in a javascript project](#method-3-imple-include-in-a-javascript-project)\n- [Documentation](#documentation)\n  - [Instantiation options](#instantiation-options)\n  - [Module methods](#module-methods)\n    - [**`ovbserveMedia(media: HTMLVideoElement)`**](#ovbservemediamedia-htmlvideoelement)\n    - [**`dispose()`**](#dispose)\n\n\n\u003c!--\u003c/documentation_excluded\u003e--\u003e\n\u003c!--\u003cdocumentation_only\u003e\n---\ntitle: api.video Player analytics plugin\nmeta: \n  description: The official api.video Player analytics plugin for api.video. [api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand \u0026 low latency live streaming features in your app.\n---\n\n# api.video Player analytics plugin\n\n[api.video](https://api.video/) is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand \u0026 low latency live streaming features in your app.\n\n\u003c/documentation_only\u003e--\u003e\n## Project description\n\nJavascript module to manually call the api.video analytics collector. \n\nThis is useful if you are using a video player for which we do not yet provide a ready-to-use monitoring module.\n\nIf you use one of the following video player, you should rather use the associated packaged monitoring module:\n\n| Player   | monitoring module                                                                           |\n| -------- | ------------------------------------------------------------------------------------------- |\n| video.js | [@api.video/api.video-videojs-analytics](https://github.com/apivideo/api.video-videojs-analytics) |\n| hls.js   | [@api.video/api.video-hlsjs-analytics](https://github.com/apivideo/api.video-hlsjs-analytics)     |\n\n\nThis module is compatible with React Native.\n\n## Getting started\n\n### Installation \n\n#### Method #1: requirejs\n\nIf you use requirejs you can add the module as a dependency to your project with \n\n```sh\n$ npm install --save @api.video/player-analytics\n```\n\nYou can then use the module in your script: \n\n```javascript\nvar { PlayerAnalytics } = require('@api.video/player-analytics');\n\n\nconst playerAnalytics = new PlayerAnalytics({\n    ...options // see below for available options\n});\n```\n\n#### Method #2: typescript\n\nIf you use Typescript you can add the SDK as a dependency to your project with \n\n```sh\n$ npm install --save @api.video/player-analytics\n```\n\nYou can then use the SDK in your script: \n\n```typescript\nimport { PlayerAnalytics } from '@api.video/player-analytics'\n\nconst playerAnalytics = new PlayerAnalytics({\n    ...options // see below for available options\n});\n```\n\n#### Method #3: imple include in a javascript project\n\nInclude the SDK in your HTML file like so:\n\n```html\n\u003chead\u003e\n    ...\n    \u003cscript src=\"https://unpkg.com/@api.video/player-analytics\" defer\u003e\u003c/script\u003e\n\u003c/head\u003e\n```\n\nThen, once the `window.onload` event has been trigered, instantiate the module with `new PlayerAnalytics()`:\n```html\n\u003cscript type=\"text/javascript\"\u003e\n    var playerAnalytics = new PlayerAnalytics(\"#target\", { \n        ...options // see below for available options\n    });\n\u003c/script\u003e\n```\n\n## Documentation\n\n### Instantiation options\n\nThe analytics module constructor takes a `PlayerAnalyticsOptions` parameter that contains the following options:\n\n \n|         Option name | Mandatory | Type                                  | Description                                                                                                  |\n| ------------------: | --------- | ------------------------------------- | ------------------------------------------------------------------------------------------------------------ |\n|            mediaUrl | **yes**   | string                                | url of the media (eg. `https://cdn.api.video/vod/vi5oDagRVJBSKHxSiPux5rYD/hls/manifest.m3u8`)                |\n|        userMetadata | no        | ```{ [name: string]: string }[]```    | object containing [metadata](https://api.video/blog/tutorials/dynamic-metadata/) (see **Full example** below) |\n|            sequence | no        | ```{start: number; end?: number;} ``` | if only a sequence of the video is going to be played                                                        |\n| onSessionIdReceived | no        | ```(sessionId: string) =\u003e void```     | callback to be called once the session id is reveiced                                                        |\n \n\nOnce the module is instantiated, the following methods have to be called to monitor the playback events.\n\n### Module methods\n\n#### **`ovbserveMedia(media: HTMLVideoElement)`**\n\nthis method attaches event listeners to the provided HTMLVideoElement to track and analyze media playback events. No data will be collected before this method is called. \n\n\n#### **`dispose()`**\n\nhis method removes all event listeners attached by `observeMedia` and cleans up any resources used for tracking media playback events.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapivideo%2Fapi.video-player-analytics","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapivideo%2Fapi.video-player-analytics","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapivideo%2Fapi.video-player-analytics/lists"}