commit 7d9f861971fcb254fd88c1746fa087a05eeaf0cf
parent 0cd1b1fb08c2f36f7ec9c05f5f81034556ecb1ef
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Wed, 5 Dec 2018 00:25:26 +0100
log window.open
Diffstat:
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/lib/popup-window/index.js b/src/lib/popup-window/index.js
@@ -1,3 +1,5 @@
+import logging from 'lib/logging';
+
function openPopupWindow(url, width, uniqName = null) {
var left, top, height,
screenLeft = screen.availLeft || 0,
@@ -19,8 +21,20 @@ function openPopupWindow(url, width, uniqName = null) {
height = window.innerHeight;
var features = 'width=' + width + ',height=' + height + ',left=' + left + ',top=' + top;
features += ',resizable,scrollbars';
- window.open(url, uniqName, features)
- .focus();
+ const eventId = logging.randId();
+ url = `http://nakarte.me/r/?url=${encodeURIComponent(url)}&event=${eventId}`;
+ let error;
+ let isClosed;
+ let win;
+ try {
+ win = window.open(url, uniqName, features);
+ } catch (e) {
+ error = e;
+ }
+ if (win) {
+ isClosed = win.closed;
+ }
+ logging.logEvent('openPopupWindow', {win: !!win, error, isClosed, eventId});
}
export {openPopupWindow};
\ No newline at end of file