analytics-ruby 2.0.1 → 2.0.3

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- analytics-ruby (2.0.1)
4
+ analytics-ruby (2.0.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/History.md CHANGED
@@ -1,3 +1,25 @@
1
+ 2.0.3 / 2014-06-04
2
+ ==================
3
+ * fix: undefined method `is_requesting?' for nil:NilClass when calling flush (#51)
4
+
5
+ 2.0.2 / 2014-05-30
6
+ ==================
7
+ * fix: formatting ios dates
8
+ * fix: respond_to? implementation
9
+ * add: able to stub requests by setting STUB env var
10
+
11
+ 2.0.1 / 2014-05-15
12
+ ==================
13
+ * add: namespace under Segment::Analytics
14
+ * add: can create multiple instances with creator method (rather than
15
+ having a singleton)
16
+ * add: logging with Logger instance or Rails.logger if available
17
+ * add: able to stub requests so they just log and don't hit the server
18
+ * fix: worker continues running across forked processes
19
+ * fix: removed usage of ActiveSupport methods since its not a dependency
20
+ * fix: sending data that matches segment's new api spec
21
+
22
+ (there is no v2.0.0)
1
23
 
2
24
  1.1.0 / 2014-04-17
3
25
  ==================
@@ -95,4 +117,4 @@
95
117
  0.0.3 / 2013-01-16
96
118
  ==================
97
119
  * Rakefile and renaming courtesy of [@kiennt](https://github.com/kiennt)
98
- * Updated tests with mocks
120
+ * Updated tests with mocks
@@ -23,6 +23,7 @@ module Segment
23
23
  @max_queue_size = options[:max_queue_size] || Defaults::Queue::MAX_SIZE
24
24
  @options = options
25
25
  @worker_mutex = Mutex.new
26
+ @worker = Worker.new @queue, @write_key, @options
26
27
 
27
28
  check_write_key!
28
29
 
@@ -320,7 +321,6 @@ module Segment
320
321
  @worker_mutex.synchronize do
321
322
  return if worker_running?
322
323
  @worker_thread = Thread.new do
323
- @worker = Worker.new @queue, @write_key, @options
324
324
  @worker.run
325
325
  end
326
326
  end
@@ -74,6 +74,10 @@ module Segment
74
74
 
75
75
  class << self
76
76
  attr_accessor :stub
77
+
78
+ def stub
79
+ @stub || ENV['STUB']
80
+ end
77
81
  end
78
82
  end
79
83
  end
@@ -75,7 +75,7 @@ module Segment
75
75
  end
76
76
 
77
77
  def seconds_to_utc_offset(seconds, colon = true)
78
- (colon ? UTC_OFFSET_WITH_COLON : UTC_OFFSET_WITHOUT_COLON) % [(seconds < 0 ? '-' : '+'), seconds.abs, (seconds.abs % 3600)]
78
+ (colon ? UTC_OFFSET_WITH_COLON : UTC_OFFSET_WITHOUT_COLON) % [(seconds < 0 ? '-' : '+'), (seconds.abs / 3600), ((seconds.abs % 3600) / 60)]
79
79
  end
80
80
 
81
81
  UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
@@ -1,6 +1,5 @@
1
1
  module Segment
2
2
  class Analytics
3
- VERSION = '2.0.1'
3
+ VERSION = '2.0.3'
4
4
  end
5
5
  end
6
-
@@ -23,7 +23,7 @@ module Segment
23
23
  end
24
24
 
25
25
  def respond_to? method_name, include_private = false
26
- @client.respond_to?(method_missing) || super
26
+ @client.respond_to?(method_name) || super
27
27
  end
28
28
 
29
29
  include Logging
@@ -41,6 +41,20 @@ module Segment
41
41
  }.to raise_error(ArgumentError)
42
42
  end
43
43
 
44
+ it 'should use the timestamp given' do
45
+ time = Time.parse("1990-07-16 13:30:00 UTC")
46
+
47
+ @client.track({
48
+ :event => 'testing the timestamp',
49
+ :user_id => 'joe',
50
+ :timestamp => time
51
+ })
52
+
53
+ msg = @queue.pop
54
+
55
+ Time.parse(msg[:timestamp]).should == time
56
+ end
57
+
44
58
  it 'should not error with the required options' do
45
59
  @client.track Queued::TRACK
46
60
  @queue.pop
@@ -215,7 +229,7 @@ module Segment
215
229
  end
216
230
 
217
231
  context 'common' do
218
- check_property = proc { |msg, k, v| msg[k] && msg[k].should == v }
232
+ check_property = proc { |msg, k, v| msg[k] && msg[k].should == v }
219
233
 
220
234
  before(:all) do
221
235
  @client = Client.new :write_key => WRITE_KEY
@@ -236,7 +250,7 @@ module Segment
236
250
 
237
251
  it 'should send integrations' do
238
252
  [:track, :screen, :page, :group, :identify, :alias].each do |s|
239
- @client.send s, :integrations => { All: true, Salesforce: false }, :user_id => 1, :group_id => 2, :previous_id => 3, :anonymous_id => 4, :event => "coco barked", :name => "coco"
253
+ @client.send s, :integrations => { :All => true, :Salesforce => false }, :user_id => 1, :group_id => 2, :previous_id => 3, :anonymous_id => 4, :event => "coco barked", :name => "coco"
240
254
  message = @queue.pop(true)
241
255
  message[:integrations][:All].should be_true
242
256
  message[:integrations][:Salesforce].should be_false
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-15 00:00:00.000000000 Z
12
+ date: 2014-06-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &11720620 !ruby/object:Gem::Requirement
16
+ requirement: &13866940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '10.3'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *11720620
24
+ version_requirements: *13866940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: wrong
27
- requirement: &11720120 !ruby/object:Gem::Requirement
27
+ requirement: &13866440 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *11720120
35
+ version_requirements: *13866440
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &11719660 !ruby/object:Gem::Requirement
38
+ requirement: &13865980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,13 +43,14 @@ dependencies:
43
43
  version: '2.0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *11719660
46
+ version_requirements: *13865980
47
47
  description: The Segment.io ruby analytics library
48
48
  email: friends@segment.io
49
49
  executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
+ - analytics-ruby-2.0.3.gem
53
54
  - analytics-ruby.gemspec
54
55
  - Gemfile
55
56
  - Gemfile.lock
@@ -71,7 +72,6 @@ files:
71
72
  - spec/segment/analytics/worker_spec.rb
72
73
  - spec/segment/analytics_spec.rb
73
74
  - spec/spec_helper.rb
74
- - tags
75
75
  homepage: https://github.com/segmentio/analytics-ruby
76
76
  licenses:
77
77
  - MIT
data/tags DELETED
@@ -1,135 +0,0 @@
1
- !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
2
- !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
3
- !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/
4
- !_TAG_PROGRAM_NAME Exuberant Ctags //
5
- !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
6
- !_TAG_PROGRAM_VERSION 5.8 //
7
- ALIAS spec/spec_helper.rb /^ ALIAS = {$/;" c line:25
8
- Analytics lib/segment/analytics.rb /^ class Analytics$/;" c line:11 class:Segment
9
- Analytics lib/segment/analytics/client.rb /^ class Analytics$/;" c line:8 class:Segment
10
- Analytics lib/segment/analytics/defaults.rb /^ class Analytics$/;" c line:2 class:Segment
11
- Analytics lib/segment/analytics/logging.rb /^ class Analytics$/;" c line:4 class:Segment
12
- Analytics lib/segment/analytics/request.rb /^ class Analytics$/;" c line:10 class:Segment
13
- Analytics lib/segment/analytics/response.rb /^ class Analytics$/;" c line:2 class:Segment
14
- Analytics lib/segment/analytics/utils.rb /^ class Analytics$/;" c line:4 class:Segment
15
- Analytics lib/segment/analytics/version.rb /^ class Analytics$/;" c line:2 class:Segment
16
- Analytics lib/segment/analytics/worker.rb /^ class Analytics$/;" c line:7 class:Segment
17
- Analytics spec/segment/analytics/client_spec.rb /^ class Analytics$/;" c line:4 class:Segment
18
- Analytics spec/segment/analytics/worker_spec.rb /^ class Analytics$/;" c line:4 class:Segment
19
- Analytics spec/segment/analytics_spec.rb /^ class Analytics$/;" c line:4 class:Segment
20
- Analytics spec/spec_helper.rb /^ class Analytics$/;" c line:4 class:Segment
21
- BACKOFF lib/segment/analytics/defaults.rb /^ BACKOFF = 30.0$/;" c line:11
22
- BACKOFF spec/segment/analytics/worker_spec.rb /^ Segment::Analytics::Defaults::Request::BACKOFF = 0.1$/;" c line:16
23
- BACKOFF spec/segment/analytics/worker_spec.rb /^ Segment::Analytics::Defaults::Request::BACKOFF = 30.0$/;" c line:20
24
- BATCH_SIZE lib/segment/analytics/defaults.rb /^ BATCH_SIZE = 100$/;" c line:15
25
- Client lib/segment/analytics/client.rb /^ class Client$/;" c line:9 class:Segment.Analytics
26
- Defaults lib/segment/analytics/defaults.rb /^ module Defaults$/;" m line:3 class:Segment.Analytics
27
- GROUP spec/spec_helper.rb /^ GROUP = GROUP.merge :group_id => GROUP_ID, :user_id => USER_ID$/;" c line:47
28
- GROUP spec/spec_helper.rb /^ GROUP = GROUP.merge({$/;" c line:64
29
- GROUP spec/spec_helper.rb /^ GROUP = {}$/;" c line:30
30
- GROUP_ID spec/spec_helper.rb /^ GROUP_ID = 1234$/;" c line:41
31
- HEADERS lib/segment/analytics/defaults.rb /^ HEADERS = { :accept => 'application\/json' }$/;" c line:9
32
- HOST lib/segment/analytics/defaults.rb /^ HOST = 'api.segment.io'$/;" c line:5
33
- IDENTIFY spec/spec_helper.rb /^ IDENTIFY = IDENTIFY.merge :user_id => USER_ID$/;" c line:46
34
- IDENTIFY spec/spec_helper.rb /^ IDENTIFY = IDENTIFY.merge({$/;" c line:59
35
- IDENTIFY spec/spec_helper.rb /^ IDENTIFY = {$/;" c line:17
36
- Logging lib/segment/analytics/logging.rb /^ module Logging$/;" m line:5 class:Segment.Analytics
37
- MAX_SIZE lib/segment/analytics/defaults.rb /^ MAX_SIZE = 10000$/;" c line:16
38
- Makefile Makefile 1;" F line:1
39
- PAGE spec/spec_helper.rb /^ PAGE = PAGE.merge :userId => USER_ID$/;" c line:70
40
- PAGE spec/spec_helper.rb /^ PAGE = PAGE.merge :user_id => USER_ID$/;" c line:48
41
- PAGE spec/spec_helper.rb /^ PAGE = {$/;" c line:32
42
- PATH lib/segment/analytics/defaults.rb /^ PATH = '\/v1\/import'$/;" c line:7
43
- PORT lib/segment/analytics/defaults.rb /^ PORT = 443$/;" c line:6
44
- Queue lib/segment/analytics/defaults.rb /^ module Queue$/;" m line:14 class:Segment.Analytics.Defaults
45
- Queued spec/spec_helper.rb /^ module Queued$/;" m line:44 class:Segment.Analytics
46
- RETRIES lib/segment/analytics/defaults.rb /^ RETRIES = 4$/;" c line:10
47
- Request lib/segment/analytics/defaults.rb /^ module Request$/;" m line:4 class:Segment.Analytics.Defaults
48
- Request lib/segment/analytics/request.rb /^ class Request$/;" c line:11 class:Segment.Analytics
49
- Requested spec/spec_helper.rb /^ module Requested$/;" m line:53 class:Segment.Analytics
50
- Response lib/segment/analytics/response.rb /^ class Response$/;" c line:3 class:Segment.Analytics
51
- SCREEN spec/spec_helper.rb /^ SCREEN = SCREEN.merge :userId => USER_ID$/;" c line:71
52
- SCREEN spec/spec_helper.rb /^ SCREEN = SCREEN.merge :user_id => USER_ID$/;" c line:49
53
- SCREEN spec/spec_helper.rb /^ SCREEN = {$/;" c line:36
54
- SSL lib/segment/analytics/defaults.rb /^ SSL = true$/;" c line:8
55
- Segment lib/segment/analytics.rb /^module Segment$/;" m line:10
56
- Segment lib/segment/analytics/client.rb /^module Segment$/;" m line:7
57
- Segment lib/segment/analytics/defaults.rb /^module Segment$/;" m line:1
58
- Segment lib/segment/analytics/logging.rb /^module Segment$/;" m line:3
59
- Segment lib/segment/analytics/request.rb /^module Segment$/;" m line:9
60
- Segment lib/segment/analytics/response.rb /^module Segment$/;" m line:1
61
- Segment lib/segment/analytics/utils.rb /^module Segment$/;" m line:3
62
- Segment lib/segment/analytics/version.rb /^module Segment$/;" m line:1
63
- Segment lib/segment/analytics/worker.rb /^module Segment$/;" m line:6
64
- Segment spec/segment/analytics/client_spec.rb /^module Segment$/;" m line:3
65
- Segment spec/segment/analytics/worker_spec.rb /^module Segment$/;" m line:3
66
- Segment spec/segment/analytics_spec.rb /^module Segment$/;" m line:3
67
- Segment spec/spec_helper.rb /^module Segment$/;" m line:3
68
- TRACK spec/spec_helper.rb /^ TRACK = TRACK.merge :user_id => USER_ID$/;" c line:45
69
- TRACK spec/spec_helper.rb /^ TRACK = TRACK.merge({$/;" c line:54
70
- TRACK spec/spec_helper.rb /^ TRACK = {$/;" c line:7
71
- USER_ID spec/spec_helper.rb /^ USER_ID = 1234$/;" c line:40
72
- UTC_OFFSET_WITHOUT_COLON lib/segment/analytics/utils.rb /^ UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.sub(':', '')$/;" c line:82
73
- UTC_OFFSET_WITH_COLON lib/segment/analytics/utils.rb /^ UTC_OFFSET_WITH_COLON = '%s%02d:%02d'$/;" c line:81
74
- Utils lib/segment/analytics/utils.rb /^ module Utils$/;" m line:5 class:Segment.Analytics
75
- VERSION lib/segment/analytics/version.rb /^ VERSION = '2.0.0'$/;" c line:3
76
- WRITE_KEY spec/spec_helper.rb /^ WRITE_KEY = 'testsecret'$/;" c line:5
77
- Worker lib/segment/analytics/worker.rb /^ class Worker$/;" c line:8 class:Segment.Analytics
78
- add_context lib/segment/analytics/client.rb /^ def add_context(context)$/;" f line:277 class:Segment.Analytics.Client
79
- alias lib/segment/analytics/client.rb /^ def alias(options)$/;" f line:119 class:Segment.Analytics.Client
80
- analytics.rb lib/segment/analytics.rb 1;" F line:1
81
- analytics_spec.rb spec/segment/analytics_spec.rb 1;" F line:1
82
- check_non_empty_string! lib/segment/analytics/client.rb /^ def check_non_empty_string!(str, name)$/;" f line:270 class:Segment.Analytics.Client
83
- check_timestamp! lib/segment/analytics/client.rb /^ def check_timestamp!(timestamp)$/;" f line:287 class:Segment.Analytics.Client
84
- check_user_id! lib/segment/analytics/client.rb /^ def check_user_id! options$/;" f line:304 class:Segment.Analytics.Client
85
- check_write_key! lib/segment/analytics/client.rb /^ def check_write_key!$/;" f line:282 class:Segment.Analytics.Client
86
- client.rb lib/segment/analytics/client.rb 1;" F line:1
87
- client_spec.rb spec/segment/analytics/client_spec.rb 1;" F line:1
88
- date_in_iso8601 lib/segment/analytics/utils.rb /^ def date_in_iso8601 date$/;" f line:69 class:Segment.Analytics
89
- datetime_in_iso8601 lib/segment/analytics/utils.rb /^ def datetime_in_iso8601 datetime$/;" f line:51 class:Segment.Analytics.Utils
90
- defaults.rb lib/segment/analytics/defaults.rb 1;" F line:1
91
- enqueue lib/segment/analytics/client.rb /^ def enqueue(action)$/;" f line:255 class:Segment.Analytics.Client
92
- ensure_worker_running lib/segment/analytics/client.rb /^ def ensure_worker_running$/;" f line:308 class:Segment.Analytics.Client
93
- event lib/segment/analytics/client.rb /^ def event attrs$/;" f line:291 class:Segment.Analytics.Client
94
- flush lib/segment/analytics/client.rb /^ def flush$/;" f line:34 class:Segment.Analytics.Client
95
- formatted_offset lib/segment/analytics/utils.rb /^ def formatted_offset time, colon = true, alternate_utc_string = nil$/;" f line:73 class:Segment.Analytics
96
- group lib/segment/analytics/client.rb /^ def group(options)$/;" f line:148 class:Segment.Analytics.Client
97
- identify lib/segment/analytics/client.rb /^ def identify options$/;" f line:87 class:Segment.Analytics.Client
98
- included lib/segment/analytics/logging.rb /^ def self.included base$/;" F line:22 class:Segment
99
- initialize lib/segment/analytics.rb /^ def initialize options = {}$/;" f line:12 class:Segment.Analytics
100
- initialize lib/segment/analytics/client.rb /^ def initialize options = {}$/;" f line:18 class:Segment.Analytics.Client
101
- initialize lib/segment/analytics/request.rb /^ def initialize(options = {})$/;" f line:18 class:Segment.Analytics.Request
102
- initialize lib/segment/analytics/response.rb /^ def initialize(status = 200, error = nil)$/;" f line:9 class:Segment.Analytics.Response
103
- initialize lib/segment/analytics/worker.rb /^ def initialize(queue, write_key, options = {})$/;" f line:23 class:Segment.Analytics.Worker
104
- is_requesting? lib/segment/analytics/worker.rb /^ def is_requesting?$/;" f line:54 class:Segment.Analytics
105
- isoify_dates lib/segment/analytics/utils.rb /^ def isoify_dates(hash)$/;" f line:29 class:Segment.Analytics.Utils
106
- isoify_dates! lib/segment/analytics/utils.rb /^ def isoify_dates!(hash)$/;" f line:38 class:Segment.Analytics.Utils
107
- logger lib/segment/analytics/logging.rb /^ def logger$/;" f line:24 class:Segment.included
108
- logger lib/segment/analytics/logging.rb /^ def logger$/;" f line:7 class:Segment.Analytics.Logging
109
- logger lib/segment/analytics/logging.rb /^ def logger$/;" f line:30
110
- logger= lib/segment/analytics/logging.rb /^ def logger= logger$/;" f line:17 class:Segment.Analytics
111
- logging.rb lib/segment/analytics/logging.rb 1;" F line:1
112
- method_missing lib/segment/analytics.rb /^ def method_missing message, *args, &block$/;" f line:17 class:Segment.Analytics
113
- page lib/segment/analytics/client.rb /^ def page(options)$/;" f line:182 class:Segment.Analytics.Client
114
- post lib/segment/analytics/request.rb /^ def post(write_key, batch)$/;" f line:38 class:Segment.Analytics.Request
115
- queued_messages lib/segment/analytics/client.rb /^ def queued_messages$/;" f line:246 class:Segment.Analytics.Client
116
- request.rb lib/segment/analytics/request.rb 1;" F line:1
117
- respond_to? lib/segment/analytics.rb /^ def respond_to? method_name, include_private = false$/;" f line:25 class:Segment.Analytics
118
- response.rb lib/segment/analytics/response.rb 1;" F line:1
119
- run lib/segment/analytics/worker.rb /^ def run$/;" f line:35 class:Segment.Analytics.Worker
120
- screen lib/segment/analytics/client.rb /^ def screen(options)$/;" f line:216 class:Segment.Analytics.Client
121
- seconds_to_utc_offset lib/segment/analytics/utils.rb /^ def seconds_to_utc_offset(seconds, colon = true)$/;" f line:77 class:Segment.Analytics
122
- segment.rb lib/segment.rb 1;" F line:1
123
- spec_helper.rb spec/spec_helper.rb 1;" F line:1
124
- stringify_keys lib/segment/analytics/utils.rb /^ def stringify_keys(hash)$/;" f line:22 class:Segment.Analytics.Utils
125
- symbolize_keys lib/segment/analytics/utils.rb /^ def symbolize_keys(hash)$/;" f line:10 class:Segment.Analytics.Utils
126
- symbolize_keys! lib/segment/analytics/utils.rb /^ def symbolize_keys!(hash)$/;" f line:16 class:Segment.Analytics.Utils
127
- test.rb test.rb 1;" F line:1
128
- time_in_iso8601 lib/segment/analytics/utils.rb /^ def time_in_iso8601 time, fraction_digits = 0$/;" f line:61 class:Segment.Analytics.Utils
129
- track lib/segment/analytics/client.rb /^ def track options$/;" f line:49 class:Segment.Analytics.Client
130
- uid lib/segment/analytics/utils.rb /^ def uid$/;" f line:44 class:Segment.Analytics.Utils
131
- utils.rb lib/segment/analytics/utils.rb 1;" F line:1
132
- version.rb lib/segment/analytics/version.rb 1;" F line:1
133
- worker.rb lib/segment/analytics/worker.rb 1;" F line:1
134
- worker_running? lib/segment/analytics/client.rb /^ def worker_running?$/;" f line:319 class:Segment.Analytics.Client
135
- worker_spec.rb spec/segment/analytics/worker_spec.rb 1;" F line:1