plainflow 2.2.3.pre.p1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6e2315b3be8977b60b4d7d243a036dd8c63ed26
4
+ data.tar.gz: dc97871f225b43d807381038a4eacd35f241fa74
5
+ SHA512:
6
+ metadata.gz: 7a58bc89eeaa8d56162e22275ef0e783413a7acb8f13a0e603c78cd8085a3273d045ebc6dd9efbe0bdd689bb449c4651902b632aff47a22906cc8ec36067847d
7
+ data.tar.gz: 512272c46c847efc3947528def02990e22a1c8cc2b25db5e53e2ba17fde0252a09f91e96c6e595adec32e4c2cc810d2fed1e1f896848c4ff61a04ab5ae044473
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'http://rubygems.org'
2
+ gemspec
data/History.md ADDED
@@ -0,0 +1,200 @@
1
+ 2.2.3.pre.p1 / 2017-10-24
2
+ ==================
3
+
4
+ * The library has been forked to work with Plainflow.
5
+
6
+ 2.2.3.pre / 2017-09-14
7
+ ==================
8
+
9
+ * [Fix](https://github.com/segmentio/analytics-ruby/pull/120): Override `respond_to_missing` instead of `respond_to?` to facilitate mock the library in tests.
10
+
11
+
12
+ 2.2.2 / 2016-08-03
13
+ ==================
14
+
15
+ * adding commander as dep (for CLI)
16
+
17
+ 2.2.1 / 2016-08-03
18
+ ==================
19
+
20
+ * add executables to spec
21
+
22
+ 2.2.0 / 2016-08-03
23
+ ==================
24
+
25
+ * Adding an (experimental) CLI
26
+
27
+ 2.1.0 / 2016-06-17
28
+ ==================
29
+
30
+ * Fix: Ensure error handler is called before Client#flush finishes.
31
+ * Feature: Support setting a custom message ID.
32
+
33
+ 2.0.13 / 2015-09-15
34
+ ==================
35
+
36
+ * readme: updated install docs
37
+ * fix: page/screen to allow no name
38
+ * git: ignore ruby version
39
+ * travis-ci: remove old rubys
40
+
41
+ 2.0.12 / 2015-01-10
42
+ ==================
43
+
44
+ * Fix batch being cleared and causing duplicates
45
+
46
+ 2.0.11 / 2014-09-22
47
+ ==================
48
+
49
+ * fix: don't clear batch if request failed
50
+
51
+ 2.0.10 / 2014-09-22
52
+ ==================
53
+
54
+ * Move timeout retry above output
55
+
56
+ 2.0.9 / 2014-09-22
57
+ ==================
58
+
59
+ * Fix rescuing timeouts
60
+
61
+ 2.0.8 / 2014-09-11
62
+ ==================
63
+ * fix: add 3 ms to timestamp
64
+
65
+ 2.0.7 / 2014-08-27
66
+ ==================
67
+ * fix: include optional options hash in calls
68
+
69
+ 2.0.6 / 2014-08-12
70
+ ==================
71
+ * fix: category param on #page and #screen
72
+
73
+ 2.0.5 / 2014-05-26
74
+ ==================
75
+ * fix: datetime conversions
76
+
77
+ 2.0.4 / 2014-06-11
78
+ ==================
79
+ * fix: isofying trait dates in #group
80
+
81
+ 2.0.3 / 2014-06-04
82
+ ==================
83
+ * fix: undefined method `is_requesting?' for nil:NilClass when calling flush (#51)
84
+
85
+ 2.0.2 / 2014-05-30
86
+ ==================
87
+ * fix: formatting ios dates
88
+ * fix: respond_to? implementation
89
+ * add: able to stub requests by setting STUB env var
90
+
91
+ 2.0.1 / 2014-05-15
92
+ ==================
93
+ * add: namespace under Segment::Analytics
94
+ * add: can create multiple instances with creator method (rather than
95
+ having a singleton)
96
+ * add: logging with Logger instance or Rails.logger if available
97
+ * add: able to stub requests so they just log and don't hit the server
98
+ * fix: worker continues running across forked processes
99
+ * fix: removed usage of ActiveSupport methods since its not a dependency
100
+ * fix: sending data that matches segment's new api spec
101
+
102
+ (there is no v2.0.0)
103
+
104
+ 1.1.0 / 2014-04-17
105
+ ==================
106
+ * adding .initialized? by [@lumberj](https://github.com/lumberj)
107
+
108
+ 1.0.0 / 2014-03-12
109
+ ==================
110
+ * removing faraday dependency
111
+
112
+ 0.6.0 / 2014-02-19
113
+ ==================
114
+ * adding .group(), .page(), and .screen() calls
115
+ * relaxing faraday dependency, fixes #31
116
+
117
+ 0.5.4 / 2013-12-31
118
+ ==================
119
+ * Add `requestId` fields to all requests for tracing.
120
+
121
+ 0.5.3 / 2013-12-31
122
+ ==================
123
+ * Allow the consumer thread to shut down so it won't remain live in hot deploy scenarios. This fixes the jruby memory leak by [@nirvdrum](https://github.com/nirvdrum)
124
+
125
+ 0.5.2 / 2013-12-02
126
+ ==================
127
+ * adding `sleep` backoff between connection retries
128
+
129
+ 0.5.1 / 2013-11-22
130
+ ==================
131
+ * adding retries for connection hangups
132
+
133
+ 0.5.0 / 2013-10-03
134
+ ==================
135
+ * Removing global Analytics constant in favor of adding it to our config. NOTE: If you are upgrading from a previous version and want to continue using the `Analytics` namespace, you'll have to add `Analytics = AnalyticsRuby` to your config. Otherwise you WILL NOT be sending analytics data. See the [setup docs for more info](https://segment.io/libraries/ruby)
136
+
137
+ 0.4.0 / 2013-08-30
138
+ ==================
139
+ * Adding support and tests for 1.8.7
140
+
141
+ 0.3.4 / 2013-08-26
142
+ ==================
143
+ * Pass `Time` values as iso8601 timestamp strings
144
+
145
+ 0.3.3 / 2013-08-02
146
+ ==================
147
+ * Allow init/track/identify/alias to accept strings as keys. by [@shipstar](https://github.com/shipstar)
148
+
149
+ 0.3.2 / 2013-05-28
150
+ ==================
151
+ * Adding faraday timeout by [@yanchenyun](https://github.com/yangchenyun)
152
+
153
+ 0.3.1 / 2013-04-29
154
+ ==================
155
+ * Adding check for properties to be a Hash
156
+
157
+ 0.3.0 / 2013-04-05
158
+ ==================
159
+ * Adding alias call
160
+
161
+ 0.2.0 / 2013-03-21
162
+ ==================
163
+ * Adding flush method
164
+
165
+ 0.1.4 / 2013-03-19
166
+ ==================
167
+ * Adding ClassMethods for more extensibility by [arronmabrey](https://github.com/arronmabrey)
168
+
169
+ 0.1.3 / 2013-03-19
170
+ ==================
171
+ * Fixing user_id.to_s semantics, reported by [arronmabrey](https://github.com/arronmabrey)
172
+ * Reduced faraday requirements by [arronmabrey](https://github.com/arronmabrey)
173
+
174
+ 0.1.2 / 2013-03-11
175
+ ==================
176
+ * Fixing thrown exception on non-initialized tracks thanks to [sbellity](https://github.com/sbellity)
177
+
178
+ 0.1.1 / 2013-02-11
179
+ ==================
180
+ * Updating dependencies
181
+ * Adding actual support for MultiJson 1.0
182
+
183
+ 0.1.0 / 2013-01-22
184
+ ==================
185
+ * Updated docs to point at segment.io
186
+
187
+ 0.0.5 / 2013-01-21
188
+ ==================
189
+ * Renaming of all the files for proper bundling usage
190
+
191
+ 0.0.4 / 2013-01-17
192
+ ==================
193
+ * Updated readme and install instruction courtesy of [@zeke](https://github.com/zeke)
194
+ * Removed typhoeus and reverted to default adapter
195
+ * Removing session_id in favor of a single user_id
196
+
197
+ 0.0.3 / 2013-01-16
198
+ ==================
199
+ * Rakefile and renaming courtesy of [@kiennt](https://github.com/kiennt)
200
+ * Updated tests with mocks
data/Makefile ADDED
@@ -0,0 +1,11 @@
1
+
2
+ clean:
3
+ rm -f plainflow*.gem
4
+
5
+ test:
6
+ rake spec
7
+
8
+ build:
9
+ gem build ./plainflow-ruby.gemspec
10
+
11
+ .PHONY: test build
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ Plainflow-ruby
2
+ ==============
3
+
4
+ [![Build Status](https://travis-ci.org/plainflow-dcp/plainflow-ruby.png?branch=master)](https://travis-ci.org/plainflow-dcp/plainflow-ruby)
5
+
6
+ Plainflow-ruby is a ruby client for [Plainflow](https://www.plainflow.com)
7
+
8
+ ## Install
9
+
10
+ Into Gemfile from rubygems.org:
11
+ ```ruby
12
+ gem 'plainflow', require: "plainflow"
13
+ ```
14
+
15
+ Into environment gems from rubygems.org:
16
+ ```ruby
17
+ gem install 'plainflow'
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Create an instance of the Plainflow Analytics object:
23
+ ```ruby
24
+ plainflow = Plainflow::Analytics.new(secret_key: 'YOUR_SECRET_KEY')
25
+ ```
26
+
27
+ Identify the user for the people section:
28
+ ```ruby
29
+ plainflow.identify(user_id: 42,
30
+ traits: {
31
+ email: 'name@example.com',
32
+ first_name: 'Foo',
33
+ last_name: 'Bar'
34
+ })
35
+ ```
36
+
37
+ Track a user event.
38
+ ```ruby
39
+ plainflow.track(user_id: 42, event: 'Created Account')
40
+ ```
41
+
42
+ There are a few calls available, please check the documentation section.
43
+
44
+ ## Documentation
45
+
46
+ Documentation is available at [www.plainflow.com/docs/developers/sdk/ruby](https://www.plainflow.com/docs/developers/sdk/ruby)
47
+
48
+ ## Testing
49
+
50
+ You can use the `stub` option to Plainflow::Analytics.new to cause all requests to be stubbed, making it easier to test with this library.
51
+
52
+ ## License
53
+
54
+
55
+ (The MIT License)
56
+
57
+ Copyright (c) 2013 Segment Inc. <friends@segment.com>
58
+
59
+ Copyright (c) 2017 Plainflow, Inc. <friends@plainflow.com>
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
62
+
63
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
64
+
65
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
66
+
data/RELEASING.md ADDED
@@ -0,0 +1,10 @@
1
+ Releasing
2
+ =========
3
+
4
+ 1. Verify everything works with `make test build`.
5
+ 2. Bump version in [`version.rb`](https://github.com/plainflow-dcp/plainflow-ruby/blob/master/lib/plainflow/analytics/version.rb).
6
+ 3. Update [`History.md`](https://github.com/segmentio/analytics-ruby/blob/master/History.md).
7
+ 4. Commit and tag `git commit -am "Release {version}" && git tag -a {version} -m "Version {version}"`.
8
+ 5. Build the gem with the tagged version `make build`.
9
+ 6. Upload to RubyGems with `gem push analytics-ruby-{version}.gem`.
10
+ 7. Upload to Github with `git push -u origin master && git push --tags`.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'rspec/core/rake_task'
2
+
3
+ RSpec::Core::RakeTask.new(:spec) do |spec|
4
+ spec.pattern = 'spec/**/*_spec.rb'
5
+ end
6
+
7
+ task :default => :spec
data/bin/plainflow ADDED
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'plainflow/analytics'
4
+ require 'rubygems'
5
+ require 'commander/import'
6
+ require 'time'
7
+ require 'json'
8
+
9
+ program :name, 'simulator.rb'
10
+ program :version, '0.0.1'
11
+ program :description, 'scripting simulator'
12
+
13
+ # use an env var for write key, instead of a flag
14
+ Analytics = Segment::Analytics.new({
15
+ secret_key: ENV['PLAINFLOW_SECRET_KEY'],
16
+ on_error: Proc.new { |status, msg| print msg }
17
+ })
18
+
19
+ def toObject(str)
20
+ return JSON.parse(str)
21
+ end
22
+
23
+ # high level
24
+ # analytics <method> [options]
25
+ # PLAINFLOW_SECRET_KEY=<secret_key> ./analytics.rb <method> [options]
26
+ # PLAINFLOW_SECRET_KEY=<secret_key> ./analytics.rb track --event testing --user 1234 --anonymous 567 --properties '{"hello": "goodbye"}' --context '{"slow":"poke"}'
27
+
28
+
29
+
30
+ # track
31
+ command :track do |c|
32
+ c.description = 'track a user event'
33
+ c.option '--user <id>', String, 'the user id to send the event as'
34
+ c.option '--event <event>', String, 'the event name to send with the event'
35
+ c.option '--anonymous <id>', String, 'the anonymous user id to send the event as'
36
+ c.option '--properties <data>', 'the event properties to send (JSON-encoded)'
37
+ c.option '--context <data>', 'additional context for the event (JSON-encoded)'
38
+
39
+ c.action do |args, options|
40
+ Analytics.track({
41
+ user_id: options.user,
42
+ event: options.event,
43
+ anonymous_id: options.anonymous,
44
+ properties: toObject(options.properties),
45
+ context: toObject(options.context)
46
+ })
47
+ Analytics.flush
48
+ end
49
+
50
+ end
51
+
52
+ # page
53
+ command :page do |c|
54
+ c.description = 'track a page view'
55
+ c.option '--user <id>', String, 'the user id to send the event as'
56
+ c.option '--anonymous <id>', String, 'the anonymous user id to send the event as'
57
+ c.option '--name <name>', String, 'the page name'
58
+ c.option '--properties <data>', 'the event properties to send (JSON-encoded)'
59
+ c.option '--context <data>', 'additional context for the event (JSON-encoded)'
60
+ c.option '--category <category>', 'the category of the page'
61
+ c.action do |args, options|
62
+ Analytics.page({
63
+ user_id: options.user,
64
+ anonymous_id: options.anonymous,
65
+ name: options.name,
66
+ properties: toObject(options.properties),
67
+ context: toObject(options.context),
68
+ category: options.category
69
+ })
70
+ Analytics.flush
71
+ end
72
+
73
+ end
74
+
75
+ # identify
76
+ command :identify do |c|
77
+ c.description = 'identify a user'
78
+ c.option '--user <id>', String, 'the user id to send the event as'
79
+ c.option '--anonymous <id>', String, 'the anonymous user id to send the event as'
80
+ c.option '--traits <data>', String, 'the user traits to send (JSON-encoded)'
81
+ c.option '--context <data>', 'additional context for the event (JSON-encoded)'
82
+ c.action do |args, options|
83
+ Analytics.identify({
84
+ user_id: options.user,
85
+ anonymous_id: options.anonymous,
86
+ traits: toObject(options.traits),
87
+ context: toObject(options.context)
88
+ })
89
+ Analytics.flush
90
+ end
91
+
92
+ end
93
+
94
+ # screen
95
+ command :screen do |c|
96
+ c.description = 'track a screen view'
97
+ c.option '--user <id>', String, 'the user id to send the event as'
98
+ c.option '--anonymous <id>', String, 'the anonymous user id to send the event as'
99
+ c.option '--name <name>', String, 'the screen name'
100
+ c.option '--properties <data>', String, 'the event properties to send (JSON-encoded)'
101
+ c.option '--context <data>', 'additional context for the event (JSON-encoded)'
102
+ c.action do |args, options|
103
+ Analytics.identify({
104
+ user_id: options.user,
105
+ anonymous_id: options.anonymous,
106
+ name: option.name,
107
+ traits: toObject(options.traits),
108
+ properties: toObject(option.properties),
109
+ context: toObject(options.context)
110
+ })
111
+ Analytics.flush
112
+ end
113
+
114
+ end
115
+
116
+
117
+ # group
118
+ command :group do |c|
119
+ c.description = 'identify a group of users'
120
+ c.option '--user <id>', String, 'the user id to send the event as'
121
+ c.option '--anonymous <id>', String, 'the anonymous user id to send the event as'
122
+ c.option '--group <id>', String, 'the group id to associate this user with'
123
+ c.option '--traits <data>', String, 'attributes about the group (JSON-encoded)'
124
+ c.option '--context <data>', 'additional context for the event (JSON-encoded)'
125
+ c.action do |args, options|
126
+ Analytics.group({
127
+ user_id: options.user,
128
+ anonymous_id: options.anonymous,
129
+ group_id: options.group,
130
+ traits: toObject(options.traits),
131
+ context: toObject(options.context)
132
+ })
133
+ Analytics.flush
134
+ end
135
+
136
+ end
137
+
138
+ # alias
139
+ command :alias do |c|
140
+ c.description = 'remap a user to a new id'
141
+ c.option '--user <id>', String, 'the user id to send the event as'
142
+ c.option '--previous <id>', String, 'the previous user id (to add the alias for)'
143
+ c.action do |args, options|
144
+ Analytics.alias({
145
+ user_id: options.user,
146
+ previous_id: options.previous
147
+ })
148
+ Analytics.flush
149
+ end
150
+
151
+ end
152
+