Skip to content

Commit f8f1c2f

Browse files
Merge pull request #30 from AnnaKudriasheva/fix/window-in-ssr-apps
Check window for SSR applications. Fixes #29
2 parents 3e277db + 0f69032 commit f8f1c2f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Promise._immediateFn = setAsap;
1616

1717
// side effects
1818
Promise.resolve().then(() => {
19-
if (!window.VGSCollect) {
19+
if (typeof window !== 'undefined' && !window.VGSCollect) {
2020
// DNS lookup
2121
preFetch();
2222
// Establish connection to the server
@@ -38,7 +38,7 @@ const loadVGSCollect = (config: IConfig = isRequired('config')) => {
3838
registerScriptLoading({ vaultId, environment, version });
3939

4040
return new Promise((resolve, reject) => {
41-
if (typeof window === undefined) {
41+
if (typeof window === 'undefined') {
4242
reject(ERROR_MESSAGE.IS_UNDEFINED('window'));
4343
return;
4444
}

0 commit comments

Comments
 (0)