Skip to content

Commit

Permalink
🪟 🔧 Add isCorporate to Airbyte.UI.User.Create (#22137)
Browse files Browse the repository at this point in the history
* 🪟 🔧 Add isCorporate to Airbyte.UI.User.Create

We use this event to track conversions across paid channels such as
Google Ads.
Since we are only interested in corporate signups, we only want to track
a successful conversion in those cases.
Previously, we only added the `isCorporate` flag on `.identify()` but we
need this info also in `.track('Airbyte.UI.User.Create')`

Context: https://docs.google.com/document/d/13JbXLgAEVQmMoCBOPdDzAKpzwvqGclMcGSdA3bQ5KYQ/edit?disco=AAAAofb14Pg

* code style suggestion
  • Loading branch information
letiescanciano authored Jan 31, 2023
1 parent 15fce4f commit 88e95bc
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ interface AuthContextApi {
loggedOut: boolean;
providers: string[] | null;
hasPasswordLogin: () => boolean;
hasCorporateEmail: () => boolean;
hasCorporateEmail: (email?: string) => boolean;
login: AuthLogin;
loginWithOAuth: (provider: OAuthProviders) => Observable<OAuthLoginState>;
signUpWithEmailLink: (form: { name: string; email: string; password: string; news: boolean }) => Promise<void>;
Expand Down Expand Up @@ -116,6 +116,7 @@ export const AuthenticationProvider: React.FC<React.PropsWithChildren<unknown>>
user_id: firebaseUser.uid,
name: user.name,
email: user.email,
isCorporate: ctx.hasCorporateEmail(user.email),
// Which login provider was used, e.g. "password", "google.com", "github.com"
provider: firebaseUser.providerData[0]?.providerId,
...getUtmFromStorage(),
Expand Down Expand Up @@ -187,8 +188,8 @@ export const AuthenticationProvider: React.FC<React.PropsWithChildren<unknown>>
hasPasswordLogin(): boolean {
return !!state.providers?.includes("password");
},
hasCorporateEmail(): boolean {
return !FREE_EMAIL_SERVICE_PROVIDERS.some((provider) => state.currentUser?.email.endsWith(`@${provider}`));
hasCorporateEmail(email: string | undefined = state.currentUser?.email): boolean {
return !FREE_EMAIL_SERVICE_PROVIDERS.some((provider) => email?.endsWith(`@${provider}`));
},
async login(values: { email: string; password: string }): Promise<void> {
await authService.login(values.email, values.password);
Expand Down

0 comments on commit 88e95bc

Please sign in to comment.