Files
documenso/packages/lib/universal/fire-and-forget.ts
Lucas Smith ae4b56dd88 feat: optimise posthog usage and add error tracking (#3301)
Disable autocapture and person profiles for anonymous users, and
redact signing tokens from captured URLs.

Manually wire exception capture into the signing, editor and embed
flows with recipient/envelope context for debugging recipient-reported
issues.

Track activation events (webhooks, api tokens, direct links, embed
sessions) server-side with org attribution, and drop client events
already tracked in-app.
2026-08-27 11:11:51 +10:00

15 lines
454 B
TypeScript

/**
* Run a function without awaiting it or letting it affect the caller.
*
* Both synchronous throws and promise rejections are swallowed, making this
* safe to call from request handlers and loaders for side work such as
* analytics that must never block or fail the response.
*/
export const fireAndForget = (fn: () => unknown) => {
try {
void Promise.resolve(fn()).catch(() => null);
} catch {
// Swallow synchronous errors.
}
};