FEATURE: analytics client now scrape user email and room group
This commit is contained in:
parent
d0c0f3e7fc
commit
726f52976d
@ -19,10 +19,10 @@ class AnalyticsClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
identifyUser(uuid: string) {
|
identifyUser(uuid: string, email: string | null) {
|
||||||
this.posthogPromise
|
this.posthogPromise
|
||||||
.then((posthog) => {
|
.then((posthog) => {
|
||||||
posthog.identify(uuid, { uuid, wa: true });
|
posthog.identify(uuid, { uuid, email, wa: true });
|
||||||
})
|
})
|
||||||
.catch();
|
.catch();
|
||||||
}
|
}
|
||||||
@ -43,10 +43,10 @@ class AnalyticsClient {
|
|||||||
.catch();
|
.catch();
|
||||||
}
|
}
|
||||||
|
|
||||||
enteredRoom(roomId: string) {
|
enteredRoom(roomId: string, roomGroup: string | null) {
|
||||||
this.posthogPromise
|
this.posthogPromise
|
||||||
.then((posthog) => {
|
.then((posthog) => {
|
||||||
posthog.capture("$pageView", { roomId });
|
posthog.capture("$pageView", { roomId, roomGroup });
|
||||||
})
|
})
|
||||||
.catch();
|
.catch();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ class ConnectionManager {
|
|||||||
const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then(
|
const data = await Axios.post(`${PUSHER_URL}/register`, { organizationMemberToken }).then(
|
||||||
(res) => res.data
|
(res) => res.data
|
||||||
);
|
);
|
||||||
this.localUser = new LocalUser(data.userUuid, data.textures);
|
this.localUser = new LocalUser(data.userUuid, data.textures, data.email);
|
||||||
this.authToken = data.authToken;
|
this.authToken = data.authToken;
|
||||||
localUserStore.saveUser(this.localUser);
|
localUserStore.saveUser(this.localUser);
|
||||||
localUserStore.setAuthToken(this.authToken);
|
localUserStore.setAuthToken(this.authToken);
|
||||||
@ -196,7 +196,7 @@ class ConnectionManager {
|
|||||||
return Promise.reject(new Error("Invalid URL"));
|
return Promise.reject(new Error("Invalid URL"));
|
||||||
}
|
}
|
||||||
if (this.localUser) {
|
if (this.localUser) {
|
||||||
analyticsClient.identifyUser(this.localUser.uuid);
|
analyticsClient.identifyUser(this.localUser.uuid, this.localUser.email);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.serviceWorker = new _ServiceWorker();
|
this.serviceWorker = new _ServiceWorker();
|
||||||
|
@ -24,5 +24,9 @@ export function areCharacterLayersValid(value: string[] | null): boolean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class LocalUser {
|
export class LocalUser {
|
||||||
constructor(public readonly uuid: string, public textures: CharacterTexture[]) {}
|
constructor(
|
||||||
|
public readonly uuid: string,
|
||||||
|
public textures: CharacterTexture[],
|
||||||
|
public email: string | null = null
|
||||||
|
) {}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ export class Room {
|
|||||||
private instance: string | undefined;
|
private instance: string | undefined;
|
||||||
private readonly _search: URLSearchParams;
|
private readonly _search: URLSearchParams;
|
||||||
private _contactPage: string | undefined;
|
private _contactPage: string | undefined;
|
||||||
|
private _group: string | null = null;
|
||||||
|
|
||||||
private constructor(private roomUrl: URL) {
|
private constructor(private roomUrl: URL) {
|
||||||
this.id = roomUrl.pathname;
|
this.id = roomUrl.pathname;
|
||||||
@ -104,6 +105,7 @@ export class Room {
|
|||||||
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
|
console.log("Map ", this.id, " resolves to URL ", data.mapUrl);
|
||||||
this._mapUrl = data.mapUrl;
|
this._mapUrl = data.mapUrl;
|
||||||
this._textures = data.textures;
|
this._textures = data.textures;
|
||||||
|
this._group = data.group;
|
||||||
this._authenticationMandatory = data.authenticationMandatory || false;
|
this._authenticationMandatory = data.authenticationMandatory || false;
|
||||||
this._iframeAuthentication = data.iframeAuthentication;
|
this._iframeAuthentication = data.iframeAuthentication;
|
||||||
this._contactPage = data.contactPage || CONTACT_URL;
|
this._contactPage = data.contactPage || CONTACT_URL;
|
||||||
@ -185,4 +187,8 @@ export class Room {
|
|||||||
get contactPage(): string | undefined {
|
get contactPage(): string | undefined {
|
||||||
return this._contactPage;
|
return this._contactPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get group(): string | null {
|
||||||
|
return this._group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -428,7 +428,7 @@ export class GameScene extends DirtyScene {
|
|||||||
|
|
||||||
gameManager.gameSceneIsCreated(this);
|
gameManager.gameSceneIsCreated(this);
|
||||||
urlManager.pushRoomIdToUrl(this.room);
|
urlManager.pushRoomIdToUrl(this.room);
|
||||||
analyticsClient.enteredRoom(this.room.id);
|
analyticsClient.enteredRoom(this.room.id, this.room.group);
|
||||||
contactPageStore.set(this.room.contactPage);
|
contactPageStore.set(this.room.contactPage);
|
||||||
|
|
||||||
if (touchScreenManager.supportTouchScreen) {
|
if (touchScreenManager.supportTouchScreen) {
|
||||||
|
@ -148,6 +148,7 @@ export class AuthenticateController extends BaseController {
|
|||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
authToken,
|
authToken,
|
||||||
userUuid,
|
userUuid,
|
||||||
|
email,
|
||||||
roomUrl,
|
roomUrl,
|
||||||
mapUrlStart,
|
mapUrlStart,
|
||||||
organizationMemberToken,
|
organizationMemberToken,
|
||||||
|
@ -60,6 +60,7 @@ export class MapController extends BaseController {
|
|||||||
mapUrl,
|
mapUrl,
|
||||||
policy_type: GameRoomPolicyTypes.ANONYMOUS_POLICY,
|
policy_type: GameRoomPolicyTypes.ANONYMOUS_POLICY,
|
||||||
roomSlug: "", // Deprecated
|
roomSlug: "", // Deprecated
|
||||||
|
group: null,
|
||||||
tags: [],
|
tags: [],
|
||||||
textures: [],
|
textures: [],
|
||||||
contactPage: undefined,
|
contactPage: undefined,
|
||||||
|
Loading…
Reference in New Issue
Block a user