chore: 导入清理前的完整工程状态(含 Capacitor 原生壳,作为回滚备份点)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { RecipeReport, SearchSignal } from '~/adapters/feedback'
|
||||
import { createFeedbackRemote } from '~/adapters/feedback'
|
||||
import { getDeviceId, signalKey } from '~/utils/feedback'
|
||||
|
||||
const sentSignals = new Set<string>()
|
||||
|
||||
/**
|
||||
* Recipe reports and anonymous search signals, sent to the `cook-feedback`
|
||||
* cloud function. Signals are best effort and never surface errors.
|
||||
*/
|
||||
export function useRecipeFeedback() {
|
||||
const auth = useYunlefunAuth()
|
||||
const remote = () => createFeedbackRemote(auth.callFunction, getDeviceId())
|
||||
|
||||
async function report(input: RecipeReport): Promise<void> {
|
||||
await remote().report(input)
|
||||
}
|
||||
|
||||
function signal(input: SearchSignal): void {
|
||||
if (!import.meta.client || !input.stuff.length)
|
||||
return
|
||||
const key = signalKey(input)
|
||||
if (sentSignals.has(key))
|
||||
return
|
||||
sentSignals.add(key)
|
||||
// Fire once per session even if it fails, so an unconfigured backend is not retried on every change.
|
||||
remote().signal(input).catch(() => {})
|
||||
}
|
||||
|
||||
return { report, signal }
|
||||
}
|
||||
Reference in New Issue
Block a user