simple_segment 0.2.1 → 0.3.0

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: 51451276d36995db980573591e7703e32e7ba5c2
4
- data.tar.gz: e34ae21510134d077de91a191bd9d29fd613ff28
3
+ metadata.gz: dd645e7d35b8baaf841db66b9ca3910d2be0a84a
4
+ data.tar.gz: 18b9521aefd0d44f9749a59d64100f1e566a55ce
5
5
  SHA512:
6
- metadata.gz: 9060d055127519c59e9033b2a42a222321265c90f20f164e77a84a9cf7f144955a02490776fb79a57beb1cff9e7fb5d5b5f27f7f6a0c821636850c829859b7fa
7
- data.tar.gz: 156154cbb0ca38e288727142fc5d80fc9d264503259f40477b4dce8739621ef8a402467225863dff16816f0f34a4d6e50e2834cfe80dfa073f24b3dbc1a6f8d1
6
+ metadata.gz: 2847552e5f74d6f5e8ab044003e8f08837fe39334c6cf85c79c2646cabf1beaa3bae3aa3fbd8a0702de2e123f2ad577bdfaf1495fcc5c6801a4312b87cb439ab
7
+ data.tar.gz: 0e4aafdc0abb865a87b879c04bac266b25dec5fc42b22d827268c91d78f0517581e6c1dded789bb3843b26744a45dffdb906bef1b69d83c3354b235a67fe54dc
data/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+
10
+ ## [0.3.0] - 2018-03-15
11
+
12
+ ### Changed
13
+ - 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
14
+
15
+ [Unreleased]: https://github.com/whatthewhat/simple_segment/compare/v0.3.0...HEAD
16
+ [0.3.0]: https://github.com/whatthewhat/simple_segment/compare/v0.2.1...v0.3.0
17
+ [0.2.1]: https://github.com/whatthewhat/simple_segment/compare/v0.2.0...v0.2.1
18
+ [0.2.0]: https://github.com/whatthewhat/simple_segment/compare/v0.1.1...v0.2.0
19
+ [0.1.1]: https://github.com/whatthewhat/simple_segment/compare/v0.1.0...v0.1.1
20
+ [0.1.0]: https://github.com/whatthewhat/simple_segment/compare/2d62f07a1df8388000b0b5a20331409132d05ad3...v0.1.0
data/README.md CHANGED
@@ -44,7 +44,7 @@ Create a client instance:
44
44
  ```ruby
45
45
  analytics = SimpleSegment::Client.new({
46
46
  write_key: 'YOUR_WRITE_KEY', # required
47
- on_error: proc { |error_code, error_body, response, exception|
47
+ on_error: proc { |error_code, error_body, exception, response|
48
48
  # defaults to an empty proc
49
49
  }
50
50
  })
@@ -10,7 +10,7 @@ module SimpleSegment
10
10
  unless options[:group_id]
11
11
 
12
12
  base_payload.merge(
13
- traits: options[:traits],
13
+ traits: options[:traits] && isoify_dates!(options[:traits]),
14
14
  groupId: options[:group_id]
15
15
  )
16
16
  end
@@ -7,7 +7,7 @@ module SimpleSegment
7
7
 
8
8
  def build_payload
9
9
  base_payload.merge(
10
- traits: options[:traits]
10
+ traits: options[:traits] && isoify_dates!(options[:traits])
11
11
  )
12
12
  end
13
13
  end
@@ -1,6 +1,8 @@
1
1
  module SimpleSegment
2
2
  module Operations
3
3
  class Operation
4
+ include SimpleSegment::Utils
5
+
4
6
  DEFAULT_CONTEXT = {
5
7
  library: {
6
8
  name: 'simple_segment',
@@ -6,9 +6,11 @@ module SimpleSegment
6
6
  end
7
7
 
8
8
  def build_payload
9
+ properties = options[:properties] && isoify_dates!(options[:properties])
10
+
9
11
  base_payload.merge(
10
12
  name: options[:name],
11
- properties: options[:properties]
13
+ properties: properties
12
14
  )
13
15
  end
14
16
  end
@@ -9,9 +9,11 @@ module SimpleSegment
9
9
  raise ArgumentError, 'event name must be present' \
10
10
  unless options[:event]
11
11
 
12
+ properties = options[:properties] && isoify_dates!(options[:properties])
13
+
12
14
  base_payload.merge(
13
15
  event: options[:event],
14
- properties: options[:properties]
16
+ properties: properties
15
17
  )
16
18
  end
17
19
  end
@@ -9,5 +9,33 @@ module SimpleSegment
9
9
  result[key.to_sym] = value
10
10
  end
11
11
  end
12
+
13
+ # public: Converts all the date values in the into iso8601 strings in place
14
+ #
15
+ def isoify_dates!(hash)
16
+ hash.replace isoify_dates hash
17
+ end
18
+
19
+ # public: Returns a new hash with all the date values in the into iso8601
20
+ # strings
21
+ #
22
+ def isoify_dates(hash)
23
+ hash.each_with_object({}) do |(k, v), memo|
24
+ memo[k] = maybe_datetime_in_iso8601(v)
25
+ end
26
+ end
27
+
28
+ def maybe_datetime_in_iso8601(prop)
29
+ case prop
30
+ when Time
31
+ prop.iso8601(3)
32
+ when DateTime
33
+ prop.to_time.iso8601(3)
34
+ when Date
35
+ prop.strftime('%F')
36
+ else
37
+ prop
38
+ end
39
+ end
12
40
  end
13
41
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleSegment
2
- VERSION = '0.2.1'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
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: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikhail Topolskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-11 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - ".rspec"
122
122
  - ".rubocop.yml"
123
123
  - ".travis.yml"
124
+ - CHANGELOG.md
124
125
  - Gemfile
125
126
  - LICENSE.txt
126
127
  - README.md
@@ -163,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
164
  version: '0'
164
165
  requirements: []
165
166
  rubyforge_project:
166
- rubygems_version: 2.6.8
167
+ rubygems_version: 2.6.14
167
168
  signing_key:
168
169
  specification_version: 4
169
170
  summary: A simple synchronous API client for segment.io.