web-manager 3.1.53 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +84 -24
- package/package.json +2 -2
package/index.js
CHANGED
@@ -172,14 +172,29 @@ function Manager() {
|
|
172
172
|
});
|
173
173
|
|
174
174
|
// Mouse leave event
|
175
|
-
document.addEventListener('mouseleave', function() {
|
175
|
+
document.addEventListener('mouseleave', function () {
|
176
176
|
showExitPopup(self);
|
177
177
|
});
|
178
178
|
|
179
179
|
// Window blur event
|
180
|
-
window.addEventListener('blur', function() {
|
180
|
+
window.addEventListener('blur', function () {
|
181
181
|
showExitPopup(self);
|
182
182
|
});
|
183
|
+
|
184
|
+
// Re-focus events
|
185
|
+
window.addEventListener('focus', function () {
|
186
|
+
refreshNewVersion(self);
|
187
|
+
});
|
188
|
+
window.addEventListener('online', function () {
|
189
|
+
refreshNewVersion(self);
|
190
|
+
});
|
191
|
+
setInterval(function () {
|
192
|
+
refreshNewVersion(self);
|
193
|
+
}, self.properties.meta.environment === 'development'
|
194
|
+
? 1000
|
195
|
+
: (1000 * 60 * 60 * 24 * 7)
|
196
|
+
);
|
197
|
+
|
183
198
|
}
|
184
199
|
|
185
200
|
function _authStateHandler(self, user) {
|
@@ -415,7 +430,7 @@ function Manager() {
|
|
415
430
|
message: 'Get 15% off your purchase of our <strong>Premium plans</strong>. <br><br> Get access to all features and unlimited usage.',
|
416
431
|
okButton: {
|
417
432
|
text: 'Claim 15% Discount',
|
418
|
-
link: '/pricing?utm_source=exitpopup&utm_medium=popup&utm_campaign=
|
433
|
+
link: '/pricing?utm_source=exitpopup&utm_medium=popup&utm_campaign={pathname}',
|
419
434
|
},
|
420
435
|
},
|
421
436
|
},
|
@@ -545,8 +560,11 @@ function Manager() {
|
|
545
560
|
var pagePathname = window.location.pathname;
|
546
561
|
var redirect = false;
|
547
562
|
|
548
|
-
|
549
|
-
|
563
|
+
var previousUTMTimestamp = new Date(store.get('utm.timestamp', 0));
|
564
|
+
var UTMDifferenceInHours = (new Date() - previousUTMTimestamp) / 36e5;
|
565
|
+
|
566
|
+
self.properties.page.queryString.forEach(function (value, key) {
|
567
|
+
if (key.startsWith('utm_') && UTMDifferenceInHours > 72) {
|
550
568
|
store.set('utm.tags.' + key, value);
|
551
569
|
store.set('utm.timestamp', new Date().toISOString());
|
552
570
|
}
|
@@ -1082,17 +1100,19 @@ function Manager() {
|
|
1082
1100
|
function showExitPopup(self) {
|
1083
1101
|
var exitPopupSettings = self.properties.options.exitPopup;
|
1084
1102
|
|
1085
|
-
if (!exitPopupSettings.enabled)
|
1103
|
+
if (!exitPopupSettings.enabled) {
|
1104
|
+
return;
|
1105
|
+
};
|
1086
1106
|
|
1087
1107
|
var lastTriggered = new Date(storage.get('exitPopup.lastTriggered', 0));
|
1088
1108
|
var now = new Date();
|
1089
1109
|
var diff = now - lastTriggered;
|
1090
1110
|
|
1091
|
-
if (diff < exitPopupSettings.config.timeout)
|
1111
|
+
if (diff < exitPopupSettings.config.timeout) {
|
1112
|
+
return;
|
1113
|
+
};
|
1092
1114
|
|
1093
1115
|
showBootstrapModal(exitPopupSettings);
|
1094
|
-
|
1095
|
-
storage.set('exitPopup.lastTriggered', now.toISOString());
|
1096
1116
|
}
|
1097
1117
|
|
1098
1118
|
function showBootstrapModal(exitPopupSettings) {
|
@@ -1100,22 +1120,62 @@ function Manager() {
|
|
1100
1120
|
? exitPopupSettings.config.handler()
|
1101
1121
|
: true;
|
1102
1122
|
|
1103
|
-
if (!proceed) {
|
1123
|
+
if (!proceed) {
|
1124
|
+
return;
|
1125
|
+
}
|
1104
1126
|
|
1105
1127
|
var $el = document.getElementById('modal-exit-popup');
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1128
|
+
try {
|
1129
|
+
var modal = new bootstrap.Modal($el);
|
1130
|
+
modal.show();
|
1131
|
+
$el.removeAttribute('hidden');
|
1132
|
+
|
1133
|
+
var $title = $el.querySelector('.modal-title');
|
1134
|
+
var $message = $el.querySelector('.modal-body');
|
1135
|
+
var $okButton = $el.querySelector('.modal-footer .btn-primary');
|
1136
|
+
var config = exitPopupSettings.config;
|
1137
|
+
|
1138
|
+
var link = config.okButton.link
|
1139
|
+
.replace(/{pathname}/ig, window.location.pathname)
|
1140
|
+
|
1141
|
+
$title.innerHTML = config.title;
|
1142
|
+
$message.innerHTML = config.message;
|
1143
|
+
$okButton.innerHTML = config.okButton.text;
|
1144
|
+
$okButton.setAttribute('href', link);
|
1145
|
+
|
1146
|
+
storage.set('exitPopup.lastTriggered', new Date().toISOString());
|
1147
|
+
} catch (e) {
|
1148
|
+
console.warn(e);
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
|
1152
|
+
function refreshNewVersion(self) {
|
1153
|
+
console.log('refreshNewVersion()');
|
1154
|
+
|
1155
|
+
fetch('/@output/build/build.json' + '?cb=' + new Date().getTime())
|
1156
|
+
.then(function (res) {
|
1157
|
+
if (res.ok) {
|
1158
|
+
return res.json();
|
1159
|
+
} else {
|
1160
|
+
throw new Error('Bad response');
|
1161
|
+
}
|
1162
|
+
})
|
1163
|
+
.then(function (data) {
|
1164
|
+
var buildTime = new Date(data['npm-build'].timestamp_utc);
|
1165
|
+
var startTime = self.properties.page.startTime;
|
1166
|
+
|
1167
|
+
if (buildTime > startTime) {
|
1168
|
+
// console.log('refreshNewVersion(): Refreshing...');
|
1169
|
+
|
1170
|
+
window.onbeforeunload = function () {
|
1171
|
+
return undefined;
|
1172
|
+
}
|
1173
|
+
window.location.reload(true);
|
1174
|
+
}
|
1175
|
+
})
|
1176
|
+
.catch(function (e) {
|
1177
|
+
console.error(e);
|
1178
|
+
})
|
1119
1179
|
}
|
1120
1180
|
|
1121
1181
|
/*
|
@@ -1394,7 +1454,7 @@ function Manager() {
|
|
1394
1454
|
event.user.uid = storage.get('user.auth.uid', '');
|
1395
1455
|
// event.user.ip = storage.get('user.ip', '');
|
1396
1456
|
|
1397
|
-
console.
|
1457
|
+
console.error('[SENTRY] Caught error', event, hint);
|
1398
1458
|
|
1399
1459
|
if (self.isDevelopment()) {
|
1400
1460
|
return null;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "web-manager",
|
3
|
-
"version": "3.1
|
3
|
+
"version": "3.2.1",
|
4
4
|
"description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -36,4 +36,4 @@
|
|
36
36
|
"firebase": "^9.23.0",
|
37
37
|
"lazysizes": "^5.3.2"
|
38
38
|
}
|
39
|
-
}
|
39
|
+
}
|