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
  • key

    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

    config

    The configuration specifying what data to collect

  • collect() Asynchronous

    Collects comprehensive device profile data based on the configuration.

    This method orchestrates the entire device profile collection process:

    1. Configures loggers for all collectors that support logging
    2. Retrieves the unique device identifier
    3. Conditionally collects metadata if enabled in configuration
    4. Conditionally collects location if enabled in configuration

    Throws

    Any errors that occur during the collection process

    Collection Process

    1. Logger Configuration: Sets up logging for all collectors that support it
    2. Identifier Collection: Retrieves unique device identifier
    3. Metadata Collection: Gathers device specifications (if enabled)
    4. Location Collection: Obtains geographic coordinates (if enabled)
    5. Result Assembly: Combines all data into unified result structure

    Configuration Respect

    • Only collects metadata if config.metadata is true
    • Only collects location if config.location is 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 DeviceProfileResult containing the collected device profile data