mixpanel fixes
This commit is contained in:
@@ -50,6 +50,7 @@ class UsersController < ApplicationController
|
|||||||
@user.save
|
@user.save
|
||||||
if @user.errors.empty?
|
if @user.errors.empty?
|
||||||
session[:user_id] = @user.id
|
session[:user_id] = @user.id
|
||||||
|
flash[:alias_mixpanel] = true
|
||||||
else
|
else
|
||||||
flash[:notice] = "Sign up failed: #{@user.errors.full_messages.join("; ")}"
|
flash[:notice] = "Sign up failed: #{@user.errors.full_messages.join("; ")}"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -43,4 +43,4 @@ export { default as Shortcuts } from '../src/javascripts/shortcuts.js';
|
|||||||
export { default as Upload } from '../src/javascripts/uploads.js';
|
export { default as Upload } from '../src/javascripts/uploads.js';
|
||||||
export { default as Utility } from '../src/javascripts/utility.js';
|
export { default as Utility } from '../src/javascripts/utility.js';
|
||||||
export { default as Ugoira } from '../src/javascripts/ugoira.js';
|
export { default as Ugoira } from '../src/javascripts/ugoira.js';
|
||||||
export { mixpanelInit, mixpanelEvent } from '../src/javascripts/mixpanel.js';
|
export { mixpanelInit, mixpanelEvent, mixpanelAlias } from '../src/javascripts/mixpanel.js';
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
const mixpanelInit = (user_id, session_id, opt_out, user_data) => {
|
const mixpanelInit = (user_id, opt_out, user_data) => {
|
||||||
if (typeof window.mixpanel !== "object") {
|
if (typeof window.mixpanel !== "object") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user_id) {
|
window.mixpanel.identify(user_id);
|
||||||
window.mixpanel.identify(user_id);
|
|
||||||
|
|
||||||
if (opt_out) {
|
if (opt_out) {
|
||||||
window.mixpanel.opt_out_tracking();
|
window.mixpanel.opt_out_tracking();
|
||||||
} else {
|
} else {
|
||||||
window.mixpanel.people.set(user_data);
|
window.mixpanel.people.set(user_data);
|
||||||
}
|
|
||||||
} else if (session_id) {
|
|
||||||
window.mixpanel.identify("anon:" + session_id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,4 +20,12 @@ const mixpanelEvent = (title, props) => {
|
|||||||
window.mixpanel.track(title, props);
|
window.mixpanel.track(title, props);
|
||||||
}
|
}
|
||||||
|
|
||||||
export { mixpanelInit, mixpanelEvent };
|
const mixpanelAlias = (user_id) => {
|
||||||
|
if (typeof window.mixpanel !== "object") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.mixpanel.alias(user_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
export { mixpanelInit, mixpanelEvent, mixpanelAlias };
|
||||||
|
|||||||
@@ -84,18 +84,15 @@
|
|||||||
$(window).trigger("danbooru:error", msg);
|
$(window).trigger("danbooru:error", msg);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<% unless CurrentUser.is_anonymous? %>
|
||||||
window.Danbooru.mixpanelInit(
|
<script>
|
||||||
<%= CurrentUser.id || "null" %>,
|
window.Danbooru.mixpanelInit(
|
||||||
<%= raw session.id.to_json %>,
|
"<%= CurrentUser.id %>",
|
||||||
<%= CurrentUser.opt_out_mixpanel? %>,
|
<%= CurrentUser.opt_out_mixpanel? %>,
|
||||||
<% if CurrentUser.is_anonymous? %>
|
|
||||||
{}
|
|
||||||
<% else %>
|
|
||||||
<%= 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) %>
|
<%= 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>
|
</head>
|
||||||
<%= tag.body **body_attributes(CurrentUser.user) do %>
|
<%= tag.body **body_attributes(CurrentUser.user) do %>
|
||||||
|
|||||||
@@ -20,3 +20,13 @@
|
|||||||
<% content_for(:page_title) do %>
|
<% content_for(:page_title) do %>
|
||||||
Feedback - <%= @user_feedback.user_name %> - <%= Danbooru.config.app_name %>
|
Feedback - <%= @user_feedback.user_name %> - <%= Danbooru.config.app_name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if flash[:alias_mixpanel] %>
|
||||||
|
<% content_for(:html_header) do %>
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
window.Danbooru.mixpanelAlias("<%= CurrentUser.id %>");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
Reference in New Issue
Block a user