-
Notifications
You must be signed in to change notification settings - Fork 2.9k
chore: upgrade java8 to java21 for analytics folder #10148
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
base: main
Are you sure you want to change the base?
chore: upgrade java8 to java21 for analytics folder #10148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @nitesh-55, 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!
This pull request introduces a new App Engine sample for Google Analytics, specifically configured to run on Java 21. It provides a complete setup for tracking events using Google Analytics within an App Engine application, including necessary configuration files and a servlet for event tracking.
Highlights
- New App Engine Java 21 Sample: Introduces a new Google Analytics sample application under appengine-java21/analytics, demonstrating App Engine integration with Java 21.
- Google Analytics Event Tracking: The sample includes AnalyticsServlet.java which sends event data to Google Analytics using the Measurement Protocol.
- Maven Project Setup: A pom.xml is provided, configuring the project for Java 21 compilation, App Engine SDK 2.0.23, and relevant dependencies like httpclient and jstl.
- App Engine Deployment Configuration: appengine-web.xml is configured to use the java21 runtime and defines an environment variable for the Google Analytics tracking ID.
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 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
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.
Footnotes
-
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. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request upgrades the analytics sample to Java 21. The changes are a good start, but there are a few critical and high-severity issues that need to be addressed. The pom.xml
is still configured for Java 1.8, which needs to be updated to 21. Additionally, there are some security concerns, such as using HTTP instead of HTTPS for API calls. I've left specific comments with suggestions for improvement.
<maven.compiler.target>1.8</maven.compiler.target> | ||
<maven.compiler.source>1.8</maven.compiler.source> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually correct because this sample is using
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack
String trackingId = System.getenv("GA_TRACKING_ID"); | ||
URIBuilder builder = new URIBuilder(); | ||
builder | ||
.setScheme("http") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.addParameter("tid", trackingId) // Tracking ID / Property ID. | ||
// Anonymous Client Identifier. Ideally, this should be a UUID that | ||
// is associated with particular user, device, or browser instance. | ||
.addParameter("cid", "555") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on the preceding lines suggests that the client ID (cid
) should ideally be a UUID. Hardcoding it to "555"
is not ideal for a sample. Consider generating a random UUID to better demonstrate the intended usage.
.addParameter("cid", "555") | |
.addParameter("cid", java.util.UUID.randomUUID().toString()) |
<runtime>java21</runtime> | ||
<app-engine-apis>true</app-engine-apis> | ||
<system-properties> | ||
<property name="appengine.use.EE8" value="true"/> | ||
</system-properties> | ||
<env-variables> | ||
<env-var name="GA_TRACKING_ID" value="YOUR-GA-TRACKING-ID" /> | ||
</env-variables> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XML indentation in this file is inconsistent, which makes it harder to read. Please format it with consistent indentation (e.g., 2 spaces per level).
<runtime>java21</runtime>
<app-engine-apis>true</app-engine-apis>
<system-properties>
<property name="appengine.use.EE8" value="true"/>
</system-properties>
<env-variables>
<env-var name="GA_TRACKING_ID" value="YOUR-GA-TRACKING-ID" />
</env-variables>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nitesh-55 I know this was as is existing in the file, can you address this one so it's consistent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
appengine-java21/analytics/pom.xml
Outdated
@@ -0,0 +1,136 @@ | |||
<!-- | |||
Copyright 2017 Google LLC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nitesh-55 no . after LLC.
For others reading this, this is migrating an existing sample over to java 21 and so the year 2017 is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
package com.example.appengine.analytics; | ||
|
||
// [START analytics_track] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nitesh-55 please fix the region tag here. Since this is already a migration, you don't have to keep the invalid region tag. you can create updated as this file isn't in use. Talk to Fran about how to construct a valid more helpful one here please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the region tag
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not seeing the update. It should start with gae_
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
--> | ||
<!-- [END_EXCLUDE] --> | ||
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0"> | ||
<runtime>java21</runtime> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this file looks to have the correct syntax that Ludo provided as guidance for the migration.
<packaging>war</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
<groupId>com.example.appengine</groupId> | ||
<artifactId>appengine-analytics-j21</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is one of the areas that ludo gave guidance of needing to change and looks correct.
…s-samples into j21-upgrade-analytics
@@ -16,7 +16,7 @@ | |||
|
|||
package com.example.appengine.analytics; | |||
|
|||
// [START analytics_track] | |||
// [START analytics_track_j21] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you did, you updated the existing java8 file. Don't do this, update the java21 version above and remove this change from your commit. also a valid region tag would start with gae in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry,my bad. Updated region tag name
…s-samples into j21-upgrade-analytics
as discussed, let's add a subdirectory of ee8 under the runtime version. |
Description
Checklist
pom.xml
parent set to latestshared-configuration
mvn clean verify
requiredmvn -P lint checkstyle:check
requiredmvn -P lint clean compile pmd:cpd-check spotbugs:check
advisory only