-
Notifications
You must be signed in to change notification settings - Fork 135
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
RUMM-2197 Improve device
and os
info in RUM
#888
RUMM-2197 Improve device
and os
info in RUM
#888
Conversation
3463f0d
to
478c401
Compare
478c401
to
9effbb3
Compare
9effbb3
to
559daee
Compare
device.model
in RUMdevice
and os
info in RUM
defa092
to
8409225
Compare
convenience init() { | ||
let processInfo = ProcessInfo.processInfo | ||
let device = UIDevice.current | ||
let model: String | ||
|
||
#if !targetEnvironment(simulator) | ||
// Real tvOS device | ||
model = (try? Sysctl.getModel()) ?? device.model | ||
#else | ||
// tvOS Simulator | ||
let simulatorModel = processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] ?? device.model | ||
model = "\(simulatorModel) Simulator" | ||
#endif | ||
|
||
self.init( | ||
model: model, | ||
uiDevice: device, | ||
processInfo: processInfo, | ||
notificationCenter: .default | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new initialisers in MobileDevice
are added for init consistency on both iOS
and tvOS
(both define matching init()
). This and the entire MobileDevice
class should be however a subject to change in V2. Since we added tvOS
support, it should no longer be "mobile device" and we should really split its responsibilities. For example, the cohesion of this class is very low - battery reasoning and management is only implemented for iOS
and we use mock values for tvOS
just to "make it work".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
value: .constant("\(sanitizedAppName)/\(appVersion) CFNetwork (\(device.model); \(device.osName)/\(device.osVersion))") | ||
value: .constant("\(sanitizedAppName)/\(appVersion) CFNetwork (\(device.name); \(device.osName)/\(device.osVersion))") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These kind of changes in this PR are OK. What used to work as device.model
before, now is called device.name
(iPhone
| iPad
| ...). The device.model
is now reserved for exact info, e.g. iPhone10,2
.
// RUMM-2197: In very rare cases, the OS info computed below might not be exactly the one | ||
// that the app crashed on. This would correspond to a scenario when the device OS was upgraded | ||
// before restarting the app after crash. To solve this, the OS information would have to be | ||
// persisted in `crashContext` the same way as we do for other dynamic information. | ||
os: .init(from: deviceInfoProvider), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't decided for this implementation as it will only address a very rare case with quite a work required. It is however a good driver for more robust SDK context management in V2.
…ents (for integration tests)
6cdf6c6
to
1023c41
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! 👍
Once this and v2 feature scope are merged, we should apply this to the feature/v2
and its context, so we keep v2 in sync.
convenience init() { | ||
let processInfo = ProcessInfo.processInfo | ||
let device = UIDevice.current | ||
let model: String | ||
|
||
#if !targetEnvironment(simulator) | ||
// Real tvOS device | ||
model = (try? Sysctl.getModel()) ?? device.model | ||
#else | ||
// tvOS Simulator | ||
let simulatorModel = processInfo.environment["SIMULATOR_MODEL_IDENTIFIER"] ?? device.model | ||
model = "\(simulatorModel) Simulator" | ||
#endif | ||
|
||
self.init( | ||
model: model, | ||
uiDevice: device, | ||
processInfo: processInfo, | ||
notificationCenter: .default | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
What and why?
📦 This PR updates the SDK to use new
device
andos
attributes added recently to RUM schema.With this change,
device
andos
will no longer be inferred by backend from SDK UA header. Instead, BE can now read these values directly from RUM events.As a user-facing change, we now enhance the
device.model
information. Previously it was eitheriPhone
|iPad
|iPod
with no further context. Now it names the model along with its version, e.g.iPhone13,2
oriPad13,4
.How?
New spec for
device
andos
:device.name
can beiPhone
|iPad
|Apple TV
| ... (same as before),device.model
now includes version, e.g.AppleTV11,1
(can be a breaking change in some filters and dashboardsdevice.brand
is alwaysApple
,os.name
,os.version
andos.version_major
remain unchanged - their values will be just like before.I used a simplified version of CwlUtils/CwlSysctl.swift to read device information from system attributes (
HW_MACHINE
). Nice discussion on this approach and itsmacOS
vsiOS
nuances can be found here.Everything happens in
MobileDevice
class, which isn't perfect design, but seems pragmatic choice considering that we will make it more straightforward in with V2's SDK context.I added 2 layers of tests:
RUMSessionMatcher
) to ensure that values are correct for current platform (e.g. iOS Simulator).Tests
I tested all values on 4 simulator and 2 real devices:
iPhone Simulator:
iPod touch Simulator:
UIDevice.model
for iPod Simulator)iPad Simulator:
Apple TV Simulator:
Real iPhone:
Real iPad:
Review checklist
Custom CI job configuration (optional)