mixpanel fixes

This commit is contained in:
Albert Yi
2018-10-22 16:54:38 -07:00
parent ae4e40aa76
commit b999fc86ea
5 changed files with 35 additions and 23 deletions

View File

@@ -84,18 +84,15 @@
$(window).trigger("danbooru:error", msg);
}
</script>
<script>
window.Danbooru.mixpanelInit(
<%= CurrentUser.id || "null" %>,
<%= raw session.id.to_json %>,
<%= CurrentUser.opt_out_mixpanel? %>,
<% if CurrentUser.is_anonymous? %>
{}
<% else %>
<% unless CurrentUser.is_anonymous? %>
<script>
window.Danbooru.mixpanelInit(
"<%= CurrentUser.id %>",
<%= 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) %>
<% end %>
);
</script>
);
</script>
<% end %>
</head>
<%= tag.body **body_attributes(CurrentUser.user) do %>

View File

@@ -20,3 +20,13 @@
<% content_for(:page_title) do %>
Feedback - <%= @user_feedback.user_name %> - <%= Danbooru.config.app_name %>
<% end %>
<% if flash[:alias_mixpanel] %>
<% content_for(:html_header) do %>
<script>
$(function() {
window.Danbooru.mixpanelAlias("<%= CurrentUser.id %>");
});
</script>
<% end %>
<% end %>