Migration guide to branch 3.x.x

This guide contains examples that demonstrate the differences between the SDK versions 2.80 and 3.0.0. This section only covers methods that do not have backward compatibility.

  1. Added
  2. Renamed
  3. Deleted

Added

Reporter activation
Called before any actions with the reporter. If you already get the reporter, activation cannot change the parameters. Example:
YandexMetrica.activateReporter(this, ReporterConfig.newConfigBuilder(API_KEY)
              .withSessionTimeout(100)
              .build());
Profiles
Added the following classes to work with user profiles:

Added the following methods to the YandexMetrica class for user profiles:

Added the following methods to the IReporter interface for user profiles:

Revenue
Added the following classes for revenue tracking:

Added the following method to the YandexMetrica class:

Added the following method to IReporter interface:

Renamed

The YandexMetrica class.

Version 2.80Version 3.0.0
onResumeActivity(Activity activity)
// Resumes a session.resumeSession(Activity activity)
onPauseActivity(Activity activity)
// Pauses the session.pauseSession(Activity activity)
setTrackLocationEnabled(boolean enabled)
// Enables device location sending.setLocationTracking(boolean enabled)

The YandexMetricaConfig class.

Version 2.80Version 3.0.0
getApiKey()
// API key of the application.public final String apiKey
getAppVersion()
// App Version.public final String appVersion
getSessionTimeout()
// Session timeout.public final Integer sessionTimeout
isReportCrashEnabled()
// Application crashes reporting.public final Boolean crashReporting
isReportNativeCrashEnabled()
// Application native crashes reporting.public final Boolean nativeCrashReporting
getLocation()
// Location data set by user.public final Location location
isTrackLocationEnabled()
// Sending device location.public final Boolean locationTracking
isCollectInstalledApps()
// Sending data about installed apps on the device.public final Boolean installedAppCollecting
isLogEnabled
// Library logs output.public final Boolean logs
getPreloadInfo()
//  Information for tracking pre-installed apps.public final PreloadInfo preloadInfo
handleFirstActivationAsUpdate()
// The first app launch with the AppMetrica SDK should be treated as the first launch of the updated app version, and not as an install.public final Boolean firstActivationAsUpdate;

The YandexMetricaConfig.Builder class.

Version 2.80Version 3.0.0
setAppVersion()
// Sets the app version.withAppVersion()
setSessionTimeout()
// Sets the session timeout.withSessionTimeout()
setReportCrashEnabled()
// Enables application crashes reporting.withCrashReporting()
setReportNativeCrashesEnabled()
// Enables application native crashes reporting.withNativeCrashReporting()
setLocation()
// Sets the device location.withLocation()
setTrackLocationEnabled()
// Enables device location sending.withLocationTracking()
setCollectInstalledApps()
// Enables sending information about pre-installed apps.withInstalledAppCollecting()
setLogEnabled
// Enables library logging.withLogs()
setPreloadInfo()
// Sets the data for tracking pre-installed apps. withPreloadInfo()

Deleted

Version 2.80Version 3.0.0
Activation with the API key
YandexMetrica.activate(getApplicationContext(), API_KEY);
YandexMetricaConfig.Builder configBuilder = YandexMetricaConfig.newConfigBuilder(API_KEY);YandexMetrica.activate(getApplicationContext(), сonfigBuilder.build());

You can activate the library using the extended configuration YandexMetricaConfig.

Setting the session length.
YandexMetrica.setSessionTimeout(30);

You can set the session timeout using the extended configuration YandexMetricaConfig.

Monitoring app crashes.
YandexMetrica.setReportCrashesEnabled(true);
YandexMetrica.setReportNativeCrashesEnabled(true);

You can enable the crash reporting using the extended configuration YandexMetricaConfig

Setting the app version
YandexMetrica.setCustomAppVersion("1.0.5");

You can set the application version using the extended configuration YandexMetricaConfig.

Enabling logs
YandexMetrica.setLogEnabled();

You can enable the library logging using the extended configuration YandexMetricaConfig.

Enabling sending data about pre-installed apps.
YandexMetrica.setCollectInstalledApps(boolean collect);
YandexMetrica.isCollectInstalledApps();

You can enable sending data about pre-installed apps using the extended configuration YandexMetricaConfig.

Setting environment values.
YandexMetrica.setEnvironmentValue(String key, String value);
Deleted.