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

@leadble/capture

v0.5.0

Published

SDK de captura de leads para diagnósticos Leadble

Readme

@leadble/capture

SDK oficial de captura de leads para diagnósticos Leadble.

Instalação

npm install @leadble/capture

Uso rápido

import {
  Leadble,
  resolveResultPageBaseUrl,
  buildResultUrl
} from '@leadble/capture'

const lb = new Leadble({
  apiKey: 'lb_sk_...',
  diagnosticKey: 'dlg_...'
})

await lb.init()
lb.track('diagnostic_start')

const { publicKey, sessionId } = await lb.completeLead({
  contact: { name, email, phone },
  answers: [...],
  resultPageUrl: resolveResultPageBaseUrl()
})

const resultLink = buildResultUrl(
  resolveResultPageBaseUrl(),
  publicKey,
  { sessionId }
)

Recomeçar / retentativa

Cada “Recomeçar” deve criar uma nova sessão (tentativa pagável). O lead (pessoa) permanece o mesmo.

async function onRestart() {
  const { sessionId } = await lb.restart()
  resetQuizUi()
  return sessionId
}
  • restart() limpa o cache de sessionId, mantém o visitorId e chama POST /sessions.
  • init() também rotaciona se o cache local apontar para sessão paid/abandoned.
  • Depois do restart: completeLead() de novo → checkout só com o novo sessionId.

resultPageUrl (v0.4.0+)

Envie a URL base da página de resultado no completeLead (sem lead/session na query). A Leadble usa esse valor no funil de e-mail e injeta lead, session, cupom e UTMs no disparo.

Helpers:

  • resolveResultPageBaseUrl(origin?, path?) — monta a URL base (padrão /diagnostico/resultado)
  • buildResultUrl(baseUrl, publicKey, { sessionId?, coupon? }) — link permanente para o lead

Build local

cd packages/capture
pnpm install
pnpm build

Artefatos em dist/ (index.js, index.cjs, index.d.ts).

Publicar no npm

cd packages/capture
pnpm build
npm publish --access public

Changelog

0.5.0

  • lb.restart() — nova tentativa pagável (Recomeçar)
  • init() / ensureSession() não reutilizam sessão paid ou abandoned do cache local
  • Contrato: 1 lead, N sessões; pagamento por sessão

0.4.1

  • Correção crítica: completeLead enviava o objeto { sessionId, isNew } no campo sessionId (causava 422 expected string, received object). Agora desestrutura o sessionId corretamente.

0.4.0

  • completeLead aceita resultPageUrl com validação client-side
  • Novos helpers: resolveResultPageBaseUrl, DEFAULT_RESULT_PAGE_PATH
  • buildResultUrl aceita sessionId e coupon opcionais
  • completeLead alinhado à API: interests, whatsappOptIn, resultSummary tipado
  • Validação de score (0–100) no cliente

0.3.0

  • Versão anterior com init, track, completeLead, pagamentos e relatório premium