analytics-ruby 2.1.0 → 2.2.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: f272d5ddcbdd3fbded71fa72482a8d5b27679d9d
4
- data.tar.gz: 70a98af711f968d00e0e7a68144afddb98fe00e5
3
+ metadata.gz: ce7b91326f0324154c09c6483f35d90f4e435dd1
4
+ data.tar.gz: 91bb84d9d8a6424bae727ee270d3d559e6324694
5
5
  SHA512:
6
- metadata.gz: 3e61136a5eb4d08866638bb0084e4fe9977d08f15a2498ce642335b2eed4f33adcefe0c53100924bee3b4774ede158a0a8fc8a149dd20e5b8e740198add41cf7
7
- data.tar.gz: 8e93c453d66121654cb841da5937ac62409ba089b9c1d9cda708d7db1065b077a406d72198e2ba8b53f5dfacd8340271729c36bcd5d785692ab85f00f82ad645
6
+ metadata.gz: 38623225b9b78a9dae01fc725311b569b3d460a4aa815233e4d8e548cab35855f8d6e27e1fa6dc0f106c38e2269f0d2459edf9abc7ac96579c3b0545bee29bd1
7
+ data.tar.gz: b9cf18ff84576b8b42b998ff3ea409fbbc56fee80c732e760475c5cc4b996baaf444788cf5e819221c2637f36f7cf265134c3bdb0f0673018bd5e6659376257e
data/History.md CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ 2.2.0 / 2016-08-03
3
+ ==================
4
+
5
+ * Adding an (experimental) CLI
6
+
2
7
  2.1.0 / 2016-06-17
3
8
  ==================
4
9
 
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/segmentio/analytics-ruby/blob/master/lib/segment/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`.
@@ -5,6 +5,7 @@ Gem::Specification.new do |spec|
5
5
  spec.version = Segment::Analytics::VERSION
6
6
  spec.files = Dir.glob('**/*')
7
7
  spec.require_paths = ['lib']
8
+ spec.bindir = 'bin'
8
9
  spec.summary = 'Segment.io analytics library'
9
10
  spec.description = 'The Segment.io ruby analytics library'
10
11
  spec.authors = ['Segment.io']
data/bin/analytics ADDED
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'segment/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
+ write_key: ENV['SEGMENT_WRITE_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
+ # SEGMENT_WRITE_KEY=<write_key> ./analytics.rb <method> [options]
26
+ # SEGMENT_WRITE_KEY=<write_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
+
@@ -1,5 +1,5 @@
1
1
  module Segment
2
2
  class Analytics
3
- VERSION = '2.1.0'
3
+ VERSION = '2.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Segment.io
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-17 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '10.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '10.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: wrong
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
55
  - !ruby/object:Gem::Dependency
@@ -70,20 +70,20 @@ dependencies:
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 3.0.0
76
- - - <
76
+ - - "<"
77
77
  - !ruby/object:Gem::Version
78
78
  version: 4.0.0
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: 3.0.0
86
- - - <
86
+ - - "<"
87
87
  - !ruby/object:Gem::Version
88
88
  version: 4.0.0
89
89
  description: The Segment.io ruby analytics library
@@ -92,12 +92,16 @@ executables: []
92
92
  extensions: []
93
93
  extra_rdoc_files: []
94
94
  files:
95
- - analytics-ruby-2.0.13.gem
96
- - analytics-ruby-2.1.0.gem
97
- - analytics-ruby.gemspec
98
95
  - Gemfile
99
- - Gemfile.lock
100
96
  - History.md
97
+ - Makefile
98
+ - README.md
99
+ - RELEASING.md
100
+ - Rakefile
101
+ - analytics-ruby.gemspec
102
+ - bin/analytics
103
+ - lib/segment.rb
104
+ - lib/segment/analytics.rb
101
105
  - lib/segment/analytics/client.rb
102
106
  - lib/segment/analytics/defaults.rb
103
107
  - lib/segment/analytics/logging.rb
@@ -106,11 +110,6 @@ files:
106
110
  - lib/segment/analytics/utils.rb
107
111
  - lib/segment/analytics/version.rb
108
112
  - lib/segment/analytics/worker.rb
109
- - lib/segment/analytics.rb
110
- - lib/segment.rb
111
- - Makefile
112
- - Rakefile
113
- - README.md
114
113
  - spec/segment/analytics/client_spec.rb
115
114
  - spec/segment/analytics/request_spec.rb
116
115
  - spec/segment/analytics/response_spec.rb
@@ -127,17 +126,17 @@ require_paths:
127
126
  - lib
128
127
  required_ruby_version: !ruby/object:Gem::Requirement
129
128
  requirements:
130
- - - '>='
129
+ - - ">="
131
130
  - !ruby/object:Gem::Version
132
131
  version: '0'
133
132
  required_rubygems_version: !ruby/object:Gem::Requirement
134
133
  requirements:
135
- - - '>='
134
+ - - ">="
136
135
  - !ruby/object:Gem::Version
137
136
  version: '0'
138
137
  requirements: []
139
138
  rubyforge_project:
140
- rubygems_version: 2.0.14.1
139
+ rubygems_version: 2.2.2
141
140
  signing_key:
142
141
  specification_version: 4
143
142
  summary: Segment.io analytics library
data/Gemfile.lock DELETED
@@ -1,53 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- analytics-ruby (2.0.13)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- activesupport (3.2.22)
10
- i18n (~> 0.6, >= 0.6.4)
11
- multi_json (~> 1.0)
12
- diff-lcs (1.2.5)
13
- i18n (0.7.0)
14
- multi_json (1.11.2)
15
- predicated (0.2.6)
16
- rake (10.4.2)
17
- rspec (2.99.0)
18
- rspec-core (~> 2.99.0)
19
- rspec-expectations (~> 2.99.0)
20
- rspec-mocks (~> 2.99.0)
21
- rspec-core (2.99.2)
22
- rspec-expectations (2.99.2)
23
- diff-lcs (>= 1.1.3, < 2.0)
24
- rspec-mocks (2.99.4)
25
- ruby2ruby (2.2.0)
26
- ruby_parser (~> 3.1)
27
- sexp_processor (~> 4.0)
28
- ruby_parser (3.7.2)
29
- sexp_processor (~> 4.1)
30
- sexp_processor (4.6.0)
31
- thread_safe (0.3.5)
32
- tzinfo (1.2.1)
33
- thread_safe (~> 0.1)
34
- wrong (0.7.1)
35
- diff-lcs (~> 1.2.5)
36
- predicated (~> 0.2.6)
37
- ruby2ruby (>= 2.0.1)
38
- ruby_parser (>= 3.0.1)
39
- sexp_processor (>= 4.0)
40
-
41
- PLATFORMS
42
- ruby
43
-
44
- DEPENDENCIES
45
- activesupport (>= 3.0.0, < 4.0.0)
46
- analytics-ruby!
47
- rake (~> 10.3)
48
- rspec (~> 2.0)
49
- tzinfo (= 1.2.1)
50
- wrong (~> 0.0)
51
-
52
- BUNDLED WITH
53
- 1.11.2
Binary file
Binary file