mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 01:54:40 +08:00
fix(analytics): fix send later and snooze analytics
This commit is contained in:
parent
816596d422
commit
d97e724c1b
4 changed files with 18 additions and 16 deletions
|
@ -56,21 +56,21 @@ class SendLaterPopover extends Component {
|
|||
|
||||
onSelectMenuOption = (optionKey)=> {
|
||||
const date = SendLaterOptions[optionKey]();
|
||||
this.onSelectDate(date);
|
||||
this.onSelectDate(date, optionKey);
|
||||
};
|
||||
|
||||
onSelectCustomOption = (value)=> {
|
||||
const date = DateUtils.futureDateFromString(value);
|
||||
if (date) {
|
||||
this.onSelectDate(date);
|
||||
this.onSelectDate(date, "Custom");
|
||||
} else {
|
||||
NylasEnv.showErrorDialog(`Sorry, we can't parse ${value} as a valid date.`);
|
||||
}
|
||||
};
|
||||
|
||||
onSelectDate = (date)=> {
|
||||
onSelectDate = (date, label)=> {
|
||||
const formatted = DateUtils.format(date.utc());
|
||||
SendLaterActions.sendLater(this.props.draftClientId, formatted);
|
||||
SendLaterActions.sendLater(this.props.draftClientId, formatted, label);
|
||||
this.setState({scheduledDate: 'saving', inputDate: null});
|
||||
this.refs.popover.close();
|
||||
};
|
||||
|
|
|
@ -42,12 +42,13 @@ class SendLaterStore extends NylasStore {
|
|||
});
|
||||
};
|
||||
|
||||
recordAction(sendLaterDate) {
|
||||
recordAction(sendLaterDate, label) {
|
||||
try {
|
||||
if (sendLaterDate) {
|
||||
const sec = Math.round(((new Date(sendLaterDate)).valueOf() - Date.now()) / 1000);
|
||||
const min = Math.round(((new Date(sendLaterDate)).valueOf() - Date.now()) / 1000 / 60);
|
||||
Actions.recordUserEvent("Send Later", {
|
||||
snoozeTime: sec,
|
||||
sendLaterTime: min,
|
||||
optionLabel: label,
|
||||
});
|
||||
} else {
|
||||
Actions.recordUserEvent("Send Later Cancel");
|
||||
|
@ -57,8 +58,8 @@ class SendLaterStore extends NylasStore {
|
|||
}
|
||||
}
|
||||
|
||||
onSendLater = (draftClientId, sendLaterDate)=> {
|
||||
this.recordAction(sendLaterDate)
|
||||
onSendLater = (draftClientId, sendLaterDate, label)=> {
|
||||
this.recordAction(sendLaterDate, label)
|
||||
this.setMetadata(draftClientId, {sendLaterDate});
|
||||
};
|
||||
|
||||
|
|
|
@ -65,10 +65,10 @@ class SnoozePopoverBody extends Component {
|
|||
this.props.swipeCallback(this.didSnooze);
|
||||
}
|
||||
|
||||
onSnooze(dateGenerator) {
|
||||
onSnooze(dateGenerator, label) {
|
||||
const utcDate = dateGenerator().utc();
|
||||
const formatted = DateUtils.format(utcDate);
|
||||
SnoozeActions.snoozeThreads(this.props.threads, formatted);
|
||||
SnoozeActions.snoozeThreads(this.props.threads, formatted, label);
|
||||
this.didSnooze = true;
|
||||
this.props.closePopover();
|
||||
|
||||
|
@ -87,7 +87,7 @@ class SnoozePopoverBody extends Component {
|
|||
if (value.length > 0 && ["Enter", "Return"].includes(event.key)) {
|
||||
const inputDate = DateUtils.futureDateFromString(value);
|
||||
if (inputDate) {
|
||||
this.onSnooze(()=> inputDate);
|
||||
this.onSnooze(() => {return inputDate}, "Custom");
|
||||
// Prevent onInputChange from firing
|
||||
event.stopPropagation()
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ class SnoozePopoverBody extends Component {
|
|||
<div
|
||||
key={label}
|
||||
className="snooze-item"
|
||||
onClick={this.onSnooze.bind(this, dateGenerator)}>
|
||||
onClick={this.onSnooze.bind(this, dateGenerator, label)}>
|
||||
<RetinaImg
|
||||
url={iconPath}
|
||||
mode={RetinaImg.Mode.ContentIsMask} />
|
||||
|
|
|
@ -14,12 +14,13 @@ class SnoozeStore {
|
|||
this.unsubscribe = SnoozeActions.snoozeThreads.listen(this.onSnoozeThreads)
|
||||
}
|
||||
|
||||
onSnoozeThreads = (threads, snoozeDate)=> {
|
||||
onSnoozeThreads = (threads, snoozeDate, label) => {
|
||||
try {
|
||||
const sec = Math.round(((new Date(snoozeDate)).valueOf() - Date.now()) / 1000);
|
||||
const min = Math.round(((new Date(snoozeDate)).valueOf() - Date.now()) / 1000 / 60);
|
||||
Actions.recordUserEvent("Snooze Threads", {
|
||||
numThreads: threads.length,
|
||||
snoozeTime: sec,
|
||||
snoozeTime: min,
|
||||
buttonType: label,
|
||||
});
|
||||
} catch (e) {
|
||||
// Do nothing
|
||||
|
|
Loading…
Reference in a new issue