Closed albertorestifo closed 1 year ago
Hey Alberto, if I'm understanding your issue correctly, I think Interval already has the functionality you're looking for. In addition to our I/O methods, we also have an object available inside of actions called ctx
. Among other things, you can use ctx.user
to get the name and email of the person running your action.
Here's an example of that in action:
const { Interval, ctx } = require("@interval/sdk");
require("dotenv").config(); // loads environment variables from .env
const interval = new Interval({
apiKey: process.env.INTERVAL_KEY,
actions: {
hello_world: async () => {
console.log(ctx.user.email, ctx.user.firstName, ctx.user.lastName);
},
},
});
interval.listen();
Hopefully this is helpful!
Awesome, that's exactly what I was hoping for. I missed that in the documentation, thank you!
For many of our use-cases, it's quite important to be able to identity the user that is running an action (an email or interval user id).
This way we can record in our database audit log the person that made a given change.