Connection Type to include Cellular Network Technology (e.g. 3G, 4G LTE, 5G)
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.).
From https://github.com/getsentry/team-mobile/issues/150
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)
}
It's also worth noting that we could replace the current SentryReachability class with NWPathMonitor, we need to investigate the effort.
as proposed by @philipphofmann in https://github.com/getsentry/sentry-cocoa/issues/4796#issue-2832999016
We can use CoreTelephony for adding information about a user’s home cellular service provider to the device context. It's useful two know if the user had a EDGE, LTE or 5G connection.
Furthermore, we could use the information to add breadcrumb when the connection changes via the CTTelephonyNetworkInfoDelegate.
NWPathMontitor was introduced in this PR.