This commit is contained in:
+30
-6
@@ -5,16 +5,23 @@ class Telemetry {
|
||||
#af = null;
|
||||
|
||||
constructor(apiFunction, mode){
|
||||
this.events = [];
|
||||
this.mode = mode;
|
||||
this.#af = apiFunction;
|
||||
}
|
||||
setGame(game){
|
||||
if (this.game == game) { return; }
|
||||
if (this.game){
|
||||
this.#af('game:leave', this.game, {game: this.game, duration: Math.round(performance.now()/1000) - this.gameStart});
|
||||
this.#af('game:leave', this.game, {
|
||||
mode: this.mode,
|
||||
game: this.game,
|
||||
duration: Math.round(performance.now()/1000) - this.gameStart
|
||||
});
|
||||
}
|
||||
if (game){
|
||||
this.#af('game:enter', game, {game});
|
||||
this.#af('game:enter', game, {
|
||||
mode: this.mode,
|
||||
game
|
||||
});
|
||||
}
|
||||
this.game = game;
|
||||
this.gameStart = Math.round(performance.now()/1000);
|
||||
@@ -23,12 +30,17 @@ class Telemetry {
|
||||
if (this.scene == scene) { return; }
|
||||
if (this.scene){
|
||||
this.#af('scene:leave', this.scene, {
|
||||
mode: this.mode,
|
||||
duration: Math.round(performance.now()/1000) - this.sceneStart,
|
||||
game: this.game, scene: this.scene
|
||||
});
|
||||
}
|
||||
if (scene){
|
||||
this.#af('scene:enter', scene, {game: this.game, scene});
|
||||
this.#af('scene:enter', scene, {
|
||||
mode: this.mode,
|
||||
game: this.game,
|
||||
scene
|
||||
});
|
||||
}
|
||||
this.scene = scene;
|
||||
this.sceneStart = Math.round(performance.now()/1000);
|
||||
@@ -37,18 +49,30 @@ class Telemetry {
|
||||
if (this.gameObject == gameObject) { return; }
|
||||
if (this.gameObject){
|
||||
this.#af('gameobject:leave', this.gameObject, {
|
||||
mode: this.mode,
|
||||
duration: Math.round(performance.now()/1000) - this.gameObjectStart,
|
||||
game: this.game, scene: this.scene, gameObject: this.gameObject
|
||||
});
|
||||
}
|
||||
if (gameObject){
|
||||
this.#af('gameobject:enter', gameObject, {game: this.game, scene: this.scene, gameObject});
|
||||
this.#af('gameobject:enter', gameObject, {
|
||||
mode: this.mode,
|
||||
game: this.game,
|
||||
scene: this.scene,
|
||||
gameObject
|
||||
});
|
||||
}
|
||||
this.gameObject = gameObject;
|
||||
this.gameObjectStart = Math.round(performance.now()/1000);
|
||||
}
|
||||
post(action, object, data){
|
||||
this.#af('gameobject:' + action, object, {game: this.game, scene: this.scene, gameObject: this.gameObject, data});
|
||||
this.#af('gameobject:' + action, object, {
|
||||
mode: this.mode,
|
||||
game: this.game,
|
||||
scene: this.scene,
|
||||
gameObject: this.gameObject,
|
||||
data
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user