-
Notifications
You must be signed in to change notification settings - Fork 276
Fix spammy resize observer exception in Posthog #1592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
c4335d2
4c0d89e
9392cd3
f75adef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import type { CaptureResult } from 'posthog-js' | ||
|
|
||
| const IGNORED_EXCEPTION_PATTERNS = [ | ||
| /ResizeObserver loop (completed with undelivered notifications|limit exceeded)/, | ||
| ] | ||
|
|
||
| const shouldIgnoreException = (value: unknown): boolean => | ||
| typeof value === 'string' && | ||
| IGNORED_EXCEPTION_PATTERNS.some((pattern) => pattern.test(value)) | ||
|
|
||
| export const filterExceptions = ( | ||
| event: CaptureResult | null | ||
| ): CaptureResult | null => { | ||
| if (event?.event !== '$exception') return event | ||
|
|
||
| const exceptionList = event.properties?.['$exception_list'] | ||
| const values: unknown[] = Array.isArray(exceptionList) | ||
| ? exceptionList.map((exception) => exception?.value) | ||
| : [] | ||
|
|
||
| values.push(event.properties?.['$exception_message']) | ||
|
|
||
| return values.some(shouldIgnoreException) ? null : event | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { tokenize, createDefaultGrammar } from '@livekit/components-core' | ||
| import { ReactNode } from 'react' | ||
|
|
||
| const defaultGrammar = Object.freeze(createDefaultGrammar()) | ||
|
|
||
| export function formatChatMessageLinks(message: string): ReactNode { | ||
| const trimmedMessage = message.replace(/^[\r\n]+|[\r\n]+$/g, '') | ||
|
Check warning on line 7 in src/frontend/src/features/chat/utils.tsx
|
||
| return tokenize(trimmedMessage, defaultGrammar).map((tok, i) => { | ||
| if (typeof tok === `string`) { | ||
| return tok | ||
| } else { | ||
| const content = tok.content.toString() | ||
| const href = | ||
| tok.type === `url` | ||
| ? /^http(s?):\/\//.test(content) | ||
| ? content | ||
| : `https://${content}` | ||
|
Check warning on line 17 in src/frontend/src/features/chat/utils.tsx
|
||
| : `mailto:${content}` | ||
|
Comment on lines
+11
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 8 'createDefaultGrammar|`@livekit/components-core`|https\?:' . \
--glob '*.ts' --glob '*.tsx' --glob 'package.json' --glob '*lock*' || trueRepository: suitenumerique/meet Length of output: 50375 🌐 Web query:
💡 Result: In Citations:
🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- package declarations ---'
rg -n -C 3 '"`@livekit/components-`(core|react)"|createDefaultGrammar|formatChatMessageLinks' \
src/frontend/package.json src/frontend/package-lock.json src/frontend/src/features/chat \
--glob '*.ts' --glob '*.tsx' --glob 'package.json' --glob '*lock*' || true
printf '%s\n' '--- local tests and chat utilities ---'
fd -i 'chat|utils' src/frontend --type f | sort | head -80
rg -n -C 4 'formatChatMessageLinks|tokenize\\(|createDefaultGrammar' src/frontend --glob '*test*' --glob '*spec*' --glob '*.ts' --glob '*.tsx' || trueRepository: suitenumerique/meet Length of output: 4787 🏁 Script executed: #!/bin/bash
set -euo pipefail
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
curl -fsSL 'https://cdn.jsdelivr.net/npm/@livekit/components-core@0.12.13/dist/index.mjs' \
-o "$tmp/index.mjs"
printf '%s\n' '--- exported grammar/tokenizer implementation ---'
rg -n -C 12 'createDefaultGrammar|createUrlRegExp|function tokenize|const tokenize|url:' \
"$tmp/index.mjs" | head -240
printf '%s\n' '--- source map references ---'
curl -fsSL 'https://unpkg.com/@livekit/components-core@0.12.13/dist/index.mjs.map' \
-o "$tmp/index.mjs.map"
python3 - "$tmp/index.mjs.map" <<'PY'
import json, sys
data = json.load(open(sys.argv[1]))
for name, source in zip(data.get("sources", []), data.get("sourcesContent", [])):
if any(x in source for x in ("createDefaultGrammar", "createUrlRegExp", "function tokenize")):
print(f"--- {name} ---")
lines = source.splitlines()
for i, line in enumerate(lines):
if any(x in line for x in ("createDefaultGrammar", "createUrlRegExp", "function tokenize")):
lo, hi = max(0, i - 8), min(len(lines), i + 80)
print("\n".join(f"{j+1}: {lines[j]}" for j in range(lo, hi)))
PYRepository: suitenumerique/meet Length of output: 9712 🏁 Script executed: #!/bin/bash
set -euo pipefail
node - <<'JS'
const re = /^http(s?):\/\//;
const fixed = /^https?:\/\//i;
for (const value of ['http://example.com', 'https://example.com', 'HTTP://example.com', 'HtTpS://example.com']) {
console.log(JSON.stringify({ value, current: re.test(value), proposed: fixed.test(value) }));
}
JSRepository: suitenumerique/meet Length of output: 409 Make the HTTP scheme check case-insensitive.
🤖 Prompt for AI Agents |
||
| return ( | ||
| <a | ||
| className="lk-chat-link" | ||
| key={i} | ||
|
Check warning on line 22 in src/frontend/src/features/chat/utils.tsx
|
||
| href={href} | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| > | ||
| {content} | ||
| </a> | ||
| ) | ||
| } | ||
| }) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.