core-outline 1.1.26 → 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 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();
@@ -4565,7 +4567,7 @@ function flush() {
4565
4567
  }
4566
4568
  function _flush() {
4567
4569
  _flush = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
4568
- var events, body, headers, blob;
4570
+ var events, body;
4569
4571
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4570
4572
  while (1) switch (_context5.prev = _context5.next) {
4571
4573
  case 0:
@@ -4579,25 +4581,18 @@ function _flush() {
4579
4581
  organization_id: _organizationId,
4580
4582
  events: events
4581
4583
  });
4582
- headers = {
4583
- 'Content-Type': 'application/json',
4584
- Authorization: "Bearer ".concat(_token)
4585
- };
4586
- if (navigator.sendBeacon) {
4587
- blob = new Blob([body], {
4588
- type: 'application/json'
4589
- });
4590
- navigator.sendBeacon("".concat(INGEST_BASE, "/api/ingest/events"), blob);
4591
- } else {
4592
- fetch("".concat(INGEST_BASE, "/api/ingest/events"), {
4593
- method: 'POST',
4594
- headers: headers,
4595
- body: body,
4596
- keepalive: true
4597
- })["catch"](function (err) {
4598
- return console.error('[CoreOutline] Flush error:', err);
4599
- });
4600
- }
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
+ });
4601
4596
  case 6:
4602
4597
  case "end":
4603
4598
  return _context5.stop();
@@ -4617,8 +4612,11 @@ function _sendRrwebBatch() {
4617
4612
  _context6.next = 2;
4618
4613
  return _ensureFreshToken();
4619
4614
  case 2:
4620
- _context6.prev = 2;
4621
- _context6.next = 5;
4615
+ // if (!_token || !chunks || chunks.length === 0) return;
4616
+
4617
+ console.log("RRWeb here: ", chunks);
4618
+ _context6.prev = 3;
4619
+ _context6.next = 6;
4622
4620
  return fetch("".concat(INGEST_BASE, "/api/ingest/rrweb"), {
4623
4621
  method: 'POST',
4624
4622
  headers: {
@@ -4634,18 +4632,18 @@ function _sendRrwebBatch() {
4634
4632
  }),
4635
4633
  keepalive: true
4636
4634
  });
4637
- case 5:
4638
- _context6.next = 10;
4635
+ case 6:
4636
+ _context6.next = 11;
4639
4637
  break;
4640
- case 7:
4641
- _context6.prev = 7;
4642
- _context6.t0 = _context6["catch"](2);
4638
+ case 8:
4639
+ _context6.prev = 8;
4640
+ _context6.t0 = _context6["catch"](3);
4643
4641
  console.error('[CoreOutline] rrweb upload error:', _context6.t0);
4644
- case 10:
4642
+ case 11:
4645
4643
  case "end":
4646
4644
  return _context6.stop();
4647
4645
  }
4648
- }, _callee6, null, [[2, 7]]);
4646
+ }, _callee6, null, [[3, 8]]);
4649
4647
  }));
4650
4648
  return _sendRrwebBatch.apply(this, arguments);
4651
4649
  }
@@ -4666,7 +4664,7 @@ var CoreOutline = function CoreOutline(_ref) {
4666
4664
  replayEvents = _useState2[0],
4667
4665
  setReplayEvents = _useState2[1];
4668
4666
  var recorderActive = useRef(false);
4669
- var _useState3 = useState(window.location.href),
4667
+ var _useState3 = useState(typeof window !== 'undefined' ? window.location.href : ''),
4670
4668
  _useState4 = _slicedToArray(_useState3, 2),
4671
4669
  currentPage = _useState4[0],
4672
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();
@@ -4573,7 +4575,7 @@ function flush() {
4573
4575
  }
4574
4576
  function _flush() {
4575
4577
  _flush = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
4576
- var events, body, headers, blob;
4578
+ var events, body;
4577
4579
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
4578
4580
  while (1) switch (_context5.prev = _context5.next) {
4579
4581
  case 0:
@@ -4587,25 +4589,18 @@ function _flush() {
4587
4589
  organization_id: _organizationId,
4588
4590
  events: events
4589
4591
  });
4590
- headers = {
4591
- 'Content-Type': 'application/json',
4592
- Authorization: "Bearer ".concat(_token)
4593
- };
4594
- if (navigator.sendBeacon) {
4595
- blob = new Blob([body], {
4596
- type: 'application/json'
4597
- });
4598
- navigator.sendBeacon("".concat(INGEST_BASE, "/api/ingest/events"), blob);
4599
- } else {
4600
- fetch("".concat(INGEST_BASE, "/api/ingest/events"), {
4601
- method: 'POST',
4602
- headers: headers,
4603
- body: body,
4604
- keepalive: true
4605
- })["catch"](function (err) {
4606
- return console.error('[CoreOutline] Flush error:', err);
4607
- });
4608
- }
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
+ });
4609
4604
  case 6:
4610
4605
  case "end":
4611
4606
  return _context5.stop();
@@ -4625,8 +4620,11 @@ function _sendRrwebBatch() {
4625
4620
  _context6.next = 2;
4626
4621
  return _ensureFreshToken();
4627
4622
  case 2:
4628
- _context6.prev = 2;
4629
- _context6.next = 5;
4623
+ // if (!_token || !chunks || chunks.length === 0) return;
4624
+
4625
+ console.log("RRWeb here: ", chunks);
4626
+ _context6.prev = 3;
4627
+ _context6.next = 6;
4630
4628
  return fetch("".concat(INGEST_BASE, "/api/ingest/rrweb"), {
4631
4629
  method: 'POST',
4632
4630
  headers: {
@@ -4642,18 +4640,18 @@ function _sendRrwebBatch() {
4642
4640
  }),
4643
4641
  keepalive: true
4644
4642
  });
4645
- case 5:
4646
- _context6.next = 10;
4643
+ case 6:
4644
+ _context6.next = 11;
4647
4645
  break;
4648
- case 7:
4649
- _context6.prev = 7;
4650
- _context6.t0 = _context6["catch"](2);
4646
+ case 8:
4647
+ _context6.prev = 8;
4648
+ _context6.t0 = _context6["catch"](3);
4651
4649
  console.error('[CoreOutline] rrweb upload error:', _context6.t0);
4652
- case 10:
4650
+ case 11:
4653
4651
  case "end":
4654
4652
  return _context6.stop();
4655
4653
  }
4656
- }, _callee6, null, [[2, 7]]);
4654
+ }, _callee6, null, [[3, 8]]);
4657
4655
  }));
4658
4656
  return _sendRrwebBatch.apply(this, arguments);
4659
4657
  }
@@ -4674,7 +4672,7 @@ var CoreOutline = function CoreOutline(_ref) {
4674
4672
  replayEvents = _useState2[0],
4675
4673
  setReplayEvents = _useState2[1];
4676
4674
  var recorderActive = React.useRef(false);
4677
- var _useState3 = React.useState(window.location.href),
4675
+ var _useState3 = React.useState(typeof window !== 'undefined' ? window.location.href : ''),
4678
4676
  _useState4 = _slicedToArray(_useState3, 2),
4679
4677
  currentPage = _useState4[0],
4680
4678
  setCurrentPage = _useState4[1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-outline",
3
- "version": "1.1.26",
3
+ "version": "1.1.27",
4
4
  "description": "A React component for Core&Outline",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",