embulk-input-google_analytics 0.1.18 → 0.1.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ab44fb8b7d3108fc5611a58e38640eb2839478b
4
- data.tar.gz: c7dbaea282c1703273cffaf02799c5fc2a4a9013
3
+ metadata.gz: 2eea056ceeddbfd441fd63830d0dd80d1f145094
4
+ data.tar.gz: e40d6249b25c5752c10f107f3ea0259f24b8c859
5
5
  SHA512:
6
- metadata.gz: 42e3f0dedf09f963e1e8d016cc673f4c5737a41f2a708e6b5f2245769862c71ba2bd50ca79b622c66a7b896135c18f7568e1db4c059d0ba42de359c02dcae4e8
7
- data.tar.gz: 4e9e5f619ae9ddf6acfdd413984533f14d28cfbb2a59f34bf351b37a128e665e411a2f3cc49092cbf3b3841de9b099d85b42cd9b112bc7d7cc5413f6f2d32f67
6
+ metadata.gz: 569b256dc6577da275bf8c4be9806d7310c7fff1cd7dfbf24cced151b79e828335b566b4fcea96603c650cd7b09584d38438081d68e287c36a6744b5e80fb0f6
7
+ data.tar.gz: 7f235dc9a9ea8749261e36315aac61edc864a89c45ff90974b2184aebe14e6a0b75b20127cd23c8a31b8af4cb11953a6c9d9e5a42054c6f176ac826944f44dec
@@ -0,0 +1,37 @@
1
+ version: 2
2
+ jobs:
3
+ build:
4
+ parallelism: 1
5
+ environment:
6
+ JRUBY_OPTS: "-Xcli.debug=true --debug"
7
+ docker:
8
+ - image: circleci/jruby:9.1.17.0
9
+ working_directory: ~/workspace
10
+ steps:
11
+ - checkout
12
+ - restore_cache:
13
+ keys:
14
+ - deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "embulk-input-google_analytics.gemspec" }}
15
+ - run:
16
+ name: Install bundle
17
+ command: |
18
+ ruby -v
19
+ gem install bundler
20
+ - run:
21
+ name: Install dependencies
22
+ command: |
23
+ bundle -v
24
+ bundle config https://treasuredata.jfrog.io $TD_ARTIFACTORY_USERNAME:$TD_ARTIFACTORY_PASSWORD
25
+ bundle install --path=vendor/bundle
26
+ - save_cache:
27
+ paths:
28
+ - vendor/bundle
29
+ key: deps-{{ .Environment.CIRCLE_JOB }}-{{ checksum "embulk-input-google_analytics.gemspec" }}
30
+ - run:
31
+ name: Build
32
+ command: |
33
+ bundle exec rake build
34
+ - run:
35
+ name: Execute tests
36
+ command: |
37
+ bundle exec rake
data/.gitignore CHANGED
@@ -4,3 +4,4 @@
4
4
  /.bundle/
5
5
  /Gemfile.lock
6
6
  /coverage/
7
+ vendor/
@@ -1,3 +1,19 @@
1
+ ## 0.1.24 - 2020-07-14
2
+ Upgrade version of gems to be compatible with other google input plugins [#46](https://github.com/treasure-data/embulk-input-google_analytics/pull/46)
3
+ Release version 0.1.24 https://github.com/treasure-data/embulk-input-google_analytics/commit/3aef789a672227ae3ad9b58235091d34c96a4b67
4
+
5
+ ## 0.1.23 - 2019-10-24
6
+ Lock signet and activesupport by less than or equal locked version [#45](https://github.com/treasure-data/embulk-input-google_analytics/pull/45)
7
+
8
+ ## 0.1.22 - 2019-10-24
9
+ * Fix **Plugin's dependencies require Ruby > 2.3** [#44](https://github.com/treasure-data/embulk-input-google_analytics/pull/44)
10
+
11
+ ## 0.1.21 - 2019-04-01
12
+ * Fix **(ArgumentError) no time information in ""** when last_record_time is null [#42](https://github.com/treasure-data/embulk-input-google_analytics/pull/42)
13
+
14
+ ## 0.1.19 - 2018-10-03
15
+ * Make it easy to understand error message of Google Analytics connector
16
+
1
17
  ## 0.1.18 - 2018-05-23
2
18
  * Suport User Account Authentication [#33](https://github.com/treasure-data/embulk-input-google_analytics/pull/33)
3
19
  * Ignore last_record_time if non-incremental task [#34](https://github.com/treasure-data/embulk-input-google_analytics/pull/34)
data/README.md CHANGED
@@ -23,7 +23,7 @@ Embulk input plugin for Google Analytics reports.
23
23
  - **retry_initial_wait_sec**: Wait seconds for exponential backoff initial value (integer, default: 2)
24
24
 
25
25
  ### **New update from verions 0.1.18**
26
- Started from version 0.1.18, the Plugin also supports User Account Authentication along with Service Account Authentication see: [OAuth 2.0 for Server-side Web Application](https://developers.google.com/identity/protocols/OAuth2WebServer). Extra optional configuration keys were added and the **json_key_content** is made optional
26
+ Started from version 0.1.18, the Plugin also supports User Account Authentication along with Service Account Authentication see: [OAuth 2.0 for Server-side Web Application](https://developers.google.com/identity/protocols/OAuth2WebServer). Extra optional configuration keys were added and the **json_key_content** is made optional
27
27
  - **client_id**: client_id for application (string, optional)
28
28
  - **client_secret**: client_secret for application (string, optional)
29
29
  - **refresh_token**: the refresh_token obtained during exchange authentication code (string, optional)
@@ -45,13 +45,13 @@ You need a service account on Google.
45
45
  select a project.</li>
46
46
  <li>Click <b>Create service account</b>.</li>
47
47
  <li>
48
-
48
+
49
49
  In the <b>Create service account</b> window, type a name for the service
50
50
  account, and select <b>Furnish a new private key</b>. If you want to
51
51
  <a href="https://developers.google.com/identity/protocols/OAuth2ServiceAccount#delegatingauthority">grant
52
52
  Google Apps domain-wide authority</a> to the service account, also select
53
53
  <b>Enable Google Apps Domain-wide Delegation</b>.
54
-
54
+
55
55
  Then click <b>Create</b>.</li>
56
56
  </ol>
57
57
  From: <https://developers.google.com/identity/protocols/OAuth2ServiceAccount>
@@ -89,7 +89,7 @@ in:
89
89
  }
90
90
  view_id: 123111111
91
91
  time_series: "ga:dateHour" # hourly basis
92
-
92
+
93
93
  # https://developers.google.com/analytics/devguides/reporting/core/dimsmets
94
94
  dimensions:
95
95
  - "ga:browser"
@@ -123,5 +123,5 @@ in:
123
123
  ## Build
124
124
 
125
125
  ```
126
- $ rake
126
+ $ rake build
127
127
  ```
data/Rakefile CHANGED
@@ -18,4 +18,3 @@ GemReleaseHelper::Tasks.install({
18
18
  gemspec: "./embulk-input-google_analytics.gemspec",
19
19
  github_name: "treasure-data/embulk-input-google_analytics",
20
20
  })
21
-
@@ -1,7 +1,7 @@
1
1
 
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "embulk-input-google_analytics"
4
- spec.version = "0.1.18"
4
+ spec.version = "0.1.24"
5
5
  spec.authors = ["uu59"]
6
6
  spec.summary = "Google Analytics input plugin for Embulk"
7
7
  spec.description = "Loads records from Google Analytics."
@@ -14,17 +14,25 @@ Gem::Specification.new do |spec|
14
14
  spec.require_paths = ["lib"]
15
15
 
16
16
  spec.add_dependency "httpclient"
17
- spec.add_dependency "google-api-client", "0.10.1"
18
- spec.add_dependency "signet"
19
- spec.add_dependency "activesupport" # for Time.zone.parse, Time.zone.now
17
+ spec.add_dependency "google-api-client", [">= 0.11", "< 0.33.0"]
18
+ # signet version > 11.0 requires Ruby version >= 2.4
19
+ # activesupport version > 5.2.3 requires Ruby version >= 2.5
20
+ # Current embulk version 0.9.19 runs under jRuby 9.1.x (which is compatible with Ruby 2.3)
21
+ # So decide to lock these gem versions to prevent incompatible Ruby version
22
+ spec.add_dependency "signet", ['~> 0.7', "< 0.11.0"]
23
+ spec.add_dependency "activesupport", "<= 5.2.3" # for Time.zone.parse, Time.zone.now
24
+
20
25
  spec.add_dependency "perfect_retry", "~> 0.5"
21
26
 
22
27
  spec.add_development_dependency 'embulk', ['>= 0.8.9']
23
28
  spec.add_development_dependency 'bundler', ['>= 1.10.6']
24
29
  spec.add_development_dependency 'rake', ['>= 10.0']
25
- spec.add_development_dependency 'test-unit'
30
+ spec.add_development_dependency 'test-unit', ['< 3.2']
26
31
  spec.add_development_dependency 'test-unit-rr'
27
- spec.add_development_dependency 'simplecov'
32
+ # Lock simple cov and simplecov-html to prevent downloaded newer version which require ruby >= 2.4
33
+ # Current embulk version 0.9.19 runs under jRuby 9.1.x (which is compatible with Ruby 2.3)
34
+ spec.add_development_dependency 'simplecov', ['<= 0.12.0']
35
+ spec.add_development_dependency 'simplecov-html', ['<= 0.12.0']
28
36
  spec.add_development_dependency "codeclimate-test-reporter"
29
37
  spec.add_development_dependency "pry"
30
38
  spec.add_development_dependency "gem_release_helper", "~> 1.0"
@@ -3,10 +3,6 @@ require "active_support/core_ext/time"
3
3
  require "google/apis/analyticsreporting_v4"
4
4
  require "google/apis/analytics_v3"
5
5
 
6
- # Avoid such error:
7
- # PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
8
- Google::Apis::ClientOptions.default.use_net_http = true
9
-
10
6
  module Embulk
11
7
  module Input
12
8
  module GoogleAnalytics
@@ -20,6 +20,10 @@ module Embulk
20
20
  unless task['client_id'] && task['client_secret'] && task['refresh_token']
21
21
  raise ConfigError.new("client_id, client_secret and refresh_token are required when using Oauth authentication")
22
22
  end
23
+ elsif task['auth_method'] == Plugin::AUTH_TYPE_JSON_KEY
24
+ if !valid_json?(task["json_key_content"])
25
+ raise ConfigError.new("json_key_content is not a valid JSON object")
26
+ end
23
27
  end
24
28
 
25
29
  columns_list = Client.new(task).get_columns_list
@@ -106,8 +110,21 @@ module Embulk
106
110
  return {}
107
111
  end
108
112
 
113
+ def self.valid_json?(json_object)
114
+ # 'null' string is a valid string for parse function
115
+ # However in our case, json_content_key could not be 'null' therefore this check is added
116
+ if json_object == "null"
117
+ return false
118
+ end
119
+ begin
120
+ JSON.parse(json_object)
121
+ return true
122
+ rescue JSON::ParserError => e
123
+ return false
124
+ end
125
+ end
126
+
109
127
  def init
110
- # PLT-6753
111
128
  if task["start_date"] && !task["end_date"]
112
129
  task["end_date"] = "today"
113
130
  end
@@ -117,8 +134,7 @@ module Embulk
117
134
  client = Client.new(task, preview?)
118
135
  columns = self.class.columns_from_task(task) + ["view_id"]
119
136
 
120
- last_record_time = task['incremental'] && task["last_record_time"] ? Time.parse(task["last_record_time"]) : nil
121
-
137
+ last_record_time = Time.parse(task["last_record_time"]) if task['incremental'] && !task["last_record_time"].blank?
122
138
  latest_time_series = nil
123
139
  skip_counter, total_counter = 0, 0
124
140
  client.each_report_row do |row|
@@ -198,11 +214,13 @@ module Embulk
198
214
  # no records fetched, don't modify config_diff
199
215
  task_report = {
200
216
  start_date: task["start_date"],
201
- end_date: task["end_date"],
202
- last_record_time: task["last_record_time"],
217
+ end_date: task["end_date"]
203
218
  }
219
+ # write last_record_time only when last_record_time is not nil and not empty
220
+ unless task["last_record_time"].blank?
221
+ task_report[:last_record_time] = task["last_record_time"]
222
+ end
204
223
  end
205
-
206
224
  task_report
207
225
  end
208
226
  end
@@ -107,6 +107,26 @@ module Embulk
107
107
  end
108
108
  end
109
109
 
110
+ test "invalid json_key_content params for oauth" do
111
+ conf = valid_config["in"]
112
+ # Empty json_key_content
113
+ conf["json_key_content"] = ""
114
+ message = "json_key_content is not a valid JSON object"
115
+ assert_raise(Embulk::ConfigError.new(message)) do
116
+ Plugin.transaction(embulk_config(conf))
117
+ end
118
+ # null json_key_content
119
+ conf["json_key_content"] = "null"
120
+ assert_raise(Embulk::ConfigError.new(message)) do
121
+ Plugin.transaction(embulk_config(conf))
122
+ end
123
+ # Not a string json_key_content
124
+ conf["json_key_content"] = nil
125
+ assert_raise(Embulk::ConfigError.new(message)) do
126
+ Plugin.transaction(embulk_config(conf))
127
+ end
128
+ end
129
+
110
130
  def unknown_auth_method_message
111
131
  "Unknown Authentication method ''."
112
132
  end
@@ -360,13 +380,22 @@ module Embulk
360
380
  end
361
381
 
362
382
  sub_test_case "no records fetched" do
363
- test "config_diff won't modify" do
364
- plugin = Plugin.new(config, nil, nil, @page_builder)
383
+ data do
384
+ [
385
+ ["last_record_time is nil", [nil, nil]],
386
+ ["last_record_time is empty", ["", nil]],
387
+ ["last_record_time is blank", [" ", nil]],
388
+ ["last_record_time is valid", ["2019-01-01", "2019-01-01"]]
389
+ ]
390
+ end
391
+ test "test calculate_next_times" do |(in_last_record_time, expected_last_record_time)|
392
+ config["last_record_time"] = in_last_record_time
365
393
  expected = {
366
394
  start_date: task["start_date"],
367
- end_date: task["end_date"],
368
- last_record_time: task["last_record_time"],
395
+ end_date: task["end_date"]
369
396
  }
397
+ expected[:last_record_time] = expected_last_record_time unless expected_last_record_time.blank?
398
+ plugin = Plugin.new(config, nil, nil, @page_builder)
370
399
  assert_equal expected, plugin.calculate_next_times(DEFAULT_TIMEZONE, nil)
371
400
  end
372
401
  end
@@ -432,6 +461,7 @@ module Embulk
432
461
  setup do
433
462
  conf = valid_config["in"]
434
463
  conf["time_series"] = "ga:date"
464
+ conf["last_record_time"] = "2019-01-01"
435
465
  @config = embulk_config(conf)
436
466
  end
437
467
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-google_analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - uu59
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-23 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -27,45 +27,57 @@ dependencies:
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - '='
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.11'
33
+ - - "<"
31
34
  - !ruby/object:Gem::Version
32
- version: 0.10.1
35
+ version: 0.33.0
33
36
  name: google-api-client
34
37
  prerelease: false
35
38
  type: :runtime
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
- - - '='
41
+ - - ">="
39
42
  - !ruby/object:Gem::Version
40
- version: 0.10.1
43
+ version: '0.11'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.33.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  requirement: !ruby/object:Gem::Requirement
43
49
  requirements:
44
- - - ">="
50
+ - - "~>"
45
51
  - !ruby/object:Gem::Version
46
- version: '0'
52
+ version: '0.7'
53
+ - - "<"
54
+ - !ruby/object:Gem::Version
55
+ version: 0.11.0
47
56
  name: signet
48
57
  prerelease: false
49
58
  type: :runtime
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - ">="
61
+ - - "~>"
53
62
  - !ruby/object:Gem::Version
54
- version: '0'
63
+ version: '0.7'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: 0.11.0
55
67
  - !ruby/object:Gem::Dependency
56
68
  requirement: !ruby/object:Gem::Requirement
57
69
  requirements:
58
- - - ">="
70
+ - - "<="
59
71
  - !ruby/object:Gem::Version
60
- version: '0'
72
+ version: 5.2.3
61
73
  name: activesupport
62
74
  prerelease: false
63
75
  type: :runtime
64
76
  version_requirements: !ruby/object:Gem::Requirement
65
77
  requirements:
66
- - - ">="
78
+ - - "<="
67
79
  - !ruby/object:Gem::Version
68
- version: '0'
80
+ version: 5.2.3
69
81
  - !ruby/object:Gem::Dependency
70
82
  requirement: !ruby/object:Gem::Requirement
71
83
  requirements:
@@ -125,17 +137,17 @@ dependencies:
125
137
  - !ruby/object:Gem::Dependency
126
138
  requirement: !ruby/object:Gem::Requirement
127
139
  requirements:
128
- - - ">="
140
+ - - "<"
129
141
  - !ruby/object:Gem::Version
130
- version: '0'
142
+ version: '3.2'
131
143
  name: test-unit
132
144
  prerelease: false
133
145
  type: :development
134
146
  version_requirements: !ruby/object:Gem::Requirement
135
147
  requirements:
136
- - - ">="
148
+ - - "<"
137
149
  - !ruby/object:Gem::Version
138
- version: '0'
150
+ version: '3.2'
139
151
  - !ruby/object:Gem::Dependency
140
152
  requirement: !ruby/object:Gem::Requirement
141
153
  requirements:
@@ -153,17 +165,31 @@ dependencies:
153
165
  - !ruby/object:Gem::Dependency
154
166
  requirement: !ruby/object:Gem::Requirement
155
167
  requirements:
156
- - - ">="
168
+ - - "<="
157
169
  - !ruby/object:Gem::Version
158
- version: '0'
170
+ version: 0.12.0
159
171
  name: simplecov
160
172
  prerelease: false
161
173
  type: :development
162
174
  version_requirements: !ruby/object:Gem::Requirement
163
175
  requirements:
164
- - - ">="
176
+ - - "<="
165
177
  - !ruby/object:Gem::Version
166
- version: '0'
178
+ version: 0.12.0
179
+ - !ruby/object:Gem::Dependency
180
+ requirement: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "<="
183
+ - !ruby/object:Gem::Version
184
+ version: 0.12.0
185
+ name: simplecov-html
186
+ prerelease: false
187
+ type: :development
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - "<="
191
+ - !ruby/object:Gem::Version
192
+ version: 0.12.0
167
193
  - !ruby/object:Gem::Dependency
168
194
  requirement: !ruby/object:Gem::Requirement
169
195
  requirements:
@@ -213,6 +239,7 @@ executables: []
213
239
  extensions: []
214
240
  extra_rdoc_files: []
215
241
  files:
242
+ - ".circleci/config.yml"
216
243
  - ".gitignore"
217
244
  - ".ruby-version"
218
245
  - CHANGELOG.md
@@ -220,7 +247,6 @@ files:
220
247
  - LICENSE.txt
221
248
  - README.md
222
249
  - Rakefile
223
- - circle.yml
224
250
  - embulk-input-google_analytics.gemspec
225
251
  - lib/embulk/input/google_analytics.rb
226
252
  - lib/embulk/input/google_analytics/client.rb
data/circle.yml DELETED
@@ -1,26 +0,0 @@
1
- machine:
2
- java:
3
- version: oraclejdk8
4
- ruby:
5
- version: jruby-9.1.5.0
6
- environment:
7
- JRUBY_OPTS: "-Xcli.debug=true --debug"
8
-
9
- dependencies:
10
- pre:
11
- - ruby -v
12
- - bundle -v
13
- - grep bundler <<< "$(gem list)" || gem i bundler --no-document
14
- - bundle -v
15
-
16
- test:
17
- override:
18
- - bundle exec rake cov
19
- notify:
20
- webhooks:
21
- - url: http://td-beda.herokuapp.com/circleci_callback
22
-
23
- general:
24
- artifacts:
25
- - "coverage"
26
-