The hook works fine in “simulation mode” where I click the run button but it is not firing or working fine when I am adding a user from the “create user” button of the dashboard.
So my two questions are:
If it is meant to work, how can I access the logs to see the stack trace of the execution and spot the error?
If it is not working, what is the easiest way to test a ‘real scenario’?
Beside of course checking the logs on your end / API as well. I guess it’s a public API and reachable by Auth0, no IP whitelisting required, etc.
If there are still issues, you can post the hook code in here (remove anything sensitive), maybe there’s a logical issue to spot.
The hook works fine in “simulation mode” where I click the run button but it is not firing or working fine when I am adding a user from the “create user” button of the dashboard.
This shouldn’t make a difference, I just tested it. (Created a user via dashboard, hook gets called)
console.log returns the success response when running on simulation mode and of course I see the mutation in my system happening.
But I dont see it when I add a user manually. So I can already see realtime logs but not “past logs”. I.e 3 people were registered in the evening, how can I see the logs next morning to see what happened?
My hook is pretty much a commodity:
module.exports = function (user, context, cb) {
// Perform any asynchronous actions, e.g. send notification to Slack.
const body = {
'key1': 'value1',
'key2': 'value2'
}
var rp = require('request-promise');
var options = {
method: 'POST',
uri: 'https://mydomain/my_api_endpoint',
body: body,
json: true // Automatically stringifies the body to JSON
};
rp(options)
.then(function (parsedBody) {
console.log('success', parsedBody)
})
.catch(function (err) {
console.log('failed', err)
});
cb();
};
So the issue seems to be with the simulation itself. The user object passed through simulation is not the same (in terms of schema) as in the create user form.
I have to accommodate my business logic to fill in the expected fields.