facebook_app 0.0.19 → 0.0.20

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.
@@ -0,0 +1,24 @@
1
+ track = (conversion_state) ->
2
+ $.post('/trackings', {conversion_state: conversion_state})
3
+
4
+ window.removeAppPermissions = () ->
5
+ FB.api("/me/permissions", "delete", {}, () -> alert("Removed App Permission From Facebook"))
6
+
7
+ window.facebookLogin = (redirectUrl, permissions) ->
8
+ FB.getLoginStatus (status) ->
9
+ if status.authResponse
10
+ console.log "User already logged in"
11
+ window.location = redirectUrl
12
+ else
13
+ console.log "User isn't logged in. Trying to log in now"
14
+ FB.login (response) ->
15
+ # track("see_permissions_dialogue")
16
+ if response.authResponse # user has logged in
17
+ track("accept_permissions")
18
+ console.log "User accepted permissions"
19
+ window.location = redirectUrl
20
+ else
21
+ track("deny_permissions")
22
+ console.log "User denied permissions"
23
+ , {scope: permissions}
24
+
@@ -10,4 +10,7 @@
10
10
  margin-bottom: 6px
11
11
  li.total
12
12
  font-weight: bold
13
-
13
+ h4.title
14
+ font-weight: bold
15
+ margin-top: 20px
16
+
@@ -32,18 +32,6 @@ module FacebookApp
32
32
  end
33
33
  end
34
34
 
35
- def begin_tracking
36
- conversion = Conversion.find_or_create(cookies[:conversion_id],params[:marketing_mode])
37
- cookies[:conversion_id] = conversion.id
38
- end
39
-
40
- def track_conversion(conversion_state)
41
- Rails.logger.debug "Attempting to track #{conversion_state}"
42
- Conversion.track(cookies[:conversion_id], conversion_state)
43
- rescue
44
-
45
- end
46
-
47
35
  # loads the graph from the users point of view
48
36
  def load_graph
49
37
  @graph ||= Koala::Facebook::API.new(session[:at])
@@ -0,0 +1,6 @@
1
+ class FacebookSdkController < ApplicationController
2
+
3
+ def channel
4
+
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ module FacebookApp
2
+ class TrackingsController < FacebookAppController
3
+ include TrackingHelper
4
+
5
+ def create
6
+ track_conversion(params[:conversion_state])
7
+ render :nothing => true, :status => 200
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,63 @@
1
+ module FacebookApp
2
+ module FacebookSdkHelper
3
+
4
+ def add_facebook_sdk
5
+ %Q{
6
+ <div id="fb-root"></div>
7
+ <script>
8
+ window.fbAsyncInit = function() {
9
+ FB.init({
10
+ appId : '#{FacebookApp::FacebookCredentials.app_id}',
11
+ channelURL : '#{facebook_app.facebook_channel_url}',
12
+ status : true, // check login status
13
+ cookie : true, // enable cookies to allow the server to access the session
14
+ oauth : true, // enable OAuth 2.0
15
+ xfbml : true // parse XFBML
16
+ });
17
+ // Additional initialization code here
18
+ };
19
+
20
+ // Load the SDK Asynchronously
21
+ (function(d){
22
+ var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
23
+ js = d.createElement('script'); js.id = id; js.async = true;
24
+ js.src = "//connect.facebook.net/en_US/all.js";
25
+ d.getElementsByTagName('head')[0].appendChild(js);
26
+ }(document));
27
+ </script>
28
+ }.html_safe
29
+ end
30
+
31
+ def uid
32
+ javascript_tag("FB.getUserID()")
33
+ end
34
+
35
+ # Configurable[:facebook_permissions]
36
+ def facebook_login(text, permissions, log_in_url)
37
+ link_to(text, "#", :onclick => "facebookLogin('#{permissions}', '#{log_in_url}'").html_safe
38
+ end
39
+
40
+ def uninstall_facebook_app_button
41
+ button_to_function("Uninstall This Facebook App", "removeAppPermissions()")
42
+ end
43
+
44
+ def facebook_logout_button
45
+ button_to_function("Log out of App", "FB.logout()")
46
+ end
47
+
48
+ def comments_box
49
+ %Q{
50
+ <script>(function(d, s, id) {
51
+ var js, fjs = d.getElementsByTagName(s)[0];
52
+ if (d.getElementById(id)) {return;}
53
+ js = d.createElement(s); js.id = id;
54
+ js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=225198020866871";
55
+ fjs.parentNode.insertBefore(js, fjs);
56
+ }(document, 'script', 'facebook-jssdk'));</script>
57
+
58
+ <div class="fb-comments" data-href="http://apps.facebook.com/myprofilereport/" data-num-posts="20" data-width="700"></div>
59
+ }.html_safe
60
+ end
61
+
62
+ end
63
+ end
@@ -16,10 +16,6 @@ module FacebookApp
16
16
  transition :permissions_dialogue => :denied_permissions
17
17
  end
18
18
 
19
- event :deny_extended_permissions do
20
- transition [:deny_permissions, :permissions_dialogue] => :denied_extended_permissions
21
- end
22
-
23
19
  event :accept_permissions do
24
20
  transition [:denied_permissions, :denied_extended_permissions, :permissions_dialogue] => :installed
25
21
  end
@@ -11,6 +11,12 @@ module FacebookApp
11
11
  "Cannot compute yet"
12
12
  end
13
13
 
14
+ def funnel(from_state, to_state, marketing_type=:all)
15
+ state_count(from_state, marketing_type)/ state_count(to_state, marketing_type)
16
+ rescue ZeroDivisionError
17
+ "Cannot compute yet"
18
+ end
19
+
14
20
  def splash_page_state_count(marketing_mode)
15
21
  state_count(:splash_page, marketing_mode).to_s
16
22
  end
@@ -27,10 +33,6 @@ module FacebookApp
27
33
  state_count(:denied_permissions, marketing_mode).to_s
28
34
  end
29
35
 
30
- def denied_extended_state_count(marketing_mode)
31
- state_count(:denied_extended_permissions, marketing_mode).to_s
32
- end
33
-
34
36
  def infographic_state_count(marketing_mode)
35
37
  state_count(:generated_infographic, marketing_mode).to_s
36
38
  end
@@ -1,9 +1,9 @@
1
+ h4 Basic Numbers
2
+ hr
1
3
  ul
2
4
  li = "Advertising: " + conversion_summary.send(state, :advertising)
3
5
  li = "Viral: " + conversion_summary.send(state, :viral)
4
6
  li = "Unknown or testing: " + conversion_summary.send(state, nil)
5
- li = "Ration of all visitors that reach this stage: " + conversion_summary.percentage_of_total(state, :all)
6
- li = "Ratio of all advertised visitors that reach this stage: " + conversion_summary.percentage_of_total(state, :advertising)
7
- li = "Ratio of all viral visitors that reach this stage: " + conversion_summary.percentage_of_total(state, :viral)
7
+ li = "Total visitors: " + conversion_summary.send(state, :all)
8
8
  li.virality= "Virality: " + number_to_percentage(conversion_summary.virality_coefficient(state))
9
9
 
@@ -0,0 +1,6 @@
1
+ h4.title Funnel Information
2
+ hr
3
+ p Percentage of all #{from_stage.to_s.humanize} users reaching this stage: #{conversion_summary.funnel(from_stage, to_stage)}
4
+ p Percentage of viral #{from_stage.to_s.humanize} users reaching this stage: #{conversion_summary.funnel(from_stage, to_stage, :viral)}
5
+ p Percentage of advertised #{from_stage.to_s.humanize} users reaching this stage: #{conversion_summary.funnel(from_stage, to_stage, :advertising)}
6
+ hr
@@ -1,18 +1,23 @@
1
1
  h1 Spamalytics
2
2
  h2 Unique users who reached splash page
3
3
  = render :partial => 'conversion_stage', :locals => {:state => :splash_page_state_count, :conversion_summary => conversion_summary }
4
+
4
5
  h2 Unique users who saw permissions dialogue for this app
5
6
  = render :partial => 'conversion_stage', :locals => {:state => :permissions_state_count, :conversion_summary => conversion_summary }
7
+ = render :partial => "funnel", :locals => {:from_stage => :splash_page, :to_stage => :permission_dialogue, :conversion_summary => conversion_summary}
8
+
6
9
  h2 Unique users who installed this facebook app (accepted permissions)
7
10
  = render :partial => 'conversion_stage', :locals => {:state => :installed_state_count, :conversion_summary => conversion_summary }
8
- h2 Unique users who denied permissions for this app (first set of permissions)
11
+ = render :partial => "funnel", :locals => {:from_stage => :permissions_dialogue, :to_stage => :accept_infographics, :conversion_summary => conversion_summary}
12
+
13
+ h2 Unique users who denied permissions for this app
9
14
  p Note that these users are all redirected to Identified.com, so it's not a complete loss
10
15
  = render :partial => 'conversion_stage', :locals => {:state => :denied_state_count, :conversion_summary => conversion_summary }
11
- h2 Unique users who denied extended permissions for this app (publish rights etc)
12
- p Note that these users are all redirected to Identified.com, so it's not a complete loss
13
- = render :partial => 'conversion_stage', :locals => {:state => :denied_extended_state_count, :conversion_summary => conversion_summary }
14
16
  h2 Unique users who sent an infographic
15
17
  = render :partial => 'conversion_stage', :locals => {:state => :infographic_state_count, :conversion_summary => conversion_summary }
18
+ = render :partial => "funnel", :locals => {:from_stage => :accept_permissions, :to_stage => :generate_infographic, :conversion_summary => conversion_summary}
19
+
16
20
  h2 Unique users who installed Identified app after coming through here
17
21
  p Installed the Identified Facebook app (success)
18
22
  = render :partial => 'conversion_stage', :locals => {:state => :signed_up_identified_state_count, :conversion_summary => conversion_summary }
23
+ = render :partial => "funnel", :locals => {:from_stage => :generate_infographic, :to_stage => :signed_up_identified, :conversion_summary => conversion_summary}
@@ -1,10 +1,11 @@
1
+ = add_facebook_sdk
1
2
  #spamalytics
2
3
  = render :partial => 'spamalytics', :locals => {:conversion_summary => @conversion_summary}
3
4
  h2 Testing
4
5
  p Delete all stored conversion data. Useful for testing conversions are working.
5
6
  = button_to "Delete Data", facebook_app.clear_conversion_data_path, :confirm => "Are you sure you want to permanently delete all conversion data?"
6
7
  p Remove app permission. Useful for checking if permissions dialogue shows at right time. Will log you in if you are logged out.
7
- = button_to "Log me out", facebook_app.log_me_out_path
8
+ = uninstall_facebook_app_button
8
9
  p Register Achievements With Facebook(must be done with each new app)
9
10
  = button_to "Register Achivements", facebook_app.register_with_fb_achievement_path(1)
10
11
 
@@ -0,0 +1 @@
1
+ <script src="//connect.facebook.net/en_US/all.js"></script>
@@ -0,0 +1,10 @@
1
+ # The asset pipeline logger is messy and destroys the ability to debug
2
+
3
+ Rails.application.assets.logger = Logger.new('/dev/null')
4
+ Rails::Rack::Logger.class_eval do
5
+ def before_dispatch_with_quiet_assets(env)
6
+ before_dispatch_without_quiet_assets(env) unless env['PATH_INFO'].index("/assets/") == 0
7
+ end
8
+ alias_method_chain :before_dispatch, :quiet_assets
9
+ end
10
+
data/config/routes.rb CHANGED
@@ -7,6 +7,10 @@ FacebookApp::Engine.routes.draw do
7
7
  end
8
8
  end
9
9
 
10
+ get "/channel" => "facebook_sdk#channel", :as => :facebook_channel
11
+
12
+ post "/trackings" => "trackings#create", :as => :trackings
13
+
10
14
  match "/oauth_callback" => "oauth#create", :as => :oauth_callback
11
15
  match "/denied" => "oauth#denied", :as => :denied
12
16
 
