|
|
|
@ -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);
|
|
|
|
|