analytics_instrumentation 0.2.2 → 0.2.3

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: 77f50f177067a9a299d72ebb7f3423b5537f0a13
4
- data.tar.gz: 94ef87789279dfb43eea6f224a56885537b02b1e
3
+ metadata.gz: a49cdda4f334338025192fb0f21028076c244f56
4
+ data.tar.gz: b3fa86e90b125b0a6247a2e727ac98698cc668ac
5
5
  SHA512:
6
- metadata.gz: 5ed2496fee2ab1a172547d99a4e8582dc0bb704db07f72a38045b400e91cc223e275f127838242d021247647c611c683f5a1a2c1736133bd4c8a1c95c3473fa8
7
- data.tar.gz: 024a8c1dc51295ab2ffdea5a51ca372c8b6ceb8cc4ade3b584650c2502f776fb5c03cdf804bad3a7ec16672a520295857ff7773311513abfb56874b194d587d2
6
+ metadata.gz: 3d8b4cfa3059750962ec84826706893acf11a487e144a32795c55ef482573f24c1d8c4d7bcbadc66358db9681f90e199ba88c01f35e0a623a8458af79a28f11a
7
+ data.tar.gz: 49a44cc033c37a32fc508e69c2a5e165657c0a905a6a32fae031568a02d8cecf1b2b83a6a5d048c222e40f2285479b4831a4c442803cb07de0a61484832645ff
@@ -33,6 +33,9 @@ The behaviors exposed are:
33
33
  # Your Segment.io write key is required. We will instantiate the client.
34
34
  config.segment_write_key = ENV["SEGMENT_API_KEY"] || ""
35
35
 
36
+ # # Track "Page View" events for ajax requests? (Default = false)
37
+ # config.track_ajax_as_page_view = true
38
+
36
39
  # Define a hash of traits to be passed to `#identify()` calls for each user.
37
40
  config.custom_user_traits = Proc.new { |user|
38
41
  {
@@ -71,7 +71,6 @@ module AnalyticsInstrumentation
71
71
  if current_user
72
72
  analyticsSetPerson(current_user)
73
73
  end
74
- add_attribution page_view_event[:parameters]
75
74
  analyticsTrackEvent page_view_event[:name], page_view_event[:parameters]
76
75
  analyticsStoreOriginatingPage page_view_event
77
76
  end
@@ -79,8 +78,10 @@ module AnalyticsInstrumentation
79
78
  properties = {
80
79
  page: request.path
81
80
  }
82
- properties.merge! analyticsSuperProperties
83
- analyticsTrackEvent "Page View", properties
81
+
82
+ track_page_view = request.xhr? ? @@config.track_ajax_as_page_view : true
83
+
84
+ analyticsTrackEvent("Page View", properties) if track_page_view
84
85
  rescue => e
85
86
  logger.debug "Errpr found in analyticsLogPageView: #{e.inspect}"
86
87
  @@config.error_handler.call(e, "Analytics Crash: #{request.filtered_path}")
@@ -152,6 +153,7 @@ module AnalyticsInstrumentation
152
153
  properties["source"] = params[:source] if params[:source]
153
154
 
154
155
  properties.merge! analyticsSuperProperties
156
+ add_attribution properties
155
157
 
156
158
  # User defined extra props, called in context
157
159
  extra_props = instance_exec(&@@config.extra_event_properties)
@@ -8,6 +8,7 @@ module AnalyticsInstrumentation
8
8
  attr_accessor :custom_user_traits
9
9
  attr_accessor :error_handler
10
10
  attr_accessor :segment_write_key
11
+ attr_accessor :track_ajax_as_page_view
11
12
 
12
13
  validates_presence_of :segment_write_key
13
14
 
@@ -26,9 +27,10 @@ module AnalyticsInstrumentation
26
27
  end
27
28
 
28
29
  def initialize
29
- self.extra_event_properties = Proc.new {}
30
- self.custom_user_traits = Proc.new {}
31
- self.error_handler = Proc.new { |e, msg=""| raise }
30
+ self.extra_event_properties = Proc.new {}
31
+ self.custom_user_traits = Proc.new {}
32
+ self.error_handler = Proc.new { |e, msg=""| raise }
33
+ self.track_ajax_as_page_view = false
32
34
  end
33
35
 
34
36
  def intercom?
@@ -1,3 +1,3 @@
1
1
  module AnalyticsInstrumentation
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics_instrumentation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Feldstein
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-05 00:00:00.000000000 Z
12
+ date: 2015-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails