Forward utm campaign

This commit is contained in:
tobspr 2022-06-23 18:09:40 +02:00
parent 4e25bf4045
commit 1e6199b213
2 changed files with 20 additions and 0 deletions

View File

@ -4,6 +4,7 @@ const options = queryString.parse(location.search);
export let queryParamOptions = {
embedProvider: null,
abtVariant: null,
campaign: null,
};
if (options.embed) {
@ -13,3 +14,6 @@ if (options.embed) {
if (options.abtVariant) {
queryParamOptions.abtVariant = options.abtVariant;
}
if (options.utm_campaign) {
queryParamOptions.campaign = options.utm_campaign;
}

View File

@ -3,6 +3,7 @@ import { cachebust } from "../core/cachebust";
import { globalConfig } from "../core/config";
import { GameState } from "../core/game_state";
import { createLogger } from "../core/logging";
import { queryParamOptions } from "../core/query_parameters";
import { authorizeViaSSOToken } from "../core/steam_sso";
import { getLogoSprite, timeoutPromise } from "../core/utils";
import { getRandomHint } from "../game/hints";
@ -64,6 +65,20 @@ export class PreloadState extends GameState {
});
}
async sendBeacon() {
if (G_IS_STANDALONE && !G_IS_STEAM_DEMO) {
return;
}
if (!queryParamOptions.campaign) {
return;
}
fetch(
"https://analytics.shapez.io/campaign/" + queryParamOptions.campaign + "?lpurl=nocontent"
).catch(err => {
console.warn("Failed to send beacon:", err);
});
}
onLeave() {
// this.dialogs.cleanup();
}
@ -72,6 +87,7 @@ export class PreloadState extends GameState {
this.setStatus("Booting")
.then(() => this.setStatus("Creating platform wrapper", 3))
.then(() => this.sendBeacon())
.then(() => authorizeViaSSOToken(this.app, this.dialogs))
.then(() => this.app.platformWrapper.initialize())