Merge branch 'develop' of github.com:thecodingmachine/workadventure

This commit is contained in:
_Bastler 2021-09-20 15:17:30 +02:00
commit 49bd6f8a1c
10 changed files with 60 additions and 51 deletions

View File

@ -1,13 +1,12 @@
import { POSTHOG_API_KEY, POSTHOG_URL } from "../Enum/EnvironmentVariable";
class AnalyticsClient {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private posthogPromise: Promise<any>;
constructor() {
if (POSTHOG_API_KEY && POSTHOG_URL) {
this.posthogPromise = import('posthog-js').then(({default: posthog}) => {
this.posthogPromise = import("posthog-js").then(({ default: posthog }) => {
posthog.init(POSTHOG_API_KEY, { api_host: POSTHOG_URL, disable_cookie: true });
return posthog;
});
@ -17,45 +16,59 @@ class AnalyticsClient {
}
identifyUser(uuid: string) {
this.posthogPromise.then(posthog => {
this.posthogPromise
.then((posthog) => {
posthog.identify(uuid, { uuid, wa: true });
}).catch();
})
.catch();
}
loggedWithSso() {
this.posthogPromise.then(posthog => {
posthog.capture('wa-logged-sso');
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.capture("wa-logged-sso");
})
.catch();
}
loggedWithToken() {
this.posthogPromise.then(posthog => {
posthog.capture('wa-logged-token');
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.capture("wa-logged-token");
})
.catch();
}
enteredRoom(roomId: string) {
this.posthogPromise.then(posthog => {
posthog.capture('$pageView', {roomId});
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.capture("$pageView", { roomId });
})
.catch();
}
openedMenu() {
this.posthogPromise.then(posthog => {
posthog.capture('wa-opened-menu');
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.capture("wa-opened-menu");
})
.catch();
}
launchEmote(emote: string) {
this.posthogPromise.then(posthog => {
posthog.capture('wa-emote-launch', {emote});
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.capture("wa-emote-launch", { emote });
})
.catch();
}
enteredJitsi(roomName: string, roomId: string) {
this.posthogPromise.then(posthog => {
posthog.capture('wa-entered-jitsi', {roomName, roomId});
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.capture("wa-entered-jitsi", { roomName, roomId });
})
.catch();
}
}
export const analyticsClient = new AnalyticsClient();

View File

@ -68,9 +68,9 @@
height: 100%;
justify-content: center;
align-items: center;
}
.emote-menu {
pointer-events: all;
}
}
</style>

View File

@ -9,7 +9,6 @@ class EmoteEventStream {
private _stream: Subject<EmoteEvent> = new Subject();
public stream = this._stream.asObservable();
fire(userId: number, emote: string) {
this._stream.next({ userId, emote });
}

View File

@ -20,7 +20,7 @@ export const DISPLAY_TERMS_OF_USE = process.env.DISPLAY_TERMS_OF_USE == "true";
export const NODE_ENV = process.env.NODE_ENV || "development";
export const CONTACT_URL = process.env.CONTACT_URL || undefined;
export const PROFILE_URL = process.env.PROFILE_URL || undefined;
export const POSTHOG_API_KEY: string = process.env.POSTHOG_API_KEY as string || '';
export const POSTHOG_API_KEY: string = (process.env.POSTHOG_API_KEY as string) || "";
export const POSTHOG_URL = process.env.POSTHOG_URL || undefined;
export const isMobile = (): boolean => window.innerWidth <= 800 || window.innerHeight <= 600;

View File

@ -300,7 +300,6 @@ export abstract class Character extends Container {
}
private createStartTransition(emoteY: number) {
if (this.emote) {
this.emoteTween = this.scene?.tweens.add({
targets: this.emote,
props: {
@ -314,7 +313,6 @@ export abstract class Character extends Container {
},
});
}
}
private startPulseTransition(emoteY: number) {
if (this.emote) {

View File

@ -644,7 +644,7 @@ export class GameScene extends DirtyScene {
} else {
this.userInputManager.restoreControls();
}
})
});
Promise.all([this.connectionAnswerPromise as Promise<unknown>, ...scriptPromises]).then(() => {
this.scene.wake();
@ -1511,7 +1511,7 @@ export class GameScene extends DirtyScene {
} else {
emoteMenuStore.openEmoteMenu();
}
})
});
this.CurrentPlayer.on(requestEmoteEventName, (emoteKey: string) => {
this.connection?.emitEmoteEvent(emoteKey);
analyticsClient.launchEmote(emoteKey);

View File

@ -84,5 +84,4 @@ export class Player extends Character {
public isMoving(): boolean {
return this.wasMoving;
}
}

View File

@ -8,7 +8,7 @@ export const menuIconVisiblilityStore = writable(false);
export const menuVisiblilityStore = writable(false);
menuVisiblilityStore.subscribe((value) => {
if (value) analyticsClient.openedMenu();
})
});
export const menuInputFocusStore = writable(false);
export const userIsConnected = writable(false);