core-outline 1.1.25 → 1.1.27
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 +35 -53
- package/dist/index.js +35 -53
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -4355,6 +4355,7 @@ record.mirror = mirror;
|
|
|
4355
4355
|
var ANON_ID_KEY = 'co_anon_id';
|
|
4356
4356
|
var SESSION_ID_KEY = 'co_session_id';
|
|
4357
4357
|
function getAnonymousId() {
|
|
4358
|
+
if (typeof window === 'undefined') return '';
|
|
4358
4359
|
var id = localStorage.getItem(ANON_ID_KEY);
|
|
4359
4360
|
if (!id) {
|
|
4360
4361
|
id = v4();
|
|
@@ -4363,6 +4364,7 @@ function getAnonymousId() {
|
|
|
4363
4364
|
return id;
|
|
4364
4365
|
}
|
|
4365
4366
|
function getSessionId() {
|
|
4367
|
+
if (typeof window === 'undefined') return '';
|
|
4366
4368
|
var id = sessionStorage.getItem(SESSION_ID_KEY);
|
|
4367
4369
|
if (!id) {
|
|
4368
4370
|
id = v4();
|
|
@@ -4533,19 +4535,13 @@ function _ensureFreshToken2() {
|
|
|
4533
4535
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4534
4536
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4535
4537
|
case 0:
|
|
4536
|
-
if (!_token) {
|
|
4537
|
-
_context4.next = 2;
|
|
4538
|
-
break;
|
|
4539
|
-
}
|
|
4540
|
-
return _context4.abrupt("return");
|
|
4541
|
-
case 2:
|
|
4542
4538
|
if (!(_warehouseId && _dataSourceId && _dataSourceSecret)) {
|
|
4543
|
-
_context4.next =
|
|
4539
|
+
_context4.next = 3;
|
|
4544
4540
|
break;
|
|
4545
4541
|
}
|
|
4546
|
-
_context4.next =
|
|
4542
|
+
_context4.next = 3;
|
|
4547
4543
|
return _doAuthorize(_warehouseId, _dataSourceId, _dataSourceSecret);
|
|
4548
|
-
case
|
|
4544
|
+
case 3:
|
|
4549
4545
|
case "end":
|
|
4550
4546
|
return _context4.stop();
|
|
4551
4547
|
}
|
|
@@ -4554,7 +4550,8 @@ function _ensureFreshToken2() {
|
|
|
4554
4550
|
return _ensureFreshToken2.apply(this, arguments);
|
|
4555
4551
|
}
|
|
4556
4552
|
function trackEvent(eventType, payload) {
|
|
4557
|
-
if (!_token) return;
|
|
4553
|
+
// if (!_token) return;
|
|
4554
|
+
|
|
4558
4555
|
var event = _objectSpread2({
|
|
4559
4556
|
event_id: v4(),
|
|
4560
4557
|
event_type: eventType,
|
|
@@ -4570,45 +4567,33 @@ function flush() {
|
|
|
4570
4567
|
}
|
|
4571
4568
|
function _flush() {
|
|
4572
4569
|
_flush = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
4573
|
-
var events, body
|
|
4570
|
+
var events, body;
|
|
4574
4571
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
4575
4572
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4576
4573
|
case 0:
|
|
4577
4574
|
_context5.next = 2;
|
|
4578
4575
|
return _ensureFreshToken();
|
|
4579
4576
|
case 2:
|
|
4580
|
-
if (!
|
|
4581
|
-
_context5.next = 4;
|
|
4582
|
-
break;
|
|
4583
|
-
}
|
|
4584
|
-
return _context5.abrupt("return");
|
|
4585
|
-
case 4:
|
|
4577
|
+
// if (!_token || _buffer.length === 0) return;
|
|
4586
4578
|
events = _buffer.splice(0, _buffer.length);
|
|
4587
4579
|
body = JSON.stringify({
|
|
4588
4580
|
warehouse_id: _warehouseId,
|
|
4589
4581
|
organization_id: _organizationId,
|
|
4590
4582
|
events: events
|
|
4591
4583
|
});
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
}
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
body: body,
|
|
4606
|
-
keepalive: true
|
|
4607
|
-
})["catch"](function (err) {
|
|
4608
|
-
return console.error('[CoreOutline] Flush error:', err);
|
|
4609
|
-
});
|
|
4610
|
-
}
|
|
4611
|
-
case 8:
|
|
4584
|
+
console.log("Flushing here: ", body);
|
|
4585
|
+
fetch("".concat(INGEST_BASE, "/api/ingest/events"), {
|
|
4586
|
+
method: 'POST',
|
|
4587
|
+
headers: {
|
|
4588
|
+
'Content-Type': 'application/json',
|
|
4589
|
+
Authorization: "Bearer ".concat(_token)
|
|
4590
|
+
},
|
|
4591
|
+
body: body,
|
|
4592
|
+
keepalive: true
|
|
4593
|
+
})["catch"](function (err) {
|
|
4594
|
+
return console.error('[CoreOutline] Flush error:', err);
|
|
4595
|
+
});
|
|
4596
|
+
case 6:
|
|
4612
4597
|
case "end":
|
|
4613
4598
|
return _context5.stop();
|
|
4614
4599
|
}
|
|
@@ -4627,14 +4612,11 @@ function _sendRrwebBatch() {
|
|
|
4627
4612
|
_context6.next = 2;
|
|
4628
4613
|
return _ensureFreshToken();
|
|
4629
4614
|
case 2:
|
|
4630
|
-
if (!
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
case 4:
|
|
4636
|
-
_context6.prev = 4;
|
|
4637
|
-
_context6.next = 7;
|
|
4615
|
+
// if (!_token || !chunks || chunks.length === 0) return;
|
|
4616
|
+
|
|
4617
|
+
console.log("RRWeb here: ", chunks);
|
|
4618
|
+
_context6.prev = 3;
|
|
4619
|
+
_context6.next = 6;
|
|
4638
4620
|
return fetch("".concat(INGEST_BASE, "/api/ingest/rrweb"), {
|
|
4639
4621
|
method: 'POST',
|
|
4640
4622
|
headers: {
|
|
@@ -4650,18 +4632,18 @@ function _sendRrwebBatch() {
|
|
|
4650
4632
|
}),
|
|
4651
4633
|
keepalive: true
|
|
4652
4634
|
});
|
|
4653
|
-
case
|
|
4654
|
-
_context6.next =
|
|
4635
|
+
case 6:
|
|
4636
|
+
_context6.next = 11;
|
|
4655
4637
|
break;
|
|
4656
|
-
case
|
|
4657
|
-
_context6.prev =
|
|
4658
|
-
_context6.t0 = _context6["catch"](
|
|
4638
|
+
case 8:
|
|
4639
|
+
_context6.prev = 8;
|
|
4640
|
+
_context6.t0 = _context6["catch"](3);
|
|
4659
4641
|
console.error('[CoreOutline] rrweb upload error:', _context6.t0);
|
|
4660
|
-
case
|
|
4642
|
+
case 11:
|
|
4661
4643
|
case "end":
|
|
4662
4644
|
return _context6.stop();
|
|
4663
4645
|
}
|
|
4664
|
-
}, _callee6, null, [[
|
|
4646
|
+
}, _callee6, null, [[3, 8]]);
|
|
4665
4647
|
}));
|
|
4666
4648
|
return _sendRrwebBatch.apply(this, arguments);
|
|
4667
4649
|
}
|
|
@@ -4682,7 +4664,7 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
4682
4664
|
replayEvents = _useState2[0],
|
|
4683
4665
|
setReplayEvents = _useState2[1];
|
|
4684
4666
|
var recorderActive = useRef(false);
|
|
4685
|
-
var _useState3 = useState(window.location.href),
|
|
4667
|
+
var _useState3 = useState(typeof window !== 'undefined' ? window.location.href : ''),
|
|
4686
4668
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
4687
4669
|
currentPage = _useState4[0],
|
|
4688
4670
|
setCurrentPage = _useState4[1];
|
package/dist/index.js
CHANGED
|
@@ -4363,6 +4363,7 @@ record.mirror = mirror;
|
|
|
4363
4363
|
var ANON_ID_KEY = 'co_anon_id';
|
|
4364
4364
|
var SESSION_ID_KEY = 'co_session_id';
|
|
4365
4365
|
function getAnonymousId() {
|
|
4366
|
+
if (typeof window === 'undefined') return '';
|
|
4366
4367
|
var id = localStorage.getItem(ANON_ID_KEY);
|
|
4367
4368
|
if (!id) {
|
|
4368
4369
|
id = uuid.v4();
|
|
@@ -4371,6 +4372,7 @@ function getAnonymousId() {
|
|
|
4371
4372
|
return id;
|
|
4372
4373
|
}
|
|
4373
4374
|
function getSessionId() {
|
|
4375
|
+
if (typeof window === 'undefined') return '';
|
|
4374
4376
|
var id = sessionStorage.getItem(SESSION_ID_KEY);
|
|
4375
4377
|
if (!id) {
|
|
4376
4378
|
id = uuid.v4();
|
|
@@ -4541,19 +4543,13 @@ function _ensureFreshToken2() {
|
|
|
4541
4543
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
4542
4544
|
while (1) switch (_context4.prev = _context4.next) {
|
|
4543
4545
|
case 0:
|
|
4544
|
-
if (!_token) {
|
|
4545
|
-
_context4.next = 2;
|
|
4546
|
-
break;
|
|
4547
|
-
}
|
|
4548
|
-
return _context4.abrupt("return");
|
|
4549
|
-
case 2:
|
|
4550
4546
|
if (!(_warehouseId && _dataSourceId && _dataSourceSecret)) {
|
|
4551
|
-
_context4.next =
|
|
4547
|
+
_context4.next = 3;
|
|
4552
4548
|
break;
|
|
4553
4549
|
}
|
|
4554
|
-
_context4.next =
|
|
4550
|
+
_context4.next = 3;
|
|
4555
4551
|
return _doAuthorize(_warehouseId, _dataSourceId, _dataSourceSecret);
|
|
4556
|
-
case
|
|
4552
|
+
case 3:
|
|
4557
4553
|
case "end":
|
|
4558
4554
|
return _context4.stop();
|
|
4559
4555
|
}
|
|
@@ -4562,7 +4558,8 @@ function _ensureFreshToken2() {
|
|
|
4562
4558
|
return _ensureFreshToken2.apply(this, arguments);
|
|
4563
4559
|
}
|
|
4564
4560
|
function trackEvent(eventType, payload) {
|
|
4565
|
-
if (!_token) return;
|
|
4561
|
+
// if (!_token) return;
|
|
4562
|
+
|
|
4566
4563
|
var event = _objectSpread2({
|
|
4567
4564
|
event_id: uuid.v4(),
|
|
4568
4565
|
event_type: eventType,
|
|
@@ -4578,45 +4575,33 @@ function flush() {
|
|
|
4578
4575
|
}
|
|
4579
4576
|
function _flush() {
|
|
4580
4577
|
_flush = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
4581
|
-
var events, body
|
|
4578
|
+
var events, body;
|
|
4582
4579
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
4583
4580
|
while (1) switch (_context5.prev = _context5.next) {
|
|
4584
4581
|
case 0:
|
|
4585
4582
|
_context5.next = 2;
|
|
4586
4583
|
return _ensureFreshToken();
|
|
4587
4584
|
case 2:
|
|
4588
|
-
if (!
|
|
4589
|
-
_context5.next = 4;
|
|
4590
|
-
break;
|
|
4591
|
-
}
|
|
4592
|
-
return _context5.abrupt("return");
|
|
4593
|
-
case 4:
|
|
4585
|
+
// if (!_token || _buffer.length === 0) return;
|
|
4594
4586
|
events = _buffer.splice(0, _buffer.length);
|
|
4595
4587
|
body = JSON.stringify({
|
|
4596
4588
|
warehouse_id: _warehouseId,
|
|
4597
4589
|
organization_id: _organizationId,
|
|
4598
4590
|
events: events
|
|
4599
4591
|
});
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
}
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
body: body,
|
|
4614
|
-
keepalive: true
|
|
4615
|
-
})["catch"](function (err) {
|
|
4616
|
-
return console.error('[CoreOutline] Flush error:', err);
|
|
4617
|
-
});
|
|
4618
|
-
}
|
|
4619
|
-
case 8:
|
|
4592
|
+
console.log("Flushing here: ", body);
|
|
4593
|
+
fetch("".concat(INGEST_BASE, "/api/ingest/events"), {
|
|
4594
|
+
method: 'POST',
|
|
4595
|
+
headers: {
|
|
4596
|
+
'Content-Type': 'application/json',
|
|
4597
|
+
Authorization: "Bearer ".concat(_token)
|
|
4598
|
+
},
|
|
4599
|
+
body: body,
|
|
4600
|
+
keepalive: true
|
|
4601
|
+
})["catch"](function (err) {
|
|
4602
|
+
return console.error('[CoreOutline] Flush error:', err);
|
|
4603
|
+
});
|
|
4604
|
+
case 6:
|
|
4620
4605
|
case "end":
|
|
4621
4606
|
return _context5.stop();
|
|
4622
4607
|
}
|
|
@@ -4635,14 +4620,11 @@ function _sendRrwebBatch() {
|
|
|
4635
4620
|
_context6.next = 2;
|
|
4636
4621
|
return _ensureFreshToken();
|
|
4637
4622
|
case 2:
|
|
4638
|
-
if (!
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
case 4:
|
|
4644
|
-
_context6.prev = 4;
|
|
4645
|
-
_context6.next = 7;
|
|
4623
|
+
// if (!_token || !chunks || chunks.length === 0) return;
|
|
4624
|
+
|
|
4625
|
+
console.log("RRWeb here: ", chunks);
|
|
4626
|
+
_context6.prev = 3;
|
|
4627
|
+
_context6.next = 6;
|
|
4646
4628
|
return fetch("".concat(INGEST_BASE, "/api/ingest/rrweb"), {
|
|
4647
4629
|
method: 'POST',
|
|
4648
4630
|
headers: {
|
|
@@ -4658,18 +4640,18 @@ function _sendRrwebBatch() {
|
|
|
4658
4640
|
}),
|
|
4659
4641
|
keepalive: true
|
|
4660
4642
|
});
|
|
4661
|
-
case
|
|
4662
|
-
_context6.next =
|
|
4643
|
+
case 6:
|
|
4644
|
+
_context6.next = 11;
|
|
4663
4645
|
break;
|
|
4664
|
-
case
|
|
4665
|
-
_context6.prev =
|
|
4666
|
-
_context6.t0 = _context6["catch"](
|
|
4646
|
+
case 8:
|
|
4647
|
+
_context6.prev = 8;
|
|
4648
|
+
_context6.t0 = _context6["catch"](3);
|
|
4667
4649
|
console.error('[CoreOutline] rrweb upload error:', _context6.t0);
|
|
4668
|
-
case
|
|
4650
|
+
case 11:
|
|
4669
4651
|
case "end":
|
|
4670
4652
|
return _context6.stop();
|
|
4671
4653
|
}
|
|
4672
|
-
}, _callee6, null, [[
|
|
4654
|
+
}, _callee6, null, [[3, 8]]);
|
|
4673
4655
|
}));
|
|
4674
4656
|
return _sendRrwebBatch.apply(this, arguments);
|
|
4675
4657
|
}
|
|
@@ -4690,7 +4672,7 @@ var CoreOutline = function CoreOutline(_ref) {
|
|
|
4690
4672
|
replayEvents = _useState2[0],
|
|
4691
4673
|
setReplayEvents = _useState2[1];
|
|
4692
4674
|
var recorderActive = React.useRef(false);
|
|
4693
|
-
var _useState3 = React.useState(window.location.href),
|
|
4675
|
+
var _useState3 = React.useState(typeof window !== 'undefined' ? window.location.href : ''),
|
|
4694
4676
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
4695
4677
|
currentPage = _useState4[0],
|
|
4696
4678
|
setCurrentPage = _useState4[1];
|