DeviceProfileCollector
public class DeviceProfileCollector : DeviceCollector, @unchecked Sendable
Main collector that orchestrates comprehensive device profile collection.
This collector serves as the root coordinator for gathering all device profile information based on a specified configuration. It manages the collection process, handles conditional data gathering, and combines results into a unified profile.
-
Declaration
Swift
public typealias DataType = DeviceProfileResult -
The key identifier for this collector (empty string as this is the root collector)
Declaration
Swift
public let key: String -
Initializes the device profile collector with the specified configuration
Declaration
Swift
public init(config: DeviceProfileConfig)Parameters
configThe configuration specifying what data to collect
-
collect()AsynchronousCollects comprehensive device profile data based on the configuration.
This method orchestrates the entire device profile collection process:
- Configures loggers for all collectors that support logging
- Retrieves the unique device identifier
- Conditionally collects metadata if enabled in configuration
- Conditionally collects location if enabled in configuration
Throws
Any errors that occur during the collection processCollection Process
- Logger Configuration: Sets up logging for all collectors that support it
- Identifier Collection: Retrieves unique device identifier
- Metadata Collection: Gathers device specifications (if enabled)
- Location Collection: Obtains geographic coordinates (if enabled)
- Result Assembly: Combines all data into unified result structure
Configuration Respect
- Only collects metadata if
config.metadatais true - Only collects location if
config.locationis true - Uses configured device identifier or falls back to empty string
- Applies configured logger to all supporting collectors
Error Handling
- Propagates identifier collection errors
- Handles metadata collection failures gracefully
- Treats location collection failures as non-fatal
Declaration
Swift
public func collect() async throws -> DeviceProfileResult?Return Value
A
DeviceProfileResultcontaining the collected device profile data
View on GitHub