analytics_flutter icon indicating copy to clipboard operation
analytics_flutter copied to clipboard

Error loading storage: FormatException due to corrupted serialized state

Open felixwoestmann opened this issue 1 year ago • 8 comments

Hello, we ran into the issue that the serialized state is broken and can't be deserialized. When initializing the Client we are now catching the error, but would like to have an option to delete all stored state to remove the error. Currently it occurs every time when starting the application.

Is there a way to do so?

The following is the data which is not valid Json and therefore couldn't be deserialized. It was from the file analytics-flutter-queue_flushing_plugin.json.

{"queue":[{"anonymousId":"cfe0edd5-2348-47f0-a1e4-6a3ecedf07b9","messageId":"0d9de8ea-c709-4e96-aea4-b66bc51db74a","userId":null,"timestamp":"2024-04-30T13:22:09.965928","context":{"app":{"build":"1","name":"App Name","namespace":"com.app.name","version":"3.40.0"},"device":{"manufacturer":"Google","model":"sdk_gphone64_arm64","name":"emu64a","type":"android"},"library":{"name":"analytics-flutter","version":"1.0.0"},"locale":"en-US","network":{"cellular":false,"wifi":true},"os":{"name":"Android","version":"14"},"screen":{"height":1270,"width":720,"density":2.0},"timezone":"Europe/Ljubljana","instanceId":"5e8546bb-bba3-4ff7-b3b1-f5ab3d42d7a6","traits":{}},"integrations":null,"_metadata":{"bundled":[],"unbundled":["Actions Amplitude"],"bundledIds":[]},"event":"responseReceived","properties":{"screen":"LoginRoute","value":"Success"},"type":"track"},{"anonymousId":"cfe0edd5-2348-47f0-a1e4-6a3ecedf07b9","messageId":"bf9ead8c-29df-4fd2-9b02-71dee4ba5e55","userId":null,"timestamp":"2024-04-30T13:22:09.983209","context":{"app":{"build":"1","name":"App Name","namespace":"com.app.name","version":"3.40.0"},"device":{"manufacturer":"Google","model":"sdk_gphone64_arm64","name":"emu64a","type":"android"},"library":{"name":"analytics-flutter","version":"1.0.0"},"locale":"en-US","network":{"cellular":false,"wifi":true},"os":{"name":"Android","version":"14"},"screen":{"height":1270,"width":720,"density":2.0},"timezone":"Europe/Ljubljana","instanceId":"5e8546bb-bba3-4ff7-b3b1-f5ab3d42d7a6","traits":{}},"integrations":null,"_metadata":{"bundled":[],"unbundled":["Actions Amplitude"],"bundledIds":[]},"name":"/select-hub","properties":{},"type":"screen"},{"anonymousId":"cfe0edd5-2348-47f0-a1e4-6a3ecedf07b9","messageId":"4fda9727-48ac-40cb-856b-c6290526b02b","userId":null,"timestamp":"2024-04-30T13:22:13.209824","context":{"app":{"build":"1","name":"App Name","namespace":"com.app.name","version":"3.40.0"},"device":{"manufacturer":"Google","model":"sdk_gphone64_arm64","name":"emu64a","type":"android"},"library":{"name":"analytics-flutter","version":"1.0.0"},"locale":"en-US","network":{"cellular":false,"wifi":true},"os":{"name":"Android","version":"14"},"screen":{"height":1270,"width":720,"density":2.0},"timezone":"Europe/Ljubljana","instanceId":"5e8546bb-bba3-4ff7-b3b1-f5ab3d42d7a6","traits":{}},"integrations":null,"_metadata":{"bundled":[],"unbundled":["Actions Amplitude"],"bundledIds":[]},"traits":{"hubId":"de-hh-pauli"},"type":"identify"}]}

felixwoestmann avatar May 01 '24 08:05 felixwoestmann

hi @felixwoestmann thank you for your report, we start looking into this.

edsonjab avatar May 01 '24 17:05 edsonjab

We're experiencing the same

QuirijnGB avatar May 03 '24 09:05 QuirijnGB

hi @felixwoestmann @QuirijnGB could you help me to provide an example how you configure your project? and your Analytics configuration, please, I can't replicate the issue; all works as expected.

edsonjab avatar May 14 '24 21:05 edsonjab

We're experiencing the same

chrisk1123 avatar May 15 '24 20:05 chrisk1123

We're experiencing the same

Future _initial() async { if (_initDone) return; _initDone = true;

final segmentKey = AppConfig.current.segmentKey;

final configuration = Configuration(
  segmentKey,
  trackApplicationLifecycleEvents: false,
  flushPolicies: [
    StartupFlushPolicy(),
    TimerFlushPolicy(3000),
    CountFlushPolicy(10),
  ]
);
analytics = createClient(configuration);

}

WuChuanRong avatar May 23 '24 08:05 WuChuanRong

Config

      var segmentClient = createClient(
        Configuration(
          [KEY],
          trackApplicationLifecycleEvents: true,
          trackDeeplinks: true,
        ),
      );

Some errors in Sentry

Error loading storage: FormatException: Unexpected character (at character 13)
{"queue":[]}anonymousId":"[REDACTED]","messageId"...
FormatException: Unexpected character (at character 621)
...tal","last_name":"[REDACTED]","subscription_plan_name":"Roamer"}}":"Roamer"}}

I actually haven't been able to reliably reproduce it. Is there a way we can reliably trigger a write to cache?

QuirijnGB avatar May 23 '24 09:05 QuirijnGB

same here... it's really annoying

cerealexx avatar Jun 04 '24 17:06 cerealexx

Hi @cerealexx , could you help us to explain how replicate the issue, please? flutter version, segment version, configuration file of segmentClient

edsonjab avatar Jun 05 '24 04:06 edsonjab