{"id":46178,"library":"redis-tracker","title":"redis-tracker","description":"A TypeScript-first library for tracking RPC call counts and other action metrics using Redis time-bucketed counters. Version 1.1.9 is the current stable release with no breaking changes reported. It provides four main exports: `statis` for connection setup (standalone, cluster, or passing an existing ioredis instance), `trackAction` for incrementing counters, `searchKeys` for scanning Redis keys by pattern, and `statRedis` for reading counter values. Key differentiators include automatic time-bucket expiry (seconds to years), support for both module-specific and global counter namespaces, and native TypeScript definitions.","status":"active","version":"1.1.9","language":"javascript","source_language":"en","source_url":"https://github.com/NPM-public-repo-Jaykumar/redis-tracker","tags":["javascript","redis","tracker","metrics","analytics","rpc","typescript","jkg","jaykumar-gohil"],"install":[{"cmd":"npm install redis-tracker","lang":"bash","label":"npm"},{"cmd":"yarn add redis-tracker","lang":"bash","label":"yarn"},{"cmd":"pnpm add redis-tracker","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as a peer dependency for Redis connection. The library uses ioredis under the hood and expects it to be installed.","package":"ioredis","optional":false}],"imports":[{"note":"The package is ESM-only; CommonJS require() will fail. Always use an ESM import.","wrong":"const { statis } = require('redis-tracker')","symbol":"statis","correct":"import { statis } from 'redis-tracker'"},{"note":"trackAction is a named export, not the default export. Using a default import returns undefined.","wrong":"import trackAction from 'redis-tracker'","symbol":"trackAction","correct":"import { trackAction } from 'redis-tracker'"},{"note":"searchKeys is exported from the package root, not a subpath. No types subpath exists.","wrong":"import { searchKeys } from 'redis-tracker/types'","symbol":"searchKeys","correct":"import { searchKeys } from 'redis-tracker'"}],"quickstart":{"code":"import { statis, trackAction, searchKeys, statRedis } from 'redis-tracker';\n\nstatis.redis.standalone({\n  host: process.env.REDIS_HOST ?? '127.0.0.1',\n  port: Number(process.env.REDIS_PORT) || 6379,\n  password: process.env.REDIS_PASSWORD || '',\n});\n\n// Track an action\ntrackAction({\n  prefix: 'qa',\n  module_name: 'swap-tx-rpc',\n});\n\n// Search keys and retrieve counts\nasync function getCounts() {\n  const keys = await searchKeys('qa:swap-tx-rpc:*');\n  const results = await Promise.all(\n    keys.map(async (key) => ({\n      key,\n      value: Number((await statRedis.get(key)) || 0),\n    }))\n  );\n  console.log(results);\n}\n\ngetCounts().catch(console.error);","lang":"typescript","description":"Shows connection setup with standalone Redis, tracking an action, and retrieving counts using searchKeys and statRedis."},"warnings":[{"fix":"Upgrade to latest version: npm install redis-tracker@latest","message":"The package does not have any deprecated APIs. Always use the latest version.","severity":"deprecated","affected_versions":"<1.0.0"},{"fix":"Call trackAction without await; use a separate mechanism for error handling if needed.","message":"trackAction does not return anything; it's fire-and-forget. Do not await or expect a result.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Implement retry logic, or use a dedicated aggregation store if exact counts are required.","message":"searchKeys uses Redis SCAN, which may return empty array or incomplete results under heavy write load.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Wrap with Number() and handle null: Number((await statRedis.get(key)) || 0)","message":"statRedis.get returns a string or null; you must convert to Number for numeric operations.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.1.9':25 'action':16 'analyt':99 'automat':73 'break':33 'bucket':22,76 'call':12 'chang':34 'cluster':46 'connect':43 'count':13 'counter':23,56,68,89 'current':28 'definit':94 'differenti':71 'exist':50 'expiri':77 'export':40 'first':7 'four':38 'global':88 'gohil':105 'includ':72 'increment':55 'instanc':52 'ioredi':51 'javascript':95 'jaykumar':104 'jaykumar-gohil':103 'jkg':102 'key':61,70 'librari':8 'main':39 'metric':17,98 'modul':85 'module-specif':84 'namespac':90 'nativ':92 'pass':48 'pattern':63 'provid':37 'read':67 'redi':2,19,60,96 'redis-track':1 'releas':30 'report':35 'rpc':11,100 'scan':59 'searchkey':57 'second':78 'setup':44 'specif':86 'stabl':29 'standalon':45 'stati':41 'statredi':65 'support':81 'time':21,75 'time-bucket':20,74 'track':10 'trackact':53 'tracker':3,97 'typescript':6,93,101 'typescript-first':5 'use':18 'valu':69 'version':24 'year':80","created_at":"2026-06-07T12:58:39.612970+00:00","updated_at":"2026-06-07T12:58:39.612970+00:00","problems":[{"fix":"Ensure you called statis.redis.standalone() or .cluster() before using statRedis.","cause":"Using statRedis.get() with wrong context (e.g., not initialized properly).","error":"ERR wrong number of arguments for 'get' command"},{"fix":"Use ESM import: import { statis } from 'redis-tracker'; and upgrade to latest version.","cause":"Importing statis incorrectly, or using a very old version that doesn't have .redis.","error":"TypeError: statis.redis.standalone is not a function"},{"fix":"Install: npm install redis-tracker. Ensure your project supports ESM (e.g., \"type\": \"module\" in package.json).","cause":"Package not installed, or bundler config missing resolution for ESM.","error":"Error: Module not found: Can't resolve 'redis-tracker'"},{"fix":"Start Redis server or check REDIS_HOST/REDIS_PORT environment variables.","cause":"Redis server not running or wrong host/port.","error":"Redis connection refused"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/NPM-public-repo-Jaykumar/redis-tracker#readme","github":"https://github.com/NPM-public-repo-Jaykumar/redis-tracker","docs":null,"changelog":null,"pypi":null,"npm":"redis-tracker","openapi_spec":null,"status_page":null,"smithery":null,"categories":["analytics","devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}