Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Share tracker stats #859

Merged
merged 15 commits into from
Feb 16, 2018
Merged

Share tracker stats #859

merged 15 commits into from
Feb 16, 2018

Conversation

joeyg
Copy link
Contributor

@joeyg joeyg commented Jan 31, 2018

Fixes #858.

To do:

  • Make the button on the home screen look tappable - ideas welcome
  • Only show on devices of Phone 6, 6+, or X form factor

http://recordit.co/xlmzogfW3Y

// TODO: Telemetry

let numberOfTrackersBlocked = getNumberOfLifetimeTrackersBlocked()
let appStoreUrl = String(format: "https://itunes.apple.com/app/id%@", AppInfo.isKlar ? "1073435754" : "1055677337")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There has got to be a better way to do this.

Copy link
Contributor

Choose a reason for hiding this comment

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

We will get you adjust links to track this install channel. Stay tuned.

@@ -244,6 +246,13 @@ class BrowserViewController: UIViewController {
homeView.removeFromSuperview()
}
self.homeView = homeView

if shouldShowTrackerStatsShareButton() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is run after a user taps "Erase" so there is a chance they would not see it on launch but then see it after they erased a browsing session. Is that ok?

Copy link
Contributor

Choose a reason for hiding this comment

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

A chance they wouldn't see it on launch? And then they would see it every time they 'Erase'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh i miss understood! I thought the 10% rule was just to not show it all the time and annoy users. I will change it to bucket users into groups.

@@ -244,6 +246,13 @@ class BrowserViewController: UIViewController {
homeView.removeFromSuperview()
}
self.homeView = homeView

if shouldShowTrackerStatsShareButton() {
Copy link
Contributor

Choose a reason for hiding this comment

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

A chance they wouldn't see it on launch? And then they would see it every time they 'Erase'?


// 10% chance we show the button
// arc4random_uniform(10 returns an integer 0 through 9 (inclusive)
return arc4random_uniform(10) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

So the way I understand this, you are a flipping a 10% coin every time a user presses Erase, so that means that all users would eventually see the message? We need to only show it to maximum of 10% of users - so we have to put users in buckets and save that bucket across the install. This is something we do for onboarding too.

// TODO: Telemetry

let numberOfTrackersBlocked = getNumberOfLifetimeTrackersBlocked()
let appStoreUrl = String(format: "https://itunes.apple.com/app/id%@", AppInfo.isKlar ? "1073435754" : "1055677337")
Copy link
Contributor

Choose a reason for hiding this comment

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

We will get you adjust links to track this install channel. Stay tuned.

Copy link
Contributor

@boek boek left a comment

Choose a reason for hiding this comment

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

The one last missing thing would be adding some telemetry around how many users are in the bucket and the share button. Other than that the code looks good :) Will defer UX to @lime124

