core-outline 1.1.15 → 1.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +49 -21
- package/dist/index.js +49 -21
- package/package.json +1 -1
- package/src/components/CoreOutline/CoreOutline.js +53 -19
package/dist/index.es.js
CHANGED
|
@@ -6422,13 +6422,56 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6422
6422
|
}));
|
|
6423
6423
|
return _authorizeApp.apply(this, arguments);
|
|
6424
6424
|
}
|
|
6425
|
+
var offLoadFunctionality = function offLoadFunctionality() {
|
|
6426
|
+
var data = JSON.stringify({
|
|
6427
|
+
data_source_id: data_source_id,
|
|
6428
|
+
sessionId: sessionId,
|
|
6429
|
+
formatted_events: JSON.stringify(events),
|
|
6430
|
+
raw_events: JSON.stringify(replayEvents)
|
|
6431
|
+
});
|
|
6432
|
+
socket.send({
|
|
6433
|
+
topic: "session-data",
|
|
6434
|
+
data_source_id: data_source_id,
|
|
6435
|
+
session_id: localStorage.getItem("coreOutlineSessionId"),
|
|
6436
|
+
start_date: new Date().toLocaleString(),
|
|
6437
|
+
latitude: location.latitude,
|
|
6438
|
+
longitude: location.longitude,
|
|
6439
|
+
browser: browser,
|
|
6440
|
+
event_id: "SESSION_END"
|
|
6441
|
+
});
|
|
6442
|
+
if (navigator.sendBeacon) {
|
|
6443
|
+
navigator.sendBeacon("http://localhost:5000/upload-events", data);
|
|
6444
|
+
} else {
|
|
6445
|
+
fetch("http://localhost:5000/upload-events", {
|
|
6446
|
+
method: 'POST',
|
|
6447
|
+
body: data,
|
|
6448
|
+
keepalive: true,
|
|
6449
|
+
headers: {
|
|
6450
|
+
'Content-Type': 'application/json'
|
|
6451
|
+
}
|
|
6452
|
+
})["catch"](function (err) {
|
|
6453
|
+
return console.error('Upload failed:', err);
|
|
6454
|
+
});
|
|
6455
|
+
}
|
|
6456
|
+
};
|
|
6425
6457
|
useEffect(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
6458
|
+
var handleBeforeUnload, handleVisibilityChange;
|
|
6426
6459
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
6427
6460
|
while (1) switch (_context.prev = _context.next) {
|
|
6428
6461
|
case 0:
|
|
6429
|
-
|
|
6462
|
+
handleBeforeUnload = function handleBeforeUnload() {
|
|
6463
|
+
offLoadFunctionality();
|
|
6464
|
+
};
|
|
6465
|
+
handleVisibilityChange = function handleVisibilityChange() {
|
|
6466
|
+
if (document.visibilityState === 'hidden') {
|
|
6467
|
+
offLoadFunctionality();
|
|
6468
|
+
}
|
|
6469
|
+
};
|
|
6470
|
+
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
6471
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
6472
|
+
_context.next = 6;
|
|
6430
6473
|
return authorizeApp(data_source_id, data_source_secret);
|
|
6431
|
-
case
|
|
6474
|
+
case 6:
|
|
6432
6475
|
localStorage.setItem("coreOutlineSessionId", sessionId);
|
|
6433
6476
|
localStorage.setItem("coreOutlineDataSourceIdId", data_source_id);
|
|
6434
6477
|
console.log("Session", sessionId);
|
|
@@ -6443,6 +6486,9 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6443
6486
|
event_id: "SESSION_START"
|
|
6444
6487
|
});
|
|
6445
6488
|
return _context.abrupt("return", function () {
|
|
6489
|
+
offLoadFunctionality();
|
|
6490
|
+
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
6491
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
6446
6492
|
socket.send({
|
|
6447
6493
|
topic: "session-data",
|
|
6448
6494
|
data_source_id: data_source_id,
|
|
@@ -6454,7 +6500,7 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6454
6500
|
event_id: "SESSION_END"
|
|
6455
6501
|
});
|
|
6456
6502
|
});
|
|
6457
|
-
case
|
|
6503
|
+
case 11:
|
|
6458
6504
|
case "end":
|
|
6459
6505
|
return _context.stop();
|
|
6460
6506
|
}
|
|
@@ -6501,7 +6547,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6501
6547
|
page_name: window.location.href,
|
|
6502
6548
|
event_id: "PAGE_NAVIGATION"
|
|
6503
6549
|
});
|
|
6504
|
-
saveEvents(events);
|
|
6505
6550
|
};
|
|
6506
6551
|
window.addEventListener("popstate", handleNavigation);
|
|
6507
6552
|
var originalPushState = window.history.pushState;
|
|
@@ -6538,7 +6583,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6538
6583
|
return function () {
|
|
6539
6584
|
if (stopFn) {
|
|
6540
6585
|
stopFn();
|
|
6541
|
-
saveEvents(events);
|
|
6542
6586
|
recorderActive.current = false;
|
|
6543
6587
|
}
|
|
6544
6588
|
};
|
|
@@ -6576,7 +6620,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6576
6620
|
return function () {
|
|
6577
6621
|
if (stopFn) {
|
|
6578
6622
|
stopFn();
|
|
6579
|
-
saveEvents(events);
|
|
6580
6623
|
recorderActive.current = false;
|
|
6581
6624
|
}
|
|
6582
6625
|
};
|
|
@@ -6628,21 +6671,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6628
6671
|
document.removeEventListener("click", handleClick);
|
|
6629
6672
|
};
|
|
6630
6673
|
}, []);
|
|
6631
|
-
function saveEvents(events) {
|
|
6632
|
-
var requestOptions = {
|
|
6633
|
-
method: "PUT",
|
|
6634
|
-
headers: {
|
|
6635
|
-
"Content-Type": "application/json"
|
|
6636
|
-
},
|
|
6637
|
-
body: JSON.stringify(events)
|
|
6638
|
-
};
|
|
6639
|
-
fetch("http://localhost:5000/generate-s3-url/".concat(data_source_id, "/").concat(sessionId)).then(function (response) {
|
|
6640
|
-
return response.json();
|
|
6641
|
-
}).then(function (data) {
|
|
6642
|
-
var uploadURL = data.signed_url;
|
|
6643
|
-
return fetch(uploadURL, requestOptions);
|
|
6644
|
-
});
|
|
6645
|
-
}
|
|
6646
6674
|
function saveEventsLocally() {
|
|
6647
6675
|
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "formatted" ;
|
|
6648
6676
|
var blob = "";
|
package/dist/index.js
CHANGED
|
@@ -6430,13 +6430,56 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6430
6430
|
}));
|
|
6431
6431
|
return _authorizeApp.apply(this, arguments);
|
|
6432
6432
|
}
|
|
6433
|
+
var offLoadFunctionality = function offLoadFunctionality() {
|
|
6434
|
+
var data = JSON.stringify({
|
|
6435
|
+
data_source_id: data_source_id,
|
|
6436
|
+
sessionId: sessionId,
|
|
6437
|
+
formatted_events: JSON.stringify(events),
|
|
6438
|
+
raw_events: JSON.stringify(replayEvents)
|
|
6439
|
+
});
|
|
6440
|
+
socket.send({
|
|
6441
|
+
topic: "session-data",
|
|
6442
|
+
data_source_id: data_source_id,
|
|
6443
|
+
session_id: localStorage.getItem("coreOutlineSessionId"),
|
|
6444
|
+
start_date: new Date().toLocaleString(),
|
|
6445
|
+
latitude: location.latitude,
|
|
6446
|
+
longitude: location.longitude,
|
|
6447
|
+
browser: browser,
|
|
6448
|
+
event_id: "SESSION_END"
|
|
6449
|
+
});
|
|
6450
|
+
if (navigator.sendBeacon) {
|
|
6451
|
+
navigator.sendBeacon("http://localhost:5000/upload-events", data);
|
|
6452
|
+
} else {
|
|
6453
|
+
fetch("http://localhost:5000/upload-events", {
|
|
6454
|
+
method: 'POST',
|
|
6455
|
+
body: data,
|
|
6456
|
+
keepalive: true,
|
|
6457
|
+
headers: {
|
|
6458
|
+
'Content-Type': 'application/json'
|
|
6459
|
+
}
|
|
6460
|
+
})["catch"](function (err) {
|
|
6461
|
+
return console.error('Upload failed:', err);
|
|
6462
|
+
});
|
|
6463
|
+
}
|
|
6464
|
+
};
|
|
6433
6465
|
React.useEffect(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
6466
|
+
var handleBeforeUnload, handleVisibilityChange;
|
|
6434
6467
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
6435
6468
|
while (1) switch (_context.prev = _context.next) {
|
|
6436
6469
|
case 0:
|
|
6437
|
-
|
|
6470
|
+
handleBeforeUnload = function handleBeforeUnload() {
|
|
6471
|
+
offLoadFunctionality();
|
|
6472
|
+
};
|
|
6473
|
+
handleVisibilityChange = function handleVisibilityChange() {
|
|
6474
|
+
if (document.visibilityState === 'hidden') {
|
|
6475
|
+
offLoadFunctionality();
|
|
6476
|
+
}
|
|
6477
|
+
};
|
|
6478
|
+
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
6479
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
6480
|
+
_context.next = 6;
|
|
6438
6481
|
return authorizeApp(data_source_id, data_source_secret);
|
|
6439
|
-
case
|
|
6482
|
+
case 6:
|
|
6440
6483
|
localStorage.setItem("coreOutlineSessionId", sessionId);
|
|
6441
6484
|
localStorage.setItem("coreOutlineDataSourceIdId", data_source_id);
|
|
6442
6485
|
console.log("Session", sessionId);
|
|
@@ -6451,6 +6494,9 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6451
6494
|
event_id: "SESSION_START"
|
|
6452
6495
|
});
|
|
6453
6496
|
return _context.abrupt("return", function () {
|
|
6497
|
+
offLoadFunctionality();
|
|
6498
|
+
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
6499
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
6454
6500
|
socket.send({
|
|
6455
6501
|
topic: "session-data",
|
|
6456
6502
|
data_source_id: data_source_id,
|
|
@@ -6462,7 +6508,7 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6462
6508
|
event_id: "SESSION_END"
|
|
6463
6509
|
});
|
|
6464
6510
|
});
|
|
6465
|
-
case
|
|
6511
|
+
case 11:
|
|
6466
6512
|
case "end":
|
|
6467
6513
|
return _context.stop();
|
|
6468
6514
|
}
|
|
@@ -6509,7 +6555,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6509
6555
|
page_name: window.location.href,
|
|
6510
6556
|
event_id: "PAGE_NAVIGATION"
|
|
6511
6557
|
});
|
|
6512
|
-
saveEvents(events);
|
|
6513
6558
|
};
|
|
6514
6559
|
window.addEventListener("popstate", handleNavigation);
|
|
6515
6560
|
var originalPushState = window.history.pushState;
|
|
@@ -6546,7 +6591,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6546
6591
|
return function () {
|
|
6547
6592
|
if (stopFn) {
|
|
6548
6593
|
stopFn();
|
|
6549
|
-
saveEvents(events);
|
|
6550
6594
|
recorderActive.current = false;
|
|
6551
6595
|
}
|
|
6552
6596
|
};
|
|
@@ -6584,7 +6628,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6584
6628
|
return function () {
|
|
6585
6629
|
if (stopFn) {
|
|
6586
6630
|
stopFn();
|
|
6587
|
-
saveEvents(events);
|
|
6588
6631
|
recorderActive.current = false;
|
|
6589
6632
|
}
|
|
6590
6633
|
};
|
|
@@ -6636,21 +6679,6 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
6636
6679
|
document.removeEventListener("click", handleClick);
|
|
6637
6680
|
};
|
|
6638
6681
|
}, []);
|
|
6639
|
-
function saveEvents(events) {
|
|
6640
|
-
var requestOptions = {
|
|
6641
|
-
method: "PUT",
|
|
6642
|
-
headers: {
|
|
6643
|
-
"Content-Type": "application/json"
|
|
6644
|
-
},
|
|
6645
|
-
body: JSON.stringify(events)
|
|
6646
|
-
};
|
|
6647
|
-
fetch("http://localhost:5000/generate-s3-url/".concat(data_source_id, "/").concat(sessionId)).then(function (response) {
|
|
6648
|
-
return response.json();
|
|
6649
|
-
}).then(function (data) {
|
|
6650
|
-
var uploadURL = data.signed_url;
|
|
6651
|
-
return fetch(uploadURL, requestOptions);
|
|
6652
|
-
});
|
|
6653
|
-
}
|
|
6654
6682
|
function saveEventsLocally() {
|
|
6655
6683
|
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "formatted" ;
|
|
6656
6684
|
var blob = "";
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@ import socket from "./socket";
|
|
|
5
5
|
|
|
6
6
|
import { EventType, eventWithTime, IncrementalSource, MouseInteractions } from "rrweb";
|
|
7
7
|
|
|
8
|
+
|
|
8
9
|
const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
9
10
|
const [events, setEvents] = useState([]);
|
|
10
11
|
const [replayEvents, setReplayEvents] = useState([]);
|
|
@@ -38,7 +39,56 @@ const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
|
38
39
|
});
|
|
39
40
|
return response;
|
|
40
41
|
}
|
|
42
|
+
|
|
43
|
+
const offLoadFunctionality = () => {
|
|
44
|
+
const data = JSON.stringify({
|
|
45
|
+
data_source_id: data_source_id,
|
|
46
|
+
sessionId: sessionId,
|
|
47
|
+
formatted_events: JSON.stringify(events),
|
|
48
|
+
raw_events: JSON.stringify(replayEvents),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
socket.send({
|
|
52
|
+
topic: "session-data",
|
|
53
|
+
data_source_id: data_source_id,
|
|
54
|
+
session_id: localStorage.getItem("coreOutlineSessionId"),
|
|
55
|
+
start_date: new Date().toLocaleString(),
|
|
56
|
+
latitude: location.latitude,
|
|
57
|
+
longitude: location.longitude,
|
|
58
|
+
browser: browser,
|
|
59
|
+
event_id: "SESSION_END",
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (navigator.sendBeacon) {
|
|
63
|
+
navigator.sendBeacon(
|
|
64
|
+
`http://localhost:5000/upload-events`, data
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
fetch(`http://localhost:5000/upload-events`, {
|
|
69
|
+
method: 'POST',
|
|
70
|
+
body: data,
|
|
71
|
+
keepalive: true,
|
|
72
|
+
headers: {
|
|
73
|
+
'Content-Type': 'application/json',
|
|
74
|
+
},
|
|
75
|
+
}).catch(err => console.error('Upload failed:', err));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
|
|
41
80
|
useEffect(async () => {
|
|
81
|
+
const handleBeforeUnload = () => {
|
|
82
|
+
offLoadFunctionality();
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const handleVisibilityChange = () => {
|
|
86
|
+
if (document.visibilityState === 'hidden') {
|
|
87
|
+
offLoadFunctionality();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
window.addEventListener('beforeunload', handleBeforeUnload);
|
|
91
|
+
document.addEventListener('visibilitychange', handleVisibilityChange);
|
|
42
92
|
await authorizeApp(data_source_id, data_source_secret);
|
|
43
93
|
localStorage.setItem("coreOutlineSessionId", sessionId);
|
|
44
94
|
localStorage.setItem("coreOutlineDataSourceIdId", data_source_id);
|
|
@@ -55,6 +105,9 @@ const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
|
55
105
|
});
|
|
56
106
|
|
|
57
107
|
return () => {
|
|
108
|
+
offLoadFunctionality();
|
|
109
|
+
window.removeEventListener('beforeunload', handleBeforeUnload);
|
|
110
|
+
document.removeEventListener('visibilitychange', handleVisibilityChange);
|
|
58
111
|
socket.send({
|
|
59
112
|
topic: "session-data",
|
|
60
113
|
data_source_id: data_source_id,
|
|
@@ -104,7 +157,6 @@ const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
|
104
157
|
page_name: window.location.href,
|
|
105
158
|
event_id: "PAGE_NAVIGATION",
|
|
106
159
|
});
|
|
107
|
-
saveEvents(events);
|
|
108
160
|
};
|
|
109
161
|
|
|
110
162
|
window.addEventListener("popstate", handleNavigation);
|
|
@@ -142,7 +194,6 @@ const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
|
142
194
|
return () => {
|
|
143
195
|
if (stopFn) {
|
|
144
196
|
stopFn();
|
|
145
|
-
saveEvents(events);
|
|
146
197
|
|
|
147
198
|
recorderActive.current = false;
|
|
148
199
|
}
|
|
@@ -182,7 +233,6 @@ const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
|
182
233
|
return () => {
|
|
183
234
|
if (stopFn) {
|
|
184
235
|
stopFn();
|
|
185
|
-
saveEvents(events);
|
|
186
236
|
|
|
187
237
|
recorderActive.current = false;
|
|
188
238
|
}
|
|
@@ -239,22 +289,6 @@ const CoreOutline = ({ children, data_source_id, data_source_secret }) => {
|
|
|
239
289
|
};
|
|
240
290
|
}, []);
|
|
241
291
|
|
|
242
|
-
function saveEvents(events) {
|
|
243
|
-
const requestOptions = {
|
|
244
|
-
method: "PUT",
|
|
245
|
-
headers: {
|
|
246
|
-
"Content-Type": "application/json",
|
|
247
|
-
},
|
|
248
|
-
body: JSON.stringify(events),
|
|
249
|
-
};
|
|
250
|
-
const res = fetch(`http://localhost:5000/generate-s3-url/${data_source_id}/${sessionId}`)
|
|
251
|
-
.then((response) => response.json())
|
|
252
|
-
.then((data) => {
|
|
253
|
-
const uploadURL = data.signed_url;
|
|
254
|
-
return fetch(uploadURL, requestOptions);
|
|
255
|
-
});
|
|
256
|
-
console.log("Events saved successfully:", res);
|
|
257
|
-
}
|
|
258
292
|
|
|
259
293
|
function saveEventsLocally(type = "formatted" || "raw") {
|
|
260
294
|
let blob = "";
|