ga_events 2.0.0 → 2.1.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
  SHA256:
3
- metadata.gz: 8733925b29ae71da3da081d25679727857f92ee7bcb5390c72b97a87fc3c9b53
4
- data.tar.gz: 67d86fd9ea6ced7564d851b40faa957d2138a92977a5d3197a2a6f7bdcdd7068
3
+ metadata.gz: 205433864fd2efabf0cf787da0be314c9bc48fd644773d8df29f6ca66327ba43
4
+ data.tar.gz: fa05cd8ee83f4b73fa23a3562e19d0ec2fcbb1a684c7ee49c357d0e78a54c3a7
5
5
  SHA512:
6
- metadata.gz: 0ffaa24b43857c82f369e98861b82ddd99dca42bc88b97148d4a055210e0ed76b2f82961932e83e03b76264e091a7e698577b07a69cb2efef6d40b92616965c0
7
- data.tar.gz: 59e2857a160797e12bfec180e10aadae8f66633e303cb9c41e739a77669ee03f2b13c22faea9f10df263e1d43f2eef172f6c5d03cbca90b7a9944597c8390a77
6
+ metadata.gz: 472515474d12c53c4f3d43b8c577a45776ed983149c8347940294ca1128e907d101f48054eee7c00468cafdc3f1e7aba33c3cdfa08f43d81ebc0bd25c91f884f
7
+ data.tar.gz: 483bbdb595f20e852ec8f6b74366251e91e84b76cde7454721136d42cfd31586e36c88bd015ac6cbf321a673e2779e5f29b96cb345924d7606f648e36da67aa9
data/README.md CHANGED
@@ -70,6 +70,15 @@ GaEvents.Event.adapter = function() {
70
70
  }
71
71
  ```
72
72
 
73
+ ### Optional consent settings
74
+
75
+ Events are flushed immediatly by default. If you need to wait for user consent
76
+ you can set `GaEvents.Event.require_user_consent = true`.
77
+
78
+ With `require_user_consent` enabled all events are buffered until
79
+ `GaEvents.Event.user_consent_given = true` is set. Events are flushed as soon
80
+ as `GaEvents.Event.flush()` is called.
81
+
73
82
  ### Testing
74
83
 
75
84
  For your testing pleasure we included `NullAdapter`.
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
-
5
- task default: :spec
@@ -9,6 +9,8 @@ class GaEvents.Event
9
9
  @may_flush: false
10
10
  @header_key: "X-GA-Events"
11
11
  @html_key: "ga-events"
12
+ @require_user_consent: false
13
+ @user_consent_given: false
12
14
  klass: @
13
15
 
14
16
  # Decompose a event-string (ruby side) into an event object.
@@ -23,6 +25,8 @@ class GaEvents.Event
23
25
 
24
26
  # Events should not be send to an adapter unless the DOM has finished loading.
25
27
  @flush: ->
28
+ return if @require_user_consent && !@user_consent_given
29
+
26
30
  if @list.length > 0 and @may_flush
27
31
  $.map @list, (event) -> event.push_to_adapter()
28
32
  @list = []
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GaEvents
4
- VERSION = '2.0.0'
4
+ VERSION = '2.1.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ga_events
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Dütsch
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-11-20 00:00:00.000000000 Z
12
+ date: 2021-09-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails