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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@trap_stevo/metrictide-client

v0.0.7

Published

A resilient, smart client designed to stream, store, and query metrics to and from a MetricTide analytics server. Whether you're tracking product usage, performance signals, or user behavior, MetricTide Client offers seamless integration, offline robustne

Readme

🌐 MetricTide Client

Real-Time Metric Reporting Made Effortless

A resilient, smart client designed to stream, store, and query metrics to and from a MetricTide analytics server. Whether you're tracking product usage, performance signals, or user behavior, MetricTide Client offers seamless integration, offline robustness, and predictive insights out of the box.


🚀 Features

  • 📡 MetricTide Server Integration – Stream custom metrics to a MetricTide server in real time.
  • 📦 Offline-First Buffering – Automatically stores unsent metrics and syncs them once connectivity is restored.
  • 🧠 Device-Aware Identity – Assigns a consistent, device-specific metric identifier.
  • 🔄 Auto Syncing – Periodically flushes stored metrics to the backend with retry logic.
  • 🔍 Flexible Querying – Retrieve historical, real-time, and aggregate analytics.
  • 🔐 Session-Based Communication – Securely transmit metrics through authenticated, session-aware channels.
  • 🔧 Custom Gateways – Override transport logic with your own network layer.

⚙️ System Requirements

| Requirement | Version | |----------------|-----------------------------| | Browser | Chrome ≥ 91, Firefox ≥ 90 | | JavaScript | ES2020+ | | npm | ≥ 9.x (recommended) | | OS | Windows, macOS, Linux |


🛠️ Configuration

MetricTideClient Options

| Option | Type | Default | Description | |----------------------------|-------------|-------------|-------------| | connectionURL | string | "" | URL to check server availability. | | baseURL | string | "" | API base path for reporting and querying metrics. | | deviceIDPrefix | string | "MT-" | Prefix used for the generated metric device ID. | | flushInterval | number | 10000 | How often (in ms) to attempt syncing stored metrics. | | offlineFirst | boolean | false | Enables buffering and deferred syncing when offline. | | metricRequester | function | null | Optional custom request logic. | | metricGateway | function | fetch | Network method used for transport. | | metricLinkPairPath | string | "/metric-device/pair" | Endpoint for authenticating client device. | | metricLinkConfigurations | object | {} | Enables optional session-based communication. | | metricCacheConfigurations | object | {} | Storage configuration (name, version, store list, etc). | | metricStatusCheckerOptions| object | {} | Options for availability checking logic. |


📘 API Specifications

🎯 Tracking

| Method | Description | |--------|-------------| | track(domain, metric, options?) | Records a metric and attempts immediate or deferred transmission. | | sync() | Manually triggers an attempt to flush all stored metrics. | | activateOnlineListener() | Initiates the client's online event for metric syncing. | | activateSyncInterval() | Initiates metric flushing per flush interval. | | destroyOnlineListener() | Stops listening to the client's online event preventing metric syncing upon client connection. | | destroySyncInterval() | Stops metric flushing. | | destroy() | Stops syncing behavior and removes internal listeners. | | getDeviceID() | Returns the consistent, client-generated metric device ID. |

📄 Querying

| Method | Description | |--------|-------------| | getMetrics(filter) | Retrieves current metrics from the server. | | getMetricsSince(interval, source, filter) | Gets metrics from a time window (e.g., "5m", "1d"). | | getMetricsBetween(start, end, source, filter) | Retrieves metrics between two timestamps. | | getStoredMetrics(filter) | Loads metrics that were saved but not yet synced. | | getMetricsFromDomains(domains, options) | Queries multiple domains in a single request. | | getMetricsInDomain(domain, options) | Queries metrics within a specific domain. | | getMetricByID(id) | Retrieves a metric by its unique ID. | | updateMetric(id, updates) | Updates an existing metric. |

📊 Aggregation & Prediction

| Method | Description | |--------|-------------| | getAggregate(name) | Returns aggregate stats for a named metric. | | getAggregateByType(type) | Retrieves grouped aggregates by type. | | groupByTag(tagKey) | Groups metrics based on a tag. | | getTimeSeries(name, options) | Returns a time series view of a metric. | | predictMetric(name, config) | Generates a short-term forecast for a metric. |

🧹 Cleanup

| Method | Description | |--------|-------------| | clearMetricsInDomain(domain, options) | Removes all metrics associated with a given domain. | | clearAllMetrics() | Removes all metrics globally. |


🔐 Session Communication (Optional)

Enable secure, session-aware metric transport using the metricLinkConfigurations object:

const client = new MetricTideClient({
     baseURL : "https://metrics.example.com",
     metricLinkPairPath : "/devices/pair",
     metricLinkConfigurations : {
          enabled : true,
          options : {
               persistSessionKey : false,
               persistSessionID : false,
               headers : {
                    Authorization : "Bearer YOUR_TOKEN"
               }
          }
     }
});

📦 Installation

npm install @trap_stevo/metrictide-client

✨ Basic Usage

import HUDMetricTide from "@trap_stevo/metrictide-client";

const client = new HUDMetricTide({
     baseURL : "https://metrics.example.com",
     connectionURL : "https://metrics.example.com/ping",
     offlineFirst : true,
     flushInterval : 8000
});

client.track("page_view", {
     value : 1,
     metadata : { route : "/dashboard" },
     tags : ["navigation"]
});

🔁 Example: Buffered Tracking

await client.track("interaction", {
     value : 1,
     metadata : { type : "click" },
     tags : ["button", "ui"]
});

If offline mode is enabled, this metric will be held until syncing becomes possible.


📊 Example: Fetching Recent Activity

const recent = await client.getMetricsSince("10m");

console.log("Recent Metrics:", recent);

🔮 Example: Forecasting Engagement

const prediction = await client.predictMetric("engagement_score", {
     interval : "5m",
     range : "1h",
     stepsAhead : 3
});

console.log("Predicted Engagement:", prediction);

📌 Example: Clearing a Domain

await client.clearMetricsInDomain("video_player");

📡 Server Integration

Designed to interface seamlessly with MetricTide, enabling full tracking, querying, and forecasting.


📜 License

See LICENSE.md for details.