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

@ -72,11 +72,11 @@ export interface IMatrixClientPeg {
* If we've registered a user ID we set this to the ID of the
* user we've just registered. If they then go & log in, we
* can send them to the welcome user (obviously this doesn't
* guarentee they'll get a chat with the welcome user).
* guarantee they'll get a chat with the welcome user).
*
* @param {string} uid The user ID of the user we've just registered
*/
setJustRegisteredUserId(uid: string): void;
setJustRegisteredUserId(uid: string | null): void;
/**
* Returns true if the current user has just been registered by this
@ -139,7 +139,8 @@ class MatrixClientPegClass implements IMatrixClientPeg {
public setJustRegisteredUserId(uid: string | null): void {
this.justRegisteredUserId = uid;
if (uid) {
window.localStorage.setItem("mx_registration_time", String(new Date().getTime()));
const registrationTime = Date.now().toString();
window.localStorage.setItem("mx_registration_time", registrationTime);
}
}
@ -156,7 +157,7 @@ class MatrixClientPegClass implements IMatrixClientPeg {
}
try {
const registrationTime = parseInt(window.localStorage.getItem("mx_registration_time"));
const registrationTime = parseInt(window.localStorage.getItem("mx_registration_time"), 10);
const diff = Date.now() - registrationTime;
return (diff / 36e5) <= hours;
} catch (e) {