Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
5a73570b
Unverified
Commit
5a73570b
authored
7 years ago
by
Cam Saul
Browse files
Options
Downloads
Patches
Plain Diff
Humanize error message when GA needs API enabled
parent
3367d28e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
project.clj
+2
-2
2 additions, 2 deletions
project.clj
src/metabase/api/setup.clj
+2
-3
2 additions, 3 deletions
src/metabase/api/setup.clj
src/metabase/driver/googleanalytics.clj
+37
-26
37 additions, 26 deletions
src/metabase/driver/googleanalytics.clj
with
41 additions
and
31 deletions
project.clj
+
2
−
2
View file @
5a73570b
...
...
@@ -47,9 +47,9 @@
[
com.draines/postal
"2.0.2"
]
; SMTP library
[
com.github.brandtg/stl-java
"0.1.1"
]
; STL decomposition
[
com.google.apis/google-api-services-analytics
; Google Analytics Java Client Library
"v3-rev1
39
-1.2
2
.0"
]
"v3-rev1
42
-1.2
3
.0"
]
[
com.google.apis/google-api-services-bigquery
; Google BigQuery Java Client Library
"v2-rev3
42
-1.2
2
.0"
]
"v2-rev3
68
-1.2
3
.0"
]
[
com.jcraft/jsch
"0.1.54"
]
; SSH client for tunnels
[
com.h2database/h2
"1.4.194"
]
; embedded SQL database
[
com.mattbertolini/liquibase-slf4j
"2.0.0"
]
; Java Migrations lib
...
...
This diff is collapsed.
Click to expand it.
src/metabase/api/setup.clj
+
2
−
3
View file @
5a73570b
...
...
@@ -5,8 +5,7 @@
[
email
:as
email
]
[
events
:as
events
]
[
public-settings
:as
public-settings
]
[
setup
:as
setup
]
[
util
:as
u
]]
[
setup
:as
setup
]]
[
metabase.api
[
common
:as
api
]
[
database
:as
database-api
:refer
[
DBEngineString
]]]
...
...
@@ -16,7 +15,7 @@
[
session
:refer
[
Session
]]
[
user
:as
user
:refer
[
User
]]]
[
metabase.util.schema
:as
su
]
[
puppetlabs.i18n.core
:as
i18n
:refer
[
tru
]]
[
puppetlabs.i18n.core
:refer
[
tru
]]
[
schema.core
:as
s
]
[
toucan.db
:as
db
]))
...
...
This diff is collapsed.
Click to expand it.
src/metabase/driver/googleanalytics.clj
+
37
−
26
View file @
5a73570b
...
...
@@ -6,13 +6,14 @@
[
util
:as
u
]]
[
metabase.driver.google
:as
google
]
[
metabase.driver.googleanalytics.query-processor
:as
qp
]
[
metabase.models.database
:refer
[
Database
]])
[
metabase.models.database
:refer
[
Database
]]
[
puppetlabs.i18n.core
:refer
[
tru
]])
(
:import
com.google.api.client.googleapis.auth.oauth2.GoogleCredential
[
com.google.api.services.analytics
Analytics
Analytics$Builder
Analytics$Data$Ga$Get
AnalyticsScopes
]
[
com.google.api.services.analytics.model
Column
Columns
Profile
Profiles
Webproperties
Webproperty
]
[
java.util
Collections
Date
Map
]))
;;; ----------------------------------------
Client
----------------------------------------
;;; ----------------------------------------
------------- Client -------------
----------------------------------------
(
defn-
^
Analytics
credential->client
[
^
GoogleCredential
credential
]
(
.build
(
doto
(
Analytics$Builder.
google/http-transport
google/json-factory
credential
)
...
...
@@ -25,7 +26,7 @@
(
comp
credential->client
database->credential
))
;;; ---------------------------------------- describe-database ----------------------------------------
;;; ----------------------------------------
-------
describe-database ----------------------------------------
--------
(
defn-
fetch-properties
^
Webproperties
[
^
Analytics
client,
^
String
account-id
]
...
...
@@ -223,6 +224,15 @@
;;; ----------------------------------------------------- Driver -----------------------------------------------------
(
defn-
humanize-connection-error-message
[
message
]
;; if we get a big long message about how we need to enable the GA API, then replace it with a short message about
;; how we need to enable the API
(
if-let
[[
_
enable-api-url
]
(
re-find
#
"Enable it by visiting ([^\s]+) then retry."
message
)]
(
tru
"You must enable the Google Analytics API. Use this link to go to the Google Developers Console: {0}"
enable-api-url
)
message
))
(
defrecord
GoogleAnalyticsDriver
[]
clojure.lang.Named
(
getName
[
_
]
"Google Analytics"
))
...
...
@@ -230,29 +240,30 @@
(
u/strict-extend
GoogleAnalyticsDriver
driver/IDriver
(
merge
driver/IDriverDefaultsMixin
{
:can-connect?
(
u/drop-first-arg
can-connect?
)
:describe-database
(
u/drop-first-arg
describe-database
)
:describe-table
(
u/drop-first-arg
describe-table
)
:details-fields
(
constantly
[{
:name
"account-id"
:display-name
"Google Analytics Account ID"
:placeholder
"1234567"
:required
true
}
{
:name
"client-id"
:display-name
"Client ID"
:placeholder
"1201327674725-y6ferb0feo1hfssr7t40o4aikqll46d4.apps.googleusercontent.com"
:required
true
}
{
:name
"client-secret"
:display-name
"Client Secret"
:placeholder
"dJNi4utWgMzyIFo2JbnsK6Np"
:required
true
}
{
:name
"auth-code"
:display-name
"Auth Code"
:placeholder
"4/HSk-KtxkSzTt61j5zcbee2Rmm5JHkRFbL5gD5lgkXek"
:required
true
}])
:execute-query
(
u/drop-first-arg
(
partial
qp/execute-query
do-query
))
:process-query-in-context
(
u/drop-first-arg
process-query-in-context
)
:mbql->native
(
u/drop-first-arg
qp/mbql->native
)
:table-rows-seq
(
u/drop-first-arg
table-rows-seq
)}))
{
:can-connect?
(
u/drop-first-arg
can-connect?
)
:describe-database
(
u/drop-first-arg
describe-database
)
:describe-table
(
u/drop-first-arg
describe-table
)
:details-fields
(
constantly
[{
:name
"account-id"
:display-name
"Google Analytics Account ID"
:placeholder
"1234567"
:required
true
}
{
:name
"client-id"
:display-name
"Client ID"
:placeholder
"1201327674725-y6ferb0feo1hfssr7t40o4aikqll46d4.apps.googleusercontent.com"
:required
true
}
{
:name
"client-secret"
:display-name
"Client Secret"
:placeholder
"dJNi4utWgMzyIFo2JbnsK6Np"
:required
true
}
{
:name
"auth-code"
:display-name
"Auth Code"
:placeholder
"4/HSk-KtxkSzTt61j5zcbee2Rmm5JHkRFbL5gD5lgkXek"
:required
true
}])
:execute-query
(
u/drop-first-arg
(
partial
qp/execute-query
do-query
))
:process-query-in-context
(
u/drop-first-arg
process-query-in-context
)
:mbql->native
(
u/drop-first-arg
qp/mbql->native
)
:table-rows-seq
(
u/drop-first-arg
table-rows-seq
)
:humanize-connection-error-message
(
u/drop-first-arg
humanize-connection-error-message
)}))
(
defn
-init-driver
"Register the Google Analytics driver"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment