Skip to content

Conversation

tifandotme
Copy link

@tifandotme tifandotme commented Oct 3, 2025

Problem

PostHog/posthog#38691

Changes

Added validation to skip non-Element DOM nodes in autocapturePropertiesForElement. The code was trying to access .tagName on nodes that don't have this property (text nodes, comment nodes, etc), causing crashes

Two checks added:

  • Check parentNode is an Element before adding it to the list
  • Skip non-Element nodes when iterating using the existing isElementNode() helper

Also fixed a type mismatch where getAttribute('href') returns string | null but the code expected string | false, causing a TypeScript error

Release info Sub-libraries affected

Libraries affected

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react
  • @posthog/ai
  • @posthog/nextjs-config

Checklist

  • Tests for new code
  • Accounted for the impact of any changes across different platforms
  • Accounted for backwards compatibility of any changes (no breaking changes!)
  • Took care not to unnecessarily increase the bundle size

If releasing new changes

  • Ran pnpm changeset to generate a changeset file
  • Added the "release" label to the PR to indicate we're publishing new versions for the affected packages

Copy link

vercel bot commented Oct 3, 2025

@tifandotme is attempting to deploy a commit to the PostHog Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

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.

1 participant