Client Usage

Client Usage in Foundation


The detailed description of Usage component can be found at Client Usage in Common.

Additional convenience method on SAPcpmsUsage

The SAPFoundation framework makes it possible to use SAPcpmsSettingsParameters as convenience parameter. Reporting using SAPcpmsUsage to the default target:

// Only the applicationID and applicationVersion fields are used from the settingsParameter.
SAPcpmsUsage.sessionStart(settingsParameters: <#mySettingsParameters#> )
// ...
SAPcpmsUsage.event(type: "testType", key: "testKey")
SAPcpmsUsage.sessionEnd()

reporter = Usage.shared.reporter(for: "myTarget")
reporter.report(SAPcpmsRecord.sessionStart(settingsParameters: <#mySettingsParameters#>))
// ...
reporter.report( SAPcpmsRecord.event(type: "testType", key: "testKey") )

Report uploading

Uploading reports using SAPcpms compatible uploader

Upload the collected data to SAP Cloud Platform Mobile Services where the data is processed and presented on a dedicated UI. The SAPcpmsUsageUploader eases the uploading task. Assuming there is a ‘urlSession’ variable containing the SAPURLSession which has been initialized with the proper authentication observers:

// upload the default target
// note: only the 'backendURL' and the 'applicationID' parameters are used from mySettingsParameters to create the full endpoint URL
SAPcpmsUsageUploader.upload(to: <#mySettingsParameters#>, sapURLSession: <#mySAPURLSession#>) { result in
    // handle result of upload
}
// or upload another target
// note: only the 'backendURL' and the 'applicationID' parameters are used from mySettingsParameters to create the full endpoint URL
SAPcpmsUsageUploader.upload(to: <#mySettingsParameters#>, sapURLSession: <#mySAPURLSession#>, target: "myTarget") { result in
    // handle result of upload
}
// upload in case the SAPcpms used behind other server
SAPcpmsUsageUploader.upload(to: <#myCustomServerURL#>, sapURLSession: <#mySAPURLSession#>)
{ result in
    // handle result of upload
}

Usage component Logger ID

This component uses the following name prefix for logging: ‘SAP.Foundation.Usage’

  • Errors the LocationCollector could encounter.

    • Singleton not initializated properly.
    See more

    Declaration

    Swift

    public enum LocationCollectorError : Error
  • This component is capable of collecting and uploading usage records to SAPcpms server (or custom endpoint).

    See more

    Declaration

    Swift

    public class SAPcpmsUsageUploader
  • High-level wrapper around Usage API implemented as a singleton to encapsulate lifecycle events (optional sessions), and uploading of usage event logs.

    See more

    Declaration

    Swift

    open class UsageBroker
  • Enumeration to describe the errors of the UsageBroker.

    See more

    Declaration

    Swift

    public enum UsageBrokerError : Error
  • A representation of the UsageStore narrowed down to a target identigier. One can obtain an instance of this class by calling the snapshot(for:) method of the UsageStore object.

    See more

    Declaration

    Swift

    public class UsageSnapshot : UsageSnapshotting
  • The store implementation to store and read usage records.

    See more

    Declaration

    Swift

    public class UsageStore : UsageStoring