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 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’
-
Declaration
Swift
public extension SAPcpmsRecord
-
Declaration
Swift
public extension SAPcpmsUsage
-
This component is capable of collecting and uploading usage records to SAPcpms server (or custom endpoint).
See moreDeclaration
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 moreDeclaration
Swift
open class UsageBroker
-
Enumeration to describe the errors of the UsageBroker.
See moreDeclaration
Swift
public enum UsageBrokerError : Error
extension UsageBrokerError: SAPError
-
Definition of categories of data to collect.
See moreDeclaration
Swift
public struct UsageDataCollectionItems : OptionSet
-
A representation of the UsageStore narrowed down to a target identigier. One can obtain an instance of this class by calling the
See moresnapshot(for:)
method of the UsageStore object.Declaration
Swift
public class UsageSnapshot : UsageSnapshotting
-
The store implementation to store and read usage records.
See moreDeclaration
Swift
public class UsageStore : UsageStoring