customerio 6.0.0 → 6.1.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/lib/customerio/client.rb +13 -2
- data/lib/customerio/requests/send_push_request.rb +0 -1
- data/lib/customerio/version.rb +1 -1
- data/lib/customerio.rb +0 -1
- metadata +5 -6
- data/CHANGELOG.markdown +0 -190
- data/lib/customerio/param_encoder.rb +0 -63
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 901ad05a932585330dd1455f401b1a281b2a3390d2618d0623de62cdd4458988
|
|
4
|
+
data.tar.gz: 93f962b44d651e177407a68de2ed555fd6fb0a711a3180afda823eee6973b5a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9b787fe471290dd64811543d77f24bced641762d894824ffb1d43d671ed0179a6fb536477040bbceb797ca6ccb5f8c6164b085477dfea58db1cac311fd492be3
|
|
7
|
+
data.tar.gz: e6c251d418be193333c26d07b78f78c61fa61cb3800f5e89dfef9a8c4680a3fcea9a67db09fa793a843172c6daf9ad800a222d6ce2bc0c9c2a2e99e1b633df21
|
data/lib/customerio/client.rb
CHANGED
|
@@ -141,6 +141,7 @@ module Customerio
|
|
|
141
141
|
raise ParamError, "delivery_id must be a non-empty string" if empty?(attributes[:delivery_id])
|
|
142
142
|
|
|
143
143
|
body = { delivery_id: attributes[:delivery_id], metric: metric_name }
|
|
144
|
+
validate_timestamp!(attributes[:timestamp])
|
|
144
145
|
body[:timestamp] = attributes[:timestamp] if valid_timestamp?(attributes[:timestamp])
|
|
145
146
|
body[:recipient] = attributes[:recipient] unless empty?(attributes[:recipient])
|
|
146
147
|
body[:reason] = attributes[:reason] unless empty?(attributes[:reason])
|
|
@@ -271,8 +272,11 @@ module Customerio
|
|
|
271
272
|
|
|
272
273
|
def create_event(url:, event_name:, anonymous_id: nil, event_type: nil, attributes: {}, id: nil, timestamp: nil) # rubocop:disable Metrics/ParameterLists
|
|
273
274
|
body = { name: event_name, data: attributes }
|
|
274
|
-
|
|
275
|
-
|
|
275
|
+
effective_timestamp = timestamp || attributes[:timestamp]
|
|
276
|
+
if effective_timestamp
|
|
277
|
+
validate_timestamp!(effective_timestamp)
|
|
278
|
+
body[:timestamp] = effective_timestamp
|
|
279
|
+
end
|
|
276
280
|
body[:anonymous_id] = anonymous_id unless empty?(anonymous_id)
|
|
277
281
|
body[:type] = event_type unless empty?(event_type)
|
|
278
282
|
body[:id] = id unless empty?(id)
|
|
@@ -284,6 +288,13 @@ module Customerio
|
|
|
284
288
|
timestamp.is_a?(Integer) && timestamp > 999_999_999 && timestamp < 100_000_000_000
|
|
285
289
|
end
|
|
286
290
|
|
|
291
|
+
def validate_timestamp!(timestamp)
|
|
292
|
+
return if timestamp.nil?
|
|
293
|
+
return if valid_timestamp?(timestamp)
|
|
294
|
+
|
|
295
|
+
raise ParamError, "timestamp must be a valid integer (seconds since epoch, 10-digit range)"
|
|
296
|
+
end
|
|
297
|
+
|
|
287
298
|
def empty?(val)
|
|
288
299
|
val.nil? || (val.is_a?(String) && val.strip.empty?)
|
|
289
300
|
end
|
data/lib/customerio/version.rb
CHANGED
data/lib/customerio.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: customerio
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.
|
|
4
|
+
version: 6.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Allison
|
|
@@ -37,21 +37,20 @@ dependencies:
|
|
|
37
37
|
- - "~>"
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
39
|
version: '0.3'
|
|
40
|
-
description: A ruby client for the Customer.io
|
|
40
|
+
description: A ruby client for the Customer.io Journeys Track API and Transactional
|
|
41
|
+
API.
|
|
41
42
|
email:
|
|
42
43
|
- john@customer.io
|
|
43
44
|
executables: []
|
|
44
45
|
extensions: []
|
|
45
46
|
extra_rdoc_files: []
|
|
46
47
|
files:
|
|
47
|
-
- CHANGELOG.markdown
|
|
48
48
|
- LICENSE
|
|
49
49
|
- README.md
|
|
50
50
|
- lib/customerio.rb
|
|
51
51
|
- lib/customerio/api.rb
|
|
52
52
|
- lib/customerio/base_client.rb
|
|
53
53
|
- lib/customerio/client.rb
|
|
54
|
-
- lib/customerio/param_encoder.rb
|
|
55
54
|
- lib/customerio/regions.rb
|
|
56
55
|
- lib/customerio/requests/send_email_request.rb
|
|
57
56
|
- lib/customerio/requests/send_in_app_request.rb
|
|
@@ -65,7 +64,7 @@ licenses:
|
|
|
65
64
|
- MIT
|
|
66
65
|
metadata:
|
|
67
66
|
bug_tracker_uri: https://github.com/customerio/customerio-ruby/issues
|
|
68
|
-
changelog_uri: https://github.com/customerio/customerio-ruby/
|
|
67
|
+
changelog_uri: https://github.com/customerio/customerio-ruby/releases
|
|
69
68
|
homepage_uri: https://customer.io
|
|
70
69
|
rubygems_mfa_required: 'true'
|
|
71
70
|
source_code_uri: https://github.com/customerio/customerio-ruby
|
|
@@ -85,5 +84,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
85
84
|
requirements: []
|
|
86
85
|
rubygems_version: 3.6.9
|
|
87
86
|
specification_version: 4
|
|
88
|
-
summary: A ruby client for the Customer.io
|
|
87
|
+
summary: A ruby client for the Customer.io Journeys Track API and Transactional API.
|
|
89
88
|
test_files: []
|
data/CHANGELOG.markdown
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
## Customerio 5.7.0 - Unreleased
|
|
2
|
-
### Added
|
|
3
|
-
- Added `track_delivery_metric` to `Client` for reporting delivery metrics via the `/api/v1/metrics` endpoint, replacing the deprecated `/push/events` endpoint. Supports metrics: opened, clicked, converted, delivered, bounced, deferred, dropped, and spammed.
|
|
4
|
-
- Added `DELIVERY_*` constants and `VALID_DELIVERY_METRICS` to `Customerio::Client`.
|
|
5
|
-
|
|
6
|
-
## Customerio 5.4.0 - June 13, 2025
|
|
7
|
-
### Changed
|
|
8
|
-
- Added `send_sms` to `APIClient` and `SendSMSRequest` to support sending transactional push notifications.
|
|
9
|
-
|
|
10
|
-
## Customerio 5.3.0 - December 8, 2023
|
|
11
|
-
### Changed
|
|
12
|
-
- The `identify` method has been updated to allow the customer ID to be specified separately from the attributes, using the `customer_id` attribute. This allows a person to be updated by identifying them by e.g.: their email address. Thanks to trwalzer, jrbeck and jeremyw for the original changes that this is based on.
|
|
13
|
-
- It is no longer possible to set the `customer_id` attribute on a person. This is a side-effect of the changes to the `identify` method.
|
|
14
|
-
|
|
15
|
-
## Customerio 5.2.0 - December 8, 2023
|
|
16
|
-
### Changed
|
|
17
|
-
- The `identify` method will now automatically use the `cio_id` attribute as the customer ID when calling the track service. This allows a customer to be updated using `identify` to modify the `id` and `email` attributes.
|
|
18
|
-
|
|
19
|
-
## Customerio 5.1.0 - May 5, 2023
|
|
20
|
-
### Added
|
|
21
|
-
- Added `send_push` to `APIClient` and `SendPushRequest` to support sending transactional push notifications.
|
|
22
|
-
|
|
23
|
-
## Customerio 4.3.1 - January 5, 2023
|
|
24
|
-
### Added
|
|
25
|
-
- Added the `disable_css_preprocessing` and `language` optional fields to send request
|
|
26
|
-
|
|
27
|
-
## Customerio 4.3.0 - April 26, 2022
|
|
28
|
-
### Added
|
|
29
|
-
- Support for [anonymous invite events](https://customer.io/docs/anonymous-invite-emails/) by setting `anonymous_id` to `nil`.
|
|
30
|
-
|
|
31
|
-
## Customerio 4.1.0 - Sep 27, 2021
|
|
32
|
-
### Added
|
|
33
|
-
- Added support for [merge customers](https://customer.io/docs/api/#operation/merge) API
|
|
34
|
-
|
|
35
|
-
## Customerio 4.0.1 - July 13, 2021
|
|
36
|
-
### Changed
|
|
37
|
-
- Update addressable gem dependency to v2.8.0
|
|
38
|
-
|
|
39
|
-
## Customerio 4.0.0 - July 6, 2021
|
|
40
|
-
### Removed
|
|
41
|
-
- The `anonymous_track` method.
|
|
42
|
-
|
|
43
|
-
### Added
|
|
44
|
-
- The `track_anonymous` method replaces `anonymous_track`. This method requires an `anonymous_id` parameter and will no longer trigger campaigns. If you previously used anonymous events to trigger campaigns, you can still do so [directly through the API](https://customer.io/docs/api/#operation/trackAnonymous). We now refer to anonymous events that trigger campaigns as ["invite events"](https://customer.io/docs/anonymous-events/#anonymous-or-invite).
|
|
45
|
-
|
|
46
|
-
## Customerio 3.1.0 - March 25, 2021
|
|
47
|
-
### Added
|
|
48
|
-
- Support for EU region
|
|
49
|
-
|
|
50
|
-
### Removed
|
|
51
|
-
### Changed
|
|
52
|
-
- `Customerio::Client` and `CustomerIO::APIClient` have a new parameter `region` that can be set to either `Customerio::Regions::EU` or `Customerio::Regions::US` (defaults to `Customerio::Regions::US`)
|
|
53
|
-
|
|
54
|
-
## Customerio 3.0.0 - Dec 2, 2020
|
|
55
|
-
|
|
56
|
-
### Added
|
|
57
|
-
- Support for the Transactional API
|
|
58
|
-
|
|
59
|
-
### Removed
|
|
60
|
-
- `add_to_segment` and `remove_from_segment` methods
|
|
61
|
-
- Support for non-JSON data
|
|
62
|
-
|
|
63
|
-
### Changed
|
|
64
|
-
- IDs in the URLs are now escaped.
|
|
65
|
-
- Improved validations for data that's passed in.
|
|
66
|
-
- Earlier, if you passed in an event name without a customer ID to the `track` method, we would create an anonymous event. That is now removed. To create an anonymous event, use the `anonymous_track` method.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
## Customerio 3.0.0 - Dec 2, 2020
|
|
70
|
-
|
|
71
|
-
### Added
|
|
72
|
-
- Support for the Transactional API
|
|
73
|
-
|
|
74
|
-
### Removed
|
|
75
|
-
- `add_to_segment` and `remove_from_segment` methods
|
|
76
|
-
- Support for non-JSON data
|
|
77
|
-
|
|
78
|
-
### Changed
|
|
79
|
-
- IDs in the URLs are now escaped.
|
|
80
|
-
- Improved validations for data that's passed in.
|
|
81
|
-
- Earlier, if you passed in an event name without a customer ID to the `track` method, we would create an anonymous event. That is now removed. To create an anonymous event, use the `anonymous_track` method.
|
|
82
|
-
|
|
83
|
-
## Customerio 2.2.1 - Mar 23, 2020
|
|
84
|
-
|
|
85
|
-
- Add license to gemspec [#55](https://github.com/customerio/customerio-ruby/pull/55)
|
|
86
|
-
- Bubble up error message [#51](https://github.com/customerio/customerio-ruby/pull/51)
|
|
87
|
-
|
|
88
|
-
## Customerio 2.2.0 - Oct 18, 2018
|
|
89
|
-
|
|
90
|
-
Add support for manual segments [#52](https://github.com/customerio/customerio-ruby/pull/52)
|
|
91
|
-
|
|
92
|
-
## Customerio 2.1.0 - May 22, 2018
|
|
93
|
-
|
|
94
|
-
Added support for the suppress / unsuppress methods [#49](https://github.com/customerio/customerio-ruby/pull/49)
|
|
95
|
-
|
|
96
|
-
## Customerio 2.0.0 - Apr 10, 2018
|
|
97
|
-
|
|
98
|
-
With this release we have dropped the support for ruby 1.8.7.
|
|
99
|
-
|
|
100
|
-
- Support new add and remove device endpoints for push notifications [#47](https://github.com/customerio/customerio-ruby/pull/47)
|
|
101
|
-
|
|
102
|
-
## Customerio 1.0.0 - Mar 15, 2016
|
|
103
|
-
|
|
104
|
-
There is a slight breaking change in this release. If you are depending on the HTTP response object included in the InvalidResponse exception (introduced in 0.6.1), note that it is now a `Net::HTTPBadRequest`.
|
|
105
|
-
|
|
106
|
-
- Remove HTTParty dependency, use Net::HTTP instead. [#42](https://github.com/customerio/customerio-ruby/pull/42)
|
|
107
|
-
|
|
108
|
-
- Update test suite to use webmock, to increase confidence that we're not changing our HTTP requests [#41](https://github.com/customerio/customerio-ruby/pull/41)
|
|
109
|
-
|
|
110
|
-
## Customerio 0.7.0 - Mar 2, 2016
|
|
111
|
-
|
|
112
|
-
- Add new method for tracking anonymous events: `anonymous_track`. See README for more details. Many thanks to @sdawson for this contribution! [#36](https://github.com/customerio/customerio-ruby/pull/36)
|
|
113
|
-
|
|
114
|
-
- Use JSON encoding by default. [#37](https://github.com/customerio/customerio-ruby/pull/37)
|
|
115
|
-
|
|
116
|
-
If you want to stick with form-encoding for your integration, you must add `:json => false` to your Customerio::Client initializer. Like this:
|
|
117
|
-
|
|
118
|
-
```ruby
|
|
119
|
-
customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", :json => false)
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Customerio 0.6.1 - Oct 8, 2015
|
|
123
|
-
|
|
124
|
-
- Include HTTP response as an attribute on the InvalidResponse exception to help with debugging failed API requests. For example:
|
|
125
|
-
|
|
126
|
-
```ruby
|
|
127
|
-
begin
|
|
128
|
-
$customerio.track(1, 'event', { :test => 'testing' })
|
|
129
|
-
rescue => e
|
|
130
|
-
puts e.message
|
|
131
|
-
puts e.response.status
|
|
132
|
-
puts e.response.body
|
|
133
|
-
end
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
## Customerio 0.6.0 - Oct 6, 2015
|
|
137
|
-
|
|
138
|
-
Deprecation warning: we are going to switch to JSON encoding by default for the next release. The current default is form-encoding. This will probably not affect you, unless you rely on how form-encoding arrays work.
|
|
139
|
-
|
|
140
|
-
If you want to stick with form-encoding for your integration, you must add `:json => false` to your Customerio::Client initializer. Like this:
|
|
141
|
-
|
|
142
|
-
```ruby
|
|
143
|
-
customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", :json => false)
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
Other fixes and improvements, with many thanks to the community contributors:
|
|
147
|
-
|
|
148
|
-
- Added HTTP timeout of 10 seconds (@stayhero)
|
|
149
|
-
- Added JSON support for events (@kemper)
|
|
150
|
-
- Convert attribute keys to symbols (@joshnabbott)
|
|
151
|
-
|
|
152
|
-
## Customerio 0.5.0 - Mar 28, 2014
|
|
153
|
-
|
|
154
|
-
- Added flag to send body encoded as JSON, rather than the default form encoding.
|
|
155
|
-
|
|
156
|
-
## Customerio 0.5.0 - Apr 8, 2013
|
|
157
|
-
|
|
158
|
-
- Removed deprecated methods around using a customer object. All calls simply take a hash of attributes now.
|
|
159
|
-
- Added ability to set a timestamp on a tracked event. Useful for backfilling past events.
|
|
160
|
-
|
|
161
|
-
## Customerio 0.4.1 - Feb 18, 2013
|
|
162
|
-
|
|
163
|
-
- Bug fixes related to the 4.0 change.
|
|
164
|
-
|
|
165
|
-
## Customerio 0.4.0 - Feb 18, 2013
|
|
166
|
-
|
|
167
|
-
- Added support for deleting customers.
|
|
168
|
-
|
|
169
|
-
## Customerio 0.3.0 - Dec 28, 2012
|
|
170
|
-
|
|
171
|
-
- Now raise an error if an API call doesn't respond with a 200 response code
|
|
172
|
-
- Removed dependency on ActiveSupport
|
|
173
|
-
|
|
174
|
-
## Customerio 0.2.0 - Nov 21, 2012
|
|
175
|
-
|
|
176
|
-
- Allow raw hashes to be passed into `identify` and `track` methods rather than a customer object.
|
|
177
|
-
- Passing a customer object has been depreciated.
|
|
178
|
-
- Customizing ids with `Customerio::Client.id` block is deprecated.
|
|
179
|
-
|
|
180
|
-
## Customerio 0.1.0 - Nov 15, 2012
|
|
181
|
-
|
|
182
|
-
- Allow tracking of anonymous events.
|
|
183
|
-
|
|
184
|
-
## Customerio 0.0.3 - Nov 5, 2012
|
|
185
|
-
|
|
186
|
-
- Bump httparty dependency to the latest version.
|
|
187
|
-
|
|
188
|
-
## Customerio 0.0.2 - May 22, 2012
|
|
189
|
-
|
|
190
|
-
- First release.
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Based on HTTParty's HashConversions:
|
|
4
|
-
#
|
|
5
|
-
# https://github.com/jnunemaker/httparty/blob/master/lib/httparty/hash_conversions.rb
|
|
6
|
-
#
|
|
7
|
-
# License: MIT https://github.com/jnunemaker/httparty/blob/master/MIT-LICENSE
|
|
8
|
-
|
|
9
|
-
require "erb"
|
|
10
|
-
|
|
11
|
-
module Customerio
|
|
12
|
-
class ParamEncoder
|
|
13
|
-
# @return <String> This hash as a query string
|
|
14
|
-
#
|
|
15
|
-
# @example
|
|
16
|
-
# { name: "Bob",
|
|
17
|
-
# address: {
|
|
18
|
-
# street: '111 Ruby Ave.',
|
|
19
|
-
# city: 'Ruby Central',
|
|
20
|
-
# phones: ['111-111-1111', '222-222-2222']
|
|
21
|
-
# }
|
|
22
|
-
# }.to_params
|
|
23
|
-
# #=> "name=Bob&address[city]=Ruby Central&..."
|
|
24
|
-
def self.to_params(hash)
|
|
25
|
-
hash.to_hash.map { |k, v| normalize_param(k, v) }.join.chop
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# @param key<Object> The key for the param.
|
|
29
|
-
# @param value<Object> The value for the param.
|
|
30
|
-
#
|
|
31
|
-
# @return <String> This key value pair as a param
|
|
32
|
-
#
|
|
33
|
-
# @example normalize_param(:name, "Bob Jones") #=> "name=Bob%20Jones&"
|
|
34
|
-
def self.normalize_param(key, value)
|
|
35
|
-
param = String.new
|
|
36
|
-
stack = []
|
|
37
|
-
|
|
38
|
-
if value.respond_to?(:to_ary)
|
|
39
|
-
param << value.to_ary.map { |element| normalize_param("#{key}[]", element) }.join
|
|
40
|
-
elsif value.respond_to?(:to_hash)
|
|
41
|
-
stack << [key, value.to_hash]
|
|
42
|
-
else
|
|
43
|
-
param << "#{key}=#{escape_value(value)}&"
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
stack.each do |parent, hash|
|
|
47
|
-
hash.each do |k, v|
|
|
48
|
-
if v.respond_to?(:to_hash)
|
|
49
|
-
stack << ["#{parent}[#{k}]", v.to_hash]
|
|
50
|
-
else
|
|
51
|
-
param << normalize_param("#{parent}[#{k}]", v)
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
param
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def self.escape_value(value)
|
|
60
|
-
ERB::Util.url_encode(value.to_s)
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|