Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #15 from yandexmobile/release-1.0.0
Browse files Browse the repository at this point in the history
Release AppMetrica Cordova Plugin 1.0.0
  • Loading branch information
NesterovichAlexey committed Aug 2, 2019
2 parents 3e1c9df + 2d16204 commit bb3115b
Show file tree
Hide file tree
Showing 33 changed files with 1,077 additions and 451 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# AppMetrica Cordova Plugin

## Documentation
Common documentation available on [AppMetrica official site][DOCUMENTATION].
Common documentation available on [AppMetrica official site][DOCUMENTATION].
Documentation for this plugin will be published soon.

## Sample project
Expand All @@ -27,6 +27,10 @@ advertisement**.

## Changelog

### Version 1.0.0
* Updated versions of the AppMetrica SDK (iOS 3.7.1 and Android 3.6.4).
* Changed API methods.

### Version 0.4.0
* Updated iOS version of the AppMetrica SDK (iOS 2.9.8).
* Changed the SDK to meet the requirements of the Apple App Store Review Team. Update the AppMetrica SDK to avoid any issues during the App Store moderation process.
Expand All @@ -48,5 +52,5 @@ License agreement on use of Yandex AppMetrica is available at [EULA site][LICENS


[LICENSE]: https://yandex.com/legal/appmetrica_sdk_agreement/ "Yandex AppMetrica agreement"
[DOCUMENTATION]: https://tech.yandex.com/appmetrica/doc/mobile-sdk-dg/concepts/about-docpage/ "Yandex AppMetrica documentation"
[DOCUMENTATION]: https://appmetrica.yandex.com/docs/quick-start/concepts/quick-start.html "Yandex AppMetrica documentation"
[GitHubSAMPLE]: https://github.com/yandexmobile/metrica-plugin-cordova/tree/master/sample "Sample from reository"
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yandex-appmetrica-plugin-cordova",
"version": "0.4.0",
"version": "1.0.0",
"description": "Cordova/PhoneGap plugin for AppMetrica analytics tool",
"cordova": {
"id": "yandex-appmetrica-plugin-cordova",
Expand Down Expand Up @@ -30,7 +30,7 @@
],
"author": "Yandex, LLC",
"license": "ISC",
"homepage": "https://tech.yandex.ru/metrica-mobile-sdk",
"homepage": "https://appmetrica.yandex.com/docs",
"bugs": {
"url": "https://github.com/yandexmobile/metrica-plugin-cordova/issues"
},
Expand Down
14 changes: 11 additions & 3 deletions platforms/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
repositories{
/*
* Version for Cordova/PhoneGap
* © 2017-2019 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
*/

repositories{
jcenter()
mavenCentral()
}

dependencies {
compile 'com.yandex.android:mobmetricalib:2.78'
}
compile 'com.yandex.android:mobmetricalib:3.6.4'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Version for Cordova/PhoneGap
* © 2017 YANDEX
* © 2017-2019 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
Expand Down Expand Up @@ -47,22 +47,10 @@ public void run() {
reportEvent(args, callbackContext);
} else if ("reportError".equals(action)) {
reportError(args, callbackContext);
} else if ("setCustomAppVersion".equals(action)) {
setCustomAppVersion(args, callbackContext);
} else if ("setLocation".equals(action)) {
setLocation(args, callbackContext);
} else if ("setTrackLocationEnabled".equals(action)) {
setTrackLocationEnabled(args, callbackContext);
} else if ("setEnvironmentValue".equals(action)) {
setEnvironmentValue(args, callbackContext);
} else if ("setSessionTimeout".equals(action)) {
setSessionTimeout(args, callbackContext);
} else if ("setReportCrashesEnabled".equals(action)) {
setReportCrashesEnabled(args, callbackContext);
} else if ("setLoggingEnabled".equals(action)) {
setLoggingEnabled(args, callbackContext);
} else if ("setCollectInstalledAppsEnabled".equals(action)) {
setCollectInstalledAppsEnabled(args, callbackContext);
} else if ("setLocationTracking".equals(action)) {
setLocationTracking(args, callbackContext);
} else {
callbackContext.error("Unknown action: " + action);
}
Expand All @@ -76,12 +64,12 @@ public void run() {

@Override
public void onPause(final boolean multitasking) {
onPauseActivity();
onPauseSession();
}

@Override
public void onResume(final boolean multitasking) {
onResumeActivity();
onResumeSession();
}

@Override
Expand All @@ -104,20 +92,20 @@ private ExecutorService getAppMetricaExecutor() {
return mExecutor;
}

private void onPauseActivity() {
private void onPauseSession() {
synchronized (mLock) {
mActivityPaused = true;
if (mAppMetricaActivated) {
YandexMetrica.onPauseActivity(getActivity());
YandexMetrica.pauseSession(getActivity());
}
}
}

private void onResumeActivity() {
private void onResumeSession() {
synchronized (mLock) {
mActivityPaused = false;
if (mAppMetricaActivated) {
YandexMetrica.onResumeActivity(getActivity());
YandexMetrica.resumeSession(getActivity());
}
}
}
Expand Down Expand Up @@ -154,40 +142,40 @@ public static YandexMetricaConfig toConfig(final JSONObject configObj) throws JS
final String apiKey = configObj.getString("apiKey");
final YandexMetricaConfig.Builder builder = YandexMetricaConfig.newConfigBuilder(apiKey);

if (configObj.has("handleFirstActivationAsUpdateEnabled")) {
builder.handleFirstActivationAsUpdate(configObj.getBoolean("handleFirstActivationAsUpdateEnabled"));
if (configObj.has("handleFirstActivationAsUpdate")) {
builder.handleFirstActivationAsUpdate(configObj.getBoolean("handleFirstActivationAsUpdate"));
}
if (configObj.has("trackLocationEnabled")) {
builder.setTrackLocationEnabled(configObj.getBoolean("trackLocationEnabled"));
if (configObj.has("locationTracking")) {
builder.withLocationTracking(configObj.getBoolean("locationTracking"));
}
if (configObj.has("sessionTimeout")) {
builder.setSessionTimeout(configObj.getInt("sessionTimeout"));
builder.withSessionTimeout(configObj.getInt("sessionTimeout"));
}
if (configObj.has("reportCrashesEnabled")) {
builder.setReportCrashesEnabled(configObj.getBoolean("reportCrashesEnabled"));
if (configObj.has("crashReporting")) {
builder.withCrashReporting(configObj.getBoolean("crashReporting"));
}
if (configObj.has("appVersion")) {
builder.setAppVersion(configObj.getString("appVersion"));
builder.withAppVersion(configObj.getString("appVersion"));
}
if (configObj.optBoolean("loggingEnabled", false)) {
builder.setLogEnabled();
if (configObj.optBoolean("logs", false)) {
builder.withLogs();
}
if (configObj.has("location")) {
final Location location = toLocation(configObj.getJSONObject("location"));
builder.setLocation(location);
builder.withLocation(location);
}
if (configObj.has("preloadInfo")) {
final JSONObject preloadInfoObj = configObj.getJSONObject("preloadInfo");
final PreloadInfo.Builder infoBuilder = PreloadInfo.newBuilder(preloadInfoObj.getString("trackingId"));
final JSONObject additionalInfoObj = preloadInfoObj.optJSONObject("additionalInfo");
final JSONObject additionalInfoObj = preloadInfoObj.optJSONObject("additionalParams");
if (additionalInfoObj != null) {
for (Iterator<String> keyIterator = additionalInfoObj.keys(); keyIterator.hasNext();) {
for (Iterator<String> keyIterator = additionalInfoObj.keys(); keyIterator.hasNext(); ) {
final String key = keyIterator.next();
final String value = additionalInfoObj.getString(key);
infoBuilder.setAdditionalParams(key, value);
}
}
builder.setPreloadInfo(infoBuilder.build());
builder.withPreloadInfo(infoBuilder.build());
}

return builder.build();
Expand All @@ -205,7 +193,7 @@ private void activate(final JSONArray args,
if (mAppMetricaActivated == false) {
YandexMetrica.reportAppOpen(getActivity());
if (mActivityPaused == false) {
YandexMetrica.onResumeActivity(getActivity());
YandexMetrica.resumeSession(getActivity());
}
}
mAppMetricaActivated = true;
Expand Down Expand Up @@ -240,13 +228,6 @@ private void reportError(final JSONArray args,
YandexMetrica.reportError(errorName, errorThrowable);
}

private void setCustomAppVersion(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final String appVersion = args.getString(0);

YandexMetrica.setCustomAppVersion(appVersion);
}

private void setLocation(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final JSONObject locationObj = args.getJSONObject(0);
Expand All @@ -255,45 +236,10 @@ private void setLocation(final JSONArray args,
YandexMetrica.setLocation(location);
}

private void setTrackLocationEnabled(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final boolean enabled = args.getBoolean(0);

YandexMetrica.setTrackLocationEnabled(enabled);
}

private void setEnvironmentValue(final JSONArray args,
private void setLocationTracking(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final String key = args.getString(0);
final String value = args.getString(1);

YandexMetrica.setEnvironmentValue(key, value);
}

private void setSessionTimeout(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final int sessionTimeout = args.getInt(0);

YandexMetrica.setSessionTimeout(sessionTimeout);
}

private void setReportCrashesEnabled(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final boolean enabled = args.getBoolean(0);

YandexMetrica.setReportCrashesEnabled(enabled);
}

private void setLoggingEnabled(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
YandexMetrica.setLogEnabled();
}

private void setCollectInstalledAppsEnabled(final JSONArray args,
final CallbackContext callbackContext) throws JSONException {
final boolean enabled = args.getBoolean(0);

YandexMetrica.setCollectInstalledApps(enabled);
YandexMetrica.setLocationTracking(enabled);
}

}
10 changes: 2 additions & 8 deletions platforms/ios/YMMAppMetricaPlugin.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Version for Cordova/PhoneGap
* © 2017 YANDEX
* © 2017-2019 YANDEX
* You may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* https://yandex.com/legal/appmetrica_sdk_agreement/
Expand All @@ -13,14 +13,8 @@
- (void)activate:(CDVInvokedUrlCommand *)command;
- (void)reportEvent:(CDVInvokedUrlCommand *)command;
- (void)reportError:(CDVInvokedUrlCommand *)command;
- (void)setCustomAppVersion:(CDVInvokedUrlCommand *)command;
- (void)setLocation:(CDVInvokedUrlCommand *)command;
- (void)setTrackLocationEnabled:(CDVInvokedUrlCommand *)command;
- (void)setEnvironmentValue:(CDVInvokedUrlCommand *)command;
- (void)setSessionTimeout:(CDVInvokedUrlCommand *)command;
- (void)setReportCrashesEnabled:(CDVInvokedUrlCommand *)command;
- (void)setLoggingEnabled:(CDVInvokedUrlCommand *)command;
- (void)setCollectInstalledAppsEnabled:(CDVInvokedUrlCommand *)command;
- (void)setLocationTracking:(CDVInvokedUrlCommand *)command;
+ (void)activateWithConfigurationDictionary:(NSDictionary *)configuration;
+ (bool)isAppMetricaActivated;

Expand Down
Loading

0 comments on commit bb3115b

Please sign in to comment.