Get language after apple signup

We use the apple connection widget from marketplace.
I read a post how i could capture and update users metadata after the signup.
The user is also getting logged in, now my question.

Is it possible to capture the browser language on the fist login when the user returns from apple?

Hi @dariusz.kloda

Welcome back to the Auth0 Community!

Thank you for posting your question. Due to the nature of the Pre and Post User Registration Flow you can’t user them with Social Connection, they only work with Database and Passwordless connection.

You can try to utilize the post-login flow with action that will conditionally trigger upon first login Actions Triggers: post-login - Event Object. From the request you will be able to update the user metadata with browser information.

Let me know if this helps you.

Thanks
Dawid

ok, so i did that. I did even more i saved the whole event object on the user.
But on the event.request object should be a property called language but its missing. so i took
event.transaction.locale which is fine for now.

Then the other handler should simply check if users have a preferredLanguage property but also here event.request.language is missing.

Could you explain me why the language property is missing and when i can rellay on them?

exports.onExecutePostLogin = async (event, api) => {
  const tr_languages = ["es","en","de"];
  //after apple signup set language to user
  if(event.connection.strategy === event.connection.name && event.stats.logins_count === 1){
    let language = event.transaction.locale;
    language = language.length>2?language.slice(0,2):language;
    const exists = tr_languages.some((item)=> item === language);
    language = exists?language:"en";
    api.user.setUserMetadata("preferredLanguage", language); 
  }

  if(!event.user.user_metadata.preferredLanguage && event.request.language){
    let language = event.request.language;
    language = language.length>2?language.slice(0,2):language;
    const exists = tr_languages.some((item)=> item === language);
    language = exists?language:"en";
    api.user.setUserMetadata("preferredLanguage", language); 
  }
}

We have 2 scenarios, the first one you mentioned.
But here the event.request.language is undefined.