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";
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 => {
posthog.identify(uuid, { uuid, wa: true });
}).catch();
this.posthogPromise
.then((posthog) => {
posthog.identify(uuid, { uuid, wa: true });
})
.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;
}
.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,20 +300,18 @@ export abstract class Character extends Container {
}
private createStartTransition(emoteY: number) {
if (this.emote) {
this.emoteTween = this.scene?.tweens.add({
targets: this.emote,
props: {
alpha: 1,
y: emoteY,
},
ease: "Power2",
duration: 500,
onComplete: () => {
this.startPulseTransition(emoteY);
},
});
}
this.emoteTween = this.scene?.tweens.add({
targets: this.emote,
props: {
alpha: 1,
y: emoteY,
},
ease: "Power2",
duration: 500,
onComplete: () => {
this.startPulseTransition(emoteY);
},
});
}
private startPulseTransition(emoteY: number) {

View File

@ -644,9 +644,9 @@ export class GameScene extends DirtyScene {
} else {
this.userInputManager.restoreControls();
}
})
});
Promise.all([ this.connectionAnswerPromise as Promise<unknown>, ...scriptPromises ]).then(() => {
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

@ -2,13 +2,13 @@ import { get, writable } from "svelte/store";
import Timeout = NodeJS.Timeout;
import { userIsAdminStore } from "./GameStore";
import { CONTACT_URL } from "../Enum/EnvironmentVariable";
import {analyticsClient} from "../Administration/AnalyticsClient";
import { analyticsClient } from "../Administration/AnalyticsClient";
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);

View File

@ -23,7 +23,7 @@ import { Game } from "./Phaser/Game/Game";
import App from "./Components/App.svelte";
import { HtmlUtils } from "./WebRtc/HtmlUtils";
import WebGLRenderer = Phaser.Renderer.WebGL.WebGLRenderer;
import {analyticsClient} from "./Administration/AnalyticsClient";
import { analyticsClient } from "./Administration/AnalyticsClient";
const { width, height } = coWebsiteManager.getGameSize();
const valueGameQuality = localUserStore.getGameQualityValue();

View File

@ -7,7 +7,7 @@ import MiniCssExtractPlugin from "mini-css-extract-plugin";
import sveltePreprocess from "svelte-preprocess";
import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin";
import NodePolyfillPlugin from "node-polyfill-webpack-plugin";
import {POSTHOG_API_KEY, PROFILE_URL} from "./src/Enum/EnvironmentVariable";
import { POSTHOG_API_KEY, PROFILE_URL } from "./src/Enum/EnvironmentVariable";
const mode = process.env.NODE_ENV ?? "development";
const buildNpmTypingsForApi = !!process.env.BUILD_TYPINGS;