amplitude / experiment-js-client

Amplitude Experiment client-side SDK for JavaScript
MIT License
7 stars 7 forks source link

Error: localStorage is not defined #87

Closed gsheppard closed 10 months ago

gsheppard commented 1 year ago

Version: 1.9.0 Framework: NextJS 13 Project: The SSR Demo in the node package

Issue: If you upgrade the client version to 1.9, it throws the above error (localStorage is not defined).

Short-term fix: Downgrading to 1.8.x fixes this

qasimitv commented 12 months ago

Yea I'm getting the same issue here - reverting back down to 1.8.2 resolve this issue.

bgiori commented 10 months ago

Hi all, sorry for the delay. This issue should be fixed in v1.9.6.

Thanks for your patience.

helloendoftheworld commented 9 months ago

I'm getting this error: Failed to load flags and variants from localStorage ReferenceError: localStorage is not defined.

Since it's not uncommon to use the SDK on server, would it make sense to have an equivalent storage (if needed?), or replace console.warn that prints the error with something else (e.g. console.debug) as console.warn in node.js [is just an alias for console.error ](https://nodejs.org/api/console.html#consolewarndata-args:~:text=The%20console.warn()%20function%20is%20an%20alias%20for%20console.error().) and will pollute error tracking tools?

smol-honk commented 8 months ago

Hi! I'm also getting this error with v1.9.7. I'm using it with NextJS so I'm trying to initialize this on the server. Getting the same error as @SherifGhoz

Failed to load flags and variants from localStorage ReferenceError: localStorage is not defined
    at LocalStorage.get (/Users/my.user/project/node_modules/@amplitude/experiment-js-client/dist/experiment.umd.js:2941:13)
tyiuhc commented 8 months ago

@SherifGhoz @smol-honk thank you for your patience on this, the relevant console.warn messages have been removed in v1.9.8