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

Connection Type to include Cellular Network Technology (e.g. 3G, 4G LTE, 5G) #4488

Open
Tracked by #4256
brustolin opened this issue Oct 30, 2024 · 2 comments
Open
Tracked by #4256

Comments

@brustolin
Copy link
Contributor

Description

Sentry events currently show Connection Type, but only with values wifi, ethernet, cellular, or null. https://github.com/getsentry/sentry-java/blob/5b8a9a6b2d40e03d1e5d0a38237db370c0f6cfd0/sentry-android-core/src/main/java/io/sentry/android/core/internal/util/ConnectivityChecker.java#L195

Extend the connection_type field to include cellular network technology (3G, 4G LTE, and 5G etc.).
image

From getsentry/team-mobile#150

@brustolin
Copy link
Contributor Author

Swift snippet

import Network
import CoreTelephony

func checkNetworkType() {
    let monitor = NWPathMonitor()
    let queue = DispatchQueue(label: "NetworkMonitor")

    monitor.pathUpdateHandler = { path in
        if path.status == .satisfied {
            // Device is connected to the internet
            if path.usesInterfaceType(.cellular) {
                // Cellular connection
                let networkInfo = CTTelephonyNetworkInfo()

                if let carrierType = networkInfo.serviceCurrentRadioAccessTechnology?.values.first {
                    switch carrierType {
                    case CTRadioAccessTechnologyLTE:
                        print("Connected via 4G (LTE)")
                    case CTRadioAccessTechnologyNRNSA, CTRadioAccessTechnologyNR:
                        print("Connected via 5G")
                    default:
                        print("Other cellular network (3G, etc.)")
                    }
                }
            } else if path.usesInterfaceType(.wifi) {
                print("Connected via WiFi")
            }
        } else {
            print("No internet connection")
        }
    }

    monitor.start(queue: queue)
}

@brustolin
Copy link
Contributor Author

It's also worth noting that we could replace the current SentryReachability class with NWPathMonitor, we need to investigate the effort.

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

No branches or pull requests

1 participant