What is billing event tracking in Node.js
Tracking billing events in your Node.js app helps you monitor payments, subscriptions, and refunds in real time. For example, you can log when a customer’s payment succeeds and alert your team on failures.
Tracking billing events with Operational
Operational is an open-source event tracking tool. You can use it to ingest and view billing events from your app in a single dashboard.
Setting up Operational
- Go to the signup page at app.operational.co and create an account.
- In your dashboard, copy your API key.
- Install the SDK in your project:
npm install @operational.co/sdk
. - Keep your API key handy for the code examples below.
Code examples
The following snippets show how to track different billing events in Node.js using Operational.
import Operational from "@operational.co/sdk";
const ops = new Operational("API_KEY");
const payload = {
"name": "subscription created",
"avatar": "💳",
"content": "New subscription for John Smith: Pro Plan."
};
await ops.events.ingest(payload);
This example tracks a new subscription event.
import Operational from "@operational.co/sdk";
const ops = new Operational("API_KEY");
const payload = {
"name": "payment successful",
"avatar": "✅",
"content": "Payment of $20.00 received from Jane Doe."
};
await ops.events.ingest(payload);
This example logs a successful payment.
import Operational from "@operational.co/sdk";
const ops = new Operational("API_KEY");
const payload = {
"name": "refund processed",
"avatar": "↩️",
"content": "Refund of $20.00 issued to Jane Doe."
};
await ops.events.ingest(payload);
This example records a refund event.
Conclusion
Tracking billing events with Operational can save you time and hassle when managing payments and subscriptions. It offers a simple API and real-time dashboard.
Learn more on the Operational website: https://operational.co
Try the playground to copy and test snippets: https://operational.co/playground