Mixin class for Epic Telemetry implementors. 更多...
#include <AnalyticsProviderETEventCache.h>
类 | |
| class | Lock |
| For when you need to take a lock across multiple API calls 更多... | |
Public 成员函数 | |
| void | AddToCache (FString EventName, const TArray< FAnalyticsEventAttribute > &Attributes) |
| Adds a new event to the cache. 更多... | |
| bool | CanFlush () const |
| Determines whether we have anything we need to flush, either a queued flush or existing events in the payload. | |
| FAnalyticsProviderETEventCache (int32 MaximumPayloadSize=-1, int32 InPreallocatedPayloadSize=-1) | |
| Default ctor. 更多... | |
| FString | FlushCache (SIZE_T *OutEventCount=nullptr) |
| Flushes the cache as a string. 更多... | |
| TArray< uint8 > | FlushCacheUTF8 () |
| Flushes the cache as a UTF8 char array. 更多... | |
| FAnalyticsEventAttribute | GetDefaultAttribute (int32 AttributeIndex) const |
| Range checking is not done, similar to TArray. 更多... | |
| int32 | GetDefaultAttributeCount () const |
| TArray< FAnalyticsEventAttribute > | GetDefaultAttributes () const |
| int | GetNumCachedEvents () const |
| Gets the number of cached events (doesn't include any flushes that are already queued for flush). | |
| int32 | GetSetPreallocatedPayloadSize () const |
| Gets the preallocated size of the payload buffer. | |
| bool | HasFlushesQueued () const |
| Lets external code know that there are payloads queued for flush. 更多... | |
| void | SetDefaultAttributes (TArray< FAnalyticsEventAttribute > &&DefaultAttributes) |
| Sets an array of attributes that will automatically be appended to any event that is sent. 更多... | |
| void | SetPreallocatedPayloadSize (int32 InSetPreallocatedPayloadSize) |
| Sets the preallocated payload size 更多... | |
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.
| FAnalyticsProviderETEventCache::FAnalyticsProviderETEventCache | ( | int32 | MaximumPayloadSize = -1, |
| int32 | InPreallocatedPayloadSize = -1 |
||
| ) |
Default ctor.
| 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. |
| 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.
| 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.
| 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.
| FAnalyticsEventAttribute FAnalyticsProviderETEventCache::GetDefaultAttribute | ( | int32 | AttributeIndex | ) | const |
Range checking is not done, similar to TArray.
Use GetDefaultAttributeCount() first!
| int32 FAnalyticsProviderETEventCache::GetDefaultAttributeCount | ( | ) | const |
| TArray< FAnalyticsEventAttribute > FAnalyticsProviderETEventCache::GetDefaultAttributes | ( | ) | const |
| 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.
| 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.
| void FAnalyticsProviderETEventCache::SetPreallocatedPayloadSize | ( | int32 | InSetPreallocatedPayloadSize | ) |
Sets the preallocated payload size
| InPreallocatedCacheSize | size to preallocate the payload buffer to during init and after flushing. If negative, will match the INI-configured MaximumPayloadSize. |