🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@maveio/metrics

Package Overview
Dependencies
Maintainers
0
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@maveio/metrics

privacy friendly (🇪🇺) video metrics hosted on mave.io

latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
0
Created
Source

mave.io logo black

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

Install • Usage

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();
}

FAQs

Package last updated on 16 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts