File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1
1
import { REPLAY_SESSION_KEY , WINDOW } from '../../src/constants' ;
2
2
import type { ReplayContainer } from '../../src/types' ;
3
+ import { hasSessionStorage } from '../util/hasSessionStorage' ;
3
4
4
5
/**
5
6
* Removes the session from Session Storage and unsets session in replay instance
@@ -13,9 +14,7 @@ export function clearSession(replay: ReplayContainer): void {
13
14
* Deletes a session from storage
14
15
*/
15
16
function deleteSession ( ) : void {
16
- const hasSessionStorage = 'sessionStorage' in WINDOW ;
17
-
18
- if ( ! hasSessionStorage ) {
17
+ if ( ! hasSessionStorage ( ) ) {
19
18
return ;
20
19
}
21
20
Original file line number Diff line number Diff line change 1
1
import { REPLAY_SESSION_KEY , WINDOW } from '../constants' ;
2
2
import type { Session } from '../types' ;
3
+ import { hasSessionStorage } from '../util/hasSessionStorage' ;
3
4
import { makeSession } from './Session' ;
4
5
5
6
/**
6
7
* Fetches a session from storage
7
8
*/
8
9
export function fetchSession ( ) : Session | null {
9
- const hasSessionStorage = 'sessionStorage' in WINDOW ;
10
-
11
- if ( ! hasSessionStorage ) {
10
+ if ( ! hasSessionStorage ( ) ) {
12
11
return null ;
13
12
}
14
13
Original file line number Diff line number Diff line change 1
1
import { REPLAY_SESSION_KEY , WINDOW } from '../constants' ;
2
2
import type { Session } from '../types' ;
3
+ import { hasSessionStorage } from '../util/hasSessionStorage' ;
3
4
4
5
/**
5
6
* Save a session to session storage.
6
7
*/
7
8
export function saveSession ( session : Session ) : void {
8
- const hasSessionStorage = 'sessionStorage' in WINDOW ;
9
- if ( ! hasSessionStorage ) {
9
+ if ( ! hasSessionStorage ( ) ) {
10
10
return ;
11
11
}
12
12
Original file line number Diff line number Diff line change
1
+ import { WINDOW } from '../constants' ;
2
+
3
+ /** If sessionStorage is available. */
4
+ export function hasSessionStorage ( ) : boolean {
5
+ return 'sessionStorage' in WINDOW && ! ! WINDOW . sessionStorage ;
6
+ }
You can’t perform that action at this time.
0 commit comments