using System.Collections.Generic; using System.Threading.Tasks; using Unity.Services.Analytics.Internal; namespace Unity.Services.Analytics { public interface IAnalyticsService { /// /// This is the URL for the Unity Analytics privacy policy. This policy page should /// be presented to the user in a platform-appropriate way along with the ability to /// opt out of data collection. /// string PrivacyUrl { get; } /// /// Forces an immediately upload of all recorded events to the server, if there is an internet connection. /// /// Thrown if the required consent flow cannot be determined.. void Flush(); void AdImpression(AdImpressionParameters parameters); /// /// Record a Transaction event. /// /// (Required) Helper object to handle parameters. void Transaction(TransactionParameters transactionParameters); /// /// Record a TransactionFailed event. /// /// (Required) Helper object to handle parameters. void TransactionFailed(TransactionFailedParameters parameters); /// /// Record a custom event. A schema for this event must exist on the dashboard or it will be ignored. /// void CustomData(string eventName, IDictionary eventParams); /// /// Returns identifiers of required consents we need to gather from the user /// in order to be allowed to sent analytics events. /// This method must be called every time the game starts - without checking the geolocation, /// no event will be sent (even if the consent was already given). /// If the required consent was already given, an empty list is returned. /// If the user already opted out from the current legislation, an empty list is returned. /// It involves the GeoIP call. /// `ConsentCheckException` is thrown if the GeoIP call was unsuccessful. /// /// /// A list of consent identifiers that are required for sending analytics events. /// Thrown if the GeoIP call was unsuccessful. Task> CheckForRequiredConsents(); /// /// Sets the consent status for the specified opt-in-based legislation (PIPL etc). /// The required legislation identifier can be found by calling `CheckForRequiredConsents` method. /// If this method is tried to be used for the incorrect legislation (PIPL outside China etc), /// the `ConsentCheckException` is thrown. /// /// /// The legislation identifier for which the consent status should be changed. /// The consent status which should be set for the specified legislation. /// Thrown if the incorrect legislation was being provided or /// the required consent flow cannot be determined. void ProvideOptInConsent(string identifier, bool consent); /// /// Opts the user out of sending analytics from all legislations. /// To deny consent for a specific opt-in legislation, like PIPL, use `ProvideConsent(string key, bool consent)` method) /// All existing cached events and any subsequent events will be discarded immediately. /// A final 'forget me' signal will be uploaded which will trigger purge of analytics data for this user from the back-end. /// If this 'forget me' event cannot be uploaded immediately (e.g. due to network outage), it will be reattempted regularly /// until successful upload is confirmed. /// Consent status is stored in PlayerPrefs so that the opted-out status is maintained over app restart. /// This action cannot be undone. /// /// Thrown if the required consent flow cannot be determined.. void OptOut(); /// /// Allows other sources to write events with common analytics parameters to the Analytics service. This is primarily for use /// by other packages - as this method adds common parameters that may not be expected in the general case, for custom events /// you should use the CustomData method instead. /// /// Internal event to record void RecordInternalEvent(Event eventToRecord); /// /// Record an acquisitionSource event. /// /// (Required) Helper object to handle parameters. void AcquisitionSource(AcquisitionSourceParameters acquisitionSourceParameters); /// /// Allows you to disable the Analytics service. When the service gets disabled all currently cached data both in RAM and on disk /// will be deleted and any new events will be voided. By default the service is enabled so you do not need to call this method on start. /// Will return instantly when disabling, must be awaited when re-enabling. /// /// To disable the Analytics Service before the game starts /// /// [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] /// static void DisableAnalytics() /// { /// AnalyticsService.Instance.SetAnalyticsEnabled(false); /// } /// /// /// Task SetAnalyticsEnabled(bool enabled); /// /// Converts an amount of currency to the minor units required for the objects passed to the Transaction method. /// This method uses data from ISO 4217. Note that this method expects you to pass in currency in the major units for /// conversion - if you already have data in the minor units you don't need to call this method. /// For example - 1.99 USD would be converted to 199, 123 JPY would be returned unchanged. /// /// The ISO4217 currency code for the input currency. For example, USD for dollars, or JPY for Japanese Yen /// The major unit value of currency, for example 1.99 for 1 dollar 99 cents. /// The minor unit value of the input currency, for example for an input of 1.99 USD 199 would be returned. long ConvertCurrencyToMinorUnits(string currencyCode, double value); } }