eliminate mixpanel references

This commit is contained in:
Albert Yi
2019-01-23 16:37:44 -08:00
parent 60f0aeeb99
commit 17ae357da9
8 changed files with 5 additions and 59 deletions

View File

@@ -50,7 +50,6 @@ 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
@@ -95,7 +94,7 @@ class UsersController < ApplicationController
disable_categorized_saved_searches disable_tagged_filenames disable_categorized_saved_searches disable_tagged_filenames
enable_recent_searches disable_cropped_thumbnails disable_mobile_gestures enable_recent_searches disable_cropped_thumbnails disable_mobile_gestures
enable_safe_mode disable_responsive_mode disable_post_tooltips enable_safe_mode disable_responsive_mode disable_post_tooltips
enable_recommended_posts opt_out_mixpanel enable_recommended_posts opt_out_tracking
] ]
permitted_params += [dmail_filter_attributes: %i[id words]] permitted_params += [dmail_filter_attributes: %i[id words]]

View File

@@ -43,4 +43,3 @@ 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, mixpanelAlias } from '../src/javascripts/mixpanel.js';

View File

@@ -1,31 +0,0 @@
const mixpanelInit = (user_id, opt_out, user_data) => {
if (typeof window.mixpanel !== "object") {
return;
}
window.mixpanel.identify(user_id);
if (opt_out) {
window.mixpanel.opt_out_tracking();
} else {
window.mixpanel.people.set(user_data);
}
}
const mixpanelEvent = (title, props) => {
if (typeof window.mixpanel !== "object") {
return;
}
window.mixpanel.track(title, props);
}
const mixpanelAlias = (user_id) => {
if (typeof window.mixpanel !== "object") {
return;
}
window.mixpanel.alias(user_id);
}
export { mixpanelInit, mixpanelEvent, mixpanelAlias };

View File

@@ -60,7 +60,7 @@ class User < ApplicationRecord
disable_responsive_mode disable_responsive_mode
disable_post_tooltips disable_post_tooltips
enable_recommended_posts enable_recommended_posts
opt_out_mixpanel opt_out_tracking
no_flagging no_flagging
no_feedback no_feedback
) )

View File

@@ -87,11 +87,11 @@
$(window).trigger("danbooru:error", msg); $(window).trigger("danbooru:error", msg);
} }
window._paq = window._paq || []; window._paq = window._paq || [];
<% if CurrentUser.is_member? && !CurrentUser.opt_out_mixpanel? %> <% if CurrentUser.is_member? && !CurrentUser.opt_out_tracking? %>
window._paq.push(["setUserId", '<%= CurrentUser.id %>']); window._paq.push(["setUserId", '<%= CurrentUser.id %>']);
<% end %> <% end %>
window._paq.push(["setDomains", "*.donmai.us"]); window._paq.push(["setDomains", "*.donmai.us"]);
<% if !CurrentUser.opt_out_mixpanel? %> <% if !CurrentUser.opt_out_tracking? %>
window._paq.push(["setCustomVariable", 1, "level", <%= CurrentUser.level %>, "visit"]); window._paq.push(["setCustomVariable", 1, "level", <%= CurrentUser.level %>, "visit"]);
window._paq.push(["setCustomVariable", 2, "age", <%= ((Time.now - CurrentUser.created_at) / 1.year).to_i %>, "visit"]); window._paq.push(["setCustomVariable", 2, "age", <%= ((Time.now - CurrentUser.created_at) / 1.year).to_i %>, "visit"]);
window._paq.push(["setCustomVariable", 3, "postUpdateCount", <%= CurrentUser.post_update_count.to_i / 100 %>, "visit"]); window._paq.push(["setCustomVariable", 3, "postUpdateCount", <%= CurrentUser.post_update_count.to_i / 100 %>, "visit"]);

View File

@@ -20,13 +20,3 @@
<% 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 %>

View File

@@ -2,14 +2,3 @@
<h1><%= link_to "Upgrade your account for only $20!", new_user_upgrade_path, id: "goto-upgrade-account" %></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> <p><%= link_to "No thanks", "#", :id => "hide-upgrade-account-notice" %></p>
</div> </div>
<% content_for(:html_header) do %>
<script>
$(function() {
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 %>

View File

@@ -97,7 +97,7 @@
<%= 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 :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 tracking" %> <%= f.input :opt_out_tracking, :as => :select, :collection => [["No", "false"], ["Yes", "true"]], :include_blank => false, :hint => "Opt out of 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"} %> <%= 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> </fieldset>