Skip to content
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

Merged
merged 4 commits into from
Dec 15, 2021
Merged

Conversation

jmkiley
Copy link
Contributor

@jmkiley jmkiley commented Dec 7, 2021

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Update the changelog

Summary of changes

Snapshotter will now send a turnstile event upon initialization. This mirrors mapbox/mapbox-maps-android#920

EventsManager has been simplified and converted to a singleton to address the comment below.

@jmkiley jmkiley added the feature 🍏 When working on a new feature or feature enhancement label Dec 7, 2021
@jmkiley jmkiley requested a review from macdrevx December 7, 2021 15:25
@jmkiley jmkiley self-assigned this Dec 7, 2021
@jmkiley jmkiley force-pushed the jk/snapshotter-turnstile branch 2 times, most recently from cec5a9c to e627c4c Compare December 7, 2021 17:11
@@ -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()
Copy link
Contributor

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 an EventsManager is initialized, it will call MMEEventsManager.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?
  • 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 call flush upon receiving a memory warning. These behaviors only need to happen once per MMEEventsManager 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

Copy link
Contributor

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.

@macdrevx macdrevx requested a review from vayesh December 14, 2021 22:08
@macdrevx macdrevx assigned macdrevx and unassigned jmkiley Dec 14, 2021
Copy link
Contributor

@Chaoba Chaoba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@macdrevx macdrevx merged commit 196f256 into main Dec 15, 2021
@macdrevx macdrevx deleted the jk/snapshotter-turnstile branch December 15, 2021 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 🍏 When working on a new feature or feature enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants