/** * Perform any initialization. */ FAnalyticsProviderET::FAnalyticsProviderET(const FAnalyticsET::Config& ConfigValues) :bSessionInProgress(false) , MaxCachedNumEvents(20) , MaxCachedElapsedTime(60.0f) , bShouldCacheEvents(!FParse::Param(FCommandLine::Get(), TEXT("ANALYTICSDISABLECACHING"))) , FlushEventsCountdown(MaxCachedElapsedTime) , bInDestructor(false) { // if we are not caching events, we are operating in debug mode. Turn on super-verbose analytics logging if (!bShouldCacheEvents) { UE_SET_LOG_VERBOSITY(LogAnalytics, VeryVerbose); } APIKey = ConfigValues.APIKeyET; UE_LOG(LogAnalytics, Verbose, TEXT("[%s] Initializing ET Analytics provider"), *APIKey); // allow the APIServer value to be empty and use defaults. APIServer = ConfigValues.APIServerET.IsEmpty() ? FAnalyticsET::Config::GetDefaultAPIServer() : ConfigValues.APIServerET; // default to GEngineVersion if one is not provided, append GEngineVersion otherwise. FString ConfigAppVersion = ConfigValues.AppVersionET; // Allow the cmdline to force a specific AppVersion so it can be set dynamically. FParse::Value(FCommandLine::Get(), TEXT("ANALYTICSAPPVERSION="), ConfigAppVersion, false); AppVersion = ConfigAppVersion.IsEmpty() ? GEngineVersion.ToString() : ConfigAppVersion.Replace(TEXT("%VERSION%"), *GEngineVersion.ToString(), ESearchCase::CaseSensitive); UE_LOG(LogAnalytics, Log, TEXT("[%s] APIServer = %s. AppVersion = %s"), *APIKey, *APIServer, *AppVersion); // cache the build type string FAnalytics::BuildType BuildTypeEnum = FAnalytics::Get().GetBuildType(); BuildType = BuildTypeEnum == FAnalytics::Debug ? "Debug" : BuildTypeEnum == FAnalytics::Development ? "Development" : BuildTypeEnum == FAnalytics::Release ? "Release" : BuildTypeEnum == FAnalytics::Test ? "Test" : "UNKNOWN"; // see if there is a cmdline supplied UserID. #if !UE_BUILD_SHIPPING FString ConfigUserID; if (FParse::Value(FCommandLine::Get(), TEXT("ANALYTICSUSERID="), ConfigUserID, false)) { SetUserID(ConfigUserID); } #endif // !UE_BUILD_SHIPPING }
/** * Perform any initialization. */ FAnalyticsProviderET::FAnalyticsProviderET(const FAnalyticsET::Config& ConfigValues) :bSessionInProgress(false) , APIKey(ConfigValues.APIKeyET) , APIServer(ConfigValues.APIServerET) , MaxCachedNumEvents(20) , MaxCachedElapsedTime(60.0f) , bShouldCacheEvents(!FParse::Param(FCommandLine::Get(), TEXT("ANALYTICSDISABLECACHING"))) , FlushEventsCountdown(MaxCachedElapsedTime) , bInDestructor(false) , UseLegacyProtocol(ConfigValues.UseLegacyProtocol) , bUsingLegacyAppServer(false) { if (APIKey.IsEmpty() || APIServer.IsEmpty()) { UE_LOG(LogAnalytics, Fatal, TEXT("AnalyticsET: APIKey (%s) and APIServer (%s) cannot be empty!"), *APIKey, *APIServer); } // if we are not caching events, we are operating in debug mode. Turn on super-verbose analytics logging if (!bShouldCacheEvents) { UE_SET_LOG_VERBOSITY(LogAnalytics, VeryVerbose); } UE_LOG(LogAnalytics, Verbose, TEXT("[%s] Initializing ET Analytics provider"), *APIKey); // default to FEngineVersion::Current() if one is not provided, append FEngineVersion::Current() otherwise. FString ConfigAppVersion = ConfigValues.AppVersionET; // Allow the cmdline to force a specific AppVersion so it can be set dynamically. FParse::Value(FCommandLine::Get(), TEXT("ANALYTICSAPPVERSION="), ConfigAppVersion, false); AppVersion = ConfigAppVersion.IsEmpty() ? FEngineVersion::Current().ToString() : ConfigAppVersion.Replace(TEXT("%VERSION%"), *FEngineVersion::Current().ToString(), ESearchCase::CaseSensitive); // support legacy connections that send to the old URL and route them to the new URL. // This automatically route older titles to the new endpoint until all their configs can be updated. // @todo: Remove this hack once all internal titles have been updated to use the new URL explicitly. if (APIServer.Equals(TEXT("http://et2.epicgames.com/ET2/"), ESearchCase::IgnoreCase)) { UE_LOG(LogAnalytics, Warning, TEXT("[%s] APIServer is using legacy URL (%s). Automatically updating to the new data router endpoint. Please update your configuration to explicitly point to a data router endpoint."), *APIKey, *APIServer); bUsingLegacyAppServer = true; APIServer = TEXT("https://datarouter.ol.epicgames.com/"); } UE_LOG(LogAnalytics, Log, TEXT("[%s] APIServer = %s. AppVersion = %s"), *APIKey, *APIServer, *AppVersion); // only need these if we are using the data router protocol. if (!UseLegacyProtocol) { AppEnvironment = ConfigValues.AppEnvironment.IsEmpty() ? FAnalyticsET::Config::GetDefaultAppEnvironment() : ConfigValues.AppEnvironment; UploadType = ConfigValues.UploadType.IsEmpty() ? FAnalyticsET::Config::GetDefaultUploadType() : ConfigValues.UploadType; } // see if there is a cmdline supplied UserID. #if !UE_BUILD_SHIPPING FString ConfigUserID; if (FParse::Value(FCommandLine::Get(), TEXT("ANALYTICSUSERID="), ConfigUserID, false)) { SetUserID(ConfigUserID); } #endif // !UE_BUILD_SHIPPING }