# FAnalyticsProviderTreasureData

## Overview


```cpp
class FAnalyticsProviderTreasureData;
```

Treasure Data Unreal Engine Analytics Provider plugin. This SDK will immediately upload events upon adding them. No local buffer used.

## Public Types

### enum FAnalyticsRegion

| Enumerator | Value | Description |
|  --- | --- | --- |
| US01 |  | USA - us01.records.in.treasuredata.com |
| AP01 |  | Japan - ap01.records.in.treasuredata.com |
| AP02 |  | Korea - ap02.records.in.treasuredata.com |
| EU01 |  | Europe - eu01.records.in.treasuredata.com. |


Check your organizations settings to verify the correct selection.

## Public Functions

### Create


```cpp
static inline TSharedPtr< IAnalyticsProvider > Create(
    const FString Key,
    const FString DBName,
    FAnalyticsRegion Region
)
```

Create Treasure Data Instance. All events will be recorded to two tables, `Sessions` and `Events`.

| Param | Description |
|  --- | --- |
| Key | Write only API Key |
| DBName | Database Name to log data to. Maximum length of 120 characters. |
| Region | Treasure Account Region |


**Return**: TD Analytics Provider Instance

### Destroy


```cpp
static inline void Destroy()
```

Remove all configuration data from the Treasure Data instance.

### StartSession


```cpp
virtual bool StartSession(
    const TArray< FAnalyticsEventAttribute > & Attributes
) override
```

Start the session

| Param | Description |
|  --- | --- |
| Attributes | Additional event attributes |


**Return**: bool true if session started successfully

### EndSession


```cpp
virtual void EndSession() override
```

End the session

### SetUserID


```cpp
virtual void SetUserID(
    const FString & InUserID
) override
```

Set the ID of the User

| Param | Description |
|  --- | --- |
| InUserID | String representing the User ID. Preferably Unique. |


### GetUserID


```cpp
virtual FString GetUserID() const override
```

Get the ID of the User

**Return**: FString string representing the User ID

### GetSessionID


```cpp
virtual FString GetSessionID() const override
```

Get the current session ID

**Return**: FString string representing the current session ID

### SetSessionID


```cpp
virtual bool SetSessionID(
    const FString & InSessionID
) override
```

Set the Session ID of the User

| Param | Description |
|  --- | --- |
| InSessionID | session id as a string |


**Return**: bool true if session id set successfully

### RecordEvent


```cpp
virtual void RecordEvent(
    const FString & EventName,
    const TArray< FAnalyticsEventAttribute > & Attributes
) override
```

Record an event

| Param | Description |
|  --- | --- |
| EventName | Name of Event |
| Attributes | Attributes as an array |


### RecordItemPurchase


```cpp
virtual void RecordItemPurchase(
    const FString & ItemId,
    const FString & Currency,
    int PerItemCost,
    int ItemQuantity
) override
```

Record an item purchase

| Param | Description |
|  --- | --- |
| ItemId | string representing ID of item |
| Currency | string representing ID of currency |
| PerItemCost | integer cost of item |
| ItemQuantity | number of items |


### RecordCurrencyPurchase


```cpp
virtual void RecordCurrencyPurchase(
    const FString & GameCurrencyType,
    int GameCurrencyAmount,
    const FString & RealCurrencyType,
    float RealMoneyCost,
    const FString & PaymentProvider
) override
```

Record purchase of currency

| Param | Description |
|  --- | --- |
| GameCurrencyType | Type of currency as a string |
| GameCurrencyAmount | Amount of currency as a integer |
| RealCurrencyType | Currency type as a string |
| RealMoneyCost | Cost in Real dollars as a float |
| PaymentProvider | Payment Provider as a string |


### RecordCurrencyGiven


```cpp
virtual void RecordCurrencyGiven(
    const FString & GameCurrencyType,
    int GameCurrencyAmount
) override
```

Record the currency given to the user

| Param | Description |
|  --- | --- |
| GameCurrencyType | Type of in-game currency as a string |
| GameCurrencyAmount | Amount of in-game currency as an integer |


### SetBuildInfo


```cpp
virtual void SetBuildInfo(
    const FString & InBuildInfo
) override
```

Set the build information

| Param | Description |
|  --- | --- |
| InBuildInfo | Build information as a string |


### SetGender


```cpp
virtual void SetGender(
    const FString & InGender
) override
```

Set the Gender of the User

| Param | Description |
|  --- | --- |
| InGender | String representing the gender |


### SetLocation


```cpp
virtual void SetLocation(
    const FString & InLocation
) override
```

Set the Location of the User

| Param | Description |
|  --- | --- |
| InLocation | String representing the location of the user |


### SetAge


```cpp
virtual void SetAge(
    const int32 InAge
) override
```

Set the Age of the User

| Param | Description |
|  --- | --- |
| InAge | Integer representing the age of the user |


### RecordItemPurchase


```cpp
virtual void RecordItemPurchase(
    const FString & ItemId,
    int ItemQuantity,
    const TArray< FAnalyticsEventAttribute > & EventAttrs
) override
```

Record the purchase of an in-game item

| Param | Description |
|  --- | --- |
| ItemId | ID of the item as a string |
| ItemQuantity | Number of items as an integer |
| EventAttrs | Additional event attributes |


### RecordCurrencyPurchase


```cpp
virtual void RecordCurrencyPurchase(
    const FString & GameCurrencyType,
    int GameCurrencyAmount,
    const TArray< FAnalyticsEventAttribute > & EventAttrs
) override
```

Record purchase of in-game currency

| Param | Description |
|  --- | --- |
| GameCurrencyType | Type of currency in game as a string |
| GameCurrencyAmount | Amount of currency as an integer |
| EventAttrs | Additional event attributes |


### RecordCurrencyGiven


```cpp
virtual void RecordCurrencyGiven(
    const FString & GameCurrencyType,
    int GameCurrencyAmount,
    const TArray< FAnalyticsEventAttribute > & EventAttrs
) override
```

Record currency given to user in-game

| Param | Description |
|  --- | --- |
| GameCurrencyType | Type of currency |
| GameCurrencyAmount | Amount of currency |
| EventAttrs | Additional event attributes |


### RecordError


```cpp
virtual void RecordError(
    const FString & Error,
    const TArray< FAnalyticsEventAttribute > & EventAttrs
) override
```

When things go wrong, record an error

| Param | Description |
|  --- | --- |
| Error | Error event name |
| EventAttrs | Error event attributes |


### RecordProgress


```cpp
virtual void RecordProgress(
    const FString & ProgressType,
    const FString & ProgressHierarchy,
    const TArray< FAnalyticsEventAttribute > & EventAttrs
) override
```

Record progress of user

| Param | Description |
|  --- | --- |
| ProgressType | Type of progress as a string |
| ProgressHierarchy | Hierarchy of progress as a string |
| EventAttrs | Additional event attributes |


### AddEventAttribute


```cpp
void AddEventAttribute(
    const FString & EventName,
    const FString & EventValue
)
```

Add basic event with value

| Param | Description |
|  --- | --- |
| EventName | Name of Event |
| EventValue | Value of event |


### ClearEventAttributes


```cpp
void ClearEventAttributes()
```

Clear event attributes

### GetRegion


```cpp
inline FAnalyticsRegion GetRegion()
```

Return the [AnalyticsRegion](#enum-fanalyticsregion) currently set for the object instance.

### GetAPIURL


```cpp
inline FString GetAPIURL()
```

Convenience function to transform API Endpoint enumerations into Postback API address string.

**Return**: string with the Postback API endpoint