Update savegame imports, minor adjustments

pull/1415/merge
tobspr 2 years ago
parent 8f6ccc0d67
commit 9b8789527e

@ -28,6 +28,8 @@
"@babel/plugin-transform-classes": "^7.5.5",
"@babel/preset-env": "^7.5.4",
"@nastyox/rando.js": "^2.0.5",
"@openreplay/tracker": "^3.5.12",
"@openreplay/tracker-fetch": "^3.5.3",
"@types/cordova": "^0.0.34",
"@types/filesystem": "^0.0.29",
"ajv": "^6.10.2",

@ -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() {

@ -1102,6 +1102,18 @@
dependencies:
"@types/node" ">= 8"
"@openreplay/tracker-fetch@^3.5.3":
version "3.5.3"
resolved "https://registry.yarnpkg.com/@openreplay/tracker-fetch/-/tracker-fetch-3.5.3.tgz#f4a8308cfffc83918e8d34716bae771cb442b41b"
integrity sha512-09vcR1H8178uDpaA2U4u1GvzAQD94ASmvrWM8dVXY0SmZdQHTTmNdkb4xijhkUY99gtJdB8qFgnIr+dP3FsSbg==
"@openreplay/tracker@^3.5.12":
version "3.5.12"
resolved "https://registry.yarnpkg.com/@openreplay/tracker/-/tracker-3.5.12.tgz#141205bfefa42c767eaad1938cd206e3d551e171"
integrity sha512-R8s87HevJRzC/yujzswll+UyF0kybEax9UJr2eu7Y2nf1QhioD589HwDPlsXb1SxkMDd2yDQYfhbF0FXpCEfQA==
dependencies:
error-stack-parser "^2.0.6"
"@sindresorhus/is@^0.7.0":
version "0.7.0"
resolved "https://registry.npmjs.org/@sindresorhus/is/-/is-0.7.0.tgz"
@ -3336,6 +3348,13 @@ error-ex@^1.2.0, error-ex@^1.3.1:
dependencies:
is-arrayish "^0.2.1"
error-stack-parser@^2.0.6:
version "2.1.4"
resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.1.4.tgz#229cb01cdbfa84440bfa91876285b94680188286"
integrity sha512-Sk5V6wVazPhq5MhpO+AUxJn5x7XSXGl1R93Vn7i+zS15KDVxQijejNCrz8340/2bgLBjR9GtEG8ZVKONDjcqGQ==
dependencies:
stackframe "^1.3.4"
es-abstract@^1.17.0-next.1, es-abstract@^1.17.2, es-abstract@^1.17.5:
version "1.17.5"
resolved "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.5.tgz"
@ -7800,6 +7819,11 @@ stable@^0.1.8:
resolved "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz"
integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==
stackframe@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310"
integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw==
static-extend@^0.1.1:
version "0.1.2"
resolved "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz"

Loading…
Cancel
Save