Interface IAnalyticsService
Namespace: Unity.Services.Analytics
Assembly: Unity.Services.Analytics.dll
Syntax
public interface IAnalyticsService
Properties
PrivacyUrl
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.
Declaration
string PrivacyUrl { get; }
Property Value
Type | Description |
---|---|
string |
SessionID
Gets the session ID that is currently recording into the sessionID field of events.
Declaration
string SessionID { get; }
Property Value
Type | Description |
---|---|
string | The session ID as a string |
Methods
ConvertCurrencyToMinorUnits(string, double)
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.
Declaration
long ConvertCurrencyToMinorUnits(string currencyCode, double value)
Parameters
Type | Name | Description |
---|---|---|
string | currencyCode | The ISO4217 currency code for the input currency. For example, USD for dollars, or JPY for Japanese Yen |
double | value | The major unit value of currency, for example 1.99 for 1 dollar 99 cents. |
Returns
Type | Description |
---|---|
long | The minor unit value of the input currency, for example for an input of 1.99 USD 199 would be returned. |
Flush()
Forces an immediately upload of all recorded events to the server, if there is an internet connection and a flush is not already in progress. Flushing is triggered automatically on a regular cadence so you should not need to use this method, unless you specifically require some queued events to be uploaded immediately.
Declaration
void Flush()
GetAnalyticsUserID()
Gets the user ID that Analytics is currently recording into the userId field of events.
Declaration
string GetAnalyticsUserID()
Returns
Type | Description |
---|---|
string | The user ID as a string |
RecordEvent(string)
Record an event that has no parameters, if the player has opted in to data collection (see StartDataCollection method).
A schema for this event must exist on the dashboard or it will be ignored.
Declaration
void RecordEvent(string eventName)
Parameters
Type | Name | Description |
---|---|---|
string | eventName |
RecordEvent(Event)
Record an event, if the player has opted in to data collection (see StartDataCollection method).
Once the event has been serialized, the Event instance will be cleared so it can be safely reused.
A schema for this event must exist on the dashboard or it will be ignored.
Declaration
void RecordEvent(Event e)
Parameters
Type | Name | Description |
---|---|---|
Event | e | (Required) The event to be recorded. |
RequestDataDeletion()
Requests that all historic data for this user be purged from the back-end and disables data collection. This can be called regardless of whether data collection is currently enabled or disabled.
If the purge request fails (e.g. due to the client being offline), it will be retried until it is successful, even across multiple sessions if necessary.
Declaration
void RequestDataDeletion()
StartDataCollection()
Signals that consent has been obtained from the player and enables data collection.
By calling this method you confirm that consent has been obtained or is not required from the player under any applicable data privacy laws (e.g. GDPR in Europe, PIPL in China). Please obtain your own legal advice to ensure you are in compliance with any data privacy laws regarding personal data collection in the territories in which your app is available.
Declaration
void StartDataCollection()
StopDataCollection()
Disables data collection, preventing any further events from being recorded or uploaded. A final upload containing any events that are currently buffered will be attempted.
Data collection can be re-enabled later, by calling the StartDataCollection method.
Declaration
void StopDataCollection()