Skip to content
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

"[Amplitude] TypeError: undefined is not an object (evaluating 't._metadataStorage.save')" errors seen on Sentry #611

Closed
bitttttten opened this issue Oct 18, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bitttttten
Copy link

bitttttten commented Oct 18, 2024

We are seeing "[Amplitude] TypeError: undefined is not an object (evaluating 't._metadataStorage.save')" errors from Sentry. We also found the _metadataStorage.save code here:

scope._metadataStorage.save(cookieData);

We are wondering if this is something like a bug in the amplitude client, or are we setting up Amplitude incorrectly?

Environment

{
"node_modules/amplitude-js": {
      "version": "8.21.9",
      "resolved": "https://registry.npmjs.org/amplitude-js/-/amplitude-js-8.21.9.tgz",
      "integrity": "sha512-d0jJH00wbXu7sxKtVwkdSXtVffjqdUrxuACKlnzP7jU5qt9wriXXMgHifdH5Oq+buKmyF8wKL9S02gAykysURA==",
      "dependencies": {
        "@amplitude/analytics-connector": "^1.4.6",
        "@amplitude/ua-parser-js": "0.7.33",
        "@amplitude/utils": "^1.10.2",
        "@babel/runtime": "^7.21.0",
        "blueimp-md5": "^2.19.0",
        "query-string": "8.1.0"
      }
    },
}

How we initialise:

export const Amplitude = () => {
  const userId = useUserId()
  const amplitudeCookieSessionId = useCookie(AMPLITUDE_SESSION_ID_COOKIE_NAME)

  React.useEffect(() => {
    if (deviceId) {
      amplitude.getInstance().setDeviceId(deviceId)
    }
  
    amplitude.getInstance().init(AMPLITUDE_API_KEY, undefined, {
      includeUtm: true,
      includeReferrer: true,
      includeGclid: true,
      saveParamsReferrerOncePerSession: true,
      unsetParamsReferrerOnNewSession: true,
    })
  }, [amplitudeCookieDeviceId])

  React.useEffect(() => {
    amplitude.getInstance().setUserId(userId)
  }, [userId])

  return null
}

We've been trying to dig around but we have had no leads. Let me know if anything sticks out, happy to help try and debug too.

@bitttttten bitttttten added the bug Something isn't working label Oct 18, 2024
@Mercy811
Copy link
Contributor

Hi @bitttttten, thanks for choosing Amplitude. To further debug this error, we need more info.

  • How often do you see this error?
  • Could you provide the website so that we can test on?
  • What device and environment did this error was on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants