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

@glimt.dev/otel-browser

v0.2.1

Published

Minimal browser-only OpenTelemetry bootstrap for Glimt.dev

Downloads

120

Readme

@glimt.dev/otel-browser

OpenTelemetry for the browser. Works out of the box, highly configurable.

Quick Start (3 lines)

npm install @glimt.dev/otel-browser @opentelemetry/api @opentelemetry/api-logs
import { registerOTelBrowser } from '@glimt.dev/otel-browser'

registerOTelBrowser({ serviceName: 'my-web-app' })

Done. Traces go to https://ingest.glimt.dev/v1/traces, logs to /v1/logs.

Local Development

For local development with a local collector:

registerOTelBrowser({
  serviceName: 'my-web-app',
  exporterUrl: 'http://localhost:4318',
})

Production: Glimt.dev Ingest

For production with Glimt authentication:

registerOTelBrowser({
  serviceName: 'my-web-app',
  // exporterUrl defaults to https://ingest.glimt.dev
  organisationId: 'your-org-id',
  publishableKey: 'your-publishable-key',
})

Full Example (all options)

import { registerOTelBrowser } from '@glimt.dev/otel-browser'

const sdk = registerOTelBrowser({
  // Identity
  serviceName: 'my-web-app',

  // Glimt auth
  organisationId: 'org_xxx',
  publishableKey: 'pk_xxx',

  // Release metadata (CRITICAL for source mapping)
  release: {
    commit: process.env.NEXT_PUBLIC_COMMIT_SHA,  // or 'abc1234'
    branch: process.env.NEXT_PUBLIC_COMMIT_REF,  // or 'main'
    version: '1.0.0',
    environment: 'production',
  },

  // Export - base URL, SDK derives /v1/traces and /v1/logs
  exporterUrl: 'https://ingest.glimt.dev',
  exporter: 'http/protobuf',  // or 'http/json'
  exporterHeaders: { 'x-tenant-id': 'acme' },
  credentials: 'include',  // for CORS

  // Logs (auto-derived to /v1/logs)
  logs: {
    exporter: 'http/protobuf',
  },

  // Instrumentations
  instrumentations: ['auto'],  // document-load, user-interaction, xhr, fetch
  fetch: {
    ignoreUrls: [/\/healthz?$/, /analytics\.js$/],
    propagateContextUrls: [/^https:\/\/api\.myapp\.com/],
  },

  // Capture
  captureUnhandledErrors: true,  // window.onerror, unhandledrejection (default: true)
  captureConsoleLogs: true,      // console.* as OTLP logs (default: false)
  includeUserAgent: false,       // privacy default

  // Initial user context
  user: { userId: 'user_123', role: 'admin' },

  // Debug
  logLevel: 'DEBUG',
})

// Update user on login/logout
sdk.setUserContext({ userId: 'user_456' })
sdk.setUserContext(null)

Environment Variables (via Build Tools)

Browsers don't have runtime environment variables, but you can inject them at build time using your bundler:

Next.js (next.config.mjs):

// Automatically available as process.env.NEXT_PUBLIC_*
// Set in .env or CI environment

Vite (vite.config.ts):

export default defineConfig({
  define: {
    'import.meta.env.VITE_OTEL_ENDPOINT': JSON.stringify(process.env.OTEL_EXPORTER_OTLP_ENDPOINT),
    'import.meta.env.VITE_COMMIT_SHA': JSON.stringify(process.env.COMMIT_SHA),
  }
})

Webpack:

new webpack.DefinePlugin({
  'process.env.OTEL_ENDPOINT': JSON.stringify(process.env.OTEL_EXPORTER_OTLP_ENDPOINT),
})

React / Next.js Integration

'use client'
import { useEffect, useRef } from 'react'
import { registerOTelBrowser, type BrowserSDK } from '@glimt.dev/otel-browser'

export function TelemetryProvider({ userId }: { userId?: string }) {
  const sdk = useRef<BrowserSDK | null>(null)

  useEffect(() => {
    sdk.current = registerOTelBrowser({
      serviceName: process.env.NEXT_PUBLIC_OTEL_SERVICE_NAME!,
      exporterUrl: process.env.NEXT_PUBLIC_OTEL_EXPORTER_OTLP_ENDPOINT,
      user: userId ? { userId } : undefined,
      release: {
        commit: process.env.NEXT_PUBLIC_COMMIT_SHA || process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,
        branch: process.env.NEXT_PUBLIC_COMMIT_REF || process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF,
        environment: process.env.NEXT_PUBLIC_VERCEL_ENV,
      }
    })
  }, [])

  useEffect(() => {
    sdk.current?.setUserContext(userId ? { userId } : null)
  }, [userId])

  return null
}
// app/layout.tsx
export default async function RootLayout({ children }) {
  const user = await getCurrentUser()
  return (
    <html>
      <body>
        <TelemetryProvider userId={user?.id} />
        {children}
      </body>
    </html>
  )
}

Server-side traceparent

Inject in your HTML to correlate browser ↔ server:

<meta name="traceparent" content="00-abc123...-def456...-01" />

The SDK picks this up automatically as the parent span.


CORS Requirements

Your collector must allow:

Access-Control-Allow-Origin: * (or your origin)
Access-Control-Allow-Headers: content-type, traceparent, baggage, authorization
Access-Control-Allow-Credentials: true (if using credentials)

Defaults

| Feature | Default | |---------|---------| | Trace exporter | http/protobufhttps://ingest.glimt.dev/v1/traces | | Log exporter | http/protobufhttps://ingest.glimt.dev/v1/logs | | Instrumentations | document-load, user-interaction, xhr, fetch | | Error capture | window.onerror, unhandledrejection | | User agent | NOT included (privacy) | | Console capture | OFF |


User Context Attributes

When you call sdk.setUserContext(), these attributes are added to all spans:

| Attribute | Description | |-----------|-------------| | enduser.id | Primary user identifier | | enduser.pseudo.id | Privacy-preserving hash | | enduser.email | PII, use with caution | | enduser.role | Permission scope |


License

MIT