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

Providing TrackerConfiguration overrides the TrackerDefaults.devicePlatform #893

Open
markst opened this issue Jun 4, 2024 · 3 comments
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.

Comments

@markst
Copy link

markst commented Jun 4, 2024

Describe the bug

If no devicePlatform is provided to TrackerConfiguration, the device platform defaults to mobile

To Reproduce

Device platform is initialised here:
https://github.com/snowplow/snowplow-ios-tracker/blob/master/Sources/Core/Utils/Utilities.swift#L45

Tracker adds devicePlatform with param p to payload:
https://github.com/snowplow/snowplow-ios-tracker/blob/master/Sources/Core/Tracker/Tracker.swift#L525

Which is redefined here when providing TrackerConfiguration:
https://github.com/snowplow/snowplow-ios-tracker/blob/master/Sources/Core/Tracker/ServiceProvider.swift#L298

Which defaults to DevicePlatform.mobile

Device information (please complete the following information):

  • Device: Apple TV
  • OS: tvOS 17.0
  • SnowplowTracker: 6.0.3
@markst markst added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Jun 4, 2024
@markst markst changed the title Proving TrackerConfiguration overrides the TrackerDefaults.devicePlatform Providing TrackerConfiguration overrides the TrackerDefaults.devicePlatform Jun 4, 2024
@markst
Copy link
Author

markst commented Jun 4, 2024

One solution could be to use the TrackerDefaults.devicePlatform for the nil coalescing optional TrackerConfiguration initialiser:

        if let devicePlatform = dictionary["devicePlatform"] as? String {
            self.devicePlatform = stringToDevicePlatform(devicePlatform) ?? TrackerDefaults.devicePlatform
        }

@markst
Copy link
Author

markst commented Jun 4, 2024

or in the getter optional rather than defaulting to mobile:

    @objc
    public var devicePlatform: DevicePlatform {
        get { return _devicePlatform ?? sourceConfig?.devicePlatform ?? TrackerDefaults.devicePlatform }

@markst
Copy link
Author

markst commented Jun 4, 2024

our solution for now is to simply provide a devicePlatform:

TrackerConfiguration()
    .appId(appId)
    .devicePlatform(.current)
extension DevicePlatform {
  /// Local replacement for `Utilities.platform`
  static var current: DevicePlatform {
#if os(tvOS)
    return .connectedTV
#else
    return .mobile
#endif
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Projects
None yet
Development

No branches or pull requests

1 participant