UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FAnalyticsProviderETEventCache Class Reference

#include <AnalyticsProviderETEventCache.h>

Classes

class  Lock
 

Public Member Functions

ANALYTICSET_API FAnalyticsProviderETEventCache (int32 MaximumPayloadSize=-1, int32 InPreallocatedPayloadSize=-1)
 
ANALYTICSET_API void AddToCache (FString EventName, const TArray< FAnalyticsEventAttribute > &Attributes)
 
ANALYTICSET_API void AddToCache (FString EventName)
 
ANALYTICSET_API void SetDefaultAttributes (TArray< FAnalyticsEventAttribute > &&DefaultAttributes)
 
ANALYTICSET_API TArray< FAnalyticsEventAttributeGetDefaultAttributes () const
 
ANALYTICSET_API int32 GetDefaultAttributeCount () const
 
ANALYTICSET_API FAnalyticsEventAttribute GetDefaultAttribute (int32 AttributeIndex) const
 
ANALYTICSET_API FString FlushCache (SIZE_T *OutEventCount=nullptr)
 
ANALYTICSET_API TArray< uint8FlushCacheUTF8 ()
 
ANALYTICSET_API TArray< uint8CreateImmediatePayload (const FString &EventName, const TArray< FAnalyticsEventAttribute > &Attributes) const
 
ANALYTICSET_API bool CanFlush () const
 
ANALYTICSET_API bool HasFlushesQueued () const
 
ANALYTICSET_API int GetNumCachedEvents () const
 
ANALYTICSET_API void SetPreallocatedPayloadSize (int32 InSetPreallocatedPayloadSize)
 
ANALYTICSET_API int32 GetSetPreallocatedPayloadSize () const
 

Static Public Member Functions

static ANALYTICSET_API void OnStartupModule ()
 

Friends

class Lock
 

Detailed Description

Mixin class for Epic Telemetry implementors. The purpose of this class is to support the concept of caching events that are added via the standard RecordEvent API and serializing them into a payload in a Json format compatible with Epic's backend data collectors. The job of transporting these payloads to an external collector (generally expected to be via HTTP) is left to higher level classes to implement.

All public APIs in this class are threadsafe. Implemented via crappy critical sections for now, but they are safe.

Constructor & Destructor Documentation

◆ FAnalyticsProviderETEventCache()

FAnalyticsProviderETEventCache::FAnalyticsProviderETEventCache ( int32  MaximumPayloadSize = -1,
int32  InPreallocatedPayloadSize = -1 
)

Default ctor.

Parameters
InPreallocatedPayloadSize- size to preallocate the payload buffer to during init and after flushing. If negative, will match the INI-configured MaximumPayloadSize.
MaximumPayloadSize- size before a payload will be queued for flush. This ensures that no payload ever gets too large. See AddToCache() and HasFlushesQueued() for details. If negative, will use INI-configured value: Engine:[AnalyticsProviderETEventCache]MaximumPayloadSize, or 100KB if not configured.

Member Function Documentation

◆ AddToCache() [1/2]

void FAnalyticsProviderETEventCache::AddToCache ( FString  EventName)

◆ AddToCache() [2/2]

void FAnalyticsProviderETEventCache::AddToCache ( FString  EventName,
const TArray< FAnalyticsEventAttribute > &  Attributes 
)

Adds a new event to the cache. If the estimated payload size will increase beyond MaximumPayloadSize then a flush will be queued here. This will make HasFlushesQueued() == true.

◆ CanFlush()

bool FAnalyticsProviderETEventCache::CanFlush ( ) const

Determines whether we have anything we need to flush, either a queued flush or existing events in the payload.

◆ CreateImmediatePayload()

TArray< uint8 > FAnalyticsProviderETEventCache::CreateImmediatePayload ( const FString &  EventName,
const TArray< FAnalyticsEventAttribute > &  Attributes 
) const

Creates a immediate payload with the existing default attributes

◆ FlushCache()

FString FAnalyticsProviderETEventCache::FlushCache ( SIZE_T OutEventCount = nullptr)

Flushes the cache as a string. This method is inefficient because we build up the array directly as UTF8. If nothing is cached, returns an empty string.

◆ FlushCacheUTF8()

TArray< uint8 > FAnalyticsProviderETEventCache::FlushCacheUTF8 ( )

Flushes the cache as a UTF8 char array. Returns a uint8 because that's what IHttpRequest prefers. If nothing is cached, returns an empty array.

◆ GetDefaultAttribute()

FAnalyticsEventAttribute FAnalyticsProviderETEventCache::GetDefaultAttribute ( int32  AttributeIndex) const

Range checking is not done, similar to TArray. Use GetDefaultAttributeCount() first!

Returns
one attribute of the default attributes so we don't have to copy the entire attribute array.

◆ GetDefaultAttributeCount()

int32 FAnalyticsProviderETEventCache::GetDefaultAttributeCount ( ) const
Returns
the number of default attributes are currently being applied.

◆ GetDefaultAttributes()

TArray< FAnalyticsEventAttribute > FAnalyticsProviderETEventCache::GetDefaultAttributes ( ) const
Returns
the current array of default attributes.

◆ GetNumCachedEvents()

int FAnalyticsProviderETEventCache::GetNumCachedEvents ( ) const

Gets the number of cached events (doesn't include any flushes that are already queued for flush).

◆ GetSetPreallocatedPayloadSize()

int32 FAnalyticsProviderETEventCache::GetSetPreallocatedPayloadSize ( ) const

Gets the preallocated size of the payload buffer.

◆ HasFlushesQueued()

bool FAnalyticsProviderETEventCache::HasFlushesQueued ( ) const

Lets external code know that there are payloads queued for flush. This happens when AddCache() calls cause the payload size to exceed MaxPayloadSize. Calling code needs to notice this and flush the queue.

◆ OnStartupModule()

ANALYTICSET_API void FAnalyticsProviderETEventCache::OnStartupModule ( )
static

◆ SetDefaultAttributes()

void FAnalyticsProviderETEventCache::SetDefaultAttributes ( TArray< FAnalyticsEventAttribute > &&  DefaultAttributes)

Sets an array of attributes that will automatically be appended to any event that is sent. Logical effect is like adding them to all events before calling RecordEvent. Practically, it is implemented much more efficiently from a storage and allocation perspective.

◆ SetPreallocatedPayloadSize()

void FAnalyticsProviderETEventCache::SetPreallocatedPayloadSize ( int32  InSetPreallocatedPayloadSize)

Sets the preallocated payload size

Parameters
InPreallocatedCacheSizesize to preallocate the payload buffer to during init and after flushing. If negative, will match the INI-configured MaximumPayloadSize.

Friends And Related Symbol Documentation

◆ Lock

friend class Lock
friend

The documentation for this class was generated from the following files: