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

@opencampus/ochub-utils

v0.4.1

Published

Open Campus Hub utilities library for analytics and account management

Downloads

128

Readme

@opencampus/ochub-utils

Open Campus Hub utilities library providing analytics and account management modules.

Installation

npm install @opencampus/ochub-utils

Usage

Analytics Module

import { OCAnalytics } from "@opencampus/ochub-utils";

// Initialize with app name and GTM container ID (no secrets exposed!)
OCAnalytics.initialize("my-app", {
  containerId: "GTM-XXXXXXXXX",
});

// Get the instance and track events
const analytics = OCAnalytics.getInstance();

// Track a custom event
// Pushes: { event: 'app_event', app_name, event_name, event_payload: {...} }
analytics.trackEvent("user_signup", {
  signup_method: "email",
  user_age: 25,
});

// Set user ID for tracking
analytics.setUserId("user123");

Note: GTM is the recommended approach for frontend tracking as it doesn't require exposing API secrets or measurement IDs directly in code. All events are pushed to the GTM data layer, which can be configured securely in the GTM console.

Account Module

import { getInstance } from "@opencampus/ochub-utils";

// Get the module-level singleton instance (instantiates only once)
const account = getInstance({
  sandboxMode: false, // Set to true for sandbox/test mode
  opts: {
    // OCID Connect options here
  },
});

// Subsequent calls return the same instance, config is ignored
const accountAgain = getInstance(); // Returns same instance

// Subscribe to authentication state changes
const unsubscribe = account.subscribe((authState) => {
  console.log("Auth state updated:", authState);
});

// Access authentication state
if (account.isAuthenticated()) {
  const ocId = account.getOCId();
  const ethAddress = account.getEthAddress();
  const authState = account.getAuthState();

  // Access JWT tokens
  const idToken = account.getIdToken();
  const accessToken = account.getAccessToken();
}

// Check SDK initialization status
if (account.isSDKInitialized()) {
  console.log("OCID SDK is ready");
}

// Unsubscribe when done
unsubscribe();

Note:

  • getInstance() is a module-level singleton function - instantiates only once
  • Configuration is only used on first instantiation
  • It's read-only for accessing authentication state
  • Connection management is handled by the OCID Connect component in your application

Modules

  • analytics - Google Tag Manager integration for frontend tracking
    • OCAnalytics - Singleton class for tracking custom events
    • Secure frontend tracking without exposing API secrets
    • App name set once at initialization, included in all events
    • Supports custom event parameters
    • Automatic GTM script injection and data layer management
  • account - Account and user management utilities
    • OCAccount - Singleton class for OCID Connect SDK management
    • Authentication state management with subscription support
    • Support for sandbox and live modes
    • Access to OCId, Ethereum address, and JWT tokens (idToken, accessToken)

License

MIT