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

@qurvo/sdk-tma

v0.0.2

Published

Telegram Mini Apps SDK for Qurvo analytics — event tracking, user identification, CloudStorage queue

Readme

@qurvo/sdk-tma

Telegram Mini Apps SDK for Qurvo analytics.

A thin wrapper around @qurvo/sdk-core adapted for the TMA runtime:

  • distinctId derived from Telegram.WebApp.initDataUnsafe.user.id — no anonymous UUID in localStorage
  • Queue backed by Telegram.WebApp.CloudStorage — events survive app restarts and session gaps
  • session_id stored in sessionStorage (same as the browser SDK)
  • Auto-context: platform, start_param, is_premium, language_code
  • Auto-event tma_opened on init; optional main_button_clicked, back_button_pressed, invoice_closed
  • Flush triggered on viewportChanged (TMA close/collapse) and visibilitychange

Installation

npm install @qurvo/sdk-tma
# or
pnpm add @qurvo/sdk-tma

Quick start

import { qurvo } from '@qurvo/sdk-tma';

// Call as early as possible, after Telegram.WebApp.ready()
Telegram.WebApp.ready();

qurvo.init({
  apiKey: 'sk_your_api_key',
  endpoint: 'https://ingest.your-domain.com',
});

// Track a custom event
qurvo.track('item_viewed', { item_id: '42', category: 'shoes' });

On init, the SDK:

  1. Reads Telegram.WebApp.initDataUnsafe.user.id and uses it as distinct_id
  2. Loads any previously unsent events from CloudStorage and re-queues them
  3. Tracks a tma_opened event with platform and user context
  4. Starts the periodic flush timer (default: every 3 seconds)

Identify

In most cases you do not need to call identify() — the Telegram user ID is already the distinct_id. Call it only when you want to link the Telegram numeric ID to your own internal user ID:

// After your backend resolves the Telegram user to your application user
qurvo.identify('your-internal-user-id', {
  email: '[email protected]',
  plan: 'premium',
});

User properties

// Set (overwrite) user properties
qurvo.set({ subscription_tier: 'gold', referral_code: 'ABC123' });

// Set only if not already set (first touch attribution)
qurvo.setOnce({ first_seen_start_param: 'summer_promo' });

Optional auto-events

qurvo.init({
  apiKey: 'sk_...',
  endpoint: 'https://ingest.your-domain.com',
  autoEvents: {
    mainButton: true,     // tracks 'main_button_clicked'
    backButton: true,     // tracks 'back_button_pressed'
    invoiceClosed: true,  // tracks 'invoice_closed' with { url, status }
  },
});

invoice_closed status values: 'paid', 'cancelled', 'failed', 'pending'


Automatic context

Every event automatically includes:

| Property | Source | Example | |---|---|---| | platform | Telegram.WebApp.platform | "ios", "android", "tdesktop" | | tma_start_param | initDataUnsafe.start_param | "summer_promo" | | tma_is_premium | initDataUnsafe.user.is_premium | true | | tma_language_code | initDataUnsafe.user.language_code | "ru" | | session_id | sessionStorage (per session) | UUID | | sdk_name | constant | "@qurvo/sdk-tma" | | sdk_version | package version | "0.0.1" |


CloudStorage queue

Events are serialised to Telegram.WebApp.CloudStorage under the key qurvo_queue. On the next app open, the SDK loads and replays any events that were not flushed in the previous session (e.g. due to sudden closure or network failure).

If CloudStorage is unavailable (running in a regular browser for development), the SDK falls back gracefully to an in-memory queue with no persistence.


TelegramUser type

import type { TelegramUser } from '@qurvo/sdk-tma';

// { id, username?, first_name, last_name?, is_premium?, language_code?, photo_url? }

Reset

// Clears the current identity and stops the queue (e.g. on logout)
qurvo.reset();

After calling reset(), call qurvo.init(config) again to start a new session.


CDN / IIFE bundle

If you load the SDK via a <script> tag:

<script src="https://cdn.jsdelivr.net/npm/@qurvo/sdk-tma/dist/qurvo-tma.iife.js"></script>
<script>
  QurvoTma.init({ apiKey: 'sk_...', endpoint: 'https://ingest.your-domain.com' });
  QurvoTma.track('button_click');
</script>

License

MIT