woopra_track 0.1.2 → 0.1.3

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: d0ec5bbcdfb259b824ad0450c7215c9449331b8a
4
- data.tar.gz: f1bcdd1c44d0d42fd15c6416caaa48cffa69ccad
3
+ metadata.gz: 5cd80a9b897128d3188fc214d56920b0f6f6e71a
4
+ data.tar.gz: eb6b0184dd4c0f383473317738fe82cee005d0ce
5
5
  SHA512:
6
- metadata.gz: 76db189c30fabc451bfbd37154576b88eefca920665abb23f95b85483cd7a37d217ca5b230e67aabb2244f3f3d974640c0d3a4c872d600b059c3dbcfdeb276b1
7
- data.tar.gz: 8583505c7b2891ddc8adbe6a3ea244cd18965a961dadc400b383f69411d6d06868659aa24526e62a85b1db9525a11b2447ca66171558c3f8ea090eb54013fe0b
6
+ metadata.gz: e37c7cac2c3225ca71a0e1544477c1eef7bac2bdf961e4c7a09825d63284f4c076c8b4babc209ec8f9fe58b80978f6dc0e8c51ac37e6894586dc718567a20ed2
7
+ data.tar.gz: c4c94bd8732f547324f213e0cdf382ccecfbb26d3c4ae9542ec074fc985ebe550ffb21d51c60038626ef1897805ad27b87a9f6efb268db132e21d8f312b057db
data/README.md CHANGED
@@ -154,12 +154,18 @@ woopra(request, config, cookies)
154
154
  @woopra.set_cookie(cookies)
155
155
  ```
156
156
 
157
- Finally, if you want to enable logging for back-end tracking requests, just call `enable_logging`:
157
+ If you want to enable logging for back-end tracking requests, just call `enable_logging`:
158
158
 
159
159
  ``` ruby
160
160
  @woopra.enable_logging
161
161
  ```
162
162
 
163
+ You can also disable tracking globally, by setting `disable_tracking` to `true` in the config hash.
164
+
165
+ ``` ruby
166
+ config = { domain: 'website.com', idle_timeout: 15000, disable_tracking: true }
167
+ ```
168
+
163
169
  ## Development
164
170
 
165
171
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -21,6 +21,7 @@ module WoopraTrack
21
21
  hide_campaign: false,
22
22
  ip_address: nil,
23
23
  cookie_value: nil,
24
+ disable_tracking: false
24
25
  }
25
26
 
26
27
  def initialize(request)
@@ -88,6 +89,8 @@ module WoopraTrack
88
89
  end
89
90
 
90
91
  def javascript_tag
92
+ return if disable_tracking?
93
+
91
94
  code = ['(function(){var t,i,e,n=window,o=document,a=arguments,s="script",r=["config","track","trackForm","trackClick","identify","visit","push","call"],c=function(){var t,i=this;for(i._e=[],t=0;r.length>t;t++)(function(t){i[t]=function(){return i._e.push([t].concat(Array.prototype.slice.call(arguments,0))),i}})(r[t])};for(n._w=n._w||{},t=0;a.length>t;t++)n._w[a[t]]=n[a[t]]=n[a[t]]||new c;i=o.createElement(s),i.async=1,i.src="//static.woopra.com/js/w.js",e=o.getElementsByTagName(s)[0],e.parentNode.insertBefore(i,e)})("woopra");']
92
95
 
93
96
  code << "woopra.config(#{@custom_config.to_json});" if @custom_config.length != 0
@@ -107,12 +110,15 @@ module WoopraTrack
107
110
  end
108
111
 
109
112
  def set_cookie(cookies)
113
+ return if disable_tracking?
110
114
  cookies[@current_config[:cookie_name]] = @current_config[:cookie_value]
111
115
  end
112
116
 
113
117
  private
114
118
 
115
119
  def http_request(event=nil)
120
+ return if disable_tracking?
121
+
116
122
  request_url = 'https://www.woopra.com'
117
123
  get_params = {
118
124
  host: @current_config[:domain],
@@ -168,5 +174,9 @@ module WoopraTrack
168
174
  @request.remote_ip
169
175
  end
170
176
  end
177
+
178
+ def disable_tracking?
179
+ @current_config[:disable_tracking].is_a? TrueClass
180
+ end
171
181
  end
172
182
  end
@@ -1,3 +1,3 @@
1
1
  module WoopraTrack
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woopra_track
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonian Guveli
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-14 00:00:00.000000000 Z
11
+ date: 2017-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubyforge_project:
104
- rubygems_version: 2.6.11
104
+ rubygems_version: 2.6.13
105
105
  signing_key:
106
106
  specification_version: 4
107
107
  summary: Tracking library for woopra.com