Post reg hook, is not firing after creating a user from the create user button in dashboard

Hi there

I have setup a post-reg hook to call my API.

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’?

Thank you in advance,
P.

You can use the Realtime Webtask Logs extension to debug. Then console.log()

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)

Hi @mathiasconradt

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();
};

Ok looks like I misunderstood the realtime logs extension suggestion. Having a look, I can totally see the error.

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.

Thanks for helping out @mathiasconradt

1 Like

Thanks for the update, hope it helps others. I never used the simulation myself, always the Realtime WT logs, therefore never noticed.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.