npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@teyuto/teyuto-player-analytics

v1.0.3

Published

Teyuto Player Analytics SDK enables easy integration of analytics tracking for video playback using various popular players including Video.js, HLS.js, Plyr, and Shaka Player.

Downloads

20

Readme

badge   badge

Teyuto provides a seamless solution for managing all your video distribution needs. Whether you require video distribution in the cloud, on OTT platforms, storage, public OTT platform distribution, or secure intranet distribution, Teyuto puts everything at your fingertips, making the management of your video content effortless.

Overview

Teyuto Player Analytics SDK enables easy integration of analytics tracking for video playback using Video.js, HLS.js, Plyr, or Shaka Player.

Compatible Players

Installation

Option 1: Script Tag

Include the SDK in your HTML:

<script src="https://cdn.jsdelivr.net/gh/Teyuto/teyuto-player-analytics-sdk@production/src/TeyutoPlayerAnalytics.min.js"></script>

Option 2: As a Module

Install via npm:

npm install teyuto-player-analytics

Usage

As a Module

With Video.js

import { TeyutoVideoJsAdapter } from 'teyuto-player-analytics';

const player = videojs('my-video');
const analytics = new TeyutoVideoJsAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');

// Clean up
window.addEventListener('beforeunload', () => {
  analytics.destroy();
  player.dispose();
});

With HLS.js

import { TeyutoHlsJsAdapter } from 'teyuto-player-analytics';

const video = document.getElementById('video');
const hls = new Hls();
hls.loadSource('https://example.com/video.m3u8');
hls.attachMedia(video);

const analytics = new TeyutoHlsJsAdapter('your-channel-public', 'user-token');
analytics.init(hls, 'video-id');

// Clean up
window.addEventListener('beforeunload', () => {
  analytics.destroy();
  hls.destroy();
});

With Plyr

import { TeyutoPlyrAdapter } from 'teyuto-player-analytics';

const player = new Plyr('#player');
const analytics = new TeyutoPlyrAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');

// Clean up
window.addEventListener('beforeunload', () => {
  analytics.destroy();
  player.destroy();
});

With Shaka Player

import { TeyutoShakaPlayerAdapter } from 'teyuto-player-analytics';

const video = document.getElementById('video');
const player = new shaka.Player(video);
const analytics = new TeyutoShakaPlayerAdapter('your-channel-public', 'user-token');
analytics.init(player, 'video-id');

// Clean up
window.addEventListener('beforeunload', () => {
  analytics.destroy();
  player.destroy();
});

Without Module (Using Script Tag)

When using the SDK via a script tag, all adapters are available under the global TeyutoPlayerAnalytics object.

With Video.js

<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
  const player = videojs('my-video');
  const analytics = new TeyutoPlayerAnalytics.TeyutoVideoJsAdapter('your-channel-public', 'user-token');
  analytics.init(player, 'video-id');

  // Clean up
  window.addEventListener('beforeunload', () => {
    analytics.destroy();
    player.dispose();
  });
</script>

With HLS.js

<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
  const video = document.getElementById('video');
  const hls = new Hls();
  hls.loadSource('https://example.com/video.m3u8');
  hls.attachMedia(video);

  const analytics = new TeyutoPlayerAnalytics.TeyutoHlsJsAdapter('your-channel-public', 'user-token');
  analytics.init(hls, 'video-id');

  // Clean up
  window.addEventListener('beforeunload', () => {
    analytics.destroy();
    hls.destroy();
  });
</script>

With Plyr

<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
  const player = new Plyr('#player');
  const analytics = new TeyutoPlayerAnalytics.TeyutoPlyrAdapter('your-channel-public', 'user-token');
  analytics.init(player, 'video-id');

  // Clean up
  window.addEventListener('beforeunload', () => {
    analytics.destroy();
    player.destroy();
  });
</script>

With Shaka Player

<script src="path/to/TeyutoPlayerAnalytics.js"></script>
<script>
  const video = document.getElementById('video');
  const player = new shaka.Player(video);
  const analytics = new TeyutoPlayerAnalytics.TeyutoShakaPlayerAdapter('your-channel-public', 'user-token');
  analytics.init(player, 'video-id');

  // Clean up
  window.addEventListener('beforeunload', () => {
    analytics.destroy();
    player.destroy();
  });
</script>

API Reference

All adapters (TeyutoVideoJsAdapter, TeyutoHlsJsAdapter, TeyutoPlyrAdapter, and TeyutoShakaPlayerAdapter) have the following methods:

  • constructor(channel, token): Initialize with your channel (required) and user token (optional).
  • init(player, videoId): Start tracking for a specific player and video.
  • destroy(): Clean up resources and stop tracking.

Important Notes

  • The channel parameter is required and represents your Teyuto channel identifier.
  • The token parameter is optional and represents the token of the user you want to track. This allows you to associate the viewing analytics with a specific user in your system.
  • If you don't provide a token, the analytics will still be tracked, but without user-specific information.

Troubleshooting

If analytics data isn't appearing:

  1. Check console for errors.
  2. Verify that you've provided a valid channel identifier.
  3. If using user tracking, verify the user token.
  4. Ensure the video ID is correct.
  5. Verify that player events (play, pause, ended) are triggering correctly.

Support

For issues or questions, contact Teyuto support at [email protected] or open an issue in this repository.