meta_events 1.0.1 → 1.0.2

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
- ---
2
- SHA1:
3
- metadata.gz: 17804195b940669ecc8da4161a1f15c0027e8a61
4
- data.tar.gz: 1c8769fcc9213b3314429b982b3e039dd48a2e19
5
- SHA512:
6
- metadata.gz: 403256b58246ab75b6f935d2e3379a88b175730340c1dd9ba9fb26cae13ac0e6dd0ede0946675523ec154f8b912da898e7eb7280381a6f34c05df20845caed5b
7
- data.tar.gz: 947da714267904239fb3bc510ded6ad3b8c528a4266b99c2d8db34eb5ef0a9d8fafd768f2ba090955427ffcc0b15383484d35e506a1bda0efc0d8a02c5bd4e11
1
+ ---
2
+ SHA1:
3
+ data.tar.gz: 463ed55b0baf280ad2558b526c2d06cd78dc5ef8
4
+ metadata.gz: 4883769055fc1db0206a278ba5dc382cb2c711e3
5
+ SHA512:
6
+ data.tar.gz: 9dbe5bd43bf131c893c5b799afe3838775018a7dbcb8d349214ca8c126adc78ac9befcd428cfe068d708ae146dde01b5b32e26de4605bfaadeb34a2baa33cc08
7
+ metadata.gz: cff9954c133137b9fa77cecec136029a0e39b76decbf17c7bc60f82189c8c67ebc8ccf0135c0faac8a4737c20a89f20feda4f4d45f74e55dbc8445b0af03735d
data/README.md CHANGED
@@ -558,6 +558,11 @@ Patches are welcome. ;-)
558
558
 
559
559
  ### Times
560
560
 
561
+ MetaEvents automatically adds a `time` property to any event you fire via `#event!`; this is so that you can take the
562
+ set of properties in a receiver and make it asynchronous, and don't have to worry about getting the time right. You
563
+ can override this, however, by simply passing a `:time` property with your event; it will override any time we would
564
+ otherwise set. (You can even set `:time => nil` if you want to make sure no time is passed at all.)
565
+
561
566
  MetaEvents correctly converts any `Time` object you pass into the correct String format for Mixpanel (_e.g._,
562
567
  `2014-02-03T15:49:17`), converting it to UTC first. This should make your times much cleaner.
563
568
 
@@ -343,6 +343,7 @@ module MetaEvents
343
343
  # class.
344
344
  def event!(category_name, event_name, additional_properties = { })
345
345
  event_data = effective_properties(category_name, event_name, additional_properties)
346
+ event_data[:properties] = { 'time' => Time.now.to_i }.merge(event_data[:properties])
346
347
 
347
348
  self.event_receivers.each do |receiver|
348
349
  receiver.track(event_data[:distinct_id], event_data[:event_name], event_data[:properties])
@@ -1,3 +1,3 @@
1
1
  module MetaEvents
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -66,7 +66,20 @@ describe MetaEvents::Tracker do
66
66
  next_event = calls.shift
67
67
  expect(next_event[0]).to eq(expected_distinct_id)
68
68
  expect(next_event[1]).to eq(event_name)
69
- expect(next_event[2]).to eq(event_properties)
69
+ actual_properties = next_event[2]
70
+
71
+ filtered_actual_properties = actual_properties.dup
72
+
73
+ # handle automatic properties that we may not want to care about every time
74
+ %w{ip time}.each do |automatic_property_name|
75
+ if ! event_properties.has_key?(automatic_property_name)
76
+ filtered_actual_properties.delete(automatic_property_name)
77
+ end
78
+ end
79
+
80
+ expect(filtered_actual_properties).to eq(event_properties)
81
+
82
+ actual_properties
70
83
  end
71
84
 
72
85
  def tep_object(props)
@@ -148,13 +161,40 @@ EOS
148
161
  end
149
162
  end
150
163
 
151
- describe "#track_event" do
164
+ describe "#event!" do
152
165
  it "should allow firing a valid event" do
153
166
  i = new_instance(@distinct_id, nil, :definitions => definition_set, :version => 1)
154
167
  i.event!(:foo, :bar, { })
155
168
  expect_event('xy1_foo_bar', { })
156
169
  end
157
170
 
171
+ describe "time support" do
172
+ it "should add the time to the event" do
173
+ start_time = Time.now.to_i
174
+ i = new_instance(@distinct_id, nil, :definitions => definition_set, :version => 1)
175
+ i.event!(:foo, :bar, { })
176
+ end_time = Time.now.to_i
177
+ actual_properties = expect_event('xy1_foo_bar', { })
178
+ time = actual_properties['time']
179
+ expect(time).to be >= start_time
180
+ expect(time).to be >= end_time
181
+ end
182
+
183
+ it "should allow overriding the time" do
184
+ actual_time = Time.now.to_i - 500
185
+ i = new_instance(@distinct_id, nil, :definitions => definition_set, :version => 1)
186
+ i.event!(:foo, :bar, { :time => actual_time })
187
+ expect_event('xy1_foo_bar', { 'time' => actual_time })
188
+ end
189
+
190
+ it "should allow omitting the time" do
191
+ actual_time = Time.now.to_i - 500
192
+ i = new_instance(@distinct_id, nil, :definitions => definition_set, :version => 1)
193
+ i.event!(:foo, :bar, { :time => nil })
194
+ expect_event('xy1_foo_bar', { 'time' => nil })
195
+ end
196
+ end
197
+
158
198
  describe "ip-address passing" do
159
199
  it "should pass through an IPv4 String IP" do
160
200
  i = new_instance(@distinct_id, "138.93.206.193", :definitions => definition_set, :version => 1)
metadata CHANGED
@@ -1,98 +1,80 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: meta_events
3
- version: !ruby/object:Gem::Version
4
- version: 1.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Andrew Geweke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-15 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
11
+
12
+ date: 2014-02-18 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
14
15
  name: json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :runtime
21
16
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
24
19
  - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: activesupport
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '3.0'
34
- - - <=
35
- - !ruby/object:Gem::Version
36
- version: 4.99.99
20
+ - !ruby/object:Gem::Version
21
+ version: "1.0"
37
22
  type: :runtime
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: activesupport
38
26
  prerelease: false
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - '>='
42
- - !ruby/object:Gem::Version
43
- version: '3.0'
44
- - - <=
45
- - !ruby/object:Gem::Version
46
- version: 4.99.99
47
- - !ruby/object:Gem::Dependency
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "3.0"
32
+ - - <
33
+ - !ruby/object:Gem::Version
34
+ version: "4.0"
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ - !ruby/object:Gem::Dependency
48
38
  name: bundler
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '1.5'
54
- type: :development
55
39
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ requirements:
58
42
  - - ~>
59
- - !ruby/object:Gem::Version
60
- version: '1.5'
61
- - !ruby/object:Gem::Dependency
62
- name: rake
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - '>='
66
- - !ruby/object:Gem::Version
67
- version: '0'
43
+ - !ruby/object:Gem::Version
44
+ version: "1.5"
68
45
  type: :development
46
+ version_requirements: *id003
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
69
49
  prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - '>='
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- - !ruby/object:Gem::Dependency
76
- name: rspec
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ~>
80
- - !ruby/object:Gem::Version
81
- version: '2.14'
50
+ requirement: &id004 !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - &id006
53
+ - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
82
56
  type: :development
57
+ version_requirements: *id004
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
83
60
  prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
61
+ requirement: &id005 !ruby/object:Gem::Requirement
62
+ requirements:
86
63
  - - ~>
87
- - !ruby/object:Gem::Version
88
- version: '2.14'
64
+ - !ruby/object:Gem::Version
65
+ version: "2.14"
66
+ type: :development
67
+ version_requirements: *id005
89
68
  description:
90
- email:
69
+ email:
91
70
  - ageweke@swiftype.com
92
71
  executables: []
72
+
93
73
  extensions: []
74
+
94
75
  extra_rdoc_files: []
95
- files:
76
+
77
+ files:
96
78
  - .gitignore
97
79
  - .travis.yml
98
80
  - Gemfile
@@ -120,35 +102,32 @@ files:
120
102
  - spec/meta_events/tracker_spec.rb
121
103
  - vendor/assets/javascripts/meta_events.js.erb
122
104
  homepage: http://www.github.com/swiftype/meta_events
123
- licenses:
105
+ licenses:
124
106
  - MIT
125
107
  metadata: {}
108
+
126
109
  post_install_message:
127
110
  rdoc_options: []
128
- require_paths:
111
+
112
+ require_paths:
129
113
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - '>='
133
- - !ruby/object:Gem::Version
134
- version: '0'
135
- required_rubygems_version: !ruby/object:Gem::Requirement
136
- requirements:
137
- - - '>='
138
- - !ruby/object:Gem::Version
139
- version: '0'
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - *id006
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - *id006
140
120
  requirements: []
121
+
141
122
  rubyforge_project:
142
- rubygems_version: 2.2.1
123
+ rubygems_version: 2.0.14
143
124
  signing_key:
144
125
  specification_version: 4
145
- summary: Structured, documented, powerful event emitting library for Mixpanel and
146
- other such systems.
147
- test_files:
126
+ summary: Structured, documented, powerful event emitting library for Mixpanel and other such systems.
127
+ test_files:
148
128
  - spec/meta_events/controller_methods_and_helpers_spec.rb
149
129
  - spec/meta_events/definition/category_spec.rb
150
130
  - spec/meta_events/definition/definition_set_spec.rb
151
131
  - spec/meta_events/definition/event_spec.rb
152
132
  - spec/meta_events/definition/version_spec.rb
153
133
  - spec/meta_events/tracker_spec.rb
154
- has_rdoc: