diff --git a/LICENSE.md b/LICENSE.md index 14abc36..6cb8a13 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,54 +1,77 @@ -# Terms of Use of Yandex.Metriсa service +# Yandex AppMetrica SDK License Agreement -*This document is a translation of Terms of use of Yandex.Metriсa service in English. In case of conflict between the Russian version of Terms of use of Yandex.Metriсa service and this translation - only the Russian version of Terms of use of Yandex.Metriсa service is legally binding. The Russian version of Terms of use of Yandex.Metriсa service can be found here: https://yandex.ru/legal/metrica_termsofuse/?lang=ru.* +*This document is a translation of the Yandex AppMetrica SDK License Agreement in English. In case of conflict between the Russian version of the Yandex AppMetrica SDK License Agreement and this translation - only the Russian version of the Yandex AppMetrica SDK License Agreement is legally binding. The Russian version of the Yandex AppMetrica SDK License Agreement can be found here: https://yandex.ru/legal/appmetrica_sdk_agreement/?lang=ru.* -This document, Terms of Use of Yandex.Metriсa Service (hereinafter - Agreement) is an offer of YANDEX, LLC (hereinafter - Yandex) to an Internet user (hereinafter - User) to conclude an agreement on the use of the service Yandex.Metrica and Yandex.Metrica for applications (hereinafter each service is referred to as the Service) on the conditions stated below. +This License Agreement (the "License") is made by and between any person using Yandex AppMetrica SDK (the "User") and Yandex LLC with its registered office at 16, Lva Tolstogo St., Moscow 119021, Russia (the "Rightholder") as a holder of the exclusive right to Yandex AppMetrica SDK. -1. The use of the Service by the User is regulated by this Agreement, as well as: - * the User Agreement for Yandex services, available at: https://yandex.com/legal/rules/, - * Privacy Policy, available at: https://yandex.com/legal/confidential/, -(Hereinafter collectively referred to as - Regulatory Documents). -The User undertakes to acquaint himself with all Regulatory Documents, and shall bear the risk of failure of such acquaintance. +## 1. General Provisions -2. This Agreement and the relations between Yandex and the User arisen in connection to use of the Service, are subject to the applicable laws of the Russian Federation. Throughout the text of this Agreement, unless directly stated otherwise, the term legislation means legislation of the Russian Federation as well as legislation of the User’s place of residence. +1.1. Yandex AppMetrica SDK ("Yandex AppMetrica SDK") may be used by the User to review technical specifications for the interaction of certain AppMetrica elements with software developed by the User. -3. The Service offers a free opportunity to the User to obtain data on site traffic / mobile application traffic by embedding the counter code in the User’s site / integrating the Library into the User’s mobile application. +1.2. By using Yandex AppMetrica SDK or any parts or functions thereof in any way, the User shall expressly accept this License terms and conditions in full, without any reservations or exceptions. If the User does not accept this License terms and conditions in full, the User may not use Yandex AppMetrica SDK. Using AppMetrica SDK in violation of (failing to fulfill) any of this License terms and conditions shall be prohibited. If the User does not agree to the terms and conditions of this License, the User shall refrain from using Yandex AppMetrica SDK. -4. Having registered at the Service, received a counter code / API key, placed the counter code on the User's site / integrated the Library into the User’s mobile application or used any other function of the Service, the User expresses its unconditional consent with all terms of this Agreement and undertakes to comply with them or stop using the Service, by removing the related code from the User's site / the Library from the User’s mobile application. +1.3. Yandex AppMetrica SDK may be used on conditions and in a manner other than those set forth in this License based on a separate agreement to be made with the Rightholder. -5. When using the Service, the User must comply with the following conditions and limitations: - * to have a login on Yandex and place the counter code on his website / receive API key and integrate the Library into the mobile application. Yandex has a right to deny access to the Service without explanation; - * not to remove or alter hyperlinks to the resources of Yandex contained in the counter code / the Library; - * not to install the counter code on sites / not to integrate the Library into mobile applications that do not meet the requirements of paragraph 5 of the User Agreement for Yandex services; - * not to alter or in any way modify the program counter code / Library code, obtained through the Service, except for the change of the User's website / mobile application settings; - * not to use any automatic programs or devices to register on Yandex and/or to receive a counter code / the Library, except for programs working with the API Yandex.Metrica; - * comply with all requirements of this Agreement and the current legislation on the protection of personal data and correspondence of the User’s website visitors / mobile application end users, as well as other information, access to which is limited according to the legislation, and that can be recorded while using the Service. +1.4. This License and the relations governing the use of Yandex AppMetrica SDK shall be subject to law of the Russian Federation, and any claims or actions arising out of or in connection with this License or related to the use of Yandex AppMetrica SDK shall be submitted for consideration to a court at the Rightholder’s location. -6. The User shall be responsible for safekeeping of his login, password and API key and may not transfer or disclose it to third parties. All the actions taken by the Service under the User’s login, password and API key are considered as accomplished by the User. +1.5. The Rightholder may provide the User with a translation of this License from Russian into other languages, but in case of any conflict between the provisions of this License in Russian and its translation, only the Russian version shall have legal effect. -7. The Service (including the information obtained with its help) is provided by Yandex “as is”. Yandex does not warrant the fitness of the Service for the purposes and expectations of Users, uninterruptable and error-free operation of the Service in general and the counter installed on the User’s website website / the Library integrated into the User’s mobile application, in particular, and does not warrant the accuracy of the information obtained through the Service. Yandex shall not be liable for any damage, direct or indirect, caused to the User or any third party by use or inability to use the Service and/or counters installed on the User's website website / the Library integrated into the User’s mobile application, as well as by use or inability to use the information obtained through the Service. Yandex shall not reimburse the User or any third party for such damages. +1.6. In addition to the License, the following documents shall apply to the relations between the Rightholder and the User governing the use of Yandex AppMetrica SDK: -8. The User is solely responsible before third parties for his actions when using the Service, including the fact that they meet the requirements of the legislation and do not violate the rights and legitimate interests of third parties. The User shall settle all claims of third parties associated with the actions of the User when using the Service at his own expense. +1.6.1. User Agreement for Yandex Services permanently available at: https://yandex.com/legal/rules/. -9. The User is hereby notified and agrees that once the function WebVisor is switched on since the installation of the counter to the pages of the User, the Service provides the User with functional ability to automatically record sessions of visits by the visitors of the pages on the User’s website (hereinafter –Visit Sessions). Yandex does not place such records of Visit Sessions on open access and does not provide such records of Visit Sessions to third parties, except for those records the access to which were provided by the User himself. +1.6.2. Privacy Policy permanently available at: https://yandex.com/legal/confidential/. -10. The User shall at his own risk and discretion switch on the function of the Service WebVisor, define the amount of information on the User’s website, being recorded by the counter. The User can mark specific fields of pages of the User’s web site with a special CSS-class http://help.yandex.com/metrica/qanda/webvisor-qanda.xml#skip-fields (in the HTML-code of pages of the website) for the input of data in such fields by third parties (visitors of the User’s website) not to be recorded during recording of Visit Sessions by the counter and at his own discretion and risk make a decision on the choice of fields for such marks and is solely responsible for recording data in the fields which do not have such a mark. +1.6.3. If the User uses AppMetrica: Terms of Use of Yandex.Metriсa for Applications Service permanently available at: https://yandex.com/legal/metrica_termsofuse/. -11. The User acknowledges and agrees that the counter installed on the User’s website / the Library integrated into the User’s mobile application collects anonymous (without binding to the personal data of visitors of the web site / end users of the mobile application) data on visits of the User’s web site / data on the end user's device and its use of the User's mobile applications and automatically forwards that to Yandex to get generalized statistical information available for the further use via the Service by the User and by Yandex for its own purposes as well. If the User did not include a restriction to send pages of the web site for indexing (http://help.yandex.com/metrica/code/stop-indexing.xml), the addresses (URL) of pages with the installed counter may be forwarded for indexing by Yandex. Nevertheless, Yandex does not guarantee that pages, which URLs are obtained in this manner, will be necessarily indexed and included in search results. +## 2. Exclusive Rights -12. The User is hereby notified and agrees that Yandex does not know or can not know what information is contained in the data recorded by the counter on the site pages of the User / the Library into the User’s mobile application, as well as what information is recorded while recording Visit Sessions and saved in a temporary record of such Visit Sessions, and can not determine whether there is any personal data, correspondence and other limited to receiving, processing and distribution information of third parties in such records (hereafter - Secured information) or not. The Service operates in fully automatic mode, and does not analyse the content and meaning of information published on the pages / in the mobile application or entered by visitors in the fields on the page / in the mobile application, and records it completely, regardless of its content. Yandex does not make any modifications to the data recorded by the counter / the Library, including the recordings of Visit Sessions, and does not perform any actions focused on the collection, receipt, processing and distribution of personal data, correspondence and other Secured information of visitors of the User's website / end users of the User’s mobile application as a result of the User's use of the Service. With this in mind, the User understands that by using the Service, he might gain access to Secured information, and therefore the User undertakes not to take focused actions to obtain such Secured information, and shall to the maximum extent comply with all requirements of applicable law for collection, processing and protection of personal data and other Secured information obtained during using the Service, and shall bear all risks associated with obtaining such Secured information, and the liability for failure to comply with the legislation. +2.1. The exclusive rights to Yandex AppMetrica SDK are vested in the Rightholder. This License implies no alienation of such rights. -13. All data collected and stored by the Service shall be treated by Yandex as a confidential information of the User, and to the extent permitted by applicable law – as a trade secret of the User. Yandex shall keep that data in secret and shall not transfer that data to any third parties (except for the affiliate entities that are in the same group with Yandex), except where the User has authorized such transfer or has given an access to that data for third parties at his own discretion. Aggregate data from counters, which does not disclose precise reading of the User's counter, may be used by Yandex at its discretion, including for commercial purposes. +2.2. The exclusive rights to software developed with the use of Yandex AppMetrica SDK are vested in the respective creators thereof. The Rightholder shall not acquire any rights to such software and/or works, except for the right to require that the data defined in cl. 3.3 hereof be specified. -14. Yandex does not guarantee that the installation of the counter on the User’s website / integration of the Library into the User’s mobile application, collection, processing and transmission of this information to Yandex does not violate the legislation of the User’s place of residence. The User performs the installation of the counter on the User’s website / integration of the Library into the User’s mobile application and uses the Service at his own risk and is solely responsible for all actions related to the use of the Service, including the installation of a counter / integration of the Library, the collection and use of information specified by the User. +## 3. License -15. Yandex has the right without notice and at its sole discretion terminate or suspend the User's access to the Service without explanation, in particular, in case of violation of requirements of this Agreement by such the User. +3.1. The Rightholder shall, free of charge and under an ordinary (non-exclusive) license, grant to the User a non-transferable right to use Yandex AppMetrica SDK in all countries of the world in the following ways: -16. All claims arising from the use / inability to use the Service should be directed using the feedback form at http://feedback.yandex.com/?from=metrika. +3.1.1. To apply Yandex AppMetrica SDK for the intended functional purpose specified in cl. 1.1 hereof, by downloading (copying) and reproducing it on the User's devices. The User may use Yandex AppMetrica SDK on an unlimited number of devices. -17. Yandex may at any time without notice to the User amend the text of this Agreement and/or any other conditions of use of Service. The actual text of this Agreement is located at: https://yandex.com/legal/metrica_termsofuse/. +3.2. The User may not distribute Yandex AppMetrica SDK. The User may not change the name of Yandex AppMetrica SDK, change and/or delete copyright marks or any other references to the Rightholder, if they are included in Yandex AppMetrica SDK. -Date: 13.11.2015 +3.3. Paid or free distribution of the software developed with the use of Yandex AppMetrica SDK shall be allowed subject to mentioning of the fact that such software is developed with the use of Yandex AppMetrica SDK by inclusion of the words "Developed with the use of Yandex AppMetrica SDK" in the About section of the program interface, in the text description of the program on the download page thereof and in the program description file included in the installation package (if such file is created). -*Previous version of the document: https://yandex.com/legal/metrica_termsofuse/21102013/* -*Previous version of the document: https://yandex.com/legal/metrica_termsofuse/04062013/* +## 4. Limitations of Use and Liability of the Parties + +4.1. The User is hereby notified and agrees that the Rightholder can change the form, structure, development and operation of Yandex AppMetrica SDK without any prior notice to the User. The User acknowledges that later versions of Yandex AppMetrica SDK can differ from earlier ones and that results obtained by the User with the use of an earlier version of Yandex AppMetrica SDK may be incompatible with the subsequent versions of Yandex AppMetrica SDK. + +4.2. The User is hereby notified and agrees that the Rightholder may suspend or terminate the creation of new versions of Yandex AppMetrica SDK and also suspend or terminate its support provided in relation to the issued versions without any prior notice to the User. + +4.3. This License shall not grant to the User any rights to use the intellectual property owned by the Rightholder, including, but not limited to, the right to use trademarks, logos, domain names and corporate identity elements of the Rightholder. + +4.4. It is hereby prohibited to mislead consumers of items developed with the use of Yandex AppMetrica SDK, including, but not limited to, by way of declarations of the User concerning any guarantees made by the Rightholder as to the properties of an item developed with the use of Yandex AppMetrica SDK, the review and approval of such items by the Rightholder and the shared liability of the User and the Rightholder for the quality of the relevant item. + +4.5. It is not allowed to use Yandex AppMetrica SDK to develop any malicious software capable of making harm to devices and networks, committing illegal acts or performing functions prohibited by current laws and contradicting cl. 5 of the User Agreement for Yandex Services. + +4.6. An item developed in violation of provisions of this License may be, at the discretion of the Rightholder and without any notice to the User, prevented from interaction with the equipment and/or software of the Rightholder and services of the Rightholder. + +4.7. The User shall be solely responsible for the compliance of any software developed with the use of the Yandex AppMetrica SDK with the requirements of current laws including those related to protection of personal data owners’ rights. The Rightholder shall not be liable to the User or any third parties for any defects in the software developed with the use of AppMetrica SDK and for violation of any third party rights and legal interests and current laws by such software. + +4.8. Yandex AppMetrica SDK is provided on an "as is" basis. The Rightholder shall not guarantee that operation of the software developed with the use of Yandex AppMetrica SDK will be error- free and uninterrupted and that Yandex AppMetrica SDK will meet the particular purposes and expectations of the User, the Rightholder makes no other warranties not expressly stated in this License. + +4.9. To the maximum extent permitted by the current laws, the Rightholder shall not be liable for any direct or indirect consequences of any use of, or inability to use, Yandex AppMetrica SDK and/or damages caused to the User and/or third parties as a result of use, or inability to use, Yandex AppMetrica SDK including due to possible malfunction or faulty operation of the software developed with the use of Yandex AppMetrica SDK. + +4.10. The User hereby agrees to provide the Rightholder with the following statistics on the use of Yandex AppMetrica SDK, including, but not limited to, IDs, the User's IP address, device producer and/or model, connection type, Yandex AppMetrica SDK version number used by the User, app package name, details of what Yandex AppMetrica SDK components the User uses and how. Such data are processed to improve and optimize Yandex AppMetrica SDK subject to the Privacy Policy. If the User does not agree to provide the data specified herein, the User may not use Yandex AppMetrica SDK. + +4.11. The Rightholder may send Yandex AppMetrica SDK-related messages to the User. + +## 5. Updates and New Versions + +5.1. The Rightholder may offer updates to the User aimed to improve features of Yandex AppMetrica SDK in the form of patches, additional modules, data sets or all-new versions. The User is hereby notified and agrees to receive the Rightholder's messages of any new components or new versions of Yandex AppMetrica SDK available. + +5.2. This License covers all future updates/new versions of Yandex AppMetrica SDK. Receiving an update/new version means that the User accepts the terms of this License for corresponding updates/new versions of Yandex AppMetrica SDK, unless Yandex AppMetrica SDK is updated under another license agreement. + +## 6. Change of the License Terms and Conditions + +6.1. The Rightholder can unilaterally change this License without any prior notice to the User. The current version of this License is permanently available at: https://yandex.com/legal/appmetrica_sdk_agreement/. Any changes made to this License terms and conditions as set forth above shall come into effect from the date of their publication at the address specified above, unless otherwise specified in a corresponding publication. + +*Date of publication: November 3, 2017* \ No newline at end of file diff --git a/README.md b/README.md index 932de64..28a0493 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # AppMetrica Cordova Plugin ## Documentation -Common documentation available on [metrica official site][DOCUMENTATION]. +Common documentation available on [AppMetrica official site][DOCUMENTATION]. Documentation for this plugin will be published soon. ## Sample project @@ -27,6 +27,11 @@ advertisement**. ## Changelog +### Version 0.2.0 +* Updated versions of the AppMetrica SDK (iOS 2.9.4 and Android 2.78) +* Added a method for getting the configuration of the AppMetrica Push Cordova plugin. +* Fixed installation of iOS part from NPM (#1). + ### Version 0.1.0 * Implemented plugin for AppMetrica iOS (v2.8.0) and AppMetrica Android (v2.62). * Provided sample. @@ -35,6 +40,6 @@ advertisement**. License agreement on use of Yandex AppMetrica is available at [EULA site][LICENSE] -[LICENSE]: https://yandex.com/legal/metrica_termsofuse/ "Yandex AppMetrica agreement" +[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" [GitHubSAMPLE]: https://github.com/yandexmobile/metrica-plugin-cordova/tree/master/sample "Sample from reository" diff --git a/package.json b/package.json index 4ff37c4..1989fc5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "yandex-appmetrica-plugin-cordova", - "version": "0.1.0", + "version": "0.2.0", "description": "Cordova/PhoneGap plugin for AppMetrica analytics tool", "cordova": { "id": "yandex-appmetrica-plugin-cordova", diff --git a/platforms/android/build.gradle b/platforms/android/build.gradle new file mode 100644 index 0000000..9903616 --- /dev/null +++ b/platforms/android/build.gradle @@ -0,0 +1,11 @@ +repositories{ + jcenter() + mavenCentral() + flatDir { + dirs 'libs' + } +} + +dependencies { + compile(name:'mobmetricalib-2.78', ext:'aar') +} \ No newline at end of file diff --git a/platforms/android/com/yandex/metrica/plugin/cordova/AppMetricaPlugin.java b/platforms/android/com/yandex/metrica/plugin/cordova/AppMetricaPlugin.java index aa36f94..8909d88 100644 --- a/platforms/android/com/yandex/metrica/plugin/cordova/AppMetricaPlugin.java +++ b/platforms/android/com/yandex/metrica/plugin/cordova/AppMetricaPlugin.java @@ -1,12 +1,9 @@ /* - * AppMetricaPlugin.java - * - * This file is a part of the AppMetrica. - * - * Version for Android © 2017 YANDEX - * + * Version for Cordova/PhoneGap + * © 2017 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/metrica_termsofuse/ + * You may obtain a copy of the License at + * https://yandex.com/legal/appmetrica_sdk_agreement/ */ package com.yandex.metrica.plugin.cordova; @@ -78,17 +75,17 @@ public void run() { } @Override - public void onPause(boolean multitasking) { + public void onPause(final boolean multitasking) { onPauseActivity(); } @Override - public void onResume(boolean multitasking) { + public void onResume(final boolean multitasking) { onResumeActivity(); } @Override - public void onNewIntent(Intent intent) { + public void onNewIntent(final Intent intent) { getAppMetricaExecutor().execute(new Runnable() { @Override public void run() { @@ -125,8 +122,8 @@ private void onResumeActivity() { } } - private Location toLocation(JSONObject locationObj) throws JSONException { - Location location = new Location("Custom"); + public static Location toLocation(final JSONObject locationObj) throws JSONException { + final Location location = new Location("Custom"); if (locationObj.has("latitude")) { location.setLatitude(locationObj.getDouble("latitude")); @@ -153,9 +150,9 @@ private Location toLocation(JSONObject locationObj) throws JSONException { return location; } - private YandexMetricaConfig toConfig(JSONObject configObj) throws JSONException { - String apiKey = configObj.getString("apiKey"); - YandexMetricaConfig.Builder builder = YandexMetricaConfig.newConfigBuilder(apiKey); + public static YandexMetricaConfig toConfig(final JSONObject configObj) throws JSONException { + final String apiKey = configObj.getString("apiKey"); + final YandexMetricaConfig.Builder builder = YandexMetricaConfig.newConfigBuilder(apiKey); if (configObj.has("handleFirstActivationAsUpdateEnabled")) { builder.handleFirstActivationAsUpdate(configObj.getBoolean("handleFirstActivationAsUpdateEnabled")); @@ -176,17 +173,17 @@ private YandexMetricaConfig toConfig(JSONObject configObj) throws JSONException builder.setLogEnabled(); } if (configObj.has("location")) { - Location location = toLocation(configObj.getJSONObject("location")); + final Location location = toLocation(configObj.getJSONObject("location")); builder.setLocation(location); } if (configObj.has("preloadInfo")) { - JSONObject preloadInfoObj = configObj.getJSONObject("preloadInfo"); - PreloadInfo.Builder infoBuilder = PreloadInfo.newBuilder(preloadInfoObj.getString("trackingId")); - JSONObject additionalInfoObj = preloadInfoObj.optJSONObject("additionalInfo"); + final JSONObject preloadInfoObj = configObj.getJSONObject("preloadInfo"); + final PreloadInfo.Builder infoBuilder = PreloadInfo.newBuilder(preloadInfoObj.getString("trackingId")); + final JSONObject additionalInfoObj = preloadInfoObj.optJSONObject("additionalInfo"); if (additionalInfoObj != null) { for (Iterator keyIterator = additionalInfoObj.keys(); keyIterator.hasNext();) { - String key = keyIterator.next(); - String value = additionalInfoObj.getString(key); + final String key = keyIterator.next(); + final String value = additionalInfoObj.getString(key); infoBuilder.setAdditionalParams(key, value); } } @@ -196,29 +193,31 @@ private YandexMetricaConfig toConfig(JSONObject configObj) throws JSONException return builder.build(); } - private void activate(JSONArray args, final CallbackContext callbackContext) throws JSONException { + private void activate(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final JSONObject configObj = args.getJSONObject(0); final YandexMetricaConfig config = toConfig(configObj); - Context context = getActivity().getApplicationContext(); + final Context context = getActivity().getApplicationContext(); YandexMetrica.activate(context, config); synchronized (mLock) { if (mAppMetricaActivated == false) { YandexMetrica.reportAppOpen(getActivity()); if (mActivityPaused == false) { - onResumeActivity(); + YandexMetrica.onResumeActivity(getActivity()); } } mAppMetricaActivated = true; } } - private void reportEvent(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void reportEvent(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final String eventName = args.getString(0); String eventParametersJSONString = null; try { - JSONObject eventParametersObj = args.getJSONObject(1); + final JSONObject eventParametersObj = args.getJSONObject(1); eventParametersJSONString = eventParametersObj.toString(); } catch (JSONException ignored) {} @@ -229,60 +228,69 @@ private void reportEvent(JSONArray args, CallbackContext callbackContext) throws } } - private void reportError(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void reportError(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final String errorName = args.getString(0); Throwable errorThrowable = null; try { - String errorReason = args.getString(1); + final String errorReason = args.getString(1); errorThrowable = new Throwable(errorReason); } catch (JSONException ignored) {} YandexMetrica.reportError(errorName, errorThrowable); } - private void setCustomAppVersion(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setCustomAppVersion(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final String appVersion = args.getString(0); YandexMetrica.setCustomAppVersion(appVersion); } - private void setLocation(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setLocation(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final JSONObject locationObj = args.getJSONObject(0); - Location location = toLocation(locationObj); + final Location location = toLocation(locationObj); YandexMetrica.setLocation(location); } - private void setTrackLocationEnabled(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setTrackLocationEnabled(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final boolean enabled = args.getBoolean(0); YandexMetrica.setTrackLocationEnabled(enabled); } - private void setEnvironmentValue(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setEnvironmentValue(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(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setSessionTimeout(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final int sessionTimeout = args.getInt(0); YandexMetrica.setSessionTimeout(sessionTimeout); } - private void setReportCrashesEnabled(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setReportCrashesEnabled(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final boolean enabled = args.getBoolean(0); YandexMetrica.setReportCrashesEnabled(enabled); } - private void setLoggingEnabled(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setLoggingEnabled(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { YandexMetrica.setLogEnabled(); } - private void setCollectInstalledAppsEnabled(JSONArray args, CallbackContext callbackContext) throws JSONException { + private void setCollectInstalledAppsEnabled(final JSONArray args, + final CallbackContext callbackContext) throws JSONException { final boolean enabled = args.getBoolean(0); YandexMetrica.setCollectInstalledApps(enabled); diff --git a/platforms/android/mobmetricalib-2.62.jar b/platforms/android/mobmetricalib-2.62.jar deleted file mode 100644 index caf2b24..0000000 Binary files a/platforms/android/mobmetricalib-2.62.jar and /dev/null differ diff --git a/platforms/android/mobmetricalib-2.78.aar b/platforms/android/mobmetricalib-2.78.aar new file mode 100644 index 0000000..ed796a2 Binary files /dev/null and b/platforms/android/mobmetricalib-2.78.aar differ diff --git a/platforms/ios/YMMAppMetricaPlugin.h b/platforms/ios/YMMAppMetricaPlugin.h index 4a67d0a..36a6166 100644 --- a/platforms/ios/YMMAppMetricaPlugin.h +++ b/platforms/ios/YMMAppMetricaPlugin.h @@ -1,12 +1,9 @@ /* - * YMMAppMetricaPlugin.h - * - * This file is a part of the AppMetrica. - * - * Version for iOS © 2017 YANDEX - * + * Version for Cordova/PhoneGap + * © 2017 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/metrica_termsofuse/ + * You may obtain a copy of the License at + * https://yandex.com/legal/appmetrica_sdk_agreement/ */ #import @@ -24,5 +21,7 @@ - (void)setReportCrashesEnabled:(CDVInvokedUrlCommand *)command; - (void)setLoggingEnabled:(CDVInvokedUrlCommand *)command; - (void)setCollectInstalledAppsEnabled:(CDVInvokedUrlCommand *)command; ++ (void)activateWithConfigurationDictionary:(NSDictionary *)configuration; ++ (bool)isAppMetricaActivated; @end diff --git a/platforms/ios/YMMAppMetricaPlugin.m b/platforms/ios/YMMAppMetricaPlugin.m index bb0532d..34dda56 100644 --- a/platforms/ios/YMMAppMetricaPlugin.m +++ b/platforms/ios/YMMAppMetricaPlugin.m @@ -1,12 +1,9 @@ /* - * YMMAppMetricaPlugin.m - * - * This file is a part of the AppMetrica. - * - * Version for iOS © 2017 YANDEX - * + * Version for Cordova/PhoneGap + * © 2017 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/metrica_termsofuse/ + * You may obtain a copy of the License at + * https://yandex.com/legal/appmetrica_sdk_agreement/ */ #import "YMMAppMetricaPlugin.h" @@ -14,6 +11,8 @@ #import #import +static bool gYMMIsAppMetricaActivated = false; + @implementation YMMAppMetricaPlugin - (void)handleOpenURL:(NSNotification *)notification @@ -35,8 +34,7 @@ - (void)activate:(CDVInvokedUrlCommand *)command NSDictionary *configurationDictionary = [command argumentAtIndex:0 withDefault:nil andClass:[NSDictionary class]]; [self dispatchAsync:^{ - YMMYandexMetricaConfiguration *configuration = [self configurationForDictionary:configurationDictionary]; - [YMMYandexMetrica activateWithConfiguration:configuration]; + [[self class] activateWithConfigurationDictionary:configurationDictionary]; }]; } @@ -79,7 +77,7 @@ - (void)setLocation:(CDVInvokedUrlCommand *)command NSDictionary *locationDictionary = [command argumentAtIndex:0 withDefault:nil andClass:[NSDictionary class]]; [self dispatchAsync:^{ - CLLocation *location = [self locationForDictionary:locationDictionary]; + CLLocation *location = [[self class] locationForDictionary:locationDictionary]; [YMMYandexMetrica setLocation:location]; }]; } @@ -150,7 +148,7 @@ - (void)setCollectInstalledAppsEnabled:(CDVInvokedUrlCommand *)command }; } -- (YMMYandexMetricaConfiguration *)configurationForDictionary:(NSDictionary *)configurationDictionary ++ (YMMYandexMetricaConfiguration *)configurationForDictionary:(NSDictionary *)configurationDictionary { NSString *apiKey = configurationDictionary[@"apiKey"]; YMMYandexMetricaConfiguration *configuration = [[YMMYandexMetricaConfiguration alloc] initWithApiKey:apiKey]; @@ -199,7 +197,7 @@ - (YMMYandexMetricaConfiguration *)configurationForDictionary:(NSDictionary *)co return configuration; } -- (CLLocation *)locationForDictionary:(NSDictionary *)locationDictionary ++ (CLLocation *)locationForDictionary:(NSDictionary *)locationDictionary { if (locationDictionary == nil) { return nil; @@ -231,4 +229,16 @@ - (void)dispatchAsync:(dispatch_block_t)block [self.commandDelegate runInBackground:block]; } ++ (void)activateWithConfigurationDictionary:(NSDictionary *)configuration +{ + YMMYandexMetricaConfiguration *config = [[self class] configurationForDictionary:configuration]; + [YMMYandexMetrica activateWithConfiguration:config]; + gYMMIsAppMetricaActivated = true; +} + ++ (bool)isAppMetricaActivated +{ + return gYMMIsAppMetricaActivated; +} + @end diff --git a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMVersion.h b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMVersion.h index 3171614..a3600ac 100644 --- a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMVersion.h +++ b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMVersion.h @@ -3,7 +3,7 @@ * * This file is a part of the AppMetrica * - * Version for iOS © 2016 YANDEX + * Version for iOS © 2017 YANDEX * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/ @@ -13,9 +13,9 @@ #define __YMM_VERSION_H__ #define YMM_VERSION_MAJOR 2 -#define YMM_VERSION_MINOR 8 -#define YMM_VERSION_PATCH 0 +#define YMM_VERSION_MINOR 9 +#define YMM_VERSION_PATCH 4 -#define YMM_BUILD_NUMBER 7224 +#define YMM_BUILD_NUMBER 8876 #endif // __YMM_VERSION_H__ diff --git a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetrica.h b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetrica.h index 3d3017f..4ef31fe 100644 --- a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetrica.h +++ b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetrica.h @@ -3,7 +3,7 @@ * * This file is a part of the AppMetrica * - * Version for iOS © 2016 YANDEX + * Version for iOS © 2017 YANDEX * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/ @@ -13,6 +13,7 @@ @class CLLocation; @class YMMYandexMetricaConfiguration; +@protocol YMMYandexMetricaReporting; NS_ASSUME_NONNULL_BEGIN @@ -143,6 +144,20 @@ typedef NS_ENUM(NSInteger, YMMYandexMetricaEventErrorCode) { */ + (BOOL)handleOpenURL:(NSURL *)url; +/** Returns id that can send events to specific API key. + + @param apiKey Api key to send events to. + @return id that conforms to YMMYandexMetricaReporting and handles + sending events to specified apikey + */ ++ (nullable id)reporterForApiKey:(NSString *)apiKey; + +/** + * Sets referral URL for this installation. This might be required to track some specific traffic sources like Facebook. + * @param url referral URL value. + */ ++ (void)reportReferralUrl:(NSURL *)url; + @end @interface YMMYandexMetrica (YMMYandexMetricaDeprecatedOrUnavailable) diff --git a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaConfiguration.h b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaConfiguration.h index ebe50b1..73c2d40 100644 --- a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaConfiguration.h +++ b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaConfiguration.h @@ -3,7 +3,7 @@ * * This file is a part of the AppMetrica * - * Version for iOS © 2016 YANDEX + * Version for iOS © 2017 YANDEX * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/ diff --git a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaPreloadInfo.h b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaPreloadInfo.h index 813e451..7da0ece 100644 --- a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaPreloadInfo.h +++ b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaPreloadInfo.h @@ -3,7 +3,7 @@ * * This file is a part of the AppMetrica * - * Version for iOS © 2016 YANDEX + * Version for iOS © 2017 YANDEX * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/ diff --git a/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaReporting.h b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaReporting.h new file mode 100644 index 0000000..29f0edc --- /dev/null +++ b/platforms/ios/YandexMobileMetrica.framework/Headers/YMMYandexMetricaReporting.h @@ -0,0 +1,61 @@ +/* + * YMMYandexMetricaReporting.h + * + * This file is a part of the AppMetrica + * + * Version for iOS © 2017 YANDEX + * + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/ + */ + +#import + +NS_ASSUME_NONNULL_BEGIN + +/** YMMYandexMetricaReporting protocol groups methods that are used by custom reporting objects. + */ +@protocol YMMYandexMetricaReporting + +/** Reporting custom event. + + @param name Short name or description of the event. + @param onFailure Block to be executed if an error occurres while reporting, the error is passed as block argument. + */ +- (void)reportEvent:(NSString *)name + onFailure:(nullable void (^)(NSError *error))onFailure; + +/** Reporting custom event with additional parameters. + + @param name Short name or description of the event. + @param params Dictionary of name/value pairs that must be sent to the server. + @param onFailure Block to be executed if an error occurres while reporting, the error is passed as block argument. + */ +- (void)reportEvent:(NSString *)name + parameters:(nullable NSDictionary *)params + onFailure:(nullable void (^)(NSError *error))onFailure; + +/** Reporting custom error messages. + + @param name Short name or description of the error. + @param exception NSException object that must be sent to the server. + @param onFailure Block to be executed if an error occurres while reporting, the error is passed as block argument. + */ +- (void)reportError:(NSString *)name + exception:(nullable NSException *)exception + onFailure:(nullable void (^)(NSError *error))onFailure; + +/** Resumes last session or creates a new one if it has been expired. + Should be used when auto tracking of application state is unavailable or is different. + */ +- (void)resumeSession; + +/** Pause current session. + All events reported after calling this method and till the session timeout will still join this session. + Should be used when auto tracking of application state is unavailable or is different. + */ +- (void)pauseSession; + +@end + +NS_ASSUME_NONNULL_END diff --git a/platforms/ios/YandexMobileMetrica.framework/Headers/YandexMobileMetrica.h b/platforms/ios/YandexMobileMetrica.framework/Headers/YandexMobileMetrica.h index 22e664f..e0ac0a5 100644 --- a/platforms/ios/YandexMobileMetrica.framework/Headers/YandexMobileMetrica.h +++ b/platforms/ios/YandexMobileMetrica.framework/Headers/YandexMobileMetrica.h @@ -3,7 +3,7 @@ * * This file is a part of the AppMetrica * - * Version for iOS © 2016 YANDEX + * Version for iOS © 2017 YANDEX * * You may not use this file except in compliance with the License. * You may obtain a copy of the License at http://legal.yandex.com/metrica_termsofuse/ @@ -13,10 +13,12 @@ #import "YMMYandexMetrica.h" #import "YMMVersion.h" #import "YMMYandexMetricaConfiguration.h" + #import "YMMYandexMetricaReporting.h" #import "YMMYandexMetricaPreloadInfo.h" #else #import #import #import + #import #import #endif diff --git a/platforms/ios/YandexMobileMetrica.framework/YandexMobileMetrica b/platforms/ios/YandexMobileMetrica.framework/YandexMobileMetrica old mode 100644 new mode 100755 index eea6144..1a6c487 Binary files a/platforms/ios/YandexMobileMetrica.framework/YandexMobileMetrica and b/platforms/ios/YandexMobileMetrica.framework/YandexMobileMetrica differ diff --git a/plugin.xml b/plugin.xml index 3ea8160..5242b84 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,11 +2,11 @@ + version="0.2.0"> AppMetrica Cordova/PhoneGap plugin for AppMetrica analytics tool Yandex, LLC - https://yandex.com/legal/metrica_termsofuse/ + https://yandex.com/legal/appmetrica_sdk_agreement/ yandex appmetrica metrica analytics tracking ios android @@ -25,41 +25,12 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/sample/cordova/www/css/index.css b/sample/cordova/www/css/index.css index bc0265d..c06ca63 100644 --- a/sample/cordova/www/css/index.css +++ b/sample/cordova/www/css/index.css @@ -1,12 +1,9 @@ /* - * index.css - * - * This file is a part of the AppMetrica. - * - * Version for Cordova/PhoneGap © 2017 YANDEX - * + * Version for Cordova/PhoneGap + * © 2017 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/metrica_termsofuse/ + * You may obtain a copy of the License at + * https://yandex.com/legal/appmetrica_sdk_agreement/ */ * { diff --git a/sample/cordova/www/index.html b/sample/cordova/www/index.html index a1b3b1d..d294e71 100644 --- a/sample/cordova/www/index.html +++ b/sample/cordova/www/index.html @@ -1,13 +1,10 @@ diff --git a/sample/cordova/www/js/index.js b/sample/cordova/www/js/index.js index c71fcc9..ed19697 100644 --- a/sample/cordova/www/js/index.js +++ b/sample/cordova/www/js/index.js @@ -1,12 +1,9 @@ /* - * index.js - * - * This file is a part of the AppMetrica. - * - * Version for Cordova/PhoneGap © 2017 YANDEX - * + * Version for Cordova/PhoneGap + * © 2017 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/metrica_termsofuse/ + * You may obtain a copy of the License at + * https://yandex.com/legal/appmetrica_sdk_agreement/ */ "use strict"; diff --git a/www/appmetrica.js b/www/appmetrica.js index f10eece..c291b94 100644 --- a/www/appmetrica.js +++ b/www/appmetrica.js @@ -1,12 +1,9 @@ /* - * appmetrica.js - * - * This file is a part of the AppMetrica. - * - * Version for Cordova/PhoneGap © 2017 YANDEX - * + * Version for Cordova/PhoneGap + * © 2017 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/metrica_termsofuse/ + * You may obtain a copy of the License at + * https://yandex.com/legal/appmetrica_sdk_agreement/ */ "use strict"; @@ -57,6 +54,7 @@ module.exports = { */ activate: function (config) { appMetricaExec('activate', [config]); + cordova.fireDocumentEvent('metricaconfigurationupdate', {"config": config}); }, /** * Reports event with name and parameters.