Automattic / Automattic-Tracks-iOS

Client library for tracking user events for later analysis
GNU General Public License v2.0
43 stars 12 forks source link

Improves the error logging in `[TracksContextManager persistentStoreCoordinator]`. #223

Closed diegoreymendez closed 2 years ago

diegoreymendez commented 2 years ago

Improves the error logging in [TracksContextManager persistentStoreCoordinator] to try and detect possible issues with the URLs and prewarming.

This is because we're seeing failures in DO where the file cannot be created.

Testing:

  1. Make these two conditions always succeed by prepending them with true ||:

https://github.com/Automattic/Automattic-Tracks-iOS/blob/716bf8f5e06937cdce8801e8be22bf70abf01ce3/Sources/Model/ObjC/Common/Core%20Data/TracksContextManager.m#L49

and

https://github.com/Automattic/Automattic-Tracks-iOS/blob/716bf8f5e06937cdce8801e8be22bf70abf01ce3/Sources/Model/ObjC/Common/Core%20Data/TracksContextManager.m#L53

  1. Add the following line here:
error = [NSError errorWithDomain:"testing" code:1 userInfo:nil];
  1. Make sure you've set the Sentry's DSN in Settings.swift (there's a tracks demo android project) so you can run the demo App.

  2. Run the demo app

Make sure you see something like this in your log when it crashes:

Tracks <E>: Unresolved error Error Domain=asd Code=1 "(null)", {
}. Context info {prewarming=0, storeURL=file:///Users/kybos/Library/Developer/CoreSimulator/Devices/056C5AA2-93D7-459C-88FC-8922966C81F0/data/Containers/Data/Application/35DB0537-8EE3-47F1-9510-6F55529B3F84/Library/Application%20Support/com.automattic.TracksDemo/Tracks.sqlite}.