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

@equinor/fusion-framework-module-analytics

v1.0.0

Published

Fusion module for collecting and exporting application analytics using OpenTelemetry standards

Readme

Analytics Module

The Fusion Framework Analytics Module provides an unified way to track analytics. It offers a consistent API for logging analytics data while supporting multiple adapters and collectors.

When a collector emits a event, it will be sent to all adapters.

Configuration

To configure the analytics module, you need to provide a function that specifies the adapters and collectors you want to use. The configuration can be done in your portal entry file or wherever you initialize the Fusion Framework.

import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';

const configure = (configurator: IModulesConfigurator<any, any>) => {
  enableAnalytics(configurator, (builder) => {
    // configure the analytics module

    builder.setAdapter('console', async () => {
      return new ConsoleAnalyticsAdapter();
    });

    builder.setCollector('context-selected', async (args) => {
      const contextProvider = await args.requireInstance('context');
      const appProvider = await args.requireInstance('app');
      return new ContextSelectedCollector(contextProvider, appProvider);
    });
  });
}

Initialization

The analytics module supports asynchronous initialization of adapters and collectors. The provider exposes an initialize() method that should be called to set up all configured adapters and collectors:

// Get the analytics provider from modules
const provider = modules.analytics;

// Initialize adapters and collectors (required before use)
await provider.initialize();

// Check if provider is initialized
if (provider.initialized) {
  // Provider is ready for use
}

[!NOTE] The analytics module will automatically initialize when used within the Fusion Framework module system. Manual initialization is only required when accessing the provider directly.

Adapters

Adapters are responsible for processing and sending telemetry data to their respective destinations. All adapters support asynchronous initialization and will automatically be initialized when the analytics provider initializes.

Using setAdapter

The AnalyticsConfigurator provides a method for adding adapters: setAdapter for pre-instantiated adapters.

Simple setAdapter Example

import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';
import { ConsoleAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/adapters';

const configure = (configurator: IModulesConfigurator<any, any>) => {
  enableAnalytics(configurator, (builder) => {
    builder.setAdapter('console', async () => {
      return new ConsoleAnalyticsAdapter();
    });
  });
}

Console Adapter

The ConsoleAnalyticsAdapter provides a simple way to log analytics data to the console, useful for development and debugging.

Installation

The Console Adapter is included with the analytics module and doesn't require additional installation.

Configuration

The Console Adapter does not require any configuration.

Fusion Analytics Adapter

The FusionAnalyticsAdapter provides a way to log analytics data to a service using the OpenTelemetry Logs pattern.

Installation

The Fusion Analytics Adapter is included with the analytics module and doesn't require additional installation.

Configuration

The Fusion Analytics Adapter support the following configuration options:

  • portalId: The portal Id to be included in log records.

  • logExporter: The exporter to use. We bundle OTLPLogExporter and FusionOTLPLogExporter - see below.

Example configuration
// OTLPLogExporter
import { OTLPLogExporter } from '@equinor/fusion-framework-module-analytics/logExporters';

builder.setAdapter('fusion-log', async () => {
  const logExporter = new OTLPLogExporter({
    url: 'URL_TO_POST_TO',
    headers: {
      'Content-Type': 'application/json',
    },
  });

  return new FusionAnalyticsAdapter({
    portalId: 'PORTAL_ID',
    logExporter,
  });
});

// FusionOTLPLogExporter with httpClient
import { FusionOTLPLogExporter } from '@equinor/fusion-framework-module-analytics/logExporters';

builder.setAdapter('fusion', async (args) => {
  if (args.hasModule('serviceDiscovery')) {
    const serviceDiscovery = await args.requireInstance<ServiceDiscoveryProvider>(
      'serviceDiscovery'
    );
    const httpClient = await serviceDiscovery.createClient('SERVICE_DISCOVERY_NAME');

    const logExporter = new FusionOTLPLogExporter(httpClient);

    return new FusionAnalyticsAdapter({
      portalId: 'PORTAL_ID',
      logExporter,
    });
  }
  console.error('Could not instanziate monitor http client from service-discovery');
});

Creating Custom Adapters

You can create custom analytics adapters by implementing the IAnalyticsAdapter interface and add it in configuration.

Collectors

Collectors are responsible for sending events that adapters can pick up. All collectors support asynchronous initialization and will automatically be initialized when the analytics provider initializes.

Using setCollector

The AnalyticsConfigurator provides a method for adding collectors: setCollector for pre-instantiated collectors.

Simple setCollector Example

import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';
import { ContextSelectedCollector } from '@equinor/fusion-framework-module-analytics/collectors';

const configure = (configurator: IModulesConfigurator<any, any>) => {
  enableAnalytics(configurator, (builder) => {
    builder.setCollector('context-selected', async (args) => {
      const contextProvider = await args.requireInstance('context');
      const appProvider = await args.requireInstance('app');
      return new ContextSelectedCollector(contextProvider, appProvider);
    });
  });
}

Context Selected Collector

The ContextSelectedCollector listens for selection in the context module and emits the new and optional previous context.

Installation

The Context Selected Collector is included with the analytics module and doesn't require additional installation.

Configuration

The Context Selected Collector needs the context provider.

Example configuration
import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';
import { ContextSelectedCollector } from '@equinor/fusion-framework-module-analytics/collectors';

const configure = (configurator: IModulesConfigurator<any, any>) => {
  enableAnalytics(configurator, (builder) => {
    builder.setCollector('context-selected', async (args) => {
      const contextProvider = await args.requireInstance('context');
      const appProvider = await args.requireInstance('app');
      return new ContextSelectedCollector(contextProvider, appProvider);
    });
  });
}

Creating Custom Collectors

You can create custom analytics collector by extending the BaseCollector class, or implement the IAnalyticsCollector interface and add it in configuration.

Example Custom Collector

import { type AnalyticsEvent, enableAnalytics } from '@equinor/fusion-framework-module-analytics';

const configure = (configurator: IModulesConfigurator<any, any>) => {
  enableAnalytics(configurator, (builder) => {
    builder.setCollector('click-test', async () => {
      const subject = new Subject<AnalyticsEvent>();
      window.addEventListener('click', (e) => {
        subject.next({
          name: 'window-clicker',
          value: 42,
        });
      });

      return {
        subscribe: (subscriber) => {
          return subject.subscribe(subscriber);
        },
      };
    });
  });
}