Amplitude-JavaScript
Amplitude-JavaScript copied to clipboard
"[Amplitude] TypeError: undefined is not an object (evaluating 't._metadataStorage.save')" errors seen on Sentry
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: https://github.com/amplitude/Amplitude-JavaScript/blob/03c0a890d578db1ada383cf1e6195d71275bac44/src/amplitude-client.js#L735
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.
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?