Add missing tracking

This commit is contained in:
tobspr 2022-06-20 15:32:41 +02:00
parent 52629c5bb2
commit b446a4a915
6 changed files with 50 additions and 19 deletions

View File

@ -101,7 +101,9 @@
background: transparent;
@include S(border-radius, $globalBorderRadius);
// box-shadow: 0 D(5px) D(15px) rgba(#000, 0.2);
@include S(width, 380px);
@include S(min-width, 340px);
@include S(max-width, 380px);
width: 100%;
box-sizing: border-box;
@include S(padding, 0, 15px);
// backdrop-filter: blur(10px);
@ -209,13 +211,13 @@
.point {
display: grid;
grid-template-columns: #{D(27px)} auto;
grid-template-rows: D(11px) D(10px);
grid-template-rows: 1fr 1fr;
background: #fff #{D(10px)} center / #{D(17px)} no-repeat;
@include S(grid-row-gap, 3px);
@include S(grid-row-gap, 2px);
align-items: center;
@include S(padding, 6px);
@include S(border-radius, $globalBorderRadius);
@include S(height, 26px);
box-shadow: 0 D(5px) D(10px) rgba(#000, 0.2);
> strong {
@ -234,11 +236,9 @@
grid-column: 2 / 3;
grid-row: 2 / 3;
@include SuperSmallText;
white-space: nowrap;
@include BreakText;
@include S(font-size, 8px);
line-height: 1em;
align-self: start;
align-self: center;
opacity: 0.8;
}

View File

@ -42,9 +42,9 @@ export const THIRDPARTY_URLS = {
export function openStandaloneLink(app, campaign) {
const discount = globalConfig.currentDiscount > 0 ? "_discount" + globalConfig.currentDiscount : "";
const steamSuffix = G_IS_STEAM_DEMO ? "_steamdemo" : "";
app.platformWrapper.openExternalLink(
THIRDPARTY_URLS.standaloneCampaignLink.replace("$campaign", campaign + discount + steamSuffix)
);
const event = campaign + discount + steamSuffix;
app.platformWrapper.openExternalLink(THIRDPARTY_URLS.standaloneCampaignLink.replace("$campaign", event));
app.gameAnalytics.noteMinor("g.stdlink." + event);
}
export const globalConfig = {

View File

@ -117,6 +117,10 @@ export class HUDStandaloneAdvantages extends BaseHUDPart {
}
show(final = false) {
if (!this.visible) {
this.root.app.gameAnalytics.noteMinor("game.std_advg.show");
this.root.app.gameAnalytics.noteMinor("game.std_advg.show-" + (final ? "final" : "nonfinal"));
}
this.lastShown = this.root.time.now();
this.visible = true;
this.final = final;

View File

@ -24,6 +24,8 @@ export class HUDUnlockNotification extends BaseHUDPart {
}
this.buttonShowTimeout = null;
this.root.app.gameAnalytics.noteMinor("game.started");
}
createElements(parent) {
@ -63,6 +65,8 @@ export class HUDUnlockNotification extends BaseHUDPart {
return;
}
this.root.app.gameAnalytics.noteMinor("game.level.complete-" + level);
this.root.app.inputMgr.makeSureAttachedAndOnTop(this.inputReciever);
this.elemTitle.innerText = T.ingame.levelCompleteNotification.levelTitle.replace(
"<level>",

View File

@ -14,11 +14,18 @@ import { FILE_NOT_FOUND } from "../storage";
import OR from "@openreplay/tracker";
import OR_fetch from "@openreplay/tracker-fetch";
let connector;
if ((G_IS_STEAM_DEMO || !G_IS_STANDALONE) && !G_IS_DEV) {
connector = new OR({ projectKey: "mhZgUFQBI6QAtt3PRLer" });
connector.start();
connector.use(OR_fetch({ overrideGlobal: true }));
let eventConnector;
if (!G_IS_STANDALONE && !G_IS_DEV) {
eventConnector = new OR({
projectKey: "mhZgUFQBI6QAtt3PRLer",
respectDoNotTrack: true,
revID: G_BUILD_COMMIT_HASH,
heatmaps: false,
verbose: false,
captureIFrames: false,
});
eventConnector.start({});
eventConnector.use(OR_fetch({ overrideGlobal: true }));
}
const logger = createLogger("game_analytics");
@ -111,6 +118,16 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
}
}
noteMinor(action, payload = "") {
if (eventConnector) {
try {
eventConnector.event(action, payload);
} catch (ex) {
console.warn("Failed to note event:", ex);
}
}
}
/**
* @returns {Promise<void>}
*/
@ -153,8 +170,8 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
syncKey => {
this.syncKey = syncKey;
logger.log("Player sync key read:", this.syncKey);
if (connector) {
connector.setUserID(connector);
if (eventConnector) {
eventConnector.setUserID(syncKey);
}
},
error => {
@ -195,8 +212,8 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
this.syncKey = res.key;
logger.log("Key retrieved:", this.syncKey);
this.app.storage.writeFileAsync(analyticsLocalFile, res.key);
if (connector) {
connector.setUserID(connector);
if (eventConnector) {
eventConnector.setUserID(eventConnector);
}
} else {
throw new Error("Bad response from analytics server: " + res);

View File

@ -404,6 +404,8 @@ export class MainMenuState extends GameState {
this.fetchPlayerCount();
this.refreshInterval = setInterval(() => this.fetchPlayerCount(), 10000);
this.app.gameAnalytics.noteMinor("menu.enter");
}
renderMainMenu() {
@ -798,11 +800,13 @@ export class MainMenuState extends GameState {
this.app.savegameMgr.getSavegamesMetaData().length > 0 &&
!this.app.restrictionMgr.getHasUnlimitedSavegames()
) {
this.app.gameAnalytics.noteMinor("menu.slotlimit");
this.showSavegameSlotLimit();
return;
}
this.app.adProvider.showVideoAd().then(() => {
this.app.gameAnalytics.noteMinor("menu.play");
const savegame = this.app.savegameMgr.createNewSavegame();
this.moveToState("InGameState", {
@ -824,6 +828,7 @@ export class MainMenuState extends GameState {
}
onModsClicked() {
this.app.gameAnalytics.noteMinor("menu.mods");
this.moveToState("ModsState", {
backToStateId: "MainMenuState",
});
@ -845,6 +850,7 @@ export class MainMenuState extends GameState {
return;
}
this.app.gameAnalytics.noteMinor("menu.continue");
savegame
.readAsync()
.then(() => this.app.adProvider.showVideoAd())