0.1.2 • Published 4 months ago
@ray-js/track
Licence
MIT
Version
0.1.2
Deps
0
Size
42 kB
Vulns
0
Weekly
0
English | 简体中文
@ray-js/track
Business exception reporting & SDK usage tracking for MiniApp
Installation
npm install @ray-js/track
# or
yarn add @ray-js/track
Use Cases
- SDK usage tracking
- Common business exception monitoring via detectors
- Custom business exception monitoring
Important Notes
- External developer integration is not supported at this time; this package is intended for Tuya official developers only
- No data will be reported if the end user disables
Feature Experience Upgrade Planin the App privacy settings - Do not use in child-oriented MiniApps
- Never report personal data such as phone numbers, emails, or real names through
msg,params, or detector extension fields
Quick Start
SDK Usage Tracking (for SDK authors)
Embed in your SDK to track how many MiniApps are using it:
import { UsageTracker } from '@ray-js/track';
// Call once during SDK initialization
UsageTracker.report({
sdkName: '@ray-js/your-sdk',
sdkVersion: '1.0.0',
});
Common Exception Monitoring (via detectors)
import { TrackSDK, I18nDetector } from '@ray-js/track';
// Create detectors before any business code runs
const i18nDetector = I18nDetector();
// Initialize SDK
const track = TrackSDK.init();
// Register detectors
track.use([i18nDetector]);
Custom Business Exception Monitoring
import { TrackSDK } from '@ray-js/track';
const track = TrackSDK.init();
track.report({
msg: 'Device connection timeout',
level: 'error',
params: { deviceId: 'xxx' },
});