add opt out for mixpanel tracking

This commit is contained in:
Albert Yi
2018-10-22 10:30:45 -07:00
parent c1f70b9a02
commit 5097babfaa
8 changed files with 62 additions and 3 deletions

View File

@@ -84,6 +84,14 @@
$(window).trigger("danbooru:error", msg);
}
</script>
<script>
window.Danbooru.mixpanelInit(
<%= CurrentUser.id %>,
<%= raw session.id.to_json %>,
<%= CurrentUser.opt_out_mixpanel? %>,
<%= raw({"$created" =>CurrentUser.created_at.strftime('%F %T'), "$name" => CurrentUser.name, "level" => CurrentUser.level, "upload_count" => CurrentUser.post_upload_count, "post_update_count" => CurrentUser.post_update_count, "note_update_count" => CurrentUser.note_update_count, "favorite_count" => CurrentUser.favorite_count}.to_json) %>
);
</script>
</head>
<%= tag.body **body_attributes(CurrentUser.user) do %>

View File

@@ -120,3 +120,11 @@
<% content_for(:page_title) do %>
Upgrade - <%= Danbooru.config.app_name %>
<% end %>
<% content_for(:html_header) do %>
<script>
$(function() {
window.Danbooru.mixpanelEvent("Account Upgrade");
});
</script>
<% end %>

View File

@@ -1,4 +1,17 @@
<div class="ui-corner-all ui-state-highlight" id="upgrade-account-notice">
<h1><%= link_to "Upgrade your account for only $20!", new_user_upgrade_path %></h1>
<h1><%= link_to "Upgrade your account for only $20!", new_user_upgrade_path, id: "goto-upgrade-account" %></h1>
<p><%= link_to "No thanks", "#", :id => "hide-upgrade-account-notice" %></p>
</div>
<%= content_for(:html_header) do %>
<script>
$(function() {
$("#goto-upgrade-account").click(function() {
window.Danbooru.mixpanelEvent("clicked upgrade notice");
});
$("#hide-upgrade-account-notice").click(function() {
window.Danbooru.mixpanelEvent("hide upgrade notice");
});
})
</script>
<% end %>

View File

@@ -97,6 +97,8 @@
<%= f.input :disable_responsive_mode, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Disable alternative layout for mobile and tablet" %>
<%= f.input :opt_out_mixpanel, :as => :select, :collection => [["No", "false"], "Yes", "true"]], :include_blank => false, :hint => "Opt out of MixPanel tracking" %>
<%= f.input :custom_style, :label => "Custom <a href='https://en.wikipedia.org/wiki/Cascading_Style_Sheets'>CSS</a> style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
</fieldset>