customerio 4.2.0 → 4.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/.github/workflows/main.yml +10 -19
- data/.gitpod.yml +10 -0
- data/README.md +30 -16
- data/customerio.gemspec +1 -1
- data/lib/customerio/client.rb +1 -2
- data/lib/customerio/version.rb +1 -1
- data/spec/client_spec.rb +12 -4
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16635bdd8c1cfb5e77fbe0c29ca18a69fdbcd48b3824a19a4657f4bb9d6d0991
|
4
|
+
data.tar.gz: ad565a4bf81cb86a956893bdc104bd0967971af84b4dfcb453f47ac6fae0b6ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b944374f304906b7533def39708eb07078390e07a413bf3bec11f46aecc65683a88c1a8d89bf50d65b16fdc2d5c561f2a0b484827c8ac828b3857cf101efba5
|
7
|
+
data.tar.gz: 17fe083a74d404f9d243e0c9e0a9713e4f02fb4009d10807d30f50d192ce020ba33065684bd84aadaf02908fc9de55d950b5f23d9549ffadce1cb36502f2bc8d
|
data/.github/workflows/main.yml
CHANGED
@@ -1,30 +1,21 @@
|
|
1
|
-
name:
|
1
|
+
name: ci
|
2
2
|
|
3
3
|
on: [push,pull_request]
|
4
4
|
|
5
5
|
jobs:
|
6
|
-
|
6
|
+
test:
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
9
|
ruby: ['2.5', '2.6', '2.7']
|
10
|
-
runs-on: ubuntu-latest
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
env:
|
12
|
+
BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
|
11
13
|
steps:
|
12
14
|
- uses: actions/checkout@v2
|
13
|
-
-
|
14
|
-
uses: actions/setup-ruby@v1
|
15
|
+
- uses: ruby/setup-ruby@v1
|
15
16
|
with:
|
16
17
|
ruby-version: ${{ matrix.ruby }}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- name: Cache dependencies
|
22
|
-
uses: actions/cache@v2
|
23
|
-
with:
|
24
|
-
path: vendor/bundle
|
25
|
-
key: customerio-${{ matrix.ruby }}-${{ hashFiles('customerio.gemspec') }}
|
26
|
-
restore-keys: |
|
27
|
-
customerio-${{ matrix.ruby }}-
|
28
|
-
- name: Install dependencies
|
29
|
-
run: bundle install --path vendor/bundle
|
30
|
-
- run: bundle exec rspec
|
18
|
+
bundler-cache: true
|
19
|
+
|
20
|
+
- name: Unit Test w/ RSpec
|
21
|
+
run: bundle exec rspec
|
data/.gitpod.yml
ADDED
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
-
|
1
|
+
<p align="center">
|
2
|
+
<a href="https://customer.io">
|
3
|
+
<img src="https://files.gitbook.com/v0/b/gitbook-28427.appspot.com/o/assets%2F-LSFjPaMQn1zKdYh6i89%2F-LU6OglGKqQfqMd5Zl-V%2F-LU6OzOLnOvy8VLwfgdg%2FLogo-Color-Horizontal.png?alt=media&token=add29dd0-cabb-4440-b46b-aed21350ae90" height="60">
|
4
|
+
</a>
|
5
|
+
<p align="center">Power automated communication that people like to receive.</p>
|
6
|
+
</p>
|
2
7
|
|
3
|
-
|
8
|
+
[](https://gitpod.io/#https://github.com/customerio/customerio-ruby/)
|
9
|
+
[](https://github.com/customerio/customerio-ruby/actions/workflows/main.yml)
|
4
10
|
|
5
|
-
|
6
|
-
|
11
|
+
# Customer.io Ruby
|
12
|
+
|
13
|
+
A ruby client for the [Customer.io Track API](https://customer.io/docs/api/#tag/trackOverview).
|
7
14
|
|
8
15
|
## Installation
|
9
16
|
|
@@ -24,7 +31,7 @@ Or install it yourself:
|
|
24
31
|
### Before we get started: API client vs. JavaScript snippet
|
25
32
|
|
26
33
|
It's helpful to know that everything below can also be accomplished
|
27
|
-
through the [Customer.io JavaScript snippet](
|
34
|
+
through the [Customer.io JavaScript snippet](https://customer.io/docs/javascript-quick-start/).
|
28
35
|
|
29
36
|
In many cases, using the JavaScript snippet will be easier to integrate with
|
30
37
|
your app, but there are several reasons why using the API client is useful:
|
@@ -38,7 +45,7 @@ your app, but there are several reasons why using the API client is useful:
|
|
38
45
|
|
39
46
|
In the end, the decision on whether or not to use the API client or
|
40
47
|
the JavaScript snippet should be based on what works best for you.
|
41
|
-
You'll be able to integrate **fully** with [Customer.io](
|
48
|
+
You'll be able to integrate **fully** with [Customer.io](https://customer.io) with either approach.
|
42
49
|
|
43
50
|
### Setup
|
44
51
|
|
@@ -54,9 +61,9 @@ $customerio = Customerio::Client.new("YOUR SITE ID", "YOUR API SECRET KEY", regi
|
|
54
61
|
|
55
62
|
### Identify logged in customers
|
56
63
|
|
57
|
-
Tracking data of logged in customers is a key part of [Customer.io](
|
64
|
+
Tracking data of logged in customers is a key part of [Customer.io](https://customer.io). In order to
|
58
65
|
send triggered emails, we must know the email address of the customer. You can
|
59
|
-
also specify any number of customer attributes which help tailor [Customer.io](
|
66
|
+
also specify any number of customer attributes which help tailor [Customer.io](https://customer.io) to your
|
60
67
|
business.
|
61
68
|
|
62
69
|
Attributes you specify are useful in several ways:
|
@@ -71,7 +78,7 @@ set up triggers which are only sent to customers who have subscribed to a
|
|
71
78
|
particular plan (e.g. "premium").
|
72
79
|
|
73
80
|
You'll want to indentify your customers when they sign up for your app and any time their
|
74
|
-
key information changes. This keeps [Customer.io](
|
81
|
+
key information changes. This keeps [Customer.io](https://customer.io) up to date with your customer information.
|
75
82
|
|
76
83
|
```ruby
|
77
84
|
# Arguments
|
@@ -121,7 +128,7 @@ $customerio.merge_customers("email", "cool.person@company.com", "email", "cperso
|
|
121
128
|
|
122
129
|
### Tracking a custom event
|
123
130
|
|
124
|
-
Now that you're identifying your customers with [Customer.io](
|
131
|
+
Now that you're identifying your customers with [Customer.io](https://customer.io), you can now send events like
|
125
132
|
"purchased" or "watchedIntroVideo". These allow you to more specifically target your users
|
126
133
|
with automated emails, and track conversions when you're sending automated emails to
|
127
134
|
encourage your customers to perform an action.
|
@@ -152,15 +159,22 @@ Anonymous events cannot trigger campaigns by themselves. To trigger a campaign,
|
|
152
159
|
|
153
160
|
```ruby
|
154
161
|
# Arguments
|
155
|
-
# anonymous_id (required) - the id representing the unknown person.
|
156
|
-
# name (required)
|
157
|
-
# attributes (optional)
|
158
|
-
# event.
|
162
|
+
# anonymous_id (required, nullable) - the id representing the unknown person.
|
163
|
+
# name (required) - the name of the event you want to track.
|
164
|
+
# attributes (optional) - related information you want to attach to the event.
|
159
165
|
|
160
166
|
$customerio.track_anonymous(anonymous_id, "product_view", :type => "socks" )
|
161
167
|
```
|
162
168
|
|
163
|
-
Use the `recipient` attribute to specify the email address to send the messages to. [See our documentation on how to use anonymous events for more details](https://
|
169
|
+
Use the `recipient` attribute to specify the email address to send the messages to. [See our documentation on how to use anonymous events for more details](https://customer.io/docs/invite-emails/).
|
170
|
+
|
171
|
+
#### Anonymous invite events
|
172
|
+
|
173
|
+
If you previously sent [invite events](https://customer.io/docs/anonymous-invite-emails/), you can achieve the same functionality by sending an anonymous event with `nil` for the anonymous identifier. To send anonymous invites, your event *must* include a `recipient` attribute.
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
$customerio.track_anonymous(nil, "invite", :recipient => "new.person@example.com" )
|
177
|
+
```
|
164
178
|
|
165
179
|
### Adding a mobile device
|
166
180
|
|
@@ -187,7 +201,7 @@ $customerio.delete_device(5, "my_device_token")
|
|
187
201
|
|
188
202
|
### Suppress a user
|
189
203
|
|
190
|
-
Deletes the customer with the provided id if it exists and suppresses all future events and identifies for
|
204
|
+
Deletes the customer with the provided id if it exists and suppresses all future events and identifies for that customer.
|
191
205
|
|
192
206
|
```ruby
|
193
207
|
$customerio.suppress(5)
|
data/customerio.gemspec
CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency('addressable', '~> 2.8.0')
|
21
21
|
|
22
22
|
gem.add_development_dependency('rake', '~> 10.5')
|
23
|
-
gem.add_development_dependency('rspec', '3.
|
23
|
+
gem.add_development_dependency('rspec', '~> 3.10')
|
24
24
|
gem.add_development_dependency('webmock', '3.6.0')
|
25
25
|
gem.add_development_dependency('json')
|
26
26
|
end
|
data/lib/customerio/client.rb
CHANGED
@@ -52,7 +52,6 @@ module Customerio
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def track_anonymous(anonymous_id, event_name, attributes = {})
|
55
|
-
raise ParamError.new("anonymous_id must be a non-empty string") if is_empty?(anonymous_id)
|
56
55
|
raise ParamError.new("event_name must be a non-empty string") if is_empty?(event_name)
|
57
56
|
|
58
57
|
create_anonymous_event(anonymous_id, event_name, attributes)
|
@@ -171,7 +170,7 @@ module Customerio
|
|
171
170
|
def create_event(url:, event_name:, anonymous_id: nil, attributes: {})
|
172
171
|
body = { :name => event_name, :data => attributes }
|
173
172
|
body[:timestamp] = attributes[:timestamp] if valid_timestamp?(attributes[:timestamp])
|
174
|
-
body[:anonymous_id] = anonymous_id unless anonymous_id
|
173
|
+
body[:anonymous_id] = anonymous_id unless is_empty?(anonymous_id)
|
175
174
|
|
176
175
|
@client.request_and_verify_response(:post, url, body)
|
177
176
|
end
|
data/lib/customerio/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -433,12 +433,20 @@ describe Customerio::Client do
|
|
433
433
|
lambda { client.track_anonymous(anon_id, "purchase") }.should raise_error(Customerio::InvalidResponse)
|
434
434
|
end
|
435
435
|
|
436
|
-
it "
|
436
|
+
it "doesn't pass along anonymous_id if it is blank" do
|
437
437
|
stub_request(:post, api_uri('/api/v1/events')).
|
438
|
-
with(body: {
|
439
|
-
to_return(status:
|
438
|
+
with(body: { name: "some_event", data: {} }).
|
439
|
+
to_return(status: 200, body: "", headers: {})
|
440
|
+
|
441
|
+
client.track_anonymous("", "some_event")
|
442
|
+
end
|
443
|
+
|
444
|
+
it "doesn't pass along anonymous_id if it is nil" do
|
445
|
+
stub_request(:post, api_uri('/api/v1/events')).
|
446
|
+
with(body: { name: "some_event", data: {} }).
|
447
|
+
to_return(status: 200, body: "", headers: {})
|
440
448
|
|
441
|
-
|
449
|
+
client.track_anonymous(nil, "some_event")
|
442
450
|
end
|
443
451
|
|
444
452
|
it "throws an error when event_name is missing" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: customerio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Allison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.
|
61
|
+
version: '3.10'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
68
|
+
version: '3.10'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: webmock
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,6 +103,7 @@ extra_rdoc_files: []
|
|
103
103
|
files:
|
104
104
|
- ".github/workflows/main.yml"
|
105
105
|
- ".gitignore"
|
106
|
+
- ".gitpod.yml"
|
106
107
|
- CHANGELOG.markdown
|
107
108
|
- Gemfile
|
108
109
|
- LICENSE
|
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
141
|
- !ruby/object:Gem::Version
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
|
-
rubygems_version: 3.
|
144
|
+
rubygems_version: 3.2.5
|
144
145
|
signing_key:
|
145
146
|
specification_version: 4
|
146
147
|
summary: A ruby client for the Customer.io event API.
|