User Export: Include Applications Through which the User has Authenticated
Last Updated:
Overview
When exporting users via the user import/export extension, is there a way to include the names of applications users have logged into?
Applies To
- User Export
Solution
One solution is to create a login action that will update an app_metadata field with the application name the user has logged into, e.g.:
exports.onExecutePostLogin = async (event, api) => {
const existingApplications = event.user.app_metadata.applications || [];
const currentApplication = event.client.name;
if(!existingApplications.includes(currentApplication)) {
existingApplications.push(currentApplication);
api.user.setAppMetadata('applications', existingApplications);
}
}
When a user logs in, if the app_metadata.applications array is non-existent or does not include the current application name, it will be updated to include the existing application name.