Why view environment variables on your server?
Server environment variables hold critical config and secrets outside your code.
Viewing them can help you debug misconfigurations and verify values.
For example, you might check that DB_URL matches your database in development.
Logging environment variable events with Operational
Operational is an open source event tracking tool for your apps.
You can use it to log when you read or change env vars on your server.
Setting up Operational
- Go to app.operational.co and create an account.
- Copy your API key from the dashboard.
- Install the SDK with npm or yarn.
- Initialize Operational in your project using the API key.
Code example
import Operational from "@operational.co/sdk"
const ops = new Operational("YOUR_API_KEY")
const dbUrl = process.env.DB_URL
const payload = {
name: "Environment variable accessed",
avatar: "🔑",
content: `The DB_URL environment variable is ${dbUrl}`
}
await ops.events.ingest(payload)
This snippet logs an event when you read the DB_URL environment variable.
Conclusion
Tracking environment variable access can save time debugging and reveal config issues.
Operational makes it easy to log these events and view them in one dashboard.
Learn more at https://operational.co
Try snippets in the playground.