Add new user signup event tracking in PostHog (#8412)

This commit is contained in:
Germain 2022-04-28 11:46:02 +01:00 committed by GitHub
parent 1127db0514
commit 1ed68a718f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 79 additions and 14 deletions

View file

@ -33,6 +33,7 @@ import Field from '../elements/Field';
import RegistrationEmailPromptDialog from '../dialogs/RegistrationEmailPromptDialog';
import CountryDropdown from "./CountryDropdown";
import PassphraseConfirmField from "./PassphraseConfirmField";
import { PosthogAnalytics } from '../../../PosthogAnalytics';
enum RegistrationField {
Email = "field_email",
@ -147,6 +148,8 @@ export default class RegistrationForm extends React.PureComponent<IProps, IState
};
private doSubmit(ev) {
PosthogAnalytics.instance.setAuthenticationType("Password");
const email = this.state.email.trim();
const promise = this.props.onRegisterClick({

View file

@ -18,6 +18,7 @@ import React from "react";
import { chunk } from "lodash";
import classNames from "classnames";
import { MatrixClient } from "matrix-js-sdk/src/client";
import { Signup } from "matrix-analytics-events/types/typescript/Signup";
import PlatformPeg from "../../../PlatformPeg";
import AccessibleButton from "./AccessibleButton";
@ -25,6 +26,7 @@ import { _t } from "../../../languageHandler";
import { IdentityProviderBrand, IIdentityProvider, ISSOFlow } from "../../../Login";
import AccessibleTooltipButton from "./AccessibleTooltipButton";
import { mediaFromMxc } from "../../../customisations/Media";
import { PosthogAnalytics } from "../../../PosthogAnalytics";
interface ISSOButtonProps extends Omit<IProps, "flow"> {
idp: IIdentityProvider;
@ -50,6 +52,26 @@ const getIcon = (brand: IdentityProviderBrand | string) => {
}
};
const getAuthenticationType = (brand: IdentityProviderBrand | string): Signup["authenticationType"] => {
switch (brand) {
case IdentityProviderBrand.Apple:
return "Apple";
case IdentityProviderBrand.Facebook:
return "Facebook";
case IdentityProviderBrand.Github:
return "GitHub";
case IdentityProviderBrand.Gitlab:
return "GitLab";
case IdentityProviderBrand.Google:
return "Google";
// Not supported on the analytics SDK at the moment.
// case IdentityProviderBrand.Twitter:
// return "Twitter";
default:
return "SSO";
}
};
const SSOButton: React.FC<ISSOButtonProps> = ({
matrixClient,
loginType,
@ -62,6 +84,8 @@ const SSOButton: React.FC<ISSOButtonProps> = ({
const label = idp ? _t("Continue with %(provider)s", { provider: idp.name }) : _t("Sign in with single sign-on");
const onClick = () => {
const authenticationType = getAuthenticationType(idp.brand);
PosthogAnalytics.instance.setAuthenticationType(authenticationType);
PlatformPeg.get().startSingleSignOn(matrixClient, loginType, fragmentAfterLogin, idp?.id);
};