Skip to content
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

8830 add google analytics authentication and reporting to enso #8907

Merged
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
68b550a
updated google api to the latest and added google analytics method
Cassandra-Clark Jan 24, 2024
cab5064
updated google api to the latest and added google analytics method
Cassandra-Clark Jan 24, 2024
6a04ab4
Merge branch '8830-add-google-analytics-authentication-and-reporting-…
Cassandra-Clark Jan 24, 2024
3157e16
hardcoded values for testing
Cassandra-Clark Jan 29, 2024
1b7521c
Latest version based on session with James
Cassandra-Clark Jan 29, 2024
b0feb24
updated google api to the latest and added google analytics method
Cassandra-Clark Jan 24, 2024
fd6783a
hardcoded values for testing
Cassandra-Clark Jan 29, 2024
d73dba3
Latest version based on session with James
Cassandra-Clark Jan 29, 2024
4a021a1
Parse the result into a Table.
jdunkerley Jan 30, 2024
00b1981
Merge branch '8830-add-google-analytics-authentication-and-reporting-…
Cassandra-Clark Jan 30, 2024
22445fd
Update CHANGELOG.md
Cassandra-Clark Jan 30, 2024
10144c3
Update distribution/lib/Standard/Google_Api/0.0.0-dev/src/Main.enso
Cassandra-Clark Jan 31, 2024
370320b
Updated documentation
Cassandra-Clark Jan 31, 2024
7bef9c4
Merge branch '8830-add-google-analytics-authentication-and-reporting-…
Cassandra-Clark Jan 31, 2024
6f69f93
rename run_google_report to run_analytics_report
Cassandra-Clark Feb 5, 2024
dfdef99
adding license info 1
radeusgd Feb 6, 2024
18311b0
faster dropdown in helper tool
radeusgd Feb 6, 2024
0421c88
Merge branch 'develop' into 8830-add-google-analytics-authentication-…
radeusgd Feb 6, 2024
c9b1264
update reviews
radeusgd Feb 7, 2024
fab9861
update generated reports
radeusgd Feb 7, 2024
a0a8230
Remove jsr305 from dependencies
radeusgd Feb 7, 2024
8eb28bc
Merge branch 'develop' into 8830-add-google-analytics-authentication-…
jdunkerley Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,7 @@
- [DataflowError.withoutTrace doesn't store stacktrace][8608]
- [Derive --in-project from --run source location][8775]
- [Binary operator resolution based on that value][8779]
- [Add run_google_report method][8907]

[3227]: https://github.com/enso-org/enso/pull/3227
[3248]: https://github.com/enso-org/enso/pull/3248
Expand Down Expand Up @@ -1186,6 +1187,7 @@
[8608]: https://github.com/enso-org/enso/pull/8608
[8775]: https://github.com/enso-org/enso/pull/8775
[8779]: https://github.com/enso-org/enso/pull/8779
[8907]: https://github.com/enso-org/enso/pull/8907

# Enso 2.0.0-alpha.18 (2021-10-12)

Expand Down
5 changes: 3 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -2776,8 +2776,9 @@ lazy val `std-google-api` = project
Compile / packageBin / artifactPath :=
`google-api-polyglot-root` / "std-google-api.jar",
libraryDependencies ++= Seq(
"com.google.api-client" % "google-api-client" % "1.35.2",
"com.google.apis" % "google-api-services-sheets" % "v4-rev612-1.25.0"
"com.google.api-client" % "google-api-client" % "2.2.0",
"com.google.apis" % "google-api-services-sheets" % "v4-rev612-1.25.0",
"com.google.analytics" % "google-analytics-data" % "0.44.0"
),
Compile / packageBin := Def.task {
val result = (Compile / packageBin).value
Expand Down
42 changes: 42 additions & 0 deletions distribution/lib/Standard/Google_Api/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from Standard.Base import all
import Standard.Base.Data.Array_Proxy.Array_Proxy

from Standard.Table import Table

Expand All @@ -8,6 +9,14 @@ polyglot java import com.google.api.client.json.gson.GsonFactory
polyglot java import com.google.api.services.sheets.v4.Sheets
polyglot java import com.google.api.services.sheets.v4.SheetsScopes
polyglot java import java.util.Collections
polyglot java import com.google.analytics.data.v1beta.BetaAnalyticsDataClient
polyglot java import com.google.analytics.data.v1beta.DateRange
polyglot java import com.google.analytics.data.v1beta.Dimension
polyglot java import com.google.analytics.data.v1beta.Metric
polyglot java import com.google.analytics.data.v1beta.Row
polyglot java import com.google.analytics.data.v1beta.RunReportRequest
polyglot java import com.google.analytics.data.v1beta.RunReportResponse


## PRIVATE
type Google_Api_Client
Expand Down Expand Up @@ -58,3 +67,36 @@ initialize secret_file =
http_transport = GoogleNetHttpTransport.newTrustedTransport
json_factory = GsonFactory.getDefaultInstance
Google_Api_Client.Value credential json_factory http_transport


## PLACEHOLDER, performs google analytics call

Arguments:
- property_id
- start_date
- end_date
Cassandra-Clark marked this conversation as resolved.
Show resolved Hide resolved
run_google_report : Text -> Date -> Date -> Table
run_google_report property_id:Text start_date:Date=(Date.new 2020 3 31) end_date:Date=Date.today =
Cassandra-Clark marked this conversation as resolved.
Show resolved Hide resolved
analytics_data = BetaAnalyticsDataClient.create
request = RunReportRequest.newBuilder
. setProperty ("properties/"+property_id)
. addDimensions (Dimension.newBuilder.setName "city")
. addMetrics (Metric.newBuilder.setName "activeUsers")
. addDateRanges (DateRange.newBuilder.setStartDate start_date.to_text . setEndDate end_date.to_text)
. build
response = analytics_data.runReport request

dimension_count = response.getDimensionHeadersCount
dimensions = 0.up_to dimension_count . map i-> response.getDimensionHeaders i . getName
metric_count = response.getMetricHeadersCount
metrics = 0.up_to metric_count . map i-> response.getMetricHeaders i . getName
headers = dimensions + metrics

row_count = response.getRowCount
row_proxy = Array_Proxy.new row_count i->
row = response.getRows i
dimension_values = 0.up_to dimension_count . map i-> row.getDimensionValues i . getValue
metric_values = 0.up_to metric_count . map i-> row.getMetricValues i . getValue
dimension_values + metric_values
Cassandra-Clark marked this conversation as resolved.
Show resolved Hide resolved

Table.from_rows headers (Vector.from_polyglot_array row_proxy)
3 changes: 2 additions & 1 deletion project/Editions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ object Editions {
"Standard.Geo",
"Standard.Visualization",
"Standard.Examples",
"Standard.Searcher"
"Standard.Searcher",
"Standard.Google_Api"
)

case class ContribLibrary(name: String, version: String)
Expand Down
Loading