simple_segment 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +4 -4
- data/CHANGELOG.md +10 -4
- data/README.md +11 -0
- data/lib/simple_segment/configuration.rb +4 -1
- data/lib/simple_segment/request.rb +5 -5
- data/lib/simple_segment/version.rb +1 -1
- data/simple_segment.gemspec +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ecb763039e2fdacb85b464ebd96a7b46b4b18a92fb1a41069aff09af3c8fa92
|
4
|
+
data.tar.gz: e8bd47c02313e50940a2b3c042533b324ce4cba322572ade72562c6c39eec119
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f0097b62f7bcfdcd6ca0f7caa16dc29505b1fd6a896dac9178d481201d6aaabd1aa456760baef7dbb95de34f956374df643351b0769626566cb6cb2ae89e6cc
|
7
|
+
data.tar.gz: 571840b8b57c64ac39d574b92e90db37290eb48e9f756c594c109f1948b27246503ceca31f00151f0802f4e67801dfcbb138f5311c6d105852e84636bd0710b1
|
data/.github/workflows/ci.yml
CHANGED
@@ -10,13 +10,13 @@ jobs:
|
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
|
-
ruby
|
13
|
+
ruby: ['3.1', '3.0', '2.7']
|
14
14
|
steps:
|
15
|
-
- uses: actions/checkout@
|
16
|
-
- name: Set up Ruby ${{ matrix.ruby
|
15
|
+
- uses: actions/checkout@v3
|
16
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
17
17
|
uses: ruby/setup-ruby@v1
|
18
18
|
with:
|
19
|
-
ruby-version: ${{ matrix.ruby
|
19
|
+
ruby-version: ${{ matrix.ruby }}
|
20
20
|
bundler-cache: true
|
21
21
|
- name: Run tests
|
22
22
|
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -6,10 +6,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.4.0] - 2022-08-31
|
10
|
+
|
11
|
+
### Added
|
12
|
+
- Add host option to support regional segments https://github.com/whatthewhat/simple_segment/pull/37 by [@larsklevan](https://github.com/larsklevan)
|
13
|
+
|
9
14
|
## [1.3.0] - 2021-11-27
|
10
15
|
|
11
16
|
### Added
|
12
|
-
- Add support for message_id override https://github.com/whatthewhat/simple_segment/pull/34 by [@theblang]
|
17
|
+
- Add support for message_id override https://github.com/whatthewhat/simple_segment/pull/34 by [@theblang](https://github.com/theblang)
|
13
18
|
|
14
19
|
## [1.2.0] - 2020-07-29
|
15
20
|
|
@@ -19,13 +24,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
19
24
|
## [1.1.0] - 2020-04-11
|
20
25
|
|
21
26
|
### Added
|
22
|
-
- Added support for http_proxy and https_proxy environment variables https://github.com/whatthewhat/simple_segment/pull/26 by [@saks]
|
27
|
+
- Added support for http_proxy and https_proxy environment variables https://github.com/whatthewhat/simple_segment/pull/26 by [@saks](https://github.com/saks)
|
23
28
|
- Added Ruby 2.7 to travis.yml
|
24
29
|
|
25
30
|
## [1.0.0] - 2019-12-12
|
26
31
|
|
27
32
|
### Added
|
28
|
-
- Allow passing custom Net::HTTP options (e.g. timeout) https://github.com/whatthewhat/simple_segment/pull/23 by [@barodeur]
|
33
|
+
- Allow passing custom Net::HTTP options (e.g. timeout) https://github.com/whatthewhat/simple_segment/pull/23 by [@barodeur](https://github.com/barodeur)
|
29
34
|
|
30
35
|
### Changed
|
31
36
|
- The gem is no longer tested with Ruby versions below 2.4
|
@@ -35,7 +40,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
35
40
|
### Changed
|
36
41
|
- Date properties are now automatically converted to ISO 8601 to be consistent with the official client https://github.com/whatthewhat/simple_segment/pull/19 by @juanramoncg
|
37
42
|
|
38
|
-
[Unreleased]: https://github.com/whatthewhat/simple_segment/compare/v1.
|
43
|
+
[Unreleased]: https://github.com/whatthewhat/simple_segment/compare/v1.4.0...HEAD
|
44
|
+
[1.4.0]: https://github.com/whatthewhat/simple_segment/compare/v1.3.0...v1.4.0
|
39
45
|
[1.3.0]: https://github.com/whatthewhat/simple_segment/compare/v1.2.0...v1.3.0
|
40
46
|
[1.2.0]: https://github.com/whatthewhat/simple_segment/compare/v1.1.0...v1.2.0
|
41
47
|
[1.1.0]: https://github.com/whatthewhat/simple_segment/compare/v1.0.0...v1.1.0
|
data/README.md
CHANGED
@@ -110,6 +110,17 @@ analytics = SimpleSegment::Client.new(
|
|
110
110
|
)
|
111
111
|
```
|
112
112
|
|
113
|
+
### Configurable Host
|
114
|
+
|
115
|
+
You can use [regional segments](https://segment.com/docs/guides/regional-segment/) and send data to the desired region by setting the `host` parameter.
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
analytics = SimpleSegment::Client.new(
|
119
|
+
write_key: 'YOUR_WRITE_KEY',
|
120
|
+
host: 'events.eu1.segmentapis.com'
|
121
|
+
)
|
122
|
+
```
|
123
|
+
|
113
124
|
## Development
|
114
125
|
|
115
126
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -7,7 +7,9 @@ module SimpleSegment
|
|
7
7
|
include SimpleSegment::Utils
|
8
8
|
include SimpleSegment::Logging
|
9
9
|
|
10
|
-
|
10
|
+
DEFAULT_HOST = 'api.segment.io'
|
11
|
+
|
12
|
+
attr_reader :write_key, :on_error, :stub, :logger, :http_options, :host
|
11
13
|
|
12
14
|
def initialize(settings = {})
|
13
15
|
symbolized_settings = symbolize_keys(settings)
|
@@ -17,6 +19,7 @@ module SimpleSegment
|
|
17
19
|
@logger = default_logger(symbolized_settings[:logger])
|
18
20
|
@http_options = { use_ssl: true }
|
19
21
|
.merge(symbolized_settings[:http_options] || {})
|
22
|
+
@host = symbolized_settings[:host] || DEFAULT_HOST
|
20
23
|
raise ArgumentError, 'Missing required option :write_key' \
|
21
24
|
unless @write_key
|
22
25
|
end
|
@@ -2,13 +2,12 @@
|
|
2
2
|
|
3
3
|
module SimpleSegment
|
4
4
|
class Request
|
5
|
-
BASE_URL = 'https://api.segment.io'
|
6
5
|
DEFAULT_HEADERS = {
|
7
6
|
'Content-Type' => 'application/json',
|
8
7
|
'accept' => 'application/json'
|
9
8
|
}.freeze
|
10
9
|
|
11
|
-
attr_reader :write_key, :error_handler, :stub, :logger, :http_options
|
10
|
+
attr_reader :write_key, :error_handler, :stub, :logger, :http_options, :host
|
12
11
|
|
13
12
|
def initialize(client)
|
14
13
|
@write_key = client.config.write_key
|
@@ -16,6 +15,7 @@ module SimpleSegment
|
|
16
15
|
@stub = client.config.stub
|
17
16
|
@logger = client.config.logger
|
18
17
|
@http_options = client.config.http_options
|
18
|
+
@host = client.config.host
|
19
19
|
end
|
20
20
|
|
21
21
|
def post(path, payload, headers: DEFAULT_HEADERS) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
@@ -23,17 +23,17 @@ module SimpleSegment
|
|
23
23
|
status_code = nil
|
24
24
|
response_body = nil
|
25
25
|
|
26
|
-
uri = URI(
|
26
|
+
uri = URI("https://#{host}#{path}")
|
27
27
|
payload = JSON.generate(payload)
|
28
28
|
if stub
|
29
29
|
logger.debug "stubbed request to \
|
30
|
-
#{path}: write key = #{write_key}, \
|
30
|
+
#{uri.path}: write key = #{write_key}, \
|
31
31
|
payload = #{payload}"
|
32
32
|
|
33
33
|
{ status: 200, error: nil }
|
34
34
|
else
|
35
35
|
Net::HTTP.start(uri.host, uri.port, :ENV, http_options) do |http|
|
36
|
-
request = Net::HTTP::Post.new(path, headers)
|
36
|
+
request = Net::HTTP::Post.new(uri.path, headers)
|
37
37
|
request.basic_auth write_key, nil
|
38
38
|
http.request(request, payload).tap do |res|
|
39
39
|
status_code = res.code
|
data/simple_segment.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '>= 10.0'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
27
|
spec.add_development_dependency 'rubocop', '1.23.0'
|
28
|
-
spec.add_development_dependency 'timecop', '~> 0.
|
28
|
+
spec.add_development_dependency 'timecop', '~> 0.9.5'
|
29
29
|
spec.add_development_dependency 'webmock', '~> 3.7'
|
30
30
|
spec.metadata = {
|
31
31
|
'rubygems_mfa_required' => 'true'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_segment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikhail Topolskiy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.9.5
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.9.5
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: webmock
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -149,7 +149,7 @@ licenses:
|
|
149
149
|
- MIT
|
150
150
|
metadata:
|
151
151
|
rubygems_mfa_required: 'true'
|
152
|
-
post_install_message:
|
152
|
+
post_install_message:
|
153
153
|
rdoc_options: []
|
154
154
|
require_paths:
|
155
155
|
- lib
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubygems_version: 3.1.6
|
168
|
-
signing_key:
|
168
|
+
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: A simple synchronous API client for segment.io.
|
171
171
|
test_files: []
|