@@ -0,0 +1,16 @@
1
+ module FacebookApp
2
+ module TrackingHelper
3
+
4
+ def begin_tracking
5
+ conversion = Conversion.find_or_create(cookies[:conversion_id],params[:marketing_mode])
6
+ cookies[:conversion_id] = conversion.id
7
+ end
8
+
9
+ def track_conversion(conversion_state)
10
+ Rails.logger.debug "Attempting to track #{conversion_state}"
11
+ Conversion.track(cookies[:conversion_id], conversion_state)
12
+ rescue
13
+ end
14
+
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module FacebookApp
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.20"
3
3
  end
data/lib/facebook_app.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "facebook_app/version"
2
+ require "facebook_app/tracking_helper"
2
3
 
3
4
  module FacebookApp
4
5
  if defined?(Rails)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: facebook_app
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.19
5
+ version: 0.0.20
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jack Kinsella
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-11-04 00:00:00 Z
13
+ date: 2011-11-08 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -118,6 +118,7 @@ files:
118
118
  - app/assets/images/shared/ajax-loader.gif
119
119
  - app/assets/images/single_pixel.png
120
120
  - app/assets/javascripts/facebook_app.js
121
+ - app/assets/javascripts/javascript_sdk.js.coffee
121
122
  - app/assets/javascripts/pages.coffee.erb
122
123
  - app/assets/stylesheets/admin.sass
123
124
  - app/assets/stylesheets/configurables.sass
@@ -128,9 +129,12 @@ files:
128
129
  - app/controllers/facebook_app/admin_controller.rb
129
130
  - app/controllers/facebook_app/external_trackings_controller.rb
130
131
  - app/controllers/facebook_app/facebook_app_controller.rb
132
+ - app/controllers/facebook_app/facebook_sdk_controller.rb
131
133
  - app/controllers/facebook_app/oauth_controller.rb
132
134
  - app/controllers/facebook_app/pages_controller.rb
135
+ - app/controllers/facebook_app/trackings_controller.rb
133
136
  - app/helpers/facebook_app/application_helper.rb
137
+ - app/helpers/facebook_app/facebook_sdk_helper.rb
134
138
  - app/mailers/.gitkeep
135
139
  - app/models/.gitkeep
136
140
  - app/models/facebook_app/conversion.rb
@@ -139,19 +143,23 @@ files:
139
143
  - app/models/facebook_app/infographic_server_communicator.rb
140
144
  - app/views/facebook_app/achievements/show.html.slim
141
145
  - app/views/facebook_app/admin/_conversion_stage.html.slim
146
+ - app/views/facebook_app/admin/_funnel.html.slim
142
147
  - app/views/facebook_app/admin/_spamalytics.html.slim
143
148
  - app/views/facebook_app/admin/new_fb_credentials.html.slim
144
149
  - app/views/facebook_app/admin/show.html.slim
145
150
  - app/views/facebook_app/external_trackings/test.html.slim
151
+ - app/views/facebook_app/facebook_sdk/channel.html
146
152
  - app/views/facebook_app/pages/privacy_policy.html.slim
147
153
  - app/views/facebook_app/pages/terms_of_service.html.slim
148
154
  - app/views/layouts/facebook_app.html.slim
155
+ - config/initializers/quiet_asset_pipeline_log.rb
149
156
  - config/routes.rb
150
157
  - db/migrate/20111024214949_add_facebook_app.rb
151
158
  - facebook_app.gemspec
152
159
  - lib/facebook_app.rb
153
160
  - lib/facebook_app/engine.rb
154
161
  - lib/facebook_app/recipes.rb
162
+ - lib/facebook_app/tracking_helper.rb
155
163
  - lib/facebook_app/version.rb
156
164
  - lib/generators/facebook_app/install_generator.rb
157
165
  - lib/generators/facebook_app/templates/configurable.yml
@@ -182,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
190
  requirements: []
183
191
 
184
192
  rubyforge_project: facebook_app
185
- rubygems_version: 1.8.8
193
+ rubygems_version: 1.8.11
186
194
  signing_key:
187
195
  specification_version: 3
188
196
  summary: Base Facebook for rapid development of future Facebook applications