diff --git a/src/posthog-persistence.ts b/src/posthog-persistence.ts index 71017e659..5d70c625a 100644 --- a/src/posthog-persistence.ts +++ b/src/posthog-persistence.ts @@ -38,7 +38,6 @@ export class PostHogPersistence { expire_days: number | undefined default_expiry: number | undefined cross_subdomain: boolean | undefined - user_state: 'anonymous' | 'identified' constructor(config: PostHogConfig) { // clean chars that aren't accepted by the http spec for cookie values @@ -81,17 +80,13 @@ export class PostHogPersistence { this.storage = memoryStore } else if (storage_type === 'cookie') { this.storage = cookieStore - } else { + } else if (localPlusCookieStore.is_supported()) { // selected storage type wasn't supported, fallback to 'localstorage+cookie' if possible - if (localPlusCookieStore.is_supported()) { - this.storage = localPlusCookieStore - } else { - this.storage = cookieStore - } + this.storage = localPlusCookieStore + } else { + this.storage = cookieStore } - this.user_state = 'anonymous' - this.load() this.update_config(config) this.save()