TopsortSDK
public final class TopsortSDK
Overview
The Topsort Analytics SDK for iOS is a utilty library for logging events to Topsort’s Events API.
Copyright
2022 - Topsort-
A completion function for handling EventResponse
Declaration
Swift
public typealias Completion = (_ data: EventResponse?, _ error: Error?) -> Void
-
Declaration
Swift
public init(url: String, apiKey: String)
Parameters
url
Your marketplace’s auction engine endpoint
apiKey
Your marketplace API Key
-
Sends an impressions event to Topsort’s API
An impression is any product that has been rendered on screen. Therefore this method should be called as soon as the product is rendered on the screen.
Declaration
Swift
@available(iOS, deprecated: 13.0.0, renamed: "logImpressionsAsync", message: "Please use the new Async API") @discardableResult public func logImpressions(impressions: [Impression], completion: @escaping Completion) -> RequestTask
Parameters
impressions
List of impressions that have been recorded in one render.
completion
A completion function that receives the EventResponse, or an error.
Return Value
A cancelable async task.
-
logImpressionsAsync(impressions:
Asynchronous) Sends an impressions event to Topsort’s API
An impression is any product that has been rendered on screen. Therefore this method should be called as soon as the product is rendered on the screen.
Throws
Declaration
Swift
@available(iOS 13.0.0, *) @discardableResult public func logImpressionsAsync(impressions: [Impression]) async throws -> EventResponse
Parameters
impressions
List of impressions that have been recorded in one render.
Return Value
an EventResponse
-
Sends a hit event to Topsort’s API
A hit is any user triggered event (a tap, or a click) that the user makes on a product on your marketplace, sponsored or not.
Declaration
Swift
@available(iOS, deprecated: 13.0.0, renamed: "logHitAsync", message: "Please use the new Async API") @discardableResult public func logHit(hit: HitEvent, completion: @escaping Completion) -> RequestTask
Parameters
hit
A Hit struct that contains a Session, the product ID, a placement on the App.
completion
A Completion function that receives the EventResponse, or an error.
Return Value
A cancelable async task.
-
logHitAsync(hit:
Asynchronous) Sends a hit event to Topsort’s API
A hit is any user triggered event (a tap, or a click) that the user makes on a product on your marketplace, sponsored or not.
Throws
TopsortError
.Declaration
Swift
@available(iOS 13.0.0, *) @discardableResult public func logHitAsync(hit: HitEvent) async throws -> EventResponse
Parameters
hit
A Hit struct that contains a Session, the product ID, a placement on the App.
Return Value
an EventResponse
-
Sends a purchase event to Topsort’s API
A purchase should be generated when a user completes a transaction to buy any number of products.
Declaration
Swift
@available(iOS, deprecated: 13.0.0, renamed: "logPurchaseAsync", message: "Please use the new Async API") @discardableResult public func logPurchase(purchase: PurchaseEvent, completion: @escaping Completion) -> RequestTask
Parameters
purchase
A
PurchaseEvent
struct that contains a Session, the list product IDs.completion
A Completion function that receives the
EventResponse
, or an error.Return Value
A cancelable async task.
-
logPurchaseAsync(purchase:
Asynchronous) Sends a hit event to Topsort’s API as a click.
A hit is any user triggered event (a tap, or a gesture) that the user makes on a product on your marketplace, sponsored or not.
Throws
Declaration
Swift
@available(iOS 13.0.0, *) @discardableResult public func logPurchaseAsync(purchase: PurchaseEvent) async throws -> EventResponse
Parameters
purchase
A
PurchaseEvent
struct that contains a Session, the list product IDs.Return Value