add events for posts pages

This commit is contained in:
Albert Yi
2018-10-22 17:19:32 -07:00
parent 08e3051d31
commit 1b9e3d687d
5 changed files with 31 additions and 30 deletions

View File

@@ -78,4 +78,12 @@
<% end %>
<%= missed_post_search_count_js %>
<%= render "posts/partials/index/seo_meta_tags" %>
<script>
$(function() {
window.Danbooru.mixpanelEvent("Post Search", {
"tags": <%= params[:tags].to_json %>,
"page": <%= params[:page].to_json %>
});
});
</script>
<% end %>

View File

@@ -13,19 +13,3 @@
<%= hidden_field_tag "ms", "1" %>
<% end %>
</section>
<% content_for(:html_header) do %>
<script>
/*$(function() {
$("#tags").on("keypress autocompleteclose", function(e) {
if (!$(this).data("fakeWidth")) {
$(this).data("fakeWidth", $('<span>').hide().appendTo(document.body));
}
var width = $(this).data("fakeWidth").text($(this).val()).css('font', $(this).css("font")).width() + 15;
if (width > $(this).width()) {
$(this).width(width);
}
});
});*/
</script>
<% end %>

View File

@@ -192,6 +192,19 @@
<%= tag.meta name: "og:site", content: Danbooru.config.app_name %>
<%= auto_discovery_link_tag(:atom, comments_url(:atom, search: { post_id: @post.id }), title: "Comments for post ##{@post.id}") %>
<script>
$(function() {
window.Danbooru.mixpanelEvent("Post View", {
"id": <%= @post.id %>,
"rating": '<%= @post.rating %>',
"size": <%= @post.file_size %>,
"fav_count": <%= @post.fav_count %>,
"created_at": <%= @post.created_at.strftime('%F %T').to_json %>,
"tags": <%= @post.presenter.humanized_essential_tag_string.to_json %>
});
});
</script>
<% end %>
<%= render "posts/partials/common/secondary_links" %>

View File

@@ -6,12 +6,10 @@
<% content_for(:html_header) do %>
<script>
$(function() {
$("#sign-up-link").click(function() {
window.Danbooru.mixpanelEvent("clicked sign up");
});
$("#hide-sign-up-notice").click(function() {
window.Danbooru.mixpanelEvent("hide sign up notice");
});
})
if (typeof window.mixpanel === 'object') {
window.mixpanel.track_links('#sign-up-link', 'clicked sign up');
window.mixpanel.track_links('#hide-sign-up-notice', 'hide sign up notice');
}
});
</script>
<% end %>

View File

@@ -6,12 +6,10 @@
<% 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");
});
})
if (typeof window.mixpanel === 'object') {
window.mixpanel.track_links('#goto-upgrade-account', 'clicked upgrade notice');
window.mixpanel.track_links('#hide-upgrade-account-notice', 'hide upgrade notice');
}
});
</script>
<% end %>