Skip to content
Projects

About

Cross-platform Sentry SDK for WeChat Mini Programs, WeChat, Douyin and Kuaishou Mini Games, Taro, and uni-app — error monitoring, performance monitoring, and Source Maps | Error monitoring, performance analysis, and source-code定位 for multi-platform projects such as WeChat Mini Programs and WeChat, Douyin, and Kuaishou Mini Games

Games & Emulation

How these counts are measured

Measured star growth

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
Collecting history

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

docs/README.en.md

Original

Sentry Miniapp SDK — Mini Program Monitoring SDK

npm version npm downloads/month github forks github stars test coverage Sentry Community SDK license docs

简体中文 | English

Monitor mini programs and mini games with Sentry. Investigate production errors using device, interaction and request details; enable performance sampling as needed to measure the duration of requests and business operations.

Supports WeChat, Alipay, ByteDance, Baidu, QQ, DingTalk, and Kuaishou mini programs, plus WeChat, Douyin, and Kuaishou mini games. Works with native, Taro and uni-app projects.

Quick Start · Full Documentation · Examples

The docs site is in Chinese.


✨ Core Capabilities and Use Cases

The problem you face What you can do with the SDK
Users report production errors that are hard to reproduce locally View errors in Sentry and use device, page, interaction and request details to reconstruct what happened
Stack traces show minified files and line numbers instead of your source Upload Source Maps from the matching build to locate the original source and inspect code context
Login, checkout or a page action is slow, with no clear bottleneck Enable performance sampling to measure requests and business steps; configure tracing to connect them with backend operations already instrumented with Sentry
A business operation fails without throwing an exception Record searchable business logs and metrics to inspect key steps and track failure counts or duration distributions
A weak connection prevents monitoring requests from being delivered Buffer eligible data in a local queue with a size limit and retry when connectivity returns
Monitoring data must wait for the user's privacy consent Configure the consent gate to pause Sentry network delivery until consent, then attempt to send buffered data
WeChat / Douyin / Kuaishou mini games need error and frame-rate monitoring Monitor game errors and sessions in Sentry, with optional FPS and jank collection

Automatic collection depends on host capabilities. React / Vue component errors require framework error handling, and mini game FPS collection requires explicit opt-in. See the Taro, uni-app, mini game and platform support guides (Chinese).


Setup Requirements

This README and the current docs site cover the stable 2.x release. Before upgrading an existing 1.x project, or if your self-hosted deployment cannot be upgraded, read the version selection and migration guide (Chinese).

Privacy-policy cache invalidation, cachePrivacyVersion, and initialization retries after the host becomes available require 2.3.1 or later. Existing 2.3.x projects should review the cache migration and upgrade steps (Chinese).

Use Sentry SaaS or self-hosted Sentry 26.4.2 or higher. Older self-hosted deployments are outside the supported range for 2.x; receiving errors alone does not establish support for other monitoring features.

Mini programs are apps hosted inside platforms such as WeChat, Alipay and Douyin. Their JavaScript runtimes use platform-specific networking and lifecycle APIs rather than the browser DOM and request APIs. For H5/web builds, use the official @sentry/browser; use this SDK for mini program and mini game builds.

🚀 Get It Working In 5 Minutes

Before you start:

  • Confirm your Sentry deployment meets the requirements above, then create a project and copy its DSN.
  • Add your Sentry endpoint domain to the request trusted-domain list in your mini program console.
  • Check runtime compatibility for required JavaScript capabilities, supplied standard methods, and optional instrumentation fallbacks.

Install:

npm install sentry-miniapp

For native WeChat projects, run Tools → Build npm in WeChat Developer Tools after installing or updating the SDK. See Getting Started for directory requirements. Taro and uni-app handle dependencies through their framework builds.

Not using npm? Download the versioned sentry-miniapp.umd.js asset from GitHub Releases, place it in your project's lib/ directory, and replace the import below with const Sentry = require('./lib/sentry-miniapp.umd.js');. To run the WeChat example from source, generate its local bundle with yarn build:miniapp.

Initialize at the top of your entry file (app.js / app.ts), before App():

const Sentry = require('sentry-miniapp');

Sentry.init({
  dsn: 'YOUR_DSN', // Copy the complete DSN from your Sentry project.
  release: '[email protected]', // match the release you upload Source Maps with
  environment: 'production',
});

App({ onLaunch() {} });

Verify it works:

Sentry.captureException(new Error('sentry test'));

Then check the Sentry Issues list.

Once error delivery works, choose a tracesSampleRate appropriate for your traffic to enable performance monitoring; see Performance and Tracing (Chinese). The minimal setup above does not enable tracing.

If nothing shows up, first check the DSN, trusted domain, initialization placement, and sampling config. The full checklist lives in Getting Started and the FAQ.

🤖 AI Coding Agent Setup

Install the setup skill in your own mini program / mini game project:

npx --yes degit lizhiyao/sentry-miniapp/.agents/skills/sentry-miniapp-sdk .agents/skills/sentry-miniapp-sdk

Ask your agent to use sentry-miniapp-sdk to detect the platform and framework, initialize the SDK, and provide verification steps. If it does not auto-discover the skill, point it to .agents/skills/sentry-miniapp-sdk/SKILL.md; see the skill guide.


🧭 Where To Go Next

After the first event is working, pick the guide based on what you are doing next:

I want to... Read this
Follow the full native mini program setup Getting Started
Set up Taro / uni-app projects and handle component errors Taro / uni-app
Set up WeChat / Douyin / Kuaishou mini games and performance monitoring Mini Game Guide
Add user, interaction and business log details Errors, Logs and Context
Investigate slow requests or connect backend traces Performance and Tracing
Configure weak-network retries or consent-gated delivery Reliability and Privacy Consent
Look up public methods and initialization options Common APIs / Configuration Reference
Upload Source Maps or troubleshoot Debug IDs and WeChat merged bundles Deployment Guide / Advanced Troubleshooting
Check platform, mini program, and mini game capability differences Supported Scope
Reduce main-package size Bundle Size
See runnable examples Examples
Troubleshoot missing events or component errors FAQ
Check version history and release notes GitHub Releases
Contribute to the project Architecture (Chinese) / Development Guide / Contributing Guide

Privacy changes and cached telemetry

SDK-managed offline and consent caches are replayed only under an equivalent effective privacy policy. Reinitializing with changed query/body collection, sensitive keys, or user/IP policy discards incompatible records, including when a policy is relaxed. For custom hooks, integrations or Replay privacy changes, update a stable cachePrivacyVersion string. Old v2 cache identities are conservatively discarded on first read. Failed deletion blocks incompatible replay for the current policy but cannot guarantee disk erasure. See the cache contract.


Experimental WeChat Page Replay

To inspect UI changes before an error, opt into WeChat page replay. It records sampled layouts, text changes and clicks on selected pages; the build tool annotates supported nodes and static components. Use sentry-miniapp 2.1.0 or later, install the replay integration and generate page annotations as described in the guide. This experimental feature targets ordinary WeChat mini programs using the WebView renderer.

For Taro 4/webpack5 and uni-app Vue 3/Vite projects, use 2.2.0 or later and configure the build plugin once. Normal builds and watch mode then generate annotations automatically, without editing each page template.

The source example also supports local recording and playback: export a recording and inspect it in a PC browser without using Sentry cloud quota.


❓ FAQ

No events, missing component errors, privacy consent and Source Map issues are covered in the FAQ (Chinese). Start with a new test error and Sentry.getDiagnostics(), then check the actual request and the corresponding event in your Sentry project.


💬 Community

For setup issues or production troubleshooting, GitHub is the best first stop so answers stay searchable:

  • Bugs / no events / Source Map issues: open an issue with the SDK version, target platform, reproduction steps, relevant config, and Sentry.getDiagnostics() output.
  • Feature requests / monitoring design discussions: start a discussion with your scenario, target platforms, and expected behavior.

Remove auth tokens, app secrets and personal data before sharing logs or configuration.

For real-time mini program / mini game monitoring discussion, you can join the WeChat group. Due to WeChat group QR code expiration (7-day limit), please add the author on WeChat (note: sentry-miniapp) to be invited:

Author WeChat QR Code

Explore related projects

Loading…