@@ -747,6 +785,15 @@ extension BrowserViewController: WebControllerDelegate {
func webController(_ controller: WebController, stateDidChange state: BrowserState) {}

func webController(_ controller: WebController, didUpdateTrackingProtectionStatus trackingStatus: TrackingProtectionStatus) {
// Calculate the number of trackers blocked and add that to lifetime total
if case .on(let info) = trackingStatus {
if case .on(let oldInfo) = trackingProtectionStatus {
Copy link
Contributor

Choose a reason for hiding this comment

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

small nit: We could do this in one if statement

// Calculate the number of trackers blocked and add that to lifetime total
if case .on(let info) = trackingStatus {
if case .on(let oldInfo) = trackingProtectionStatus {
let numberOfAdditionalTrackersBlocked = max(0, info.total - oldInfo.total)
Copy link
Contributor

Choose a reason for hiding this comment

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

This took me a minute to understand what/why we're doing it this way. I wonder if we named it something like differenceSinceLastUpdate it would be more clear?

@joeyg
Copy link
Contributor Author

joeyg commented Feb 2, 2018

@boek @Sdaswani Updated the PR with changes to the logic around showing the button and added some Telemetry. Let me know if the telemetry names should be changed to be more clear or if the logic still seems off.

I can also pull the code out of BrowserViewController if that would help.

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 2, 2018

@joeyg thanks for the video! Can you move the message closer to the keyboard, make the text smaller, and add ‘Click here’ to the tell your friends message? I’ll look at the code soon.

@joeyg
Copy link
Contributor Author

joeyg commented Feb 2, 2018

simulator screen shot - iphone 6 - 2018-02-02 at 13 04 18

@lime124
Copy link

lime124 commented Feb 2, 2018

Hey guys! As always you are super fast @joeyg! I think there are a few usability concerns here that should be addressed. I made a quick mockup to illustrate what I'm thinking.

  • 1. We should avoid having something tappable too close to the keyboard, we don't want accidental hits when people are trying to tap. That spacing is 24px in my mock
  • 2. Having two blocks of same sized text makes it difficult to wade through. We should remove the tagline to clean things up. This means SE's will probably work now
  • 3. Even though it says "click here" there isn't an obvious call to action/place to tap. I separated out the action into a button so it's very clear where people tap. The button is 36px high x 80px. But we want our tap area to extend a bit beyond that so it meets min touch target guidelines.
  • 4. I added in the word "total" because it isn't super clear what this number represents. We could probably ditch the word "by" but I'll ping @BrianNJones about that one.
  • 5. I added in the TP shield so that it a) brings balance to the screen with the share button but also does a bit of reinforcing of what a tracker is. It connects that bit of UI people see in the URL bar with this concept.

We definitely need to run the suggested text (what was on the notepad) by Brian and Cherry as well. Thanks as always!

screen shot 2018-02-02 at 2 50 19 pm

@joeyg
Copy link
Contributor Author

joeyg commented Feb 3, 2018

Thanks @lime124 ! I’ll make those changes and upload a new screenshot.

@BrianNJones
Copy link

BrianNJones commented Feb 3, 2018 via email

@joeyg
Copy link
Contributor Author

joeyg commented Feb 3, 2018

@lime124 here are some updated screenshots.

iPhone 6 Portrait:
simulator screen shot - iphone 6 - 2018-02-02 at 21 15 48

iPhone 6 Landscape:
simulator screen shot - iphone 6 - 2018-02-02 at 21 15 51

iPhone 6 Plus Portrait:
simulator screen shot - iphone 6 plus - 2018-02-02 at 21 14 44

iPhone 6 Plus Landscape:
simulator screen shot - iphone 6 plus - 2018-02-02 at 21 14 49

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 3, 2018

looking awesome @joeyg !

Copy link
Contributor

@Sdaswani Sdaswani left a comment

Choose a reason for hiding this comment

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

code looking ok so far, @boek is the approver. still needs integration with the share sheet, right?

@joeyg
Copy link
Contributor Author

joeyg commented Feb 3, 2018

Updated screencast http://recordit.co/xlmzogfW3Y

@BrianNJones
Copy link

@lime124, I recommend this for the suggested text:
Firefox Focus, the privacy browser from Mozilla, has already blocked XXX trackers for me. Fewer ads and trackers following me around means faster browsing! Get Focus for yourself here: https://itunes.apple.com/app/id1055677337

(236 characters, spaces inclusive)

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 5, 2018

@joeyg please use this as the app store link: https://app.adjust.com/b8s7qo?campaign=shareblocked&creative=022018

also one more requirement - not only is this EN only, but it should be Focus only. So please don't show for Klar.

@joeyg
Copy link
Contributor Author

joeyg commented Feb 5, 2018

@Sdaswani I'll make that change. Thanks.

@BrianNJones, @lime124 Would you like this shared as just text? The app can share the URL separately instead of inline. Generally this results in a preview of the URL being rendered instead of just the URL.

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 5, 2018

@joeyg the important thing is to fill out as much as you can, like the NYTimes does.
img_3f2abd5a3d39-1
img_89cfd9adde25-1

@joeyg
Copy link
Contributor Author

joeyg commented Feb 6, 2018

@Sdaswani Share via twitter and iMessage
img_1224
img_1225

@bbinto bbinto self-requested a review February 6, 2018 21:38
@lime124
Copy link

lime124 commented Feb 6, 2018

This looks super awesome @joeyg ! Will the release version have our app icon instead of the grey box? /cc maybe @Sdaswani knows?

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 6, 2018

Ugh @lime124 good point, I'm not sure what we can do as since we are using a Adjust link (which is a redirect) the content pre-fetch isn't nice.

@joeyg can you use this link and see if it renders better: https://itunes.apple.com/app/apple-store/id1055677337?pt=373246&ct=ShareTracker&mt=8

@joeyg
Copy link
Contributor Author

joeyg commented Feb 6, 2018

@Sdaswani this is what it looks like with the itunes URL that you provided:
img_ca79c9848390-2

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 6, 2018

@lime124 is that better? we lose some analytics by not using Adjust. cc @bbinto

@joeyg is the feature done, or do you still need to do more coding?

@joeyg
Copy link
Contributor Author

joeyg commented Feb 12, 2018

@Sdaswani I think that issue you ran into is the last thing that needs to be looked at. I can try and fix that this evening.

@Sdaswani
Copy link
Contributor

As usual, thanks @joeyg - we can't wait to ship this!

@joeyg
Copy link
Contributor Author

joeyg commented Feb 13, 2018

@Sdaswani I think the update to the PR I pushed this evening should fix the overlay issue you were seeing.

@Sdaswani
Copy link
Contributor

Thanks @joeyg I'll push a build to iTunes tonight!

@Sdaswani
Copy link
Contributor

Sdaswani commented Feb 14, 2018

@joeyg we need one last change - otherwise @bbinto says let's ship this!

In shouldShowTrackerStatsShareButton, if shouldShowTrackerStatsToUser, can you append a key value to the dictionary, like is done here: https://github.com/mozilla-mobile/firefox-ios/blob/master/Client/Telemetry/UnifiedTelemetry.swift#L35-L44

Perhaps:
outputDict[userDefaultsShareTrackerStatsKey] = shouldShowTrackerStatsToUser as AnyObject?

You can also then remove the recordEvent after you determine the true/false value of shouldShowTrackerStatsToUser

Don't worry about this firing too much - we will pare those down when we run the search query. It's fine to have it for users who are true or false - that will allow us to put those folks into different buckets.

@joeyg
Copy link
Contributor Author

joeyg commented Feb 14, 2018

@Sdaswani just to clarify. Instead of sending a shareStatsCoinFlip event we should include the value of the coin flip with every CorePing?

@Sdaswani
Copy link
Contributor

Yes, exactly @joeyg . That will allow @bbinto to run crazy metrics ;) .

@joeyg
Copy link
Contributor Author

joeyg commented Feb 14, 2018

@Sdaswani I made those changes. Not sure the best way to test core ping telemetry so let me know if there is a good way to test this.

@@ -30,6 +30,7 @@ class TelemetryEventMethod {
public static let share = "share"
public static let customDomainRemoved = "removed"
public static let customDomainReordered = "reordered"
public static let shareStatsCoinFlip = "share_stats_coin_flip"
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be removed now, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch. will fix these

@@ -48,4 +49,6 @@ class TelemetryEventObject {
public static let trackingProtectionToggle = "tracking_protection_toggle"
public static let websiteLink = "website_link"
public static let autofill = "autofill"
public static let showStatsShareButton = "show_share_share_button"
Copy link
Contributor

Choose a reason for hiding this comment

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

and this too?

@Sdaswani
Copy link
Contributor

@joeyg we will test the telemetry, thanks!

@boek boek self-requested a review February 15, 2018 18:06
Copy link
Contributor

@boek boek left a comment

Choose a reason for hiding this comment

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

We just need to unwrap that optional :)

var outputDict = inputDict // make a mutable copy

let shouldShowTrackerStatsToUser = UserDefaults.standard.object(forKey: BrowserViewController.userDefaultsShareTrackerStatsKey) as! Bool?
outputDict["showTrackerStatsShare"] = shouldShowTrackerStatsToUser
Copy link
Contributor

Choose a reason for hiding this comment

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

We'll want to make sure shouldShowTrackerStatsToUser is a Boolean, not an Optional. (I don't think Telemetry unwraps things for us, just uses the description when serializing to JSON.

This could work

let shouldShowTrackerStatsToUser = (UserDefaults.standard.object(forKey: BrowserViewController.userDefaultsShareTrackerStatsKey) as? Bool) ?? false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would that report back as False even if the value is nil? Should we just not include the param if it is nil(meaning the coin flip hasn’t been done)

Copy link
Contributor

Choose a reason for hiding this comment

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

You know what? We have a reference to BrowserViewController. We could just do

outputDict["showTrackerStatsShare"] = browserViewController.shouldShowTrackerStatsShareButton()

I'm kinda okay with making that public for now since it will encourage us to clean it up if we decide to turn this on for all users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

great! made that change.

@boek
Copy link
Contributor

boek commented Feb 15, 2018

@Sdaswani I wonder if we limit the experiment to just en-US locales if we need to run this through l10n?

@Sdaswani
Copy link
Contributor

@boek by only doing en_us was hoping to avoid localization - any concerns there?

@boek boek self-requested a review February 16, 2018 17:13
@boek boek merged commit b753227 into mozilla-mobile:master Feb 16, 2018
boek pushed a commit that referenced this pull request Feb 16, 2018
* start on sharing of tracker stats

* add bold font

* adjust logic and add telemetry

* adjust share button

* update share stats ui

* round the corners of the share button

* Change share text and how the url is shared

* change url

* bump version to 4.0.3

* update share url

* Fix overlay from showing up when returning from tracker stats share screen

* change telemtry for tracker share button

* change name to be more clear

* remove unused statics

* use BrowserViewController instance
@bbinto
Copy link

bbinto commented Feb 18, 2018

@Sdaswani I made those changes. Not sure the best way to test core ping telemetry so let me know if there is a good way to test this.

@joeyg would you mind letting me know what key and value you've used in the core ping?

I've tried looking for key "userDefaultsShareTrackerStatsKey" in the core ping but couldn't find anything? Or is that the value you'd set for the "experiments" key?

@joeyg
Copy link
Contributor Author

joeyg commented Feb 18, 2018

@bbinto it should be

showTrackerStatsShare

If working properly

@bbinto
Copy link

bbinto commented Feb 18, 2018

Thanks @joeyg - also confirmed with @Sdaswani -- we need to get the data pipeline folks involved, back into our hands!

@oliviabrown9 oliviabrown9 mentioned this pull request Aug 2, 2018
isabelrios pushed a commit to isabelrios/firefox-ios that referenced this pull request Feb 14, 2024
…ile/focus-ios#859)

* start on sharing of tracker stats

* add bold font

* adjust logic and add telemetry

* adjust share button

* update share stats ui

* round the corners of the share button

* Change share text and how the url is shared

* change url

* bump version to 4.0.3

* update share url

* Fix overlay from showing up when returning from tracker stats share screen

* change telemtry for tracker share button

* change name to be more clear

* remove unused statics

* use BrowserViewController instance
isabelrios pushed a commit to isabelrios/firefox-ios that referenced this pull request Feb 20, 2024
…ozilla-mobile/focus-ios#859)

* start on sharing of tracker stats

* add bold font

* adjust logic and add telemetry

* adjust share button

* update share stats ui

* round the corners of the share button

* Change share text and how the url is shared

* change url

* bump version to 4.0.3

* update share url

* Fix overlay from showing up when returning from tracker stats share screen

* change telemtry for tracker share button

* change name to be more clear

* remove unused statics

* use BrowserViewController instance
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants