Skip to content

Commit

Permalink
CORE - Fixes issues #622 and #623 (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhil-narayana-klevu committed May 7, 2024
1 parent 264f193 commit a6a2fbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/klevu-core/src/usersession.ts
@@ -1,4 +1,4 @@
import { KlevuConfig } from "."
import { KlevuConfig } from "./index.js"
import { post } from "./connection/fetch.js"
import { Klaviyo } from "./connectors/klaviyo.js"
import { KlevuStorage } from "./utils/index.js"
Expand Down
14 changes: 11 additions & 3 deletions packages/klevu-core/src/utils/storage.ts
@@ -1,16 +1,24 @@
import { KlevuConfig } from ".."
import { KlevuConfig } from "../index.js"

export enum StorageType {
SESSION = "session",
LOCAL = "local",
}

const isSessionStorage = (storageType: StorageType) => {
return storageType === StorageType.SESSION && window.sessionStorage
return (
storageType === StorageType.SESSION &&
typeof window !== "undefined" &&
window.sessionStorage
)
}

const isLocalStorage = (storageType: StorageType) => {
return storageType === StorageType.LOCAL && window.localStorage
return (
storageType === StorageType.LOCAL &&
typeof window !== "undefined" &&
window.localStorage
)
}

export class KlevuStorage {
Expand Down

0 comments on commit a6a2fbc

Please sign in to comment.