I have an action in the Login Flow that sends a New User message every time someone signs up. My code filters out only users who have a login_count of 1.
exports.onExecutePostLogin = async (event, api) => {
// If user is logged in for the first time.
if (event.stats.logins_count === 1) {
const slack = require('slack-notify')(event.secrets.SLACK_WEBHOOK_URL);
const message = `New User: ${event.user.email} (${event.user.name || (event.user.given_name && event.user.family_name) || event.user.username || ""})`;
const channel = '#new-users';
slack.success({
text: message,
channel: channel
});
}
However, my slack got a few identical messages. One at
12:05AM PST,
12:15 AM PST,
10:46PM PST on 10/05/2021.
Thanks for the quick reply. My issue is, I want to notify signups through social logins too (fb, google). Post registration doesnāt trigger for these.
I feel like my implementation in the Login flow should work, given I filter by login_count.
Do actions trigger more than once with the same event? Any other way to get notified for social sign ups?
I tested this myself and I figured post-login action also runs on Successful silent authentication. So if you login and your app also trigger a Silent Authentication check then that will be cause the post login to run again hence that action is triggered twice. You can check Actions triggered as part of login flows in Monitoring ā Logs and select the Success Login event to see details.
That makes sense. The logs show multiple āSuccess Loginā, even thought the login_count is 1. Is there way to discern that from the Login event in the Action?