0.1.5 • Published 11 months ago

@maveio/metrics v0.1.5

Weekly downloads
-
License
APGL-3.0
Repository
github
Last release
11 months ago

metrics

npm version CodeQL Discord server

Our components library uses metrics to analyze video usage. This repo is meant to be transparent and accountable. This is only the client library and is part of Mave Metrics Server

InstallUsage

Install

Install the package within your project

npm install @maveio/metrics

Usage

import { Metrics } from '@maveio/metrics';
Metrics.config = {
  socketPath: 'wss://{your domain here}/socket',
  apiKey: '{your api key here}',
};

To collect video events you will need to create an Metrics instance using each HTMLVideoElement or Hls object:

new Metrics(<querySelector | Hls object>, <string>, <optional video query metadata>, <optional session query metadata>)

For instance, you can do this in your page:

const metrics = new Metrics('#my_video', 'label name', {
  my_custom_query_id: 1234,
});
metrics.monitor();

When you are using the hls.js library you can use the following code to monitor the video:

const video = document.getElementById('hls_video');
const videoSrc = 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8';

if (Hls.isSupported()) {
  const hls = new Hls();
  hls.loadSource(videoSrc);
  hls.attachMedia(video);
  new Metrics(hls, 'Big buck bunny').monitor();
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
  video.src = videoSrc;
  new Metrics('#hls_video', 'Big buck bunny').monitor();
}
0.1.5

11 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago