Migrating to version 5.0.0
When you migrate your app from YandexMobileMetrica
to AppMetrica
, the main IDs and data are preserved. That means the transition to the new version should not result in issues or anomalies in the reports.
To migrate to the new version, follow these steps:
- Replace dependencies. The required changes are provided in the dependency renaming section.
- Make sure you're not using 2 AppMetrica SDK versions in parallel.
- Import dependencies in the code. The required changes are provide in the dependency importing section.
- In the project code, replace the classes and methods that were simply renamed. The required changes are provided in the API renaming section.
- Switch to the new API to send errors using the instructions.
- Temporarily comment out the code with the other errors to ensure that the project can be built.
- Edit the code you commented out by following the other paragraphs in this guide. If you have any questions, contact support.
Renamed dependencies
pod 'YandexMobileMetrica', '~> 4.0'
Replace with:
pod 'AppMetricaAnalytics', '~> 5.0.0'
The AppMetrica SDK consists of multiple modules. This enables you to connect only the features you need. When AppMetricaAnalytics
is connected, all modules are connected as well. For more detailed information about setting up, see the integration section.
If dependencies are set via Xcode
-
Delete the
metrika-sdk-ios
dependency. -
In the Xcode Project Navigator window, select your project (if Workspace is used). In the top menu, click File and select Add Package Dependencies....
-
Specify the repository URL
https://github.com/appmetrica/appmetrica-sdk-ios
. -
Leave only the required modules (to disable a module, select
None
inAdd to Target
):AppMetricaCore
: The mandatory main SDK module. It must be connected for working with AppMetrica.AppMetricaAdSupport
: The module is used to collect IDs, including IDFA.AppMetricaCrashes
: The module is intended for detecting crashes and sending errors.AppMetricaWebKit
: The module enables you to send events from JavaScript code in WebView.
When using the Package.swift manifest
-
Delete the
.package
dependency withYandexMobileMetrica
from the filePackage.swift
in your project together with all references to the dependencies in thetargets:
section within your project. -
Insert the following code to add the new
appmetrica-sdk-ios
dependency:dependencies: [ .package( name: "AppMetrica", url: "https://github.com/appmetrica/appmetrica-sdk-ios", .upToNextMinor(from: "5.0.0") ), ],
-
Add the required modules to your project's targets.
AppMetricaCore
: The mandatory main SDK module. It must be connected for working with AppMetrica.AppMetricaAdSupport
: The module is used to collect IDs, including IDFA.AppMetricaCrashes
: The module is intended for detecting crashes and sending errors.AppMetricaWebKit
: The module enables you to send events from JavaScript code in WebView.
.target( name: "MyTargetName", dependencies: [ .product(name: "AppMetricaCore", package: "AppMetrica"), .product(name: "AppMetricaCrashes", package: "AppMetrica"), .product(name: "AppMetricaWebKit", package: "AppMetrica"), // .product(name: "AppMetricaAdSupport", package: "AppMetrica"), // This module is disabled ] ),
Running two versions of AppMetrica SDK in parallel
We renamed the group and main artifacts. As a result, you can use two AppMetrica SDK versions in a single app in parallel: AppMetrica version 4 and lower (YandexMobileMetrica
) and version 5 and higher (AppMetrica
). This situation is not desirable and may occur only under certain conditions.
1. The app's dependencies include dependencies on two different AppMetrica SDK versions.
Alert
We strongly advise against simultaneously running YandexMobileMetrica
and AppMetrica
with the same API key
in the app code. In other words, you can't use the same API key
to enable both YandexMetrica
and AppMetrica
at the same time. While that won't cause crashes or failures in the app, it will distort and disrupt the statistics. When migrating to AppMetrica
, make sure the app doesn't have the YandexMobileMetrica
dependency.
2. One of the app's dependencies transitively depends on the AppMetrica SDK.
If the app and libraries use different API keys
, this situation is acceptable but not desirable. The statistics should be collected normally, though minor deviations are possible. In that case, the app size might increase slightly since it will include two SDKs instead of one.
How to make sure that YandexMobileMetrica isn't used
Open Podfile.lock
and search YandexMobileMetrica
.
Using the PODS
block in Podfile.lock
, you can understand which dependency refers to YandexMobileMetrica
.
PODS:
...
YandexMobileAds (6.4.0):
- DivKit (= 28.13.0)
- YandexMobileMetrica (< 5.0.0, >= 4.0.0)
...
If dependencies are set via Xcode
Open the project in Xcode. Make sure that Package Dependencies
don't contain YandexMobileMetrica
.
When using the Package.swift manifest
If your project uses the Package.swift manifest to manage dependencies, execute the swift package show-dependencies
command in the terminal in your project's directory. This will output a list of all project dependencies, including transitive ones.
.
└── yandex-ads-sdk-ios<https://github.com/yandexmobile/yandex-ads-sdk-ios.git@6.4.0>
├── metrica-sdk-ios<https://github.com/yandexmobile/metrica-sdk-ios@4.5.2>
└── divkit-ios<https://github.com/divkit/divkit-ios@28.13.0>
└── vgsl<https://github.com/yandex/vgsl.git@2.4.1>
You can also check the Package.resolved
file for the YandexMobileMetrica
dependency.
{
"object": {
"pins": [
//...
{
"package": "YandexMobileMetrica",
"repositoryURL": "https://github.com/yandexmobile/metrica-sdk-ios",
"state": {
"branch": null,
"revision": "13d8b11181a33938ef42759d49466a621df5e7db",
"version": "4.5.2"
}
},
//...
]
},
// ...
}
Importing dependencies
import YandexMobileMetrica
Replace with:
import AppMetricaCore
import AppMetricaCrashes // if you need to work with errors/crashes
import AppMetricaWebKit // if you need to set up event sending from WebView
#import <YandexMobileMetrica/YandexMobileMetrica.h>
Replace with:
#import <AppMetricaCore/AppMetricaCore.h>
#import <AppMetricaCrashes/AppMetricaCrashes.h> // if you need to work with errors/crashes
#import <AppMetricaWebKit/AppMetricaWebKit.h> // if you need to set up event sending from WebView
Renaming the API
Removed the YMM
prefix.
- Renamed the
YMMYandexMetrica
interface toAppMetrica
.- Renamed the
handleOpen(_:)
method totrackOpeningURL(_:)
. - Renamed the
initWebViewReporting(_:onFailure:)
method tosetupWebViewReporting(with:onFailure:)
. For more information, see Sending an event from the WebView's JavaScript code. - Removed the
libraryVersion()
method, use thelibraryVersion
property. - Renamed the
report(adRevenue:onFailure:)
method toreportAdRevenue(_:onFailure)
. - Renamed the
report(eCommerce:onFailure:)
method toreportECommerce(_:onFailure:)
. - Moved the
report(error:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(error:options:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:options:onFailure:)
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Removed the
reportError(_:exception:onFailure:)
method, see Working with crashes and errors. - Renamed the
reportEvent(_:onFailure:)
method toreportEvent(name:onFailure)
. - Renamed the
reportEvent(_:parameters:onFailure:)
method toreportEvent(name:parameters:onFailure)
. - Removed the
reportReferralUrl(_:)
method. - Renamed the
reporterForApiKey(_:)
method toreporter(for:)
. - Removed the
requestAppMetricaDeviceID(withCompletionQueue:completionBlock:)
method, userequestStartupIdentifiers(for:on:completion:)
. - Removed the
setErrorEnvironmentValue(_:forKey:)
method, useAppMetricaCrashes.crashes().set(errorEnvironmentValue: value, forKey: key)
. - Removed the
setLocation(_:)
method, use thecustomLocation
property. - Removed the
setLocationTracking(_:)
method, use theisLocationTrackingEnabled
property. - Renamed the
setStatisticsSending(_:)
method tosetDataSendingEnabled(_:)
. - Removed the
setUserProfileID(_:)
method, use theuserProfileID
property.
- Renamed the
- Renamed the
YMMYandexMetricaConfiguration
interface toAppMetricaConfiguration
- Removed the
appForKids
property, see Using the SDK for children's apps. - Removed the
crashReporting
property, see Working with crashes and errors. - Renamed the
location
property tocustomLocation
. - Renamed the
logs
property toareLogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Removed the
- Renamed the
YMMYandexMetricaPreloadInfo
interface toAppMetricaPreloadInfo
.- Renamed the
setAdditional(_:forKey:)
method tosetAdditional(info:forKey:)
.
- Renamed the
Reporter
- Renamed the
YMMMutableReporterConfiguration
interface toMutableReporterConfiguration
.- Renamed the
logs
property toareLogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Renamed the
YMMPluginErrorDetails
interface toPluginErrorDetails
. - Renamed the
YMMReporterConfiguration
interface toReporterConfiguration
.- Renamed the
logs
property toareLogsEnabled
. - Renamed the
statisticsSending
property asdataSendingEnabled
.
- Renamed the
- Added the
AppMetricaCrashesConfiguration
interface. - Renamed the
YMMStackTraceElement
interface toStackTraceElement
. - Renamed the
YMMYandexMetricaPlugins
interface toAppMetricaPlugins
.- Renamed the
getPluginExtension
method topluginExtension
.
- Renamed the
- Added the
AppMetricaCrashes
interface.- Added the
-clearErrorEnvironment:
method. - Added the
-enableANRMonitoring:
method. - Added the
-enableANRMonitoringWithWatchdogInterval:pingInterval:
method. - Added the
-requestCrashReportingStateWithCompletionQueue:completionBlock:
method. - Added the
-setErrorEnvironmentValue:forKey:
method.
- Added the
- Renamed the
YMMYandexMetricaPluginReporting
protocol toAppMetricaPluginReporting
.- Renamed the
getPluginExtension
method topluginExtension
.
- Renamed the
- Renamed the
YMMYandexMetricaReporting
protocol toAppMetricaReporting
.- Renamed the
report(adRevenue:onFailure:)
method toreportAdRevenue(_:onFailure)
. - Renamed the
report(eCommerce:onFailure:)
method toreportECommerce(_:onFailure:)
. - Moved the
report(error:onFailure:)
method to theAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(error:options:onFailure:)
method to theAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:onFailure:)
method to theAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
report(nserror:options:onFailure:)
method to theAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
reportEvent(_:onFailure:)
method toreportEvent(name:onFailure)
. - Renamed the
reportEvent(_:parameters:onFailure:)
method toreportEvent(name:parameters:onFailure)
. - Renamed the
setStatisticsSending(_:)
method tosetDataSendingEnabled(_:)
. - Removed the
setUserProfileID(_:)
method, use theuserProfileID
property.
- Renamed the
- Renamed the
kYMMPlatformNative
constant toPlatformNative
. - Renamed the
kYMMPlatformFlutter
constant toPlatformFlutter
. - Added the
CrashReportingStateKey.enabledKey
constant. - Added the
CrashReportingStateKey.crashedLastLaunchKey
constant.
User attributes
- Renamed the
YMMMutableUserProfile
interface toMutableUserProfile
. - Renamed the
YMMProfileAttribute
interface toProfileAttribute
. - Renamed the
YMMUserProfile
interface toUserProfile
. - Renamed the
YMMGenderType
enumeration toGenderType
. - Renamed the
YMMBirthDateAttribute
protocol toBirthDateAttribute
. - Renamed the
YMMCustomBoolAttribute
protocol toCustomBoolAttribute
. - Renamed the
YMMCustomCounterAttribute
protocol toCustomCounterAttribute
. - Renamed the
YMMCustomNumberAttribute
protocol toCustomNumberAttribute
. - Renamed the
YMMCustomStringAttribute
protocol toCustomStringAttribute
. - Renamed the
YMMGenderAttribute
protocol toGenderAttribute
. - Renamed the
YMMNameAttribute
protocol toNameAttribute
. - Renamed the
YMMNotificationsEnabledAttribute
protocol toNotificationsEnabledAttribute
.
Errors
- Renamed the
YMMError
interface toAppMetricaError
and moved it to theAppMetricaCrashes
module. - Renamed the
YMMBacktraceErrorKey
constant toBacktraceErrorKey
and moved it to theAppMetricaCrashes
module. - Renamed the
YMMErrorReportingOptions
enumeration asErrorReportingOptions
and moved it to theAppMetricaCrashes
module. - Renamed the
YMMErrorRepresentable
protocol toErrorRepresentable
and moved it to theAppMetricaCrashes
module.
AdRevenue
- Renamed the
YMMAdRevenueInfo
interface toAdRevenueInfo
. - Renamed the
YMMMutableAdRevenueInfo
interface toMutableAdRevenueInfo
. - Renamed the
YMMAdType
enumeration toAdType
.
ECommerce
- Renamed the
YMMECommerceAmount
interface toECommerceAmount
. - Renamed the
YMMECommerceCartItem
interface toECommerceCartItem
. - Renamed the
YMMECommerceOrder
interface toECommerceOrder
. - Renamed the
YMMECommercePrice
interface toECommercePrice
. - Renamed the
YMMECommerceProduct
interface toECommerceProduct
. - Renamed the
YMMECommerceReferrer
interface toECommerceReferrer
. - Renamed the
YMMECommerceScreen
interface toECommerceScreen
. - Renamed the
YMMECommerce
interface toECommerce
.
Revenue
- Renamed the
YMMMutableRevenueInfo
interface toMutableRevenueInfo
. - Renamed the
YMMRevenueInfo
interface toRevenueInfo
.- Removed the
init(price:currency:)
constructor, useinit(priceDecimal:currency)
. - Removed the
init(price:currency:quantity:productID:transactionID:receiptData:payload:)
constructor, useinit(priceDecimal:currency:quantity:productID:transactionID:receiptData:payload:)
.
- Removed the
Changed the YMM
prefix to AMA
.
- Renamed the
YMMYandexMetrica
interface toAMAAppMetrica
.- Renamed the
-getPluginExtension:
method to-pluginExtension:
and moved it to theAMAAppMetricaCrashes
class. - Renamed the
+handleOpenURL:
method to+trackOpeningURL:
. - Renamed the
+initWebViewReporting:onFailure:
method to+setupWebViewReporting:onFailure:
. For more information, see Sending an event from the WebView's JavaScript code. - Removed the
+libraryVersion:
method, use thelibraryVersion
property. - Removed the
+reportError:exception:onFailure:
method, see Working with crashes and errors. - Moved the
+reportError:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportError:options:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
+reportEvent:params:onFailure:
method to+reportEvent:parameters:onFailure:
- Moved the
+reportNSError:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportNSError:options:onFailure:
method to theAppMetricaCrashes
class and theAppMetricaCrashes
module, see Working with crashes and errors. - Removed the
+reportReferralUrl:
method. - Renamed the
+reporterForApiKey:
method to+reporterForAPIKey:
. - Removed the
+requestAppMetricaDeviceIDWithCompletionQueue:
method, use+requestStartupIdentifiersWithKeys:completionQueue:completionBlock:
. - Removed the
+setErrorEnvironmentValue:forKey:
method, use[[AMAAppMetricaCrashes crashes] setErrorEnvironmentValue:value forKey:key]
. - Removed the
+setLocation:
method, use thecustomLocation
property. - Removed the
+setLocationTracking:
method, use thelocationTrackingEnabled
property. - Renamed the
+setStatisticsSending:
method as+setDataSendingEnabled:
. - Removed the
+setUserProfileID:
method, use theuserProfileID
property.
- Renamed the
- Renamed the
YMMYandexMetricaConfiguration
interface toAMAAppMetricaConfiguration
.- Renamed the
-initWithApiKey:
constructor as-initWithAPIKey:
. - Renamed the
apiKey
property toAPIKey
. - Removed the
appForKids
property, see Using the SDK for children's apps. - Removed the
crashReporting
property, see Working with crashes and errors. - Renamed the
location
property tocustomLocation
. - Renamed the
logs
property aslogsEnabled
. - Renamed the
statisticsSending
property todataSendingEnabled
.
- Renamed the
- Renamed the
YMMYandexMetricaPreloadInfo
interface toAMAAppMetricaPreloadInfo
.
Reporter
- Renamed the
YMMMutableReporterConfiguration
interface toAMAMutableReporterConfiguration
.- Renamed the
logs
property tologsEnabled
. - Renamed the
statisticsSending
property todataSendingEnabled
.
- Renamed the
- Renamed the
YMMPluginErrorDetails
interface toAMAPluginErrorDetails
. - Renamed the
YMMReporterConfiguration
interface toAMAReporterConfiguration
.- Renamed the
-initWithApiKey:
constructor to-initWithAPIKey:
. - Renamed the
apiKey
property toAPIKey
. - Renamed the
logs
property tologsEnabled
. - Renamed the
statisticsSending
property todataSendingEnabled
.
- Renamed the
- Added the
AMAAppMetricaCrashesConfiguration
interface. - Renamed the
YMMStackTraceElement
interface toAMAStackTraceElement
. - Renamed the
YMMYandexMetricaPlugins
interface toAMAAppMetricaPlugins
.- Renamed the
getPluginExtension
method topluginExtension
.
- Renamed the
- Added the
AMAAppMetricaCrashes
interface.- Added the
-clearErrorEnvironment:
method. - Added the
-enableANRMonitoring:
method. - Added the
-enableANRMonitoringWithWatchdogInterval:pingInterval:
method. - Added the
-requestCrashReportingStateWithCompletionQueue:completionBlock:
method. - Added the
-setErrorEnvironmentValue:forKey:
method.
- Added the
- Renamed the
YMMYandexMetricaPluginReporting
protocol toAMAAppMetricaPluginReporting
.- Renamed the
getPluginExtension
method topluginExtension
.
- Renamed the
- Renamed the
YMMYandexMetricaReporting
protocol toAMAAppMetricaReporting
.- Moved the
+reportError:onFailure:
method to theAMAAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportError:options:onFailure:
method to theAMAAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
+reportEvent:params:onFailure:
method to+reportEvent:parameters:onFailure:
. - Moved the
+reportNSError:onFailure:
method to theAMAAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Moved the
+reportNSError:options:onFailure:
method to theAMAAppMetricaCrashReporting
protocol, theAppMetricaCrashes
class, and theAppMetricaCrashes
module, see Working with crashes and errors. - Renamed the
+setStatisticsSending:
method to+setDataSendingEnabled:
.
- Moved the
- Renamed the
kYMMPlatformNative
constant tokAMAPlatformNative
. - Renamed the
kYMMPlatformFlutter
constant tokAMAPlatformFlutter
. - Added the
kAMACrashReportingStateCrashedLastLaunchKey
constant starting from version 5.4.0. - Added the
kAMACrashReportingStateEnabledKey
constant starting from version 5.4.0.
User attributes
- Renamed the
YMMMutableUserProfile
interface toAMAMutableUserProfile
. - Renamed the
YMMProfileAttribute
interface toAMAProfileAttribute
. - Renamed the
YMMUserProfile
interface toAMAUserProfile
. - Renamed the
YMMGenderType
enumeration toAMAGenderType
. - Renamed the
YMMBirthDateAttribute
protocol toAMABirthDateAttribute
. - Renamed the
YMMCustomBoolAttribute
protocol toAMACustomBoolAttribute
. - Renamed the
YMMCustomCounterAttribute
protocol toAMACustomCounterAttribute
. - Renamed the
YMMCustomNumberAttribute
protocol toAMACustomNumberAttribute
. - Renamed the
YMMCustomStringAttribute
protocol toAMACustomStringAttribute
. - Renamed the
YMMGenderAttribute
protocol toAMAGenderAttribute
. - Renamed the
YMMNameAttribute
protocol toAMANameAttribute
. - Renamed the
YMMNotificationsEnabledAttribute
protocol toAMANotificationsEnabledAttribute
.
Errors
- Renamed the
YMMError
interface toAMAError
. - Renamed the
YMMBacktraceErrorKey
constant toAMABacktraceErrorKey
. - Renamed the
YMMErrorReportingOptions
enumeration toAMAErrorReportingOptions
. - Renamed the
YMMErrorRepresentable
protocol toAMAErrorRepresentable
.
AdRevenue
- Renamed the
YMMAdRevenueInfo
interface toAMAAdRevenueInfo
. - Renamed the
YMMMutableAdRevenueInfo
interface toAMAMutableAdRevenueInfo
. - Renamed the
YMMAdType
enumeration toAMAAdType
.
ECommerce
- Renamed the
YMMECommerceAmount
interface toAMAECommerceAmount
. - Renamed the
YMMECommerceCartItem
interface toAMAECommerceCartItem
. - Renamed the
YMMECommerceOrder
interface toAMAECommerceOrder
. - Renamed the
YMMECommercePrice
interface toAMAECommercePrice
. - Renamed the
YMMECommerceProduct
interface toAMAECommerceProduct
. - Renamed the
YMMECommerceReferrer
interface toAMAECommerceReferrer
. - Renamed the
YMMECommerceScreen
interface toAMAECommerceScreen
. - Renamed the
YMMECommerce
interface toAMAECommerce
.
Revenue
- Renamed the
YMMMutableRevenueInfo
interface toAMAMutableRevenueInfo
. - Renamed the
YMMRevenueInfo
interface toAMARevenueInfo
.- Removed the
-initWithPrice:currency:
constructor, use-initWithPriceDecimal:currency:
. - Removed the
-initWithPrice:currency:quantity:productID:transactionID:receiptData:payload:
constructor, use-initWithPriceDecimal:currency:quantity:productID:transactionID:receiptData:payload:
.
- Removed the
Working with crashes and errors
The API for working with errors is now in the AppMetricaCrashes
module. If you're connecting AppMetricaAnalytics
, you don't need to connect AppMetricaCrashes
separately, because the module is included in AppMetricaAnalytics
.
Add the import to all files where you use crash or error API resources:
import AppMetricaCrashes
The crash sending logic is defined with the AppMetricaCrashesConfiguration
class:
var configuration = AppMetricaCrashesConfiguration()
configuration.autoCrashTracking = true // If this parameter is enabled, crashes are automatically sent to AppMetrca
configuration.probablyUnhandledCrashReporting = true // Use this parameter to enable or disable tracking of implicit failures, such as OOM crashes
configuration.ignoredCrashSignals = [] // This setting enables you to specify an array of UNIX signals from sys/signal.h that will be ignored by the failure tracking system
configuration.applicationNotRespondingDetection = true // This setting includes detecting situations when the main app thread stops responding (ANR)
configuration.applicationNotRespondingWatchdogInterval = 4.0 // Sets the time interval that the watchdog will wait before reporting the "Application Not Responding" status (ANR)
configuration.applicationNotRespondingPingInterval = 0.1 // Sets the frequency at which watchdog will check the "Application Not Responding" status (ANR)
AppMetricaCrashes.crashes().setConfiguration(configuration)
To send errors, use methods of the AppMetricaCrashes
class. Their signature matches that of similar methods from YMMYandexMetrica
, so all you need to do is replace YMMYandexMetrica
with AppMetricaCrashes.crashes()
.
AppMetricaCrashes.crashes().report(error:error)
AppMetricaCrashes.crashes().report(error:error, onFailure:nil)
AppMetricaCrashes.crashes().report(error:error, options:options, onFailure:nil)
AppMetricaCrashes.crashes().report(nserror:error)
AppMetricaCrashes.crashes().report(nserror:error, onFailure:nil)
AppMetricaCrashes.crashes().report(nserror:error, options:options, onFailure:nil)
Add the import to all files where you use crash or error API resources:
#import <AppMetricaCrashes/AppMetricaCrashes.h>
The crash sending logic is defined with the AMAAppMetricaCrashesConfiguration
class:
AMAAppMetricaCrashesConfiguration *configuration = [[AMAAppMetricaCrashesConfiguration alloc] init];
configuration.autoCrashTracking = YES; // If this parameter is enabled, crashes are automatically sent to AppMetrca
configuration.probablyUnhandledCrashReporting = YES; // Use this parameter to enable or disable tracking of implicit failures, such as OOM crashes
configuration.ignoredCrashSignals = @[]; // This setting enables you to specify an array of UNIX signals from sys/signal.h that will be ignored by the failure tracking system
configuration.applicationNotRespondingDetection = YES; // This setting includes detecting situations when the main app thread stops responding (ANR)
configuration.applicationNotRespondingWatchdogInterval = 4.0; // Sets the time interval that the watchdog will wait before reporting the "Application Not Responding" status (ANR)
configuration.applicationNotRespondingPingInterval = 0.1; // Sets the frequency at which watchdog will check the "Application Not Responding" status (ANR)
[[AMAAppMetricaCrashes crashes] setConfiguration:configuration];
To send errors, use methods of the AppMetricaCrashes
class. Their signature matches that of similar methods from YMMYandexMetrica
, so all you need to do is replace YMMYandexMetrica
with [AMAAppMetricaCrashes crashes]
.
[[AMAAppMetricaCrashes crashes] reportError:error onFailure:nil];
[[AMAAppMetricaCrashes crashes] reportError:error options:options onFailure:nil];
[[AMAAppMetricaCrashes crashes] reportNSError:error onFailure:nil];
[[AMAAppMetricaCrashes crashes] reportNSError:error options:options onFailure:nil];
For more information about sending errors, see usage examples.
Sending an event from WebView's JavaScript code
The API for setting up event sending from WebView's JavaScript code is now in the AppMetricaWebKit
module. If you're connecting AppMetricaAnalytics
, you don't need to connect AppMetricaWebKit
separately, because the module is included in AppMetricaAnalytics
.
Add the following string in each file where the WebView setting within the AppMetrica library is used:
import AppMetricaWebKit
You need to replace the WKUserContentController
instance with the instance of the JSController
wrapping. Replace:
let userController = WKUserContentController()
YMMYandexMetrica.initWebViewReporting(userController, onFailure: nil)
with
let userController = WKUserContentController()
AppMetrica.setupWebViewReporting(with: JSController(userContentController: userController), onFailure: nil)
Add the following string in each file where the WebView setting is used:
#import <AppMetricaWebKit/AppMetricaWebKit.h>
You need to replace the WKUserContentController
instance with the instance of the AMAJSController
wrapping. Replace:
WKUserContentController *userController = [[WKUserContentController alloc] init];
[YMMYandexMetrica initWebViewReporting:userController onFailure:nil];
with
WKUserContentController *userController = [[WKUserContentController alloc] init];
[AMAAppMetrica setupWebViewReporting:[[AMAJSController alloc] initWithUserContentController:userController] onFailure:nil];
For more information about setting up event sending from WebView, see usage examples.
Using the SDK for children's apps
To use the SDK in a children's app, exclude the AppMetricaAdSupport
module.
Instead of
pod 'AppMetricaAnalytics', '~> 5.0.0'
use
pod 'AppMetricaCore', '~> 5.0.0'
pod 'AppMetricaCrashes', '~> 5.0.0' # if you need crashes and errors
pod 'AppMetricaWebKit', '~> 5.0.0' # if you need to send events from WebView
If dependencies are set via Xcode
Exclude AppMetricaAdSupport
from Frameworks, Libraries, and Embedded Content
for your target.
When using the Package.swift manifest
Disable the AppMetricaAdSupport
module:
.target(
name: "MyTargetName",
dependencies: [
.product(name: "AppMetricaCore", package: "AppMetrica"),
.product(name: "AppMetricaCrashes", package: "AppMetrica"),
.product(name: "AppMetricaWebKit", package: "AppMetrica"),
// .product(name: "AppMetricaAdSupport", package: "AppMetrica"), // This module is disabled
]
),
If you didn't find the answer you were looking for, you can use the feedback form to submit your question. Please describe the problem in as much detail as possible. Attach a screenshot if possible.