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

@ewjdev/anyclick-core

v1.5.0

Published

Framework-agnostic core library for UI / UX events capture with DOM context

Downloads

166

Readme

@ewjdev/anyclick-core

Framework-agnostic core library for UI / UX events with DOM context

npm version License: MIT

Overview

@ewjdev/anyclick-core provides the foundational utilities for capturing UI/UX events with full DOM context. It's framework-agnostic and can be used with any JavaScript framework or vanilla JavaScript.

Installation

yarn install @ewjdev/anyclick-core

Features

  • 🎯 DOM Capture - Extract selectors, data attributes, and ancestor information
  • 📸 Screenshot Utilities - Capture element and page screenshots
  • 📦 Payload Building - Construct structured lightweight payloads
  • 🔌 Adapter Interface - Flexible adapter pattern for custom integrations

Basic Usage

import { createAnyclickClient } from "@ewjdev/anyclick-core";

// Create a anyclick client with your adapter
const client = createAnyclickClient({
  adapter: {
    async submit(payload) {
      // Your submission logic
      return { success: true };
    },
  },
});

// Attach to DOM (starts listening for context menu events)
client.attach();

// Later, submit analytic programmatically
await client.submitAnalytic(element, "issue", {
  comment: "This button is broken",
});

// Cleanup
client.detach();

HTTP Adapter

import { createHttpAdapter } from "@ewjdev/anyclick-core";

const adapter = createHttpAdapter({
  endpoint: "/api/feedback",
});

API Reference

DOM Utilities

import {
  getUniqueSelector,
  getAncestors,
  getDataAttributes,
  buildElementContext,
} from "@ewjdev/anyclick-core";

// Get a unique CSS selector for an element
const selector = getUniqueSelector(element);

// Get ancestor elements with context
const ancestors = getAncestors(element, { maxAncestors: 5 });

// Get all data-* attributes
const dataAttrs = getDataAttributes(element);

// Build full element context
const context = buildElementContext(element);

Screenshot Capture

import {
  captureScreenshot,
  captureAllScreenshots,
  isScreenshotSupported,
} from "@ewjdev/anyclick-core";

if (isScreenshotSupported()) {
  // Capture a single element
  const screenshot = await captureScreenshot(element, {
    quality: 0.9,
    format: "png",
  });

  // Capture target, container, and full page
  const screenshots = await captureAllScreenshots(
    targetElement,
    containerElement,
  );
}

Payload Building

import { buildAnyclickPayload, buildPageContext } from "@ewjdev/anyclick-core";

const payload = buildAnyclickPayload({
  element,
  type: "issue",
  comment: "Something is wrong here",
  metadata: { userId: "123" },
});

Types

AnyclickPayload

interface AnyclickPayload {
  type: AnyclickType;
  timestamp: string;
  page: PageContext;
  element: ElementContext;
  comment?: string;
  metadata?: Record<string, unknown>;
  screenshots?: ScreenshotData;
}

AnyclickAdapter

interface AnyclickAdapter {
  submit(payload: AnyclickPayload): Promise<AnyclickResult>;
}

interface AnyclickResult {
  success: boolean;
  id?: string;
  url?: string;
  error?: string;
}

Configuration

const client = createAnyclickClient({
  adapter: myAdapter,
  targetFilter: (event, target) => true,
  maxInnerTextLength: 500,
  maxOuterHTMLLength: 2000,
  maxAncestors: 5,
  cooldownMs: 1000,
  stripAttributes: ["data-sensitive"],
});

Documentation

For full documentation, visit anyclick.ewj.dev/docs/core

Related Packages

License

MIT © anyclick