Skip to content

Commit

Permalink
[DX-3045] feat: add version info to track error (#2027)
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 authored Jul 29, 2024
1 parent a520627 commit 867409e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/game-bridge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const initRequestId = '1';
let passportClient: passport.Passport | null;
let providerInstance: provider.IMXProvider | null;
let zkEvmProviderInstance: passport.Provider | null;
let versionInfo: VersionInfo | null;

declare global {
interface Window {
Expand Down Expand Up @@ -107,6 +108,17 @@ type RequestAccountsCallbackData = CommonCallbackData & {

type CallbackData = CommonCallbackData | InitDeviceFlowCallbackData | RequestAccountsCallbackData;

type VersionInfo = {
gameBridgeTag: string;
gameBridgeSha: string;
engine: string;
engineVersion: string;
engineSdkVersion: string;
platform: string;
platformVersion: string;
deviceModel: string;
};

const callbackToGame = (data: CallbackData) => {
const message = JSON.stringify(data);
console.log(`callbackToGame: ${message}`);
Expand Down Expand Up @@ -232,7 +244,7 @@ window.callFunction = async (jsonData: string) => {

// version check
const { engineVersion } = request;
const versionCheckParams = {
versionInfo = {
gameBridgeTag: sdkVersionTag,
gameBridgeSha: sdkVersionSha,
engine: engineVersion.engine,
Expand All @@ -242,10 +254,10 @@ window.callFunction = async (jsonData: string) => {
platformVersion: engineVersion.platformVersion,
deviceModel: engineVersion.deviceModel ?? 'N/A',
};
console.log(`Version check: ${JSON.stringify(versionCheckParams)}`);
console.log(`Version check: ${JSON.stringify(versionInfo)}`);

trackDuration(moduleName, 'completedInitGameBridge', mt(markStart), {
...versionCheckParams,
...versionInfo,
});
break;
}
Expand Down Expand Up @@ -738,6 +750,7 @@ window.callFunction = async (jsonData: string) => {
fxName,
requestId,
errorType,
...versionInfo,
});
trackDuration(moduleName, 'failedCallFunction', mt(markStart), {
fxName,
Expand Down

0 comments on commit 867409e

Please sign in to comment.