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

track Mac installations on Posthog #1737

Merged
merged 2 commits into from
Jan 21, 2025
Merged

Conversation

pelumy
Copy link
Contributor

@pelumy pelumy commented Jan 17, 2025

Issues covered

#130

Description

Previos PR (#1735) tracks only iOS installation. This is a continuation to track macOS installations too.

How to test

Merge and check if events shows up on Posthog after app is downloaded on TestFlight and App Store.

@pelumy pelumy changed the title track mac installations track Mac installations on Posthog Jan 17, 2025
@joshuatbrown
Copy link
Contributor

joshuatbrown commented Jan 21, 2025

👀

Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

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

Looks good! I'd love to see a little refactoring, and to figure out how I can test this on Mac.

@@ -33,16 +34,63 @@ extension Bundle {
/// Checks the app's receipt URL to determine if it contains the TestFlight-specific
/// "sandboxReceipt" identifier.
/// - Returns: `true` if the app was installed through TestFlight, `false` otherwise.
private var isTestFlight: Bool {
private var isIosTestFlight: Bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we maybe have a single isTestFlight and inside of it, check whether we're on iOS or macOS? Essentially combine isIosTestFlight and isMacTestFlight into one?

Additionally, I wonder if we need to check whether it's macOS first? https://gist.github.com/lukaskubanek/cbfcab29c0c93e0e9e0a16ab09586996?permalink_comment_id=4686545#gistcomment-4686545

Copy link
Contributor Author

@pelumy pelumy Jan 21, 2025

Choose a reason for hiding this comment

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

Thanks for the feedback @joshuatbrown. I will do the refactoring. I will also make sure to check for macOS first before iOS.

Do you also mean including comments about how to test it in the code?
Currently, to test, we need to merge the code, install the app on the Mac through TestFlight and see if it shows up in the downloads graph on post hog.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh no -- I just mean I'm hoping for a way to test like by setting a breakpoint, but I don't know if that's possible. We may just have to deploy to TestFlight and test that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think we can test with the breakpoint, I was able to test the iOS one after merging.

@pelumy pelumy requested a review from joshuatbrown January 21, 2025 17:52
Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

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

One last thing to switch, then I think this will work.

private var isTestFlight: Bool {
#if os(macOS)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I just found this in our NoteUITextViewRepresentable:

            if ProcessInfo.processInfo.isiOSAppOnMac {

I think this is the way to detect whether we're running on macOS or not. I think the #if os(macOS) only works if we have a real Mac app, or maybe if we have a Catalyst app running on Mac.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is going to be a problem then, because the mac code doesn't work (throws errors) except there is #if os(macOS). It has to actually run on a Mac.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right. I'll approve, we can merge and test, then decide next steps if needed.

Copy link
Contributor

@joshuatbrown joshuatbrown left a comment

Choose a reason for hiding this comment

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

Excellent work!

@joshuatbrown joshuatbrown added this pull request to the merge queue Jan 21, 2025
Merged via the queue into main with commit 2d59c9f Jan 21, 2025
4 checks passed
@joshuatbrown joshuatbrown deleted the it/130-track-mac-installation branch January 21, 2025 20:50
@pelumy
Copy link
Contributor Author

pelumy commented Jan 22, 2025

@joshuatbrown , this got registered as iPadOS instead of macOS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants