track user verification and add statistics of verified users who did not vote proposals
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
//= require registration_form
|
||||
//= require suggest
|
||||
//= require forms
|
||||
//= require tracks
|
||||
|
||||
var initialize_modules = function() {
|
||||
App.Comments.initialize();
|
||||
@@ -57,6 +58,7 @@ var initialize_modules = function() {
|
||||
App.RegistrationForm.initialize();
|
||||
App.Suggest.initialize();
|
||||
App.Forms.initialize();
|
||||
App.Tracks.initialize();
|
||||
};
|
||||
|
||||
$(function(){
|
||||
|
||||
28
app/assets/javascripts/tracks.js.coffee
Normal file
28
app/assets/javascripts/tracks.js.coffee
Normal file
@@ -0,0 +1,28 @@
|
||||
App.Tracks =
|
||||
|
||||
tracking_enabled: ->
|
||||
_paq?
|
||||
|
||||
set_custom_var: (id, name, value, scope) ->
|
||||
_paq.push(['setCustomVariable', id, name, value, scope])
|
||||
_paq.push(['trackPageView'])
|
||||
|
||||
track_event: ($this) ->
|
||||
category = $this.data('track-event-category')
|
||||
action = $this.data('track-event-action')
|
||||
_paq.push(['trackEvent', category, action])
|
||||
|
||||
initialize: ->
|
||||
if App.Tracks.tracking_enabled()
|
||||
$('[data-track-usertype]').each ->
|
||||
$this = $(this)
|
||||
usertype = $this.data('track-usertype')
|
||||
App.Tracks.set_custom_var(1, "usertype", usertype, "visit")
|
||||
|
||||
$('[data-track-event-category]').each ->
|
||||
$this = $(this)
|
||||
App.Tracks.track_event($this)
|
||||
|
||||
$('[data-track-click]').on 'click', ->
|
||||
$this = $(this)
|
||||
App.Tracks.track_event($this)
|
||||
@@ -18,6 +18,10 @@ class Admin::StatsController < Admin::BaseController
|
||||
@verified_users = User.with_hidden.level_two_or_three_verified.count
|
||||
@unverified_users = User.with_hidden.unverified.count
|
||||
@users = User.with_hidden.count
|
||||
|
||||
@user_ids_who_voted_proposals =
|
||||
ActsAsVotable::Vote.where(votable_type: 'Proposal').pluck(:voter_id).uniq.count
|
||||
@user_ids_who_didnt_vote_proposals = @verified_users - @user_ids_who_voted_proposals
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
12
app/helpers/tracks_helper.rb
Normal file
12
app/helpers/tracks_helper.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
module TracksHelper
|
||||
def track_event(data={})
|
||||
track_data = ""
|
||||
prefix = " data-track-event-"
|
||||
data.each do |key, value|
|
||||
track_data = track_data + prefix + key.to_s + '=' + value + " "
|
||||
end
|
||||
content_for :track_event do
|
||||
track_data
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -53,7 +53,18 @@ module Verification
|
||||
def no_phone_available?
|
||||
!verification_sms_sent?
|
||||
end
|
||||
|
||||
|
||||
def user_type
|
||||
case
|
||||
when level_three_verified?
|
||||
:level_3_user
|
||||
when level_two_verified?
|
||||
:level_2_user
|
||||
else
|
||||
:level_1_user
|
||||
end
|
||||
end
|
||||
|
||||
def sms_code_not_confirmed?
|
||||
!sms_verified?
|
||||
end
|
||||
|
||||
@@ -76,6 +76,13 @@
|
||||
<%= t "admin.stats.show.summary.user_level_three" %><br>
|
||||
<span class="number"><%= number_with_delimiter(@user_level_three) %></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<%= t "admin.stats.show.summary.verified_users_who_didnt_vote_proposals" %><br>
|
||||
<span class="number">
|
||||
<%=number_with_delimiter(@user_ids_who_didnt_vote_proposals)%>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
1
app/views/layouts/_tracking_data.html.erb
Normal file
1
app/views/layouts/_tracking_data.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<meta name="tracking_data" data-track-usertype="<%=current_user ? current_user.user_type : :anonymous%>" <%= yield(:track_event) %>/>
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<%=render "layouts/tracking_data"%>
|
||||
<title><%= content_for?(:title) ? yield(:title) : setting['org_name'] %></title>
|
||||
<%= stylesheet_link_tag "application" %>
|
||||
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="row verify">
|
||||
<%track_event(category: "verification", action: "edit_letter" )%>
|
||||
<div class="small-12 medium-9 large-6 small-centered column">
|
||||
<div class="text-center">
|
||||
<h1>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="verification account row">
|
||||
<%track_event(category: "verification", action: "success_sms" )%>
|
||||
<div class="small-12 column">
|
||||
|
||||
<div class="text-center">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="row">
|
||||
<%track_event(category: "verification", action: "start_letter" )%>
|
||||
<div class="small-12 column">
|
||||
|
||||
<%= link_to account_path, class: "back" do %>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="verification account row">
|
||||
<%track_event(category: "verification", action: "start_census" )%>
|
||||
<div class="small-12 column">
|
||||
|
||||
<div class="text-center">
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="verification account row">
|
||||
<%track_event(category: "verification", action: "start_sms" )%>
|
||||
<div class="small-12 column">
|
||||
<div class="text-center">
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="verification account row">
|
||||
<%track_event(category: "verification", action: "success_census" )%>
|
||||
<div class="small-12 column">
|
||||
<div class="text-center">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user