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

@trillboards/ctv-measurement

v0.1.0

Published

CTV co-viewing measurement and audience enrichment SDK

Readme

@trillboards/ctv-measurement

CTV co-viewing measurement and audience enrichment SDK. Zero runtime dependencies.

Features

  • BLE co-viewing measurement via Android WebView bridge
  • Device fingerprinting (canvas, WebGL, audio)
  • IP detection (WebRTC + HTTP fallback)
  • Census demographic enrichment
  • CTV viewability tracking (MRC DOOH-compliant, 95% duration threshold)
  • QR attribution URL generation
  • BLE proximity confidence scoring
  • Connection quality signals
  • Session tracking with crypto-grade session IDs
  • GDPR/CCPA consent gating

Install

npm install @trillboards/ctv-measurement

Quick Start

import { CtvMeasurement } from '@trillboards/ctv-measurement';

// Initialize
const sdk = await CtvMeasurement.create({
  apiKey: 'your-api-key',
  screenId: 'screen-123',
  debug: false,
});

// Track ad events from IMA SDK
sdk.trackAdEvent('impression', { adId: 'ad1', placementId: 'p1', scheduledDurationMs: 30000 });
sdk.trackAdEvent('start', { adId: 'ad1', placementId: 'p1' });
sdk.trackAdEvent('complete', { adId: 'ad1', placementId: 'p1', actualDurationMs: 30000 });

// Measure — runs all modules in parallel
const payload = await sdk.measure();
console.log(payload);
// => { schema_version: '0.1', sessionId: '...', bleDeviceCount: 3, viewable: true, ... }

// Check viewability
const verdict = sdk.getViewability();
console.log(verdict.viewable, verdict.reason);
// => true 'ctv_full_completion'

// Generate a QR tracking URL — appends tb_sid/tb_aid/tb_pid params to your destination URL.
// The next sdk.measure() call will include the scanId in qrScanId for impression correlation.
const qrUrl = sdk.getQrTrackingUrl('https://shop.example.com/landing', 'ad1', 'placement1');
// => https://shop.example.com/landing?tb_sid=...&tb_aid=ad1&tb_pid=placement1

// Clean up
sdk.destroy();

GDPR/CCPA Consent

// Deny consent — measure() returns zeroed payload with no signals
sdk.setConsentStatus(false);

// Re-grant consent
sdk.setConsentStatus(true);

Android WebView Integration

The companion trillboards-measurement-sdk Android library handles both modes automatically. From a publisher app:

// In Application.onCreate() or Activity.onCreate()
TrillboardsMeasurement.initialize(
    context,
    MeasurementConfig.Builder("your-api-key")
        .scanIntervalMs(30_000)
        .build()
)
TrillboardsMeasurement.setConsentStatus(true)  // After GDPR/CCPA consent

// Before WebView.loadUrl()
TrillboardsMeasurement.attachToWebView(webView)
TrillboardsMeasurement.startScheduledScans()

The Android library exposes window.TrillboardsMeasurement.getSnapshot() (pull mode) and dispatches window.dispatchEvent(new CustomEvent('trillboards:measurement', {detail})) on each scan (push mode). The JS SDK listens to both automatically.

Events

sdk.on('scan_complete', (snapshot) => {
  console.log(`BLE scan: ${snapshot.deviceCount} devices`);
});

sdk.on('viewability_update', (verdict) => {
  console.log(`Viewable: ${verdict.viewable} (${verdict.reason})`);
});

sdk.on('enrichment_received', (enrichment) => {
  console.log(`Income segment: ${enrichment.iabIncomeSegment?.name}`);
});

sdk.on('error', ({ module, message }) => {
  console.error(`Module ${module} failed: ${message}`);
});

Script Tag (IIFE)

<script src="https://cdn.trillboards.com/sdk/trillboards-ctv-measurement.global.js"></script>
<script>
  TrillboardsCtvMeasurement.create({ apiKey: 'your-key' })
    .then(sdk => sdk.measure())
    .then(payload => console.log(payload));
</script>

API Reference

CtvMeasurement.create(config)

Factory method. Returns Promise<CtvMeasurement>.

| Option | Type | Required | Default | | ---------- | ------- | -------- | -------------------------------- | | apiKey | string | Yes | | | apiBase | string | No | https://api.trillboards.com | | screenId | string | No | | | debug | boolean | No | false |

sdk.measure()

Runs all measurement modules in parallel. Returns Promise<ImpressionMetadata>.

sdk.trackAdEvent(event, data?)

Track an IMA SDK ad lifecycle event. Events: impression, start, firstQuartile, midpoint, thirdQuartile, complete.

sdk.getViewability()

Returns current ViewabilityVerdict without tracking a new event.

sdk.getQrTrackingUrl(destinationUrl, adId, placementId)

Returns a QR tracking URL by appending tb_sid, tb_aid, tb_pid query parameters to the publisher's destinationUrl. Mobile users scan the QR → land on the destination page → the publisher's page extracts tb_sid and POSTs to /v2/sdk/qr/scan to record the scan and unlock attribution.

The generated tb_sid is also stored on the SDK instance and included as qrScanId in the next measure() payload for impression correlation.

sdk.setConsentStatus(granted)

Set GDPR/CCPA consent. When false, measure() returns zeroed payload.

sdk.on(event, handler) / sdk.off(event, handler)

Subscribe/unsubscribe to SDK events.

sdk.destroy()

Clean up listeners and internal state.

License

MIT