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

fix: identify mac catalyst #287

Merged
merged 6 commits into from
Feb 4, 2025
Merged

fix: identify mac catalyst #287

merged 6 commits into from
Feb 4, 2025

Conversation

ioannisj
Copy link
Contributor

@ioannisj ioannisj commented Jan 26, 2025

💡 Motivation and Context

see: https://posthog.com/questions/i-os-app-also-available-for-mac-os-is-not-showing-any-mac-os-users-in-product-analytics

Identify as macOS when running on Mac Catalyst or compatibility mode (Designed for iPad/iPhone).

Here are the keys for the two cases:

Mac Catalyst

"$device_manufacturer": "Apple"
"$device_model": "Mac15,6"
"$device_name: "macbook-pro.local"
"$device_type": "Desktop"
"$is_emulator": "false"
"$is_ios_running_on_mac": "false"
"$is_mac_catalyst_app": "true"
"$os_name: "macOS"
"$os_version": "15.1.1"

iOS App running on Mac (Designed for iPad/iPhone)

"$device_manufacturer": "Apple"
"$device_model": "Mac15,6"
"$device_name": "macbook-pro.local"
"$device_type": "Desktop"
"$is_emulator": "false"
"$is_ios_running_on_mac": "true"
"$is_mac_catalyst_app": "false"
"$os_name": "macOS"
"$os_version": "15.1.1"

💚 How did you test it?

📝 Checklist

  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

@ioannisj ioannisj requested a review from a team January 26, 2025 21:50
@ioannisj ioannisj requested a review from marandaneto as a code owner January 26, 2025 21:50
//
// Source: https://developer.apple.com/documentation/apple-silicon/adapting-ios-code-to-run-in-the-macos-environment#Handle-unknown-device-types-gracefully
properties["$device_type"] = "Desktop"
properties["$device_name"] = processInfo.hostName
Copy link
Member

Choose a reason for hiding this comment

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

what does hostName return here? this is about the device name (Model), and not the user's name or device's nickname

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 equivalent to Host.current().localizedName that we already use on macOS targets (Host is not available on Catalyst).

I think both return the computer name which could leak PII actually, which I agree is concerning. We describe $device_name, however, as "Name of the device" in taxonomy

Regarding the actual device model, we capture as $device_model

Copy link
Member

Choose a reason for hiding this comment

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

this should be the info of the physical device.
So if we're using Host.current().localizedName because device.model isn't possible, then lets keep it

@pauldambra
Copy link
Member

fly-by that I appreciate the care and attention on this PR... some decisions are pretty hard to change and these posthog provided props are definitely that 💖

@ioannisj ioannisj merged commit fb53d3b into main Feb 4, 2025
7 checks passed
@ioannisj ioannisj deleted the fix/mac-catalyst-context branch February 4, 2025 06:11
@octohub
Copy link

octohub commented Feb 4, 2025

@pauldambra @ioannisj Thank you so much for the work on this. Excited to leverage it! How can I track when this will be in a published version of the SDK?

@marandaneto
Copy link
Member

@pauldambra @ioannisj Thank you so much for the work on this. Excited to leverage it! How can I track when this will be in a published version of the SDK?

https://github.com/PostHog/posthog-ios/releases/tag/3.19.3 :)

eakurnikov pushed a commit to trustwallet/posthog-ios that referenced this pull request Feb 6, 2025
* fix: identify mac catalyst

* fix: build

* fix: build tvos

* fix: add properties for mac catalyst and ios running on mac

* fix: same values for catalyst and ios running on mac
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.

4 participants