CleanInsightsSDK Documentation Beta

Class Clean​Insights

@objc open class CleanInsights: NSObject
CleanInsights CleanInsights NSObject NSObject CleanInsights->NSObject

Conforms To

NSObject

Initializers

init(configuration:​store:​consents​File:​)

@objc public init(configuration: Configuration, store: Store, consentsFile: URL? = nil)

Parameters

configuration Configuration

The Configuration provided as a Configuration object.

store Store

Your implementation of a Store.

consents​File URL?

A file where only the consents are stored. Useful to import consents in extensions. See #storeConsents:to

init(configuration:​storage​Dir:​consents​File:​)

@objc public convenience init(configuration: Configuration, storageDir: URL? = nil, consentsFile: URL? = nil)

Parameters

configuration Configuration

The Configuration provided as a Configuration object.

storage​Dir URL?

The location where to read and persist accumulated data. OPTIONAL. Defaults to the app's Application Support directory on MacOS or its Documents directory elsewhere.

consents​File URL?

A file where only the consents are stored. Useful to import consents in extensions. See #storeConsents:to

init(json​Configuration​File:​storage​Dir:​consents​File:​)

@objc public convenience init(jsonConfigurationFile: URL, storageDir: URL? = nil, consentsFile: URL? = nil) throws

Parameters

json​Configuration​File URL

The Configuration provided as a URL to a JSON file which can be deserialized to a Configuration object.

storage​Dir URL?

The location where to read and persist accumulated data. OPTIONAL. Defaults to the app's Documents directory.

consents​File URL?

A file where only the consents are stored. Useful to import consents in extensions. See #storeConsents:to

init(json​Configuration​File:​store:​consents​File:​)

@objc public convenience init(jsonConfigurationFile: URL, store: Store, consentsFile: URL? = nil) throws

Parameters

json​Configuration​File URL

The Configuration provided as a URL to a JSON file which can be deserialized to a Configuration object.

store Store

Your implementation of a Store.

consents​File URL?

A file where only the consents are stored. Useful to import consents in extensions. See #storeConsents:to

Properties

conf

let conf: Configuration

The used configuration.

feature​Consents​Count

var featureConsentsCount: Int

campaign​Consents​Count

var campaignConsentsCount: Int

Methods

measure(visit:​for​Campaign:​)

@objc public func measure(visit scenePath: [String], forCampaign campaignId: String)

Track a scene visit.

Parameters

scene​Path [String]

A hierarchical path best describing the structure of your scenes. E.g. ['Main', 'Settings', 'Some Setting'].

campaign​Id String

The campaign ID as per your configuration, where this measurement belongs to.

measure(event:​_:​for​Campaign:​name:​)

@objc @available(*, unavailable) public func measure(event category: String, _ action: String, forCampaign campaignId: String, name: String? = nil)

Track an event.

Parameters

category String

The event category. Must not be empty. (eg. Videos, Music, Games...)

action String

The event action. Must not be empty. (eg. Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)

campaign​Id String

The campaign ID as per your configuration, where this measurement belongs to.

name String?

The event name. OPTIONAL.

measure(event:​_:​for​Campaign:​name:​value:​)

@objc @available(*, unavailable) public func measure(event category: String, _ action: String, forCampaign campaignId: String, name: String? = nil, value: Double)

Track an event.

Parameters

category String

The event category. Must not be empty. (eg. Videos, Music, Games...)

action String

The event action. Must not be empty. (eg. Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)

campaign​Id String

The campaign ID as per your configuration, where this measurement belongs to.

name String?

The event name. OPTIONAL.

value Double

The event value. OPTIONAL.

measure(event:​_:​for​Campaign:​name:​value:​)

public func measure(event category: String, _ action: String, forCampaign campaignId: String, name: String? = nil, value: Double? = nil)

Track an event.

Parameters

category String

The event category. Must not be empty. (eg. Videos, Music, Games...)

action String

The event action. Must not be empty. (eg. Play, Pause, Duration, Add Playlist, Downloaded, Clicked...)

campaign​Id String

The campaign ID as per your configuration, where this measurement belongs to.

name String?

The event name. OPTIONAL.

value Double?

The event value. OPTIONAL.

get​Feature​Consent(by​Index:​)

@objc public func getFeatureConsent(byIndex index: Int) -> FeatureConsent?

get​Campaign​Consent(by​Index:​)

@objc public func getCampaignConsent(byIndex index: Int) -> CampaignConsent?

grant(feature:​)

@objc @discardableResult public func grant(feature: Feature) -> FeatureConsent

deny(feature:​)

@objc @discardableResult public func deny(feature: Feature) -> FeatureConsent

grant(campaign:​)

@objc @discardableResult public func grant(campaign campaignId: String) -> CampaignConsent?

deny(campaign:​)

@objc @discardableResult public func deny(campaign campaignId: String) -> CampaignConsent?

is​Campaign​Currently​Granted(_:​)

@objc public func isCampaignCurrentlyGranted(_ campaignId: String) -> Bool

request​Consent(for​Campaign:​_:​_:​)

@objc public func requestConsent(forCampaign campaignId: String, _ consentRequestUi: ConsentRequestUi, _ completed: ConsentRequestUi.Complete? = nil)

request​Consent(for​Feature:​_:​_:​)

@objc public func requestConsent(forFeature feature: Feature, _ consentRequestUi: ConsentRequestUi, _ completed: ConsentRequestUi.Complete? = nil)

store​Consents(to:​)

@objc public func storeConsents(to file: URL)

Store consents to a file, so you can share it with an app extension or a watchOS app.

Parameters

file URL

The location to store to. Possibly in an app group container, so extensions can read it.

load​Consents(from:​)

@objc public func loadConsents(from file: URL)

test​Server(_:​)

public func testServer(_ done: ((Error?) -> Void)? = nil)

Sends an empty body to the server for easy debugging of server-related issues like TLS and CORS problems.

DON'T LEAVE THIS IN PRODUCTION, once you're done fixing any server issues. There's absolutely no point in pinging the server with this all the time and it will undermine your privacy promise to your users!

Parameters

done ((Error?) -> Void)?

Callback, when the operation is finished, either successfully or not. OPTIONAL

persist()

@objc public func persist()

Persist accumulated data to the filesystem.

The app should call this on applicationDidEnterBackground:.