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

Amplitude dashboard with macOS filter return iPadOS statistics #132

Open
aureliendelrue opened this issue Mar 8, 2024 · 6 comments
Open
Labels
bug Something isn't working

Comments

@aureliendelrue
Copy link

On the Amplitude dashboard, if I want statistics about macOS version, the dashboard retrieve iPadOS data.
Capture d’écran 2024-03-08 à 08 46 13

@aureliendelrue aureliendelrue added the bug Something isn't working label Mar 8, 2024
@izaaz
Copy link
Collaborator

izaaz commented Mar 8, 2024

@aureliendelrue - We fetch the OS information from UIDevice.current.systemName. This is most likely because you've published an iOS/iPad app with macos support. On M1s, Apple lets users download the ipad version of the apps as a desktop app.

@aureliendelrue
Copy link
Author

aureliendelrue commented Mar 10, 2024

@izaaz You're right if you have the OS information from UIDevice.current.systemName but maybe you could use this

For example I have : Mac14,9 macOS Version 14.3.1 (Build 23D60)

@izaaz
Copy link
Collaborator

izaaz commented Mar 12, 2024

Thank you for the suggestion @aureliendelrue. I'll keep this issue open so we can get more feedback from others who run into this issue and decide what can be done next.

@aureliendelrue
Copy link
Author

Hi ! Any news for the bug ?

@emartinson
Copy link

@izaaz Hi! Thank you for reply! But this is definitely a bug. From real-world environment perspective the actual system is MacOS. We'll be kindly appreciate if you add check for ProcessInfo.processInfo.isiOSAppOnMac and isMacCatalystApp which are both MacOS.

    #if os(iOS)
                    if ProcessInfo.processInfo.isiOSAppOnMac {
                        log.info("[AU] Hello from macOS")
                    } else {
                        log.info("[AU] Hello from iOS")
                    }
            #elseif os(macOS)
                    log.info("[AU] Hello from macOS")
            #elseif targetEnvironment(macCatalyst)
                    log.info("[AU] Hello from Catalyst")
            #endif

@emartinson
Copy link

emartinson commented Dec 7, 2024

@aureliendelrue the only thing I figured out as workaround is to write an enrichment plugin:

final class PlatformEnrichmentPlugin: EnrichmentPlugin {

    override func execute(event: BaseEvent?) -> BaseEvent? {
        guard let event else { return nil }
        event.userProperties = event.userProperties ?? [:]
        event.eventProperties = event.eventProperties ?? [:]
        event.groupProperties = event.groupProperties ?? [:]

        func forceMacOS() {
            event.platform = "macOS"
            event.deviceModel = "macOS_Unknown_" + (event.deviceModel ?? "")
            event.osVersion  = ProcessInfo.processInfo.operatingSystemVersionString
            event.osName = "macOS_" + (event.osName ?? "")
        }

        #if os(iOS)
        if ProcessInfo.processInfo.isiOSAppOnMac {
            forceMacOS()
        }
        #elseif os(macOS) || targetEnvironment(macCatalyst)
        forceMacOS()
        #endif
        return event
    }
}

and then add it with

aimplitude.add(plugin: PlatformEnrichmentPlugin())

This will definitely give us correct platform. But detecting environment is tricky part. I was able to get MacOS version from ProcessInfo, but OS Name / Model - is quite difficult to figure out (I found several approaches with touching system plists, but haven't tested them yet). If anyone can offer a working solution - please post it here.

Above plugin will give you these Platform, OS and Device Family:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants