AppMetricaReporting protocol

Instance methods

clearAppEnvironment()

Deleting all key-value data associated with all future events.

pauseSession()

Pauses the user session.

reportAdRevenue(_:onFailure:)

Sends information about advertising revenue to the AppMetrica server.

reportECommerce(_:onFailure)

Sends a message about an E-commerce event.

reportEvent(name:onFailure)

Sends an arbitrary event message.

reportEvent(name:parameters:onFailure)

Sends an arbitrary event message with additional parameters.

reportRevenue(_:onFailure:)

Sends information about the purchase to the AppMetrica server.

reportUserProfile(_:onFailure)

Sends information about a user profile update.

resumeSession()

Resumes the session, or creates a new one if the session timeout has expired.

sendEventsBuffer()

Sends stored events from the buffer.

setAppEnvironment(_:forKey:)

Sets a key-value pair associated with all future events.

setDataSendingEnabled(_:)

Enables/disables sending statistics to the AppMetrica server.

setupWebViewReporting(with:onFailure:)

Adds a JavaScript interface with the AppMetrica name in a window to the specified WebView. This lets you send client events from JavaScript code.

Properties

userProfileID

Sets the ID of the user profile.

Method descriptions

clearAppEnvironment()

func clearAppEnvironment()

Cleaning the app environment, such as deleting all key-value data associated with all future events.

pauseSession()

func pauseSession()

Pauses the user session.

reportAdRevenue(_:onFailure)

func reportAdRevenue(_ adRevenue: AdRevenueInfo, onFailure: ((Error) -> Void)?)

Sends information about advertising revenue to the AppMetrica server.

Parameters:

adRevenue

The instance of the AdRevenueInfo class which contains information about advertising revenue.

onFailure

The block that is executed when an error occurs. The error is passed as a block argument.

reportECommerce(_:onFailure)

func reportECommerce(_ eCommerce: ECommerce, onFailure: ((Error) -> Void)?)

Sends a message about an E-commerce event.

Parameters:

eCommerce

The ECommerce class instance.

onFailure

The block that is executed when an error occurs. The error is passed as a block argument.

reportEvent(name:onFailure)

func reportEvent(name: String, onFailure: ((Error) -> Void)?)

Sends a custom event message.

Parameters:

name

Short name or description of the event.

onFailure

The block that is executed when an error occurs. The error is passed as a block argument.

reportEvent(name:parameters:onFailure)

func reportEvent(name: String, parameters: [AnyHashable : Any]?, onFailure: ((Error) -> Void)?)

Sends a custom event message with additional parameters.

Parameters:

name

Short name or description of the event.

parameters

Parameters as key-value pairs.

onFailure

The block that is executed when an error occurs. The error is passed as a block argument.

reportRevenue(_:onFailure:)

func reportRevenue(_ revenueInfo: RevenueInfo, onFailure: ((Error) -> Void)?)

Sends information about the purchase to the AppMetrica server.

Parameters:

revenueInfo

The instance of the RevenueInfo class which contains information about a purchase.

onFailure

The block that is executed when an error occurs. The error is passed as a block argument.

reportUserProfile(_:onFailure)

func reportUserProfile(_ userProfile: UserProfile, onFailure: ((Error) -> Void)?)

Sends information about the user profile update to the AppMetrica server.

Parameters:

userProfile

The instance of the UserProfile class which contains information about the user profile.

onFailure

The block that is executed when an error occurs. The error is passed as a block argument.

resumeSession()

func resumeSession()

Resumes the session, or creates a new one if the session timeout has expired.

sendEventsBuffer()

func sendEventsBuffer()

Sends stored events from the buffer.

AppMetrica SDK does not send an event immediately after it occurred. The library stores event data in the buffer. The +sendEventsBuffer method sends data from the buffer and flushes it. Use the method to force sending stored events after passing important checkpoints of user scenarios.

Alert

Frequent use of the method can lead to increased outgoing internet traffic and energy consumption.

setAppEnvironment(_:forKey:)

func setAppEnvironment(_ value: String?, forKey: String)

Setting key-value data to be used as additional information associated with all future events.

If the value is zero, the previously set key value is deleted. Nothing is done if the key wasn't added.

Parameters:

value

Value.

key

Key.

setDataSendingEnabled(_:)

func setDataSendingEnabled(_ enabled: Bool)

Enables/disables sending statistics to the AppMetrica server.

Note

Disable sending statistics to the reporter does not affect the sending of data from the main API key. But disabling data sending for the main API key stops sending statistics from all reporters.

Parameters:

enabled

A flag indicating that sending statistics is enabled. The default value is true. Possible values:

  • true: Sending statistics is enabled.
  • false: Sending statistics is disabled.

setupWebViewReporting(with:onFailure:)

class func setupWebViewReporting(with: JSControlling, onFailure: ((Error) -> Void)?)

Adds a JavaScript interface with the AppMetrica name in a window to the specified webview. This lets you send client events from JavaScript code.

Notes:

  • The method must be called from the main queue.
  • The method is not available on tvOS.
  • Call this method before loading any content. We recommend calling this method before creating a webview and before adding your scripts to WKUserContentController. For more information, see Usage examples.

Parameters:

controller

The JSControlling instance.

onFailure

A callback method to be called in the event of an error.

Property descriptions

userProfileID

var userProfileID: String { get; set; }

Sets the ID of the user profile. AppMetrica doesn't display predefined attributes in the web interface if ProfieId sending isn't configured.