Skip to content

Fix home page JSON-LD crashing structured-data readers#19

Draft
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/jsonld-graph-context
Draft

Fix home page JSON-LD crashing structured-data readers#19
posthog[bot] wants to merge 1 commit into
mainfrom
posthog-code/jsonld-graph-context

Conversation

@posthog

@posthog posthog Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Summary

The home page injected its schema.org JSON-LD as a bare top-level array (JSON.stringify([organizationJsonLd, productJsonLd, faqJsonLd])). Each object carried its own @context, but the array itself had none, so any consumer that treats the parsed JSON-LD as a single object reads r["@context"]undefined and crashes calling .toLowerCase() on it.

This wraps the three entities in a single @graph with one top-level @context, and drops the now-redundant per-object @context in seo.ts. This both removes the crash trigger and produces a more standard structured-data shape (a small SEO correctness gain).

Why

Error tracking captured an unhandled TypeError: undefined is not an object (evaluating 'r["@context"].toLowerCase') on https://amend.sh/ (Safari 26.3, 2026-06-06). The crashing code is an injected third-party JSON-LD reader (browser extension / structured-data reader), but the bare-array shape is what triggers it.


Created with PostHog Code from an inbox report.

The home page injected its JSON-LD as a bare top-level array, so any
consumer treating the parsed structured data as a single object read
`undefined["@context"]` and crashed. Wrap the three entities in a
`@graph` with one top-level `@context` and drop the now-redundant
per-object `@context`.

Generated-By: PostHog Code
Task-Id: 4d331e29-d220-4346-b6c8-43e10e90a2be
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants