diff --git a/Sources/Core/Subject/PlatformContext.swift b/Sources/Core/Subject/PlatformContext.swift index 2b8b0bbee..67410d130 100644 --- a/Sources/Core/Subject/PlatformContext.swift +++ b/Sources/Core/Subject/PlatformContext.swift @@ -106,9 +106,6 @@ class PlatformContext { if shouldTrack(.carrier) { platformDict[kSPMobileCarrier] = deviceInfoMonitor.carrierName } - if shouldTrack(.totalStorage) { - platformDict[kSPMobileTotalStorage] = deviceInfoMonitor.totalStorage - } if shouldTrack(.physicalMemory) { platformDict[kSPMobilePhysicalMemory] = deviceInfoMonitor.physicalMemory } @@ -133,9 +130,6 @@ class PlatformContext { if shouldTrack(.lowPowerMode) { platformDict[kSPMobileLowPowerMode] = deviceInfoMonitor.isLowPowerModeEnabled } - if shouldTrack(.availableStorage) { - platformDict[kSPMobileAvailableStorage] = deviceInfoMonitor.availableStorage - } if shouldTrack(.appAvailableMemory) { platformDict[kSPMobileAppAvailableMemory] = deviceInfoMonitor.appAvailableMemory } diff --git a/Sources/Core/TrackerConstants.swift b/Sources/Core/TrackerConstants.swift index 3ca535ac1..5e055a738 100644 --- a/Sources/Core/TrackerConstants.swift +++ b/Sources/Core/TrackerConstants.swift @@ -128,8 +128,6 @@ let kSPMobileAppAvailableMemory = "appAvailableMemory" let kSPMobileBatteryLevel = "batteryLevel" let kSPMobileBatteryState = "batteryState" let kSPMobileLowPowerMode = "lowPowerMode" -let kSPMobileAvailableStorage = "availableStorage" -let kSPMobileTotalStorage = "totalStorage" let kSPMobileIsPortrait = "isPortrait" let kSPMobileResolution = "resolution" let kSPMobileLanguage = "language" diff --git a/Sources/Core/Utils/DeviceInfoMonitor.swift b/Sources/Core/Utils/DeviceInfoMonitor.swift index 4d03ddf17..e333d4b13 100644 --- a/Sources/Core/Utils/DeviceInfoMonitor.swift +++ b/Sources/Core/Utils/DeviceInfoMonitor.swift @@ -221,36 +221,6 @@ class DeviceInfoMonitor { // #endif return nil } - - /// Returns number of bytes of storage remaining. The information is requested from the home directory. - /// - Returns: Bytes of storage remaining. - var availableStorage: Int64? { - #if os(iOS) - let fileURL = URL(fileURLWithPath: NSHomeDirectory() as String) - do { - let values = try fileURL.resourceValues(forKeys: [.volumeAvailableCapacityForImportantUsageKey]) - return values.volumeAvailableCapacityForImportantUsage - } catch { - logError(message: "Failed to read available storage size: \(error.localizedDescription)") - } - #endif - return nil - } - - /// Returns the total number of bytes of storage. The information is requested from the home directory. - /// - Returns: Total size of storage in bytes. - var totalStorage: Int? { - #if os(iOS) - let fileURL = URL(fileURLWithPath: NSHomeDirectory() as String) - do { - let values = try fileURL.resourceValues(forKeys: [.volumeTotalCapacityKey]) - return values.volumeTotalCapacity - } catch { - logError(message: "Failed to read available storage size: \(error.localizedDescription)") - } - #endif - return nil - } /// Whether the device orientation is portrait (either upright or upside down) var isPortrait: Bool? { diff --git a/Sources/Snowplow/Configurations/PlatformContextProperty.swift b/Sources/Snowplow/Configurations/PlatformContextProperty.swift index d1efa3d63..5c5053b4e 100644 --- a/Sources/Snowplow/Configurations/PlatformContextProperty.swift +++ b/Sources/Snowplow/Configurations/PlatformContextProperty.swift @@ -36,10 +36,6 @@ public enum PlatformContextProperty: Int { case batteryState /// A Boolean indicating whether Low Power Mode is enabled case lowPowerMode - /// Bytes of storage remaining - case availableStorage - /// Total size of storage in bytes - case totalStorage /// A Boolean indicating whether the device orientation is portrait (either upright or upside down) case isPortrait /// Screen resolution in pixels. Arrives in the form of WIDTHxHEIGHT (e.g., 1200x900). Doesn't change when device orientation changes diff --git a/Tests/TestPlatformContext.swift b/Tests/TestPlatformContext.swift index 22d57ec12..0b3f300b3 100644 --- a/Tests/TestPlatformContext.swift +++ b/Tests/TestPlatformContext.swift @@ -110,13 +110,13 @@ class TestPlatformContext: XCTestCase { let deviceInfoMonitor = MockDeviceInfoMonitor() let context = PlatformContext(mobileDictUpdateFrequency: 0, networkDictUpdateFrequency: 0, deviceInfoMonitor: deviceInfoMonitor) XCTAssertEqual(1, deviceInfoMonitor.accessCount("physicalMemory")) - XCTAssertEqual(1, deviceInfoMonitor.accessCount("totalStorage")) + XCTAssertEqual(1, deviceInfoMonitor.accessCount("carrierName")) _ = context.fetchPlatformDict(userAnonymisation: false, advertisingIdentifierRetriever: nil) XCTAssertEqual(1, deviceInfoMonitor.accessCount("physicalMemory")) - XCTAssertEqual(1, deviceInfoMonitor.accessCount("totalStorage")) + XCTAssertEqual(1, deviceInfoMonitor.accessCount("carrierName")) _ = context.fetchPlatformDict(userAnonymisation: false, advertisingIdentifierRetriever: nil) XCTAssertEqual(1, deviceInfoMonitor.accessCount("physicalMemory")) - XCTAssertEqual(1, deviceInfoMonitor.accessCount("totalStorage")) + XCTAssertEqual(1, deviceInfoMonitor.accessCount("carrierName")) } func testDoesntUpdateIdfvIfNotNil() { @@ -198,7 +198,7 @@ class TestPlatformContext: XCTestCase { func testOnlyAddsRequestedProperties() { let deviceInfoMonitor = MockDeviceInfoMonitor() let context = PlatformContext( - platformContextProperties: [.appAvailableMemory, .availableStorage, .language], + platformContextProperties: [.appAvailableMemory, .language], mobileDictUpdateFrequency: 0, networkDictUpdateFrequency: 1, deviceInfoMonitor: deviceInfoMonitor) @@ -213,7 +213,6 @@ class TestPlatformContext: XCTestCase { XCTAssertNil(platformDict[kSPMobileScale]) XCTAssertNil(platformDict[kSPMobileResolution]) XCTAssertNotNil(platformDict[kSPMobileAppAvailableMemory]) - XCTAssertNotNil(platformDict[kSPMobileAvailableStorage]) XCTAssertNil(platformDict[kSPMobilePhysicalMemory]) XCTAssertNil(platformDict[kSPMobileIsPortrait]) XCTAssertNil(platformDict[kSPMobileAppleIdfa]) diff --git a/Tests/Utils/MockDeviceInfoMonitor.swift b/Tests/Utils/MockDeviceInfoMonitor.swift index c3a56706c..4ff31912b 100644 --- a/Tests/Utils/MockDeviceInfoMonitor.swift +++ b/Tests/Utils/MockDeviceInfoMonitor.swift @@ -86,16 +86,6 @@ class MockDeviceInfoMonitor: DeviceInfoMonitor { increaseMethodAccessCount("appAvailableMemory") return 1000 } - - override var availableStorage: Int64? { - increaseMethodAccessCount("availableStorage") - return 9000 - } - - override var totalStorage: Int? { - increaseMethodAccessCount("totalStorage") - return 900000 - } override var isPortrait: Bool? { return true