Skip to content

Commit 4a09083

Browse files
authored
[FirebaseAI] Add heartbeat info (#1248)
* [FirebaseAI] Add FirebaseAI to heartbeat logic * Update app.i * Update app.i
1 parent 4c03391 commit 4a09083

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

app/src/swig/app.i

+17
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,23 @@ static firebase::AppOptions* AppOptionsLoadFromJsonConfig(const char* config) {
892892
userAgentMap[libraryPrefix + "-buildsrc"] =
893893
Firebase.VersionInfo.BuildSource;
894894

895+
try {
896+
// FirebaseAI doesn't depend on the other platforms, so the heartbeat
897+
// logic needs to check for it here, using reflection.
898+
const string firebaseAIClassName = "Firebase.AI.FirebaseAI";
899+
// Iterate over the loaded assemblies, since we don't have a known DLL name.
900+
foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies()) {
901+
System.Type foundType = assembly.GetType(firebaseAIClassName, throwOnError: false, ignoreCase: false);
902+
if (foundType != null) {
903+
// Found the class, add the FirebaseAI heartbeat to the user agent.
904+
userAgentMap["fire-vertex"] = Firebase.VersionInfo.SdkVersion;
905+
break;
906+
}
907+
}
908+
} catch {
909+
// Don't actually want to do anything if it fails
910+
}
911+
895912
RegisterLibrariesInternal(userAgentMap);
896913
}
897914

0 commit comments

Comments
 (0)