Skip to content
This repository was archived by the owner on Jan 22, 2024. It is now read-only.

samples: add Java samples for date ranges#470

Merged
ikuleshov merged 24 commits into
googleapis:mainfrom
anweshan:main
May 17, 2022
Merged

samples: add Java samples for date ranges#470
ikuleshov merged 24 commits into
googleapis:mainfrom
anweshan:main

Conversation

@anweshan
Copy link
Copy Markdown
Contributor

No description provided.

@anweshan anweshan requested review from a team April 12, 2022 21:54
@product-auto-label product-auto-label Bot added the size: l Pull request size is large. label Apr 12, 2022
@snippet-bot
Copy link
Copy Markdown

snippet-bot Bot commented Apr 12, 2022

Here is the summary of changes.

You are about to add 2 region tags.

This comment is generated by snippet-bot.
If you find problems with this result, please file an issue at:
https://github.com/googleapis/repo-automation-bots/issues.
To update this comment, add snippet-bot:force-run label or use the checkbox below:

  • Refresh this comment

@product-auto-label product-auto-label Bot added api: analyticsdata Issues related to the googleapis/java-analytics-data API. samples Issues that are directly related to samples. labels Apr 12, 2022
To run this sample using Maven:
cd java-analytics-data/samples/snippets
mvn compile
mvn exec:java -Dexec.mainClass="com.example.analytics.RunReportWithDateRangesSample"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we use exec:exec instead of exec:java?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey Averi. Just chiming in on behalf of the Google Analytics team. Is it possible you can point us to any instance of other samples using exec:exec? It does not seem to be possible to run just a single class using exec:exec, as it does not support -Dexec.mainClass argument. GoogleCloudPlatform/java-docs-samples#1523 just hardcodes the classname in pom.xml which works with a single Quickstart sample, but we have dozens of them. Thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I see that guidance doesn't work well here. You can continue to use exec:java


// Make the request.
RunReportResponse response = analyticsData.runReport(request);
RunReportSample.printRunResponseResponse(response);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Users may be confused on where this is coming from, so you may wish to note the file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@averikitsch what do you mean by note the file? Do you mean where the print method is coming from?

Such as a comment like
// Prints the response using a method in RunReportSample.java

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yes, that comment is good

RunReportRequest.newBuilder()
.setProperty("properties/" + propertyId)
.addDateRanges(DateRange.newBuilder().setStartDate("2020-01-01")
.setEndDate("2020-01-31").setName("year_ago"))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For the purpose of this sample to be clearer you may wish to create these Named date ranges outside of the request builder

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made this change, but ultimately it was because of consistency to the similar existing python sample for the same code

https://github.com/googleapis/python-analytics-data/blob/main/samples/snippets/run_report_with_named_date_ranges.py

@averikitsch averikitsch added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 2, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 2, 2022
@ikuleshov ikuleshov added the owlbot:run Add this label to trigger the Owlbot post processor. label May 4, 2022
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 4, 2022
@ikuleshov ikuleshov added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 17, 2022
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label May 17, 2022
@ikuleshov ikuleshov merged commit 9dbe3e3 into googleapis:main May 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: analyticsdata Issues related to the googleapis/java-analytics-data API. samples Issues that are directly related to samples. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants