Track performance of message sends

This commit is contained in:
Scott Nonnenberg 2021-07-30 11:37:03 -07:00 committed by GitHub
parent 2d3b1918b3
commit 0ab09711a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 13 deletions

View file

@ -74,7 +74,11 @@ export type Props = {
): unknown; ): unknown;
onTextTooLong(): unknown; onTextTooLong(): unknown;
onPickEmoji(o: EmojiPickDataType): unknown; onPickEmoji(o: EmojiPickDataType): unknown;
onSubmit(message: string, mentions: Array<BodyRangeType>): unknown; onSubmit(
message: string,
mentions: Array<BodyRangeType>,
timestamp: number
): unknown;
getQuotedMessage(): unknown; getQuotedMessage(): unknown;
clearQuotedMessage(): unknown; clearQuotedMessage(): unknown;
}; };
@ -218,6 +222,7 @@ export const CompositionInput: React.ComponentType<Props> = props => {
}; };
const submit = () => { const submit = () => {
const timestamp = Date.now();
const quill = quillRef.current; const quill = quillRef.current;
if (quill === undefined) { if (quill === undefined) {
@ -226,8 +231,10 @@ export const CompositionInput: React.ComponentType<Props> = props => {
const [text, mentions] = getTextAndMentions(); const [text, mentions] = getTextAndMentions();
window.log.info(`Submitting a message with ${mentions.length} mentions`); window.log.info(
onSubmit(text, mentions); `CompositionInput: Submitting message ${timestamp} with ${mentions.length} mentions`
);
onSubmit(text, mentions, timestamp);
}; };
if (inputApi) { if (inputApi) {

View file

@ -454,7 +454,7 @@ export class Message extends React.Component<Props, State> {
} }
public componentDidUpdate(prevProps: Props): void { public componentDidUpdate(prevProps: Props): void {
const { canDeleteForEveryone, isSelected } = this.props; const { canDeleteForEveryone, isSelected, status, timestamp } = this.props;
this.startSelectedTimer(); this.startSelectedTimer();
@ -468,6 +468,19 @@ export class Message extends React.Component<Props, State> {
if (canDeleteForEveryone !== prevProps.canDeleteForEveryone) { if (canDeleteForEveryone !== prevProps.canDeleteForEveryone) {
this.startDeleteForEveryoneTimer(); this.startDeleteForEveryoneTimer();
} }
if (
prevProps.status === 'sending' &&
(status === 'sent' ||
status === 'delivered' ||
status === 'read' ||
status === 'viewed')
) {
const delta = Date.now() - timestamp;
window.log.info(
`Message.tsx: Rendered 'send complete' for message ${timestamp}; took ${delta}ms`
);
}
} }
public checkForHeightChange(prevProps: Props): void { public checkForHeightChange(prevProps: Props): void {

View file

@ -3559,6 +3559,9 @@ export class ConversationModel extends window.Backbone
const destination = this.getSendTarget()!; const destination = this.getSendTarget()!;
const recipients = this.getRecipients(); const recipients = this.getRecipients();
if (timestamp) {
window.log.info(`sendMessage: Queueing send with timestamp ${timestamp}`);
}
this.queueJob('sendMessage', async () => { this.queueJob('sendMessage', async () => {
const now = timestamp || Date.now(); const now = timestamp || Date.now();

View file

@ -670,8 +670,9 @@ Whisper.ConversationView = Whisper.View.extend({
this.sendStickerMessage({ packId, stickerId }), this.sendStickerMessage({ packId, stickerId }),
onSubmit: ( onSubmit: (
message: string, message: string,
mentions: typeof window.Whisper.BodyRangesType mentions: typeof window.Whisper.BodyRangesType,
) => this.sendMessage(message, mentions), timestamp: number
) => this.sendMessage(message, mentions, { timestamp }),
onEditorStateChange: ( onEditorStateChange: (
msg: string, msg: string,
bodyRanges: Array<typeof window.Whisper.BodyRangeType>, bodyRanges: Array<typeof window.Whisper.BodyRangeType>,
@ -3640,7 +3641,7 @@ Whisper.ConversationView = Whisper.View.extend({
} }
}, },
async getUntrustedContacts(options: any = {}) { async getUntrustedContacts(options: { force?: boolean } = {}) {
const { model }: { model: ConversationModel } = this; const { model }: { model: ConversationModel } = this;
// This will go to the trust store for the latest identity key information, // This will go to the trust store for the latest identity key information,
@ -3781,8 +3782,13 @@ Whisper.ConversationView = Whisper.View.extend({
return false; return false;
}, },
async sendMessage(message = '', mentions = [], options = {}) { async sendMessage(
message = '',
mentions = [],
options: { timestamp?: number; force?: boolean } = {}
) {
const { model }: { model: ConversationModel } = this; const { model }: { model: ConversationModel } = this;
const timestamp = options.timestamp || Date.now();
this.sendStart = Date.now(); this.sendStart = Date.now();
@ -3793,7 +3799,7 @@ Whisper.ConversationView = Whisper.View.extend({
if (contacts && contacts.length) { if (contacts && contacts.length) {
const sendAnyway = await this.showSendAnywayDialog(contacts); const sendAnyway = await this.showSendAnywayDialog(contacts);
if (sendAnyway) { if (sendAnyway) {
this.sendMessage(message, mentions, { force: true }); this.sendMessage(message, mentions, { force: true, timestamp });
return; return;
} }
@ -3822,7 +3828,11 @@ Whisper.ConversationView = Whisper.View.extend({
} }
const attachments = await this.getFiles(); const attachments = await this.getFiles();
const sendHQImages =
window.reduxStore &&
window.reduxStore.getState().composer.shouldSendHighQualityAttachments;
const sendDelta = Date.now() - this.sendStart; const sendDelta = Date.now() - this.sendStart;
window.log.info('Send pre-checks took', sendDelta, 'milliseconds'); window.log.info('Send pre-checks took', sendDelta, 'milliseconds');
model.sendMessage( model.sendMessage(
@ -3833,10 +3843,8 @@ Whisper.ConversationView = Whisper.View.extend({
undefined, // sticker undefined, // sticker
mentions, mentions,
{ {
sendHQImages: sendHQImages,
window.reduxStore && timestamp,
window.reduxStore.getState().composer
.shouldSendHighQualityAttachments,
} }
); );