mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Android Telemetry planning

Open ljbade opened this issue 11 years ago • 17 comments

For the v0.2.0 release we plan to implement metrics.

This ticket is for planning what tasks we need to complete so we can break it out into separate issues.

Tasks:

  • [x] create an EventManager that processes and uploads events on a background thread - https://github.com/mapbox/mapbox-gl-native/issues/2422
  • [x] test low battery location strategies on Android
  • [x] copy SSL certs to common folder then use build system to copy into ios and android

ljbade avatar Sep 25 '15 01:09 ljbade

The data model and lifecycle model to mirror from iOS can be found in MGLMapboxEvents.m.

bleege avatar Nov 12 '15 01:11 bleege

Telemetry is going to need #2954 to be implemented first.

bleege avatar Nov 12 '15 01:11 bleege

I believe this is issue has gone out of date and is being tracked/evaluated elsewhere.

cc @bleege

tobrun avatar Jan 11 '16 15:01 tobrun

Nope, we'll be using this ticket to build the implementation out. This will be easier to have data and history in one ticket.

bleege avatar Jan 11 '16 15:01 bleege

We're now ready to start building out Telemetry for Android. The initial focus is going to be on building the infrastructure required to access location data with minimum friction for developers and end users. Here's the first steps:

  • [x] Build Service to manage Lifecycle of Location Listener so that it only runs when the app is running
  • [x] Integrate PASSIVE (aka only get location when other apps running on device get data) listening when GPS mode is disabled.
  • [ ] ~~Work with LOST to get support for PendingIntents built it to enable non UI thread processing.~~ NOTE: PendingIntents are not needed after all.

bleege avatar Jan 29 '16 16:01 bleege

So the basic infrastructure to listen for Location data (GPS and Passive) is now in. Before going any further we'll need to find out if we can get the PendingIntents support into LOST. If not then we'll have to revert to relying on the stock Android Location API for Telemetry and User Location data. I'll working with LOST team to see if we can make that happen next.

bleege avatar Jan 29 '16 21:01 bleege

Status Update: I was able to find a workable solution for updating the TelemetryLocationReceiver with new location data from the LocationServices infrastructure that's generated via LOST without having to rely on PendingIntent. \o/ This lets all location access controls be centralized within LocationServices while still maintaining the responsible enable and disabling of Telemetry when the app is no longer running (read: battery).

Next up is to build out the Android specific location data model with @camilleanne. This will involve finding proper unique id's for session information. Will use Google's "Best Practices for Unique Identifiers" for guidance.

bleege avatar Feb 01 '16 22:02 bleege

Made good progress today building out the event model, user agent, and finding data for the events. Next up is to finish the finding data process and confirm that it's the right kind of Location data by testing in the field. Once this (working location data collection and server), things can switch toward building out the interaction events. We'll then tune the frequency of data being sent to work towards optimizing battery life. Finally we'll implement Certificate Pairing for added security.

bleege avatar Feb 04 '16 23:02 bleege

I've now got all event attributes implemented with the exception of vendorId and accessibilityFontScale. Once those are completed we'll be able to test out Location Telemetry completely.

/cc @camilleanne @mick

bleege avatar Feb 06 '16 00:02 bleege

/cc @boundsj

bleege avatar Feb 09 '16 01:02 bleege

/cc @morganherlocker

bleege avatar Feb 09 '16 19:02 bleege

Per discussion with @camilleanne @mick the URL for the Production server will be api.mapbox.com and not api.tiles.mapbox.com. I've now implemented Certificate Pinning for the Staging and Production servers based on these URLs (both are Geotrust). I need to implement Digicert for Production and then this process should be done.

Certificate Pinning is being done via OkHttp by using their setup instructions. It appears to not need the actual .der files like iOS does.

bleege avatar Feb 10 '16 01:02 bleege

Rebased and merged into master so that internal testing can begin.

In order for Android Telemetry Iteration 1 to be considered "complete" the following tickets also must be completed:

  • [x] #3888 - Digicert Pinning
  • [x] #3889 - Interaction Events
  • [x] #3897 - Turnstile Event
  • [x] #3907 - Opt Out UI
  • [x] #4066 - Send Data At App Termination
  • [x] #4071 - API V2
  • [x] #4077 - Remove ApiAccess Use

/cc @mapbox/telemetry

bleege avatar Feb 11 '16 03:02 bleege

My opinion on Telemetry: there should be an easy opt-out procedure, whether it be not including the service in the manifest or by using a MapboxMapOptions flag.

For me, using the Telemetry service in my manifest causes a crash in my application, and I'd also like to not send user location data as I'm just displaying a Map, not displaying the user's location.

afathman avatar Mar 27 '16 23:03 afathman

Thanks for your feedback @afathman. We always love to hear from the community about Mapbox projects.

My opinion on Telemetry: there should be an easy opt-out procedure

We agree! That's why we built the Consumer Opt Out Control directly into the MapView UI so that all end users can control whether or not they want to participate.

For me, using the Telemetry service in my manifest causes a crash in my application

Can you tell us which version of the SDK you're using? Is it the latest Release Candidate from Friday night?

I'd also like to not send user location data as I'm just displaying a Map, not displaying the user's location.

The Telemetry system works by listening for Location updates from the app and operating system. The only time that User Location data will be generated by Mapbox tools is when the User Location is enabled using MapboxMap.setMyLocationEnabled(true).

bleege avatar Mar 28 '16 15:03 bleege

We agree! That's why we built the Consumer Opt Out Control directly into the MapView UI so that all end users can control whether or not they want to participate.

Was hoping for a developer opt out control, it doesn't seem very friendly to crash an app when it doesn't list your Telemetry service in the manifest.

Can you tell us which version of the SDK you're using? Is it the latest Release Candidate from Friday night?

I'm using 4.0.0-rc1 in my build.

The Telemetry system works by listening for Location updates from the app and operating system. The only time that User Location data will be generated by Mapbox tools is when the User Location is enabled using MapboxMap.setMyLocationEnabled(true).

That makes sense... though I get logcat error messages from MapBox complaining that I didn't yet give it location permissions, even when I use setMyLocationEnabled(false);

afathman avatar Mar 28 '16 15:03 afathman

I'm using 4.0.0-rc1 in my build.

Thanks for confirming. Can you provide a stack trace or more details about what's crashing?

though I get logcat error messages from MapBox complaining that I didn't yet give it location permissions, even when I use setMyLocationEnabled(false);

Yep, the Mapbox Android SDK uses the open source LOST framework which uses the stock AOSP Location API for Location data generation. This means that the usual Android Location permissions (ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION) are required in the app.

bleege avatar Mar 28 '16 16:03 bleege