simple_segment 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/README.md +1 -1
- data/lib/simple_segment/operations/group.rb +1 -1
- data/lib/simple_segment/operations/identify.rb +1 -1
- data/lib/simple_segment/operations/operation.rb +2 -0
- data/lib/simple_segment/operations/page.rb +3 -1
- data/lib/simple_segment/operations/track.rb +3 -1
- data/lib/simple_segment/utils.rb +28 -0
- data/lib/simple_segment/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd645e7d35b8baaf841db66b9ca3910d2be0a84a
|
4
|
+
data.tar.gz: 18b9521aefd0d44f9749a59d64100f1e566a55ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
47
|
+
on_error: proc { |error_code, error_body, exception, response|
|
48
48
|
# defaults to an empty proc
|
49
49
|
}
|
50
50
|
})
|
@@ -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:
|
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:
|
16
|
+
properties: properties
|
15
17
|
)
|
16
18
|
end
|
17
19
|
end
|
data/lib/simple_segment/utils.rb
CHANGED
@@ -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
|
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.
|
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:
|
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.
|
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.
|