ga_events 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +40 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +2 -1
- data/app/assets/javascripts/ga_events.js.coffee +7 -2
- data/ga_events.gemspec +2 -2
- data/lib/ga_events/event.rb +1 -1
- data/lib/ga_events/middleware.rb +10 -2
- data/lib/ga_events/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1146cf9971d12382e0aa793841cd4dd0cd76470
|
4
|
+
data.tar.gz: ff69c78fb46afe03a40685cf8f002c82161a3e27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -50,12 +50,17 @@ class GaEvents.Event
|
|
50
50
|
@may_flush = true
|
51
51
|
@flush()
|
52
52
|
|
53
|
-
|
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
|
-
|
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(
|
23
|
-
gem.test_files = gem.files.grep(
|
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
|
data/lib/ga_events/event.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module GaEvents
|
2
|
-
|
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
|
data/lib/ga_events/middleware.rb
CHANGED
@@ -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
|
19
|
+
if xhr_or_turbolinks?(request)
|
20
20
|
# AJAX request
|
21
21
|
headers['X-GA-Events'] = serialized
|
22
22
|
|
23
|
-
elsif
|
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
|
data/lib/ga_events/version.rb
CHANGED
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.
|
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-
|
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.
|
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
|