Track what user action triggered a compose

(imported from commit 3e23dd1f7e9e3a742b0c3b9e1b0eeb85cfa4c736)
This commit is contained in:
Zev Benjamin 2013-05-20 17:35:41 -04:00
parent a4bda36ab4
commit c60a500a8f
4 changed files with 22 additions and 17 deletions

View File

@ -183,7 +183,8 @@ exports.start = function (msg_type, opts) {
message_type: msg_type,
stream: '',
subject: '',
private_message_recipient: ''
private_message_recipient: '',
trigger: 'unknown'
};
// Set default parameters based on the current narrowed view.

View File

@ -183,13 +183,13 @@ function process_hotkey(e) {
compose.set_mode('private');
return true;
case 13: // Enter: respond to message (unless we need to do something else)
respond_to_message();
respond_to_message({trigger: 'hotkey enter'});
return true;
case 114: // 'r': respond to message
respond_to_message();
respond_to_message({trigger: 'hotkey'});
return true;
case 82: // 'R': respond to author
respond_to_message("personal");
respond_to_message({reply_type: "personal", trigger: 'hotkey pm'});
return true;
case 47: // '/': initiate search
search.initiate_search();

View File

@ -1052,7 +1052,7 @@ $(function () {
// Was a click (not a click-and-drag).
var row = $(this).closest(".message_row");
current_msg_list.select_id(rows.id(row));
respond_to_message();
respond_to_message({trigger: 'message click'});
e.stopPropagation();
}
mouse_moved = false;
@ -1214,7 +1214,8 @@ $(function () {
$('#user_presences').on('click', 'a', function (e) {
var email = $(e.target).attr('data-email');
compose.start('private', {private_message_recipient: email});
compose.start('private', {private_message_recipient: email,
trigger: 'presence list'});
// The preventDefault is necessary so that clicking the
// link doesn't jump us to the top of the page.
e.preventDefault();
@ -1286,11 +1287,11 @@ $(function () {
});
$('.empty_feed_compose_stream').click(function (e) {
compose.start('stream');
compose.start('stream', {trigger: 'empty feed message'});
return false;
});
$('.empty_feed_compose_private').click(function (e) {
compose.start('private');
compose.start('private', {trigger: 'empty feed message'});
return false;
});
$('.empty_feed_join').click(function (e) {
@ -1301,12 +1302,14 @@ $(function () {
// Keep these 2 feedback bot triggers separate because they have to
// propagate the event differently.
$('.feedback').click(function (e) {
compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com' });
compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com',
trigger: 'feedback menu item' });
});
$('#feedback_button').click(function (e) {
e.stopPropagation();
compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com' });
compose.start('private', { 'private_message_recipient': 'feedback@humbughq.com',
trigger: 'feedback button' });
});
$('.logout_button').click(function (e) {
@ -1328,12 +1331,12 @@ $(function () {
});
$('body').on('click', '.respond_button', function (e) {
respond_to_message();
respond_to_message({trigger: 'popover respond'});
ui.hide_actions_popover();
e.stopPropagation();
});
$('body').on('click', '.respond_personal_button', function (e) {
respond_to_message('personal');
respond_to_message({reply_type: 'personal', trigger: 'popover respond pm'});
ui.hide_actions_popover();
e.stopPropagation();
});
@ -1419,7 +1422,7 @@ $(function () {
$('body').on('click', '.compose_to_stream', function (e) {
var stream = $(e.currentTarget).parents('ul').attr('data-name');
ui.hide_sidebar_popover();
compose.start('stream', {"stream": stream});
compose.start('stream', {"stream": stream, trigger: 'sidebar stream actions'});
e.stopPropagation();
});

View File

@ -170,7 +170,7 @@ function get_private_message_recipient(message, attr) {
return recipient;
}
function respond_to_message(reply_type) {
function respond_to_message(opts) {
var message, msg_type;
// Before initiating a reply to a message, if there's an
// in-progress composition, snapshot it.
@ -190,20 +190,21 @@ function respond_to_message(reply_type) {
}
var pm_recipient = message.reply_to;
if (reply_type === "personal" && message.type === "private") {
if (opts.reply_type === "personal" && message.type === "private") {
// reply_to for private messages is everyone involved, so for
// personals replies we need to set the the private message
// recipient to just the sender
pm_recipient = message.sender_email;
}
if (reply_type === 'personal' || message.type === 'private') {
if (opts.reply_type === 'personal' || message.type === 'private') {
msg_type = 'private';
} else {
msg_type = message.type;
}
compose.start(msg_type, {'stream': stream, 'subject': subject,
'private_message_recipient': pm_recipient,
'replying_to_message': message});
'replying_to_message': message,
'trigger': opts.trigger});
}
// Returns messages from the given message list in the specified range, inclusive