Revert "feat(logging): report important keyboard events"
This reverts commit b59da8f7e4.
This commit is contained in:
@@ -31,12 +31,6 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) {
|
|||||||
containerRef: barRef,
|
containerRef: barRef,
|
||||||
active: isFocused,
|
active: isFocused,
|
||||||
onKeyboardDismiss: () => {
|
onKeyboardDismiss: () => {
|
||||||
log.important("info", "[chat-input-bar] keyboard dismissed", {
|
|
||||||
contentLength: input.length,
|
|
||||||
hasContent,
|
|
||||||
disabled,
|
|
||||||
wasFocused: isFocused,
|
|
||||||
});
|
|
||||||
setIsFocused(false);
|
setIsFocused(false);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -45,21 +39,11 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) {
|
|||||||
setInput(value);
|
setInput(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleFocusChange = (focused: boolean) => {
|
|
||||||
log.important("info", "[chat-input-bar] focus change", {
|
|
||||||
focused,
|
|
||||||
contentLength: input.length,
|
|
||||||
hasContent,
|
|
||||||
disabled,
|
|
||||||
});
|
|
||||||
setIsFocused(focused);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSend = (source: "click" | "keyboard" | "pointerdown") => {
|
const handleSend = (source: "click" | "keyboard" | "pointerdown") => {
|
||||||
if (source === "click") {
|
if (source === "click") {
|
||||||
const elapsed = Date.now() - lastPointerSendAtRef.current;
|
const elapsed = Date.now() - lastPointerSendAtRef.current;
|
||||||
if (elapsed >= 0 && elapsed < POINTER_SEND_CLICK_DEDUPE_MS) {
|
if (elapsed >= 0 && elapsed < POINTER_SEND_CLICK_DEDUPE_MS) {
|
||||||
log.important("info", "[chat-input-bar] suppress duplicate click", {
|
log.debug("[chat-input-bar] suppress duplicate click", {
|
||||||
elapsed,
|
elapsed,
|
||||||
contentLength: input.length,
|
contentLength: input.length,
|
||||||
hasContent,
|
hasContent,
|
||||||
@@ -78,13 +62,6 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) {
|
|||||||
disabled,
|
disabled,
|
||||||
isFocused,
|
isFocused,
|
||||||
});
|
});
|
||||||
log.important("info", "[chat-input-bar] send", {
|
|
||||||
source,
|
|
||||||
contentLength: input.length,
|
|
||||||
hasContent,
|
|
||||||
disabled,
|
|
||||||
isFocused,
|
|
||||||
});
|
|
||||||
dispatch({ type: "ChatSendMessage", content: input });
|
dispatch({ type: "ChatSendMessage", content: input });
|
||||||
setInput("");
|
setInput("");
|
||||||
textareaRef.current?.focus();
|
textareaRef.current?.focus();
|
||||||
@@ -106,7 +83,7 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) {
|
|||||||
value={input}
|
value={input}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
onSubmit={() => handleSend("keyboard")}
|
onSubmit={() => handleSend("keyboard")}
|
||||||
onFocusChange={handleFocusChange}
|
onFocusChange={setIsFocused}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
<ChatSendButton
|
<ChatSendButton
|
||||||
|
|||||||
@@ -67,14 +67,10 @@ export function useKeyboardHeight({
|
|||||||
const environment = getKeyboardAdaptEnvironment();
|
const environment = getKeyboardAdaptEnvironment();
|
||||||
if (!shouldEnableKeyboardAdaptation(environment)) {
|
if (!shouldEnableKeyboardAdaptation(environment)) {
|
||||||
resetInputLiftVar();
|
resetInputLiftVar();
|
||||||
const payload = {
|
log.debug("[keyboard] disabled", {
|
||||||
reason: "not-android-facebook-fallback-device",
|
reason: "not-android-facebook-fallback-device",
|
||||||
environment,
|
environment,
|
||||||
};
|
});
|
||||||
log.debug("[keyboard] disabled", payload);
|
|
||||||
if (environment.isAndroid && environment.isFacebookInAppBrowser) {
|
|
||||||
log.important("info", "[keyboard] disabled", payload);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +82,7 @@ export function useKeyboardHeight({
|
|||||||
let lastInputLift = -1;
|
let lastInputLift = -1;
|
||||||
const focusedAt = active ? performance.now() : 0;
|
const focusedAt = active ? performance.now() : 0;
|
||||||
|
|
||||||
log.important("info", "[keyboard] environment", environment);
|
log.debug("[keyboard] environment", environment);
|
||||||
|
|
||||||
const clearTimers = () => {
|
const clearTimers = () => {
|
||||||
timeoutIds.forEach((id) => window.clearTimeout(id));
|
timeoutIds.forEach((id) => window.clearTimeout(id));
|
||||||
@@ -103,7 +99,7 @@ export function useKeyboardHeight({
|
|||||||
|
|
||||||
lastInputLift = nextLift;
|
lastInputLift = nextLift;
|
||||||
setInputLiftVar(nextLift);
|
setInputLiftVar(nextLift);
|
||||||
log.important("info", "[keyboard] apply", {
|
log.debug("[keyboard] apply", {
|
||||||
reason,
|
reason,
|
||||||
inputLift: nextLift,
|
inputLift: nextLift,
|
||||||
fallback: nextLift === FALLBACK_INPUT_LIFT_PX,
|
fallback: nextLift === FALLBACK_INPUT_LIFT_PX,
|
||||||
@@ -118,7 +114,7 @@ export function useKeyboardHeight({
|
|||||||
applyLift(0, reason);
|
applyLift(0, reason);
|
||||||
blurKeyboardTarget(targetRef?.current);
|
blurKeyboardTarget(targetRef?.current);
|
||||||
onKeyboardDismissRef.current?.();
|
onKeyboardDismissRef.current?.();
|
||||||
log.important("info", "[keyboard] released", {
|
log.debug("[keyboard] released", {
|
||||||
reason,
|
reason,
|
||||||
snapshot: formatSnapshot(readKeyboardSnapshot()),
|
snapshot: formatSnapshot(readKeyboardSnapshot()),
|
||||||
});
|
});
|
||||||
@@ -175,7 +171,7 @@ export function useKeyboardHeight({
|
|||||||
const target = targetRef?.current;
|
const target = targetRef?.current;
|
||||||
const container = containerRef?.current;
|
const container = containerRef?.current;
|
||||||
if (event.target instanceof Node && container?.contains(event.target)) {
|
if (event.target instanceof Node && container?.contains(event.target)) {
|
||||||
log.important("info", "[keyboard] keep active for input container tap", {
|
log.debug("[keyboard] keep active for input container tap", {
|
||||||
snapshot: formatSnapshot(readKeyboardSnapshot()),
|
snapshot: formatSnapshot(readKeyboardSnapshot()),
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as Sentry from "@sentry/nextjs";
|
import * as Sentry from "@sentry/nextjs";
|
||||||
import type { CaptureContext, SeverityLevel } from "@sentry/nextjs";
|
import type { CaptureContext, SeverityLevel } from "@sentry/nextjs";
|
||||||
|
|
||||||
export type RemoteLogLevel = "debug" | "info" | "warn" | "error" | "fatal";
|
export type RemoteLogLevel = "warn" | "error" | "fatal";
|
||||||
|
|
||||||
export interface SentryLogPayload {
|
export interface SentryLogPayload {
|
||||||
level: RemoteLogLevel;
|
level: RemoteLogLevel;
|
||||||
|
|||||||
+3
-13
@@ -79,11 +79,6 @@ export class Logger {
|
|||||||
this.write("fatal", args);
|
this.write("fatal", args);
|
||||||
}
|
}
|
||||||
|
|
||||||
important(level: RemoteLogLevel, ...args: LogArgs): void {
|
|
||||||
Logger.reportProductionLog(level, this.component, args, true);
|
|
||||||
this.writeLocal(level, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 把日志中的任意数据转成人眼友好的多行文本。
|
* 把日志中的任意数据转成人眼友好的多行文本。
|
||||||
* - object / array: pretty JSON
|
* - object / array: pretty JSON
|
||||||
@@ -151,11 +146,8 @@ export class Logger {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private write(level: LogLevel, args: LogArgs): void {
|
private write(level: LogLevel, args: LogArgs): void {
|
||||||
Logger.reportProductionLog(level, this.component, args);
|
Logger.reportImportantProductionLog(level, this.component, args);
|
||||||
this.writeLocal(level, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
private writeLocal(level: LogLevel, args: LogArgs): void {
|
|
||||||
if (Logger.shouldUseBrowserConsole()) {
|
if (Logger.shouldUseBrowserConsole()) {
|
||||||
Logger.writeBrowserConsole(level, this.component, args);
|
Logger.writeBrowserConsole(level, this.component, args);
|
||||||
return;
|
return;
|
||||||
@@ -192,14 +184,12 @@ export class Logger {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static reportProductionLog(
|
private static reportImportantProductionLog(
|
||||||
level: LogLevel,
|
level: LogLevel,
|
||||||
component: string,
|
component: string,
|
||||||
args: LogArgs,
|
args: LogArgs,
|
||||||
force = false,
|
|
||||||
): void {
|
): void {
|
||||||
if (!force && !Logger.shouldReportToRemote(level)) return;
|
if (!Logger.shouldReportToRemote(level)) return;
|
||||||
if (force && !AppEnvUtil.isProduction()) return;
|
|
||||||
|
|
||||||
const { message, data } = Logger.toBrowserConsolePayload(args);
|
const { message, data } = Logger.toBrowserConsolePayload(args);
|
||||||
reportSentryLog({
|
reportSentryLog({
|
||||||
|
|||||||
Reference in New Issue
Block a user