GameAnalytics / GA-SDK-JAVASCRIPT

Official repository for GameAnalytics JavaScript SDK
MIT License
19 stars 6 forks source link

SDK error handling on initialisation process and network issues #298

Open rpoltorak opened 2 years ago

rpoltorak commented 2 years ago

I would like to handle two cases:

  1. The SDK is not initialised properly for some reason, for example adblock, other tools that disables scripts, etc.
  2. The SDK is not working properly because the network is blocked and it cannot sent a request for a long period of time

Does the SDK provides a way that we could handle those problems mentioned above? I mean for example I would like to collect the data and push some logs to my backend if the SDK is not initialised properly but I'm afraid I don't have some explicit to do that. Correct me if I'm wrong, but I've tried to use isSdkReady method. Not sure if this is a correct approach but anyway I had to force my linter to use it because it's a private static method. Or maybe there's better way? Unfortunately I don't see anything in the exposed methods that could help.

The second thing is with the network. I don't see any network event handlers that could trigger if the SDK cannot connect to GameAnalytics API.

Any help with this would be much appreciate it :) Thanks in advance.

the1schwartz commented 2 years ago

The SDK will initialize correctly even though it didn't get to get connected with backend as it could be offline to start with.

If the SDK fails to connect to GameAnalytics API, the SDK should try again every 8 seconds to send its cached events to the GA backend.

I am not sure how to properly check if the SDK requests are being blocked by other plugins or scripts in the browser.