ga_events 1.3.1 → 1.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f618bcb8b6143f0b27f0635ba07f7a03bf43314
4
- data.tar.gz: 243dbd6ab50485f12ef605804645f31a216b57c7
3
+ metadata.gz: e1146cf9971d12382e0aa793841cd4dd0cd76470
4
+ data.tar.gz: ff69c78fb46afe03a40685cf8f002c82161a3e27
5
5
  SHA512:
6
- metadata.gz: 5f6d47efb06212449d9c5d73ef7b7a9dd7fc159ec96083791e161bccfba041e153442b3eef6d9c4cf785bf60a1d465e740b78158e4a2e14ed360ff8f07c8d65d
7
- data.tar.gz: 72d65902c21450bcb1f6e2220d7d01680a3c1745bfdd38d57785831a5c93d8bc07536082a630b2d7f45049ad1a791cb27ca9699261df1afe2931b0bd2d1c0baa
6
+ metadata.gz: b30b861e9b436375c7615d3f3b1aee65163a38236943eaa71482fa1ff6a6ead43929bc8e50ee91532006344995d7809122e4737e0f900e46254583b20aef5049
7
+ data.tar.gz: 09e3a8b9a027f6cdeda57a5184a6d9b214edba3649bcdc6e666bf24f36d49d51b223a7c523234d47eb3b7c9a853ca77c4f92cbbdd42d54fc536430fe0a7b950d
data/.rubocop.yml ADDED
@@ -0,0 +1,40 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.2
3
+ Exclude:
4
+ - 'vendor/bundle/**/*'
5
+ DisplayCopNames: true
6
+ Rails:
7
+ Enabled: true
8
+ Style/Encoding:
9
+ EnforcedStyle: when_needed
10
+ Enabled: true
11
+ Style/AsciiComments:
12
+ Enabled: false
13
+ Style/Documentation:
14
+ Enabled: false
15
+ Metrics/MethodLength:
16
+ Enabled: false
17
+ Style/MethodDefParentheses:
18
+ Enabled: false
19
+ Style/MultilineOperationIndentation:
20
+ EnforcedStyle: aligned
21
+ Style/MultilineMethodCallIndentation:
22
+ EnforcedStyle: indented
23
+ Style/MultilineMethodDefinitionBraceLayout:
24
+ Enabled: true
25
+ Style/MultilineHashBraceLayout:
26
+ Enabled: true
27
+ Style/SignalException:
28
+ Enabled: false
29
+ Metrics/ClassLength:
30
+ Enabled: false
31
+ Lint/AssignmentInCondition:
32
+ Enabled: false
33
+ Metrics/ParameterLists:
34
+ Enabled: false
35
+ Style/MultilineBlockChain:
36
+ Enabled: false
37
+ Style/CommentAnnotation:
38
+ Enabled: false
39
+ Style/GuardClause:
40
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -25,3 +25,11 @@ The format suggested at http://keepachangelog.com/ is used.
25
25
 
26
26
  ### Added
27
27
  - Support for turbolinks.
28
+
29
+ ## 1.4.0 - 2018-03-09
30
+
31
+ ### Fixed
32
+ - Fixed turbolinks events. To prevent older events the be processed again after page
33
+ changes orchestrated by turbolinks, events are no longer processed via the
34
+ injected DOM node. (Because the node would be cached and the event already
35
+ processed.) Instead the the header-strategy is being used.
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in ga_events.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'pry'
6
7
  gem 'rake'
7
8
  gem 'rspec', '~> 3.1.0'
8
- gem 'pry'
9
+ gem 'rubocop', '~> 0.39.0', require: false
@@ -50,12 +50,17 @@ class GaEvents.Event
50
50
  @may_flush = true
51
51
  @flush()
52
52
 
53
- $(document).ajaxComplete (event, xhr) =>
53
+ process_xhr = (xhr) =>
54
54
  xhr_events = xhr.getResponseHeader @header_key
55
55
  @from_string xhr_events if xhr_events?
56
56
 
57
+ $(document).ajaxComplete((_, xhr) -> process_xhr(xhr))
58
+ $(document).on "turbolinks:request-end", (event) ->
59
+ xhr = event.originalEvent.data.xhr
60
+ process_xhr(xhr)
61
+
57
62
  @from_dom()
58
- $(document).on "turbolinks:load", => @from_dom()
63
+
59
64
 
60
65
  class GaEvents.GoogleTagManagerAdapter
61
66
  constructor: (@event = "ga_event") ->
data/ga_events.gemspec CHANGED
@@ -19,8 +19,8 @@ Gem::Specification.new do |gem|
19
19
  gem.homepage = 'https://github.com/Nix-wie-weg/ga_events'
20
20
 
21
21
  gem.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
22
- gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
23
- gem.test_files = gem.files.grep(/^(test|spec|features)\//)
22
+ gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
23
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
24
  gem.name = 'ga_events'
25
25
  gem.require_paths = ['lib']
26
26
  gem.version = GaEvents::VERSION
@@ -1,5 +1,5 @@
1
1
  module GaEvents
2
- class Event < Struct.new(:category, :action, :label, :value)
2
+ Event = Struct.new(:category, :action, :label, :value) do
3
3
  # Default values are set here, see README.md for details.
4
4
  def initialize(category = '-', action = '-', label = '-', value = 1)
5
5
  super
@@ -16,11 +16,11 @@ module GaEvents
16
16
 
17
17
  # Can outgrow, headers might get too big
18
18
  serialized = GaEvents::List.to_s
19
- if request.xhr?
19
+ if xhr_or_turbolinks?(request)
20
20
  # AJAX request
21
21
  headers['X-GA-Events'] = serialized
22
22
 
23
- elsif (300..399).include?(status)
23
+ elsif redirect?(status)
24
24
  # 30x/redirect? Then add event list to flash to survive the redirect.
25
25
  add_events_to_flash(env, serialized)
26
26
 
@@ -74,5 +74,13 @@ module GaEvents
74
74
  headers.key?('Content-Type') &&
75
75
  headers['Content-Type'].include?('text/html')
76
76
  end
77
+
78
+ def redirect?(status)
79
+ (300..399).cover?(status)
80
+ end
81
+
82
+ def xhr_or_turbolinks?(request)
83
+ request.xhr? || request.env['HTTP_TURBOLINKS_REFERRER']
84
+ end
77
85
  end
78
86
  end
@@ -1,3 +1,3 @@
1
1
  module GaEvents
2
- VERSION = '1.3.1'
2
+ VERSION = '1.4.0'.freeze
3
3
  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: 1.3.1
4
+ version: 1.4.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: 2018-03-01 00:00:00.000000000 Z
12
+ date: 2018-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -34,6 +34,7 @@ extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
36
  - ".gitignore"
37
+ - ".rubocop.yml"
37
38
  - CHANGELOG.md
38
39
  - Gemfile
39
40
  - LICENSE
@@ -69,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
70
  version: '0'
70
71
  requirements: []
71
72
  rubyforge_project:
72
- rubygems_version: 2.5.2
73
+ rubygems_version: 2.4.5.1
73
74
  signing_key:
74
75
  specification_version: 4
75
76
  summary: This gem allows you to annotate events everywhere in the code of your Rails