mirror of
https://github.com/tobspr/shapez.io.git
synced 2026-03-02 03:39:21 +00:00
Update savegame imports, minor adjustments
This commit is contained in:
@@ -11,6 +11,16 @@ import { SteamAchievementProvider } from "../electron/steam_achievement_provider
|
||||
import { GameAnalyticsInterface } from "../game_analytics";
|
||||
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) {
|
||||
connector = new OR({ projectKey: "mhZgUFQBI6QAtt3PRLer" });
|
||||
connector.start();
|
||||
connector.use(OR_fetch({ overrideGlobal: true }));
|
||||
}
|
||||
|
||||
const logger = createLogger("game_analytics");
|
||||
|
||||
const analyticsUrl = G_IS_DEV ? "http://localhost:8001" : "https://analytics.shapez.io";
|
||||
@@ -77,6 +87,30 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
|
||||
);
|
||||
}
|
||||
|
||||
note(action) {
|
||||
if (this.app.restrictionMgr.isLimitedVersion()) {
|
||||
fetch(
|
||||
"https://analytics.shapez.io/campaign/" +
|
||||
"action_" +
|
||||
this.environment +
|
||||
"_" +
|
||||
action +
|
||||
"_" +
|
||||
CURRENT_ABT +
|
||||
"_" +
|
||||
this.abtVariant +
|
||||
"?lpurl=nocontent",
|
||||
{
|
||||
method: "GET",
|
||||
mode: "no-cors",
|
||||
cache: "no-cache",
|
||||
referrer: "no-referrer",
|
||||
credentials: "omit",
|
||||
}
|
||||
).catch(err => {});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
@@ -119,6 +153,9 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
|
||||
syncKey => {
|
||||
this.syncKey = syncKey;
|
||||
logger.log("Player sync key read:", this.syncKey);
|
||||
if (connector) {
|
||||
connector.setUserID(connector);
|
||||
}
|
||||
},
|
||||
error => {
|
||||
// File was not found, retrieve new key
|
||||
@@ -158,6 +195,9 @@ 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);
|
||||
}
|
||||
} else {
|
||||
throw new Error("Bad response from analytics server: " + res);
|
||||
}
|
||||
|
||||
@@ -255,6 +255,8 @@ export class MainMenuState extends GameState {
|
||||
return;
|
||||
}
|
||||
|
||||
this.app.gameAnalytics.note("startimport");
|
||||
|
||||
// Create a 'fake' file-input to accept savegames
|
||||
startFileChoose(".bin").then(file => {
|
||||
if (file) {
|
||||
@@ -747,6 +749,8 @@ export class MainMenuState extends GameState {
|
||||
getStandalone.add(() => {
|
||||
openStandaloneLink(this.app, "shapez_slotlimit");
|
||||
});
|
||||
|
||||
this.app.gameAnalytics.note("slotlimit");
|
||||
}
|
||||
|
||||
onSettingsButtonClicked() {
|
||||
|
||||
Reference in New Issue
Block a user