This demo shows how to track usage events with Usagey. Fill out the form below to send a usage event.
Error
Submit the form to see the result
Event tracked successfully!
This demo uses the Usagey SDK to track usage events. The implementation follows these steps:
trackEvent function from our client librarytrackEvent() with the provided parameters
const { trackEvent } = require('../lib/usagey-client');
// Route handler
router.post('/track', async (req, res) => {
try {
const { event_type, quantity = 1, metadata = {} } = req.body;
// Track a usage event
const result = await trackEvent(
event_type, // Event type
quantity, // Quantity
metadata // Optional metadata
);
res.status(200).json(result);
} catch (error) {
res.status(500).json({ error: error.message });
}
});