-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send a turnstile event using Snapshotter #908
Conversation
cec5a9c
to
e627c4c
Compare
64f88e2
to
d57cd4f
Compare
@@ -32,6 +32,7 @@ public class Snapshotter { | |||
self.options = options | |||
mapSnapshotter = MapSnapshotter(options: MapboxCoreMaps.MapSnapshotOptions(options)) | |||
style = Style(with: mapSnapshotter) | |||
EventsManager(accessToken: options.resourceOptions.accessToken).sendTurnstile() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the important change. This approach matches Android, but there are a few questions we need to think about:
- EventsManager is a thin wrapper around
MMEEventsManager.shared()
. Each time anEventsManager
is initialized, it will callMMEEventsManager.shared().initialize(…)
. Is it okay for that to happen more than once (will happen with each snapshotter and map view that is created). What if you are using different access tokens for different purposes in the same app?- Based on https://github.com/mapbox/mapbox-events-ios/blob/main/Sources/MapboxMobileEvents/MMEEventsManager.m#L92-L101, it seems like subsequent calls to initialize will just update the access token, but won't repeat any other setup.
- One problem with having more than one instance of
EventsManager
is that each instance will observe changes to the"MGLMapboxMetricsEnabled"
user defaults key and will callflush
upon receiving a memory warning. These behaviors only need to happen once perMMEEventsManager
instance.- This MME design means we need to convert EventsManager to a singleton as well to avoid doing more work than necessary. @vesh93 I'd love to see us move away from using a singleton pattern. It's a bad match for our initialization APIs which would lead you to believe there's nothing stopping you from using multiple access tokens simultaneously in the same process.
cc: @vesh93
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to convert EventsManager to a singleton.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Pull request checklist:
Summary of changes
Snapshotter
will now send a turnstile event upon initialization. This mirrors mapbox/mapbox-maps-android#920EventsManager
has been simplified and converted to a singleton to address the comment below.