samples: add Java samples for date ranges#470
Conversation
|
Here is the summary of changes. You are about to add 2 region tags.
This comment is generated by snippet-bot.
|
| To run this sample using Maven: | ||
| cd java-analytics-data/samples/snippets | ||
| mvn compile | ||
| mvn exec:java -Dexec.mainClass="com.example.analytics.RunReportWithDateRangesSample" |
There was a problem hiding this comment.
Can we use exec:exec instead of exec:java?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Users may be confused on where this is coming from, so you may wish to note the file
There was a problem hiding this comment.
@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
| RunReportRequest.newBuilder() | ||
| .setProperty("properties/" + propertyId) | ||
| .addDateRanges(DateRange.newBuilder().setStartDate("2020-01-01") | ||
| .setEndDate("2020-01-31").setName("year_ago")) |
There was a problem hiding this comment.
For the purpose of this sample to be clearer you may wish to create these Named date ranges outside of the request builder
There was a problem hiding this comment.
I made this change, but ultimately it was because of consistency to the similar existing python sample for the same code
No description provided.