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

PixelKit adoption #2557

Merged
merged 48 commits into from
Apr 17, 2024
Merged

PixelKit adoption #2557

merged 48 commits into from
Apr 17, 2024

Conversation

federicocappelli
Copy link
Member

@federicocappelli federicocappelli commented Apr 5, 2024

Task/Issue URL:https://app.asana.com/0/1205842942115003/1206999268603553/f
Tech Design URL:https://app.asana.com/0/1205842942115003/1206989773504216/f
CC: @diegoreymendez

Description:

90% of this PR is changes from pixel.fire() to PixelKit.fire() with related name and frequency changes. The few logic changes are concentrated in PixelKit.

  • Old Pixel implementation removed
  • PixelKit adopted for every Pixel
  • PixelKit code improved
  • Debug menu "remove daily pixels" changed in "Remove Pixels Storage" (reset all unique and daily pixels)

Steps to test this PR:

For each area of responsibility as discussed in https://app.asana.com/0/0/1206999268603553/1207035044172102/f:

  • Review the code with focus on the Pixel's "frequency"
  • Run the app and try to replicate as much pixels as possible

Internal references:

Pull Request Review Checklist
Software Engineering Expectations
Technical Design Template
Pull Request Documentation

Copy link
Contributor

github-actions bot commented Apr 5, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 1c17e9a

alessandroboron and others added 3 commits April 8, 2024 11:07
Task/Issue URL: https://app.asana.com/0/0/1207002879349167/f

**Description**:
Migrates the Installation Attribution Pixel to use PixelKit.

<img width="1289" alt="Screenshot 2024-04-08 at 4 07 47 PM"
src="https://github.com/duckduckgo/macos-browser/assets/1089358/fcaf4fc2-f4b8-4d9e-a9b7-ef80f96cff97">

**Steps to test this PR:**

Download the Review App
[here](https://github.com/duckduckgo/macos-browser/actions/runs/8595167779/artifacts/1393075355)
Make sure to clean up the app's data directory by running sh
clean-app.sh review.
Run the App.
Search for pixel:m.mac.install in Kibana.

**Extra:**
Create the Origin.txt file manually and add it to the Bundle of the App
(.app/Contents/Resources) to test that the pixel fires and has the
origin field set.
This requires to re-sign the App again in order to run it.
Steps to re-sign the App
[here](https://github.com/duckduckgo/macos-browser/blob/988a3ef69aaf3c69fa2b56b274de5fa113d73809/.github/workflows/create_variants.yml#L142)

In terminal:

codesign -d --entitlements :- DuckDuckGo.app > entitlements.plist
Copy result of security find-certificate -a -c "Developer ID
Application" -Z | grep ^SHA-1 | cut -d " " -f3 | uniq
Code sign the App using the below:
          --force \
          --sign <paste value generated from #2 here> \
          --options runtime \
          --entitlements entitlements.plist \
          --generate-entitlement-der “DuckDuckGo.app”
Once the App is re-signed you need to open it by right-click on the icon
and select Open from the context menu otherwise you won’t be able to
open it.
# Conflicts:
#	DuckDuckGo/Application/AppDelegate.swift
#	DuckDuckGo/MainWindow/MainViewController.swift
#	DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
#	DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift
#	DuckDuckGo/NetworkProtection/AppTargets/BothAppTargets/NetworkProtectionNavBarButtonModel.swift
#	DuckDuckGo/Waitlist/Waitlist.swift
#	DuckDuckGo/Waitlist/WaitlistTermsAndConditionsActionHandler.swift
@@ -97,6 +97,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
var updateController: UpdateController!
#endif

static private var aMonthAgo = Calendar.current.date(byAdding: .month, value: -1, to: Date())! // Temporary for init
Copy link
Member Author

@federicocappelli federicocappelli Apr 8, 2024

Choose a reason for hiding this comment

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

Code moved from Pixel.swift to AppDelegate, I'm sure this isn't the right place or approach but it's comparable to the previous one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

we have Date.monthAgo in BSK.Common.DateExtensions, worths removing this

Copy link
Member Author

Choose a reason for hiding this comment

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

Much better, thanks, fixed

@testable import DuckDuckGo_Privacy_Browser

/*
WARNING: This component doesn't work anymore, re-implementation needed
https://app.asana.com/0/0/1207002879349166/f
Copy link
Member Author

@federicocappelli federicocappelli Apr 8, 2024

Choose a reason for hiding this comment

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

There's no active experiments in macOS atm, the re-implementation is scheduled as part of this refactoring.

# Conflicts:
#	DuckDuckGo/HomePage/Model/HomePageContinueSetUpModel.swift
#	DuckDuckGo/NavigationBar/View/MoreOptionsMenu.swift
#	DuckDuckGo/NavigationBar/View/NavigationBarViewController.swift
#	DuckDuckGo/Tab/Model/Tab.swift
@@ -22,6 +22,7 @@ import Combine
import BrowserServicesKit
import PrivacyDashboard
import Common
import PixelKit
Copy link
Member Author

Choose a reason for hiding this comment

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

Reviewed and tested by me

@federicocappelli federicocappelli marked this pull request as ready for review April 9, 2024 10:07
# Conflicts:
#	DuckDuckGo/Tab/Model/Tab.swift
# Conflicts:
#	DuckDuckGo/DBP/DBPHomeViewController.swift
#	DuckDuckGo/History/Services/EncryptedHistoryStore.swift
#	DuckDuckGo/NetworkProtection/NetworkExtensionTargets/NetworkExtensionTargets/MacPacketTunnelProvider.swift
#	LocalPackages/PixelKit/Sources/PixelKit/PixelKit.swift
#	LocalPackages/PixelKit/Tests/PixelKitTests/PixelKitTests.swift
Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

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

Narrow +1 on the /PasswordManager code, which LGTM 🚀. However, I left a comment on an unrelated part of the code.

DuckDuckGo/Application/AppDelegate.swift Show resolved Hide resolved
Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

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

Added some more comments, will be testing meanwhile.

@@ -16,7 +16,13 @@
// limitations under the License.
//

/*
WARNING: This component doesn't work anymore, re-implementation needed
Copy link
Collaborator

Choose a reason for hiding this comment

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

why not to drop it then?

Copy link
Member Author

@federicocappelli federicocappelli Apr 17, 2024

Choose a reason for hiding this comment

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

The reason is that the overall implementation is probably correct but it will need to be migrated to PixelKit, I wanted to make the re-implementation easier avoiding the need to recover the files. Anyway, I added all the info in https://app.asana.com/0/0/1207002879349166/f so I have no preferences, I can remove it if needed.

case .protectionToggledOffBreakageReport: return "m_mac_protection-toggled-off-breakage-report"
case .toggleProtectionsDailyCount: return "m_mac_toggle-protections-daily-count"
case .toggleReportDoNotSend: return "m_mac_toggle-report-do-not-send"
case .toggleReportDismiss: return "m_mac_toggle-report-dismiss"

// Password Import Keychain Prompt
// Password Import Keychain Prompt
Copy link
Collaborator

Choose a reason for hiding this comment

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

indentation

Copy link
Member Author

Choose a reason for hiding this comment

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

that's apparently the correct indentation in the context, all other comments are the same and Xcode re-intend it like that

case .bitwardenRespondedCannotDecryptUnique:
return "bitwarden_responded_cannot_decrypt_unique"
case .bitwardenRespondedCannotDecrypt:
return "bitwarden_responded_cannot_decrypt_d"
Copy link
Collaborator

Choose a reason for hiding this comment

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

just making sure, is this change reflected in grafana?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

@mallexxx mallexxx left a comment

Choose a reason for hiding this comment

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

The changes look good to me, see minor styling comments inline;
One note: as I remember we were going to drop pixel CoreData storage in favor of User Defaults storage, and here it‘s renamed…

@diegoreymendez diegoreymendez self-requested a review April 17, 2024 12:34
Copy link
Contributor

@diegoreymendez diegoreymendez left a comment

Choose a reason for hiding this comment

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

Approved.

@federicocappelli federicocappelli merged commit d885fd0 into main Apr 17, 2024
17 checks passed
@federicocappelli federicocappelli deleted the fcappelli/PixelKit branch April 17, 2024 15:25
diegoreymendez pushed a commit that referenced this pull request Apr 18, 2024
Task/Issue
URL:https://app.asana.com/0/1205842942115003/1206999268603553/f
Tech Design
URL:https://app.asana.com/0/1205842942115003/1206989773504216/f
CC: @diegoreymendez 

**Description**:

Migrating the entire app to PixelKit changing pixel.fire() to PixelKit.fire() with
related name and frequency changes. The few logic changes are
concentrated in PixelKit.

- Old Pixel implementation removed
- PixelKit adopted for every Pixel
- PixelKit code improved
- Debug menu "remove daily pixels" changed in "Remove Pixels Storage"
(reset all unique and daily pixels)
sjbarag added a commit that referenced this pull request May 22, 2024
Pixels fired for email autofill use-cases are intentionally not prefixed
with `m.mac.`, though the historical reason isn't clear to me. The
migration to PixelKit for pixel management[^1] caused those email-related
pixels to be prefixed. Wrap email-related JS pixels in
`NonStandardEvent`s to prevent that prefixing, to restore their original
intended names.

[^1]: d885fd0 (PixelKit adoption (#2557), 2024-04-17)
sjbarag added a commit that referenced this pull request May 22, 2024
Pixels fired for email autofill use-cases are intentionally not prefixed
with `m.mac.`, though the historical reason isn't clear to me. The
migration to PixelKit for pixel management[^1] caused those email-related
pixels to be prefixed. Wrap email-related JS pixels in
`NonStandardEvent`s to prevent that prefixing, to restore their original
intended names.

[^1]: d885fd0 (PixelKit adoption (#2557), 2024-04-17)
sjbarag added a commit that referenced this pull request May 23, 2024
Task/Issue URL:
https://app.asana.com/0/1206682621538333/1207380134103391/f
Tech Design URL: N/A

Pixels fired for email autofill use-cases are intentionally not prefixed
with `m.mac.`, though the historical reason isn't clear to me. The
migration to PixelKit for pixel management[^1] caused those
email-related pixels to be prefixed. Wrap email-related JS pixels in
`NonStandardEvent`s to prevent that prefixing, to restore their original
intended names.

[^1]: d885fd0 (PixelKit adoption (#2557), 2024-04-17)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants