Skip to content

Error "TypeError: t2.handlePageUnload is not a function" after page refresh #3251

@Vadim51515

Description

@Vadim51515

Bug description

After refreshing the page, the error "TypeError: t2.handlePageUnload is not a function" appears in the console

How to reproduce

  1. Open the browser
  2. Enable the "preserve log" function
  3. Refresh the page
  4. The console error is "TypeError: t2.handlePageUnload is not a function"

Related sub-libraries

  • All of them
  • posthog-js (web)
  • posthog-js-lite (web lite)
  • posthog-node
  • posthog-react-native
  • @posthog/react
  • @posthog/ai
  • @posthog/convex
  • @posthog/nextjs-config
  • @posthog/nuxt
  • @posthog/rollup-plugin
  • @posthog/webpack-plugin

Additional context

After updating the "posthog-js" version, the error "TypeError e.handlePageUnload is not a function" started falling in the Sentry of the work project. It occurs when the user refreshes the page, so it can only be noticed in the console when the "preserve log" mode is enabled

The path to the error is "node_modules/posthog-js/dist/module.js"

The problem appeared in version 1.310.0

Presumably, it could appear because of this change.

My config looks like this (the "api_host" and "defaults" fields are hidden) :

export const postHogConfig: Partial<PostHogConfig> = {
    api_host: '',
    defaults: '',
    session_recording: {
        recordBody: true,
        recordCrossOriginIframes: true,
        recordHeaders: true,
    },
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions