Skip to content

[FirebaseAI] Add heartbeat info #1248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 8, 2025
Merged

[FirebaseAI] Add heartbeat info #1248

merged 4 commits into from
May 8, 2025

Conversation

a-maurice
Copy link
Collaborator

@a-maurice a-maurice commented May 8, 2025

Description

Provide details of the change, and generalize the change in the PR title above.

Add FirebaseAI to heartbeat logic, by using reflection in App to determine if FirebaseAI is present, and adding the appropriate user agent.


Testing

Describe how you've tested these changes.

https://github.com/firebase/firebase-unity-sdk/actions/runs/14914214976


Type of Change

Place an x the applicable box:

  • Bug fix. Add the issue # below if applicable.
  • New feature. A non-breaking change which adds functionality.
  • Other, such as a build process or documentation change.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @a-maurice, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Summary of Changes

This pull request adds FirebaseAI to the heartbeat logic. It achieves this by using reflection to determine if FirebaseAI is present and then adding the appropriate user agent. The change modifies app/src/swig/app.i to include this new functionality.

Highlights

  • FirebaseAI Heartbeat: Adds FirebaseAI to the heartbeat logic to ensure proper user agent reporting.
  • Reflection: Uses reflection to check for the presence of FirebaseAI, avoiding direct dependencies.
  • User Agent: Adds the 'fire-vertex' user agent if FirebaseAI is detected.

Changelog

  • app/src/swig/app.i
    • Added a try-catch block to handle potential exceptions during reflection.
    • Implemented reflection logic to find the FirebaseAI class.
    • Added 'fire-vertex' to the user agent map if FirebaseAI is found.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.


Through reflection's art,
FirebaseAI finds its heart,
A user agent's call,
For one and for all,
In heartbeat's gentle start.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request adds FirebaseAI to the heartbeat logic using reflection. This approach allows the app to detect the presence of FirebaseAI without creating a direct dependency. The changes look good overall, but there are a few areas that could be improved for clarity and robustness.

Summary of Findings

  • Exception Handling: The catch block is empty, which can mask potential issues. It's better to log the exception or handle it in some way to understand why the reflection might be failing.
  • User Agent Key: The user agent key fire-vertex might not be descriptive enough. Consider using a more specific key that clearly indicates it's related to FirebaseAI.
  • Reflection Performance: Reflection can be expensive. Consider caching the result of the FirebaseAI check to avoid repeated reflection calls.

Merge Readiness

The pull request is almost ready for merging. I recommend addressing the exception handling and user agent key suggestions to improve the robustness and clarity of the code. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Given the medium severity issues, I recommend that the pull request not be merged until those are addressed.

@a-maurice a-maurice requested a review from cynthiajoan May 8, 2025 22:06
// logic needs to check for it here, using reflection.
const string firebaseAIClassName = "Firebase.AI.FirebaseAI";
// Iterate over the loaded assemblies, since we don't have a known DLL name.
foreach (var assembly in System.AppDomain.CurrentDomain.GetAssemblies()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Apple, if there's a way to associate an Objective-C class and method with the library, we could potentially extend the code at https://github.com/firebase/firebase-ios-sdk/blob/main/FirebaseCore/Sources/FIRApp.m#L816 to handle this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is what inspired me to do it this way. It is assuming the "FirebaseAI" class will be there, so maybe I should use another name in case that changes, but since that is a public facing class it isn't likely to change, so I think it should be fine.

@a-maurice a-maurice merged commit 4a09083 into main May 8, 2025
26 of 28 checks passed
@a-maurice a-maurice deleted the am-firebaseai_heartbeat branch May 8, 2025 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants