ab_panel 0.1.1 → 0.1.2

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: 67ea749f4f2e80710669492d90f163ace7311dd0
4
- data.tar.gz: e6f8ffea1418b0c80754c011160a09accaeb8a3e
3
+ metadata.gz: 144fbca692f2d9614fadb10c5c45553461634bd4
4
+ data.tar.gz: b530647a28d261a8166fccf482a993f860de7e52
5
5
  SHA512:
6
- metadata.gz: ec2cffaf2212c588187af99829e85450cb82396229fa9cdeaa40d8c0b467b8f98068206b1720ed927ae48d7950a328c351161f2cce61f320e22dd63478a1fb2a
7
- data.tar.gz: 351f325f654bd72fd5993cff00ea767873f7ba211091a4e718243a1fc7c7a66942477c5cc5b5b66bfa193b9133d8647dbad73a5ebfb4b5b1bbf0b1b8bc5701f1
6
+ metadata.gz: 23054af6d145e67ddddc1a07948d58e9a5b1036e75ee48c8a63c08621f7ffb81ed2ad9aa7c600e5f2bbfa5b80f7f83b696aa2cfc7c0eb04c8e50da51e2253888
7
+ data.tar.gz: 6f4d8f61cb18b5843d3dc3effbceeff712cc389a68f493822823ca34a048916afff1e3d8e13c33c7bf6535bb9364a9e0ec60ec1e6824dbd4ba79ea5ca48b8f3c
@@ -11,12 +11,12 @@ class PostsController < ApplicationController
11
11
  def show
12
12
  @post = Post.find(params[:id])
13
13
 
14
+ track_action '[visits] post', post_id: @post.id
15
+
14
16
  respond_to do |format|
15
17
  format.html
16
18
  format.json { render json: @post }
17
19
  end
18
-
19
- track_action '[visits] post', :post => :id
20
20
  end
21
21
 
22
22
  def new
@@ -69,4 +69,11 @@ class PostsController < ApplicationController
69
69
  format.json { head :no_content }
70
70
  end
71
71
  end
72
+
73
+ # Useful for testing if every event gets tracked when using persist: true.
74
+ def redirect
75
+ @post = Post.find(params[:id])
76
+ track_action '[redirects] post', post_id: @post.id
77
+ redirect_to @post
78
+ end
72
79
  end
@@ -1,5 +1,7 @@
1
1
  Example::Application.routes.draw do
2
- resources :posts
2
+ resources :posts do
3
+ get :redirect, on: :member
4
+ end
3
5
 
4
6
  # The priority is based upon order of creation:
5
7
  # first created -> highest priority.
@@ -55,7 +55,7 @@ module AbPanel
55
55
 
56
56
  {
57
57
  'distinct_id' => distinct_id,
58
- 'rack.session' => request['rack.session'],
58
+ 'rack.session' => request.env['rack.session'],
59
59
  'ip' => request.remote_ip
60
60
  }.each do |key, value|
61
61
  AbPanel.set_env(key, value)
@@ -70,13 +70,11 @@ module AbPanel
70
70
  # Example:
71
71
  #
72
72
  # def show
73
- # track_action '[visits] Course', { :course => :id }
73
+ # track_action '[visits] Course', { :course_id => @course.id }
74
74
  # end
75
75
  #
76
76
  # This will track the event with the given name on CoursesController#show
77
- # and assign an options hash:
78
- #
79
- # { 'course_id' => @course.id }
77
+ # with the passed in attributes.
80
78
  def track_action(name, properties = {})
81
79
  AbPanel.add_funnel(properties.delete(:funnel))
82
80
 
@@ -84,7 +82,7 @@ module AbPanel
84
82
  distinct_id: distinct_id,
85
83
  ip: request.remote_ip,
86
84
  time: Time.now.utc,
87
- }
85
+ }.merge(properties)
88
86
 
89
87
  AbPanel.funnels.each do |funnel|
90
88
  options["funnel_#{funnel}"] = true
@@ -94,27 +92,11 @@ module AbPanel
94
92
  options[exp] = AbPanel.conditions.send(exp).condition rescue nil
95
93
  end
96
94
 
97
- properties.each do |key, val|
98
- if respond_to?(key)
99
- inst = send(key)
100
- elsif instance_variable_defined?("@#{key}")
101
- inst = instance_variable_get("@#{key}")
102
- else
103
- options[key] = val
104
- next
105
- end
106
-
107
- val = *val
108
-
109
- val.each do |m|
110
- options["#{key}_#{m}"] = inst.send(m)
111
- end
112
- end
95
+ options.merge!(ab_panel_options)
96
+ AbPanel.set_env(:properties, options)
113
97
 
114
98
  AbPanel.identify(distinct_id)
115
99
  AbPanel.track(name, options.merge(ab_panel_options))
116
-
117
- session['mixpanel_events'] ||= AbPanel.env['rack.session']['mixpanel_events'] rescue []
118
100
  end
119
101
  end
120
102
  end
@@ -1,11 +1,14 @@
1
1
  module AbPanel
2
2
  class Javascript
3
3
  def self.environment
4
- props = { distinct_id: AbPanel.env["distinct_id"] }
4
+ props = {
5
+ distinct_id: AbPanel.env["distinct_id"]
6
+ }.merge(AbPanel.env[:properties])
5
7
 
6
8
  AbPanel.funnels.each { |f| props["funnel_#{f}"] = true }
7
9
 
8
10
  AbPanel.experiments.each { |exp| props[exp] = AbPanel.conditions.send(exp).condition }
11
+
9
12
  props.to_json
10
13
  end
11
14
  end
@@ -1,3 +1,3 @@
1
1
  module AbPanel
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ab_panel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter de Vos
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-18 00:00:00.000000000 Z
12
+ date: 2013-11-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler