Skip to main content
Time Range Blueprint, किसी resource के ग्राहक के लिए चलने की अवधि को milliseconds, seconds या minutes में usage event के रूप में Dodo Payments को भेजता है। उस अवधि पर Sum meter प्रत्येक ग्राहक के runtime को जोड़ता है, ताकि आप compute time के लिए बिल कर सकें। यह blueprint @dodopayments/ingestion-blueprints npm package में शामिल है और इसे trackTimeRange() के रूप में उपयोग किया जाता है।

उपयोग के मामले

Time Range Blueprint इन परिस्थितियों के लिए उपयुक्त है:

Serverless Functions

function execution time और memory usage के आधार पर बिल लें।

Container Runtime

usage-based billing के लिए container के running time को ट्रैक करें।

Compute Instances

VM runtime को मॉनिटर करें और प्रति मिनट या घंटे के हिसाब से शुल्क लें।

Background Jobs

data exports, reports और batch jobs के लिए processing time ट्रैक करें।
इसका उपयोग compute time, function execution duration, container runtime या किसी भी अन्य time-based usage के लिए बिल लेने में करें।

त्वरित शुरुआत

runtime को ट्रैक करने के लिए package install करें, meter बनाएं और हर बार किसी resource के चलना समाप्त होने पर उसकी duration भेजें।
1

Install the SDK

Dodo Payments Ingestion Blueprints package install करें:
2

Get Your API Keys

Dodo Payments dashboard में Developer → API Keys के अंतर्गत Dodo Payments API key बनाएं और उसे DODO_PAYMENTS_API_KEY environment variable में store करें। Build करते समय test mode key का उपयोग करें। Test mode key केवल test_mode के साथ काम करती है।
3

Create a Meter

Dodo Payments dashboard में Products → Meters पर जाएं और Create Meter पर क्लिक करें। ये fields सेट करें:
  • Meter Name: कोई वर्णनात्मक नाम, जैसे Compute Time।
  • Event Name: time_range_usage या अपनी पसंद का कोई नाम। यह आपके code में मौजूद eventName से बिल्कुल मेल खाना चाहिए (case-sensitive)। अगले चरण के examples में प्रत्येक resource type के लिए अलग event name का उपयोग किया गया है, जैसे function_execution, इसलिए प्रत्येक के लिए अपना meter चाहिए।
  • Aggregation Type: कुल duration जोड़ने के लिए Sum।
  • Over Property: आपके द्वारा भेजी जाने वाली duration key: durationSeconds, durationMinutes या durationMs।
  • Measurement Unit: invoices पर दिखाई जाने वाली unit, जैसे seconds।
4

Track Time Usage

काम कितनी देर चला, उसे मापें, फिर meter में उपयोग की गई unit में duration के साथ trackTimeRange() को call करें:

Configuration

Ingestion Configuration

ये options new Ingestion() को दें:
string
आवश्यक
Dashboard से प्राप्त आपकी Dodo Payments API key।
string
Environment mode: test_mode या live_mode। डिफ़ॉल्ट रूप से test_mode होता है। इसके बजाय Dodo Payments SDKs डिफ़ॉल्ट रूप से live_mode पर सेट होते हैं, इसलिए production में live_mode को स्पष्ट रूप से सेट करें।
string
आवश्यक
वह event name जो आपके meter के Event Name से मेल खाता हो (case-sensitive)।

Time Range Options को ट्रैक करें

ये options trackTimeRange() को दें। आपके द्वारा भेजी जाने वाली प्रत्येक duration को उसी नाम वाली metadata key के रूप में भेजा जाता है।
string
आवश्यक
runtime के लिए बिल किए जाने वाले Dodo Payments customer की ID, जैसे cus_123।
number
Milliseconds में duration। Sub-second precision के लिए उपयोग करें।
number
Seconds में duration। Function execution और short tasks के लिए सबसे सामान्य।
number
Minutes में duration। VM जैसे लंबे समय तक चलने वाले resources के लिए उपयोगी।
object
Resource के बारे में वैकल्पिक metadata, जैसे CPU, memory या region। प्रत्येक value string, number या boolean होनी चाहिए।

सर्वोत्तम प्रथाएं

सही Unit चुनें: Short operations के लिए milliseconds, functions के लिए seconds और लंबे समय तक चलने वाले resources के लिए minutes का उपयोग करें।
Meter केवल उसी key का योग करता है जिसका नाम उसके Over Property में दिया गया है, इसलिए हर बार duration को उसी unit में भेजें।
सटीक Timing: सटीक time tracking के लिए Date.now() या performance.now() का उपयोग करें, विशेष रूप से serverless functions के लिए।
अंतिम संशोधन 26 सितंबर 2026