@mjhls/mjh-framework 1.0.939-segment-test-v5 → 1.0.939-segment-test-v7

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/cjs/View.js CHANGED
@@ -461,9 +461,7 @@ var Recommended = function Recommended(props) {
461
461
  client = props.client,
462
462
  _props$index = props.index,
463
463
  index = _props$index === undefined ? 0 : _props$index,
464
- cpModificationRequired = props.cpModificationRequired,
465
- segmentData = props.segmentData,
466
- setSegmentData = props.setSegmentData;
464
+ cpModificationRequired = props.cpModificationRequired;
467
465
 
468
466
  var _useState = React.useState(false),
469
467
  _useState2 = slicedToArray._slicedToArray(_useState, 2),
@@ -496,7 +494,6 @@ var Recommended = function Recommended(props) {
496
494
 
497
495
  React.useEffect(function () {
498
496
  try {
499
-
500
497
  if (!segmentLoaded) {
501
498
  return;
502
499
  }
@@ -510,55 +507,29 @@ var Recommended = function Recommended(props) {
510
507
  // get users traits
511
508
  var getSegmentProfile = function () {
512
509
  var _ref = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee() {
513
- var data, anonymousId, response, addTaxonomyName, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
510
+ var anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
514
511
 
515
512
  return asyncToGenerator.regenerator.wrap(function _callee$(_context) {
516
513
  while (1) {
517
514
  switch (_context.prev = _context.next) {
518
515
  case 0:
519
- data = void 0;
520
-
521
- if (segmentData) {
522
- _context.next = 12;
523
- break;
524
- }
525
-
526
516
  anonymousId = analytics.user().anonymousId();
527
- _context.next = 5;
517
+ _context.next = 3;
528
518
  return fetch('/api/getSegmentProfile', {
529
519
  method: 'POST',
530
520
  body: stringify._JSON$stringify({ anonymousId: anonymousId })
531
521
  });
532
522
 
533
- case 5:
523
+ case 3:
534
524
  response = _context.sent;
535
- _context.next = 8;
525
+ _context.next = 6;
536
526
  return response.json();
537
527
 
538
- case 8:
528
+ case 6:
539
529
  data = _context.sent;
540
530
 
541
- if (data) {
542
- setSegmentData(data);
543
- } else {
544
- setLoaded('failed');
545
- }
546
-
547
- _context.next = 13;
548
- break;
549
-
550
- case 12:
551
- data = segmentData;
552
-
553
- case 13:
554
- if (!data || data.error || !data.traits) {
555
- setLoaded('failed');
556
- }
557
-
558
- // console.log('persona result:', data)
559
-
560
531
  if (!(data && data.traits && data.traits.favorite_article_category)) {
561
- _context.next = 29;
532
+ _context.next = 24;
562
533
  break;
563
534
  }
564
535
 
@@ -589,10 +560,10 @@ var Recommended = function Recommended(props) {
589
560
  params = {
590
561
  id: article._id
591
562
  };
592
- _context.next = 23;
563
+ _context.next = 16;
593
564
  return asyncToGenerator._Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
594
565
 
595
- case 23:
566
+ case 16:
596
567
  _ref2 = _context.sent;
597
568
  _ref3 = slicedToArray._slicedToArray(_ref2, 3);
598
569
  _articles = _ref3[0];
@@ -611,8 +582,13 @@ var Recommended = function Recommended(props) {
611
582
  }
612
583
  setArticles(_articles);
613
584
  }
585
+ _context.next = 25;
586
+ break;
587
+
588
+ case 24:
589
+ setLoaded('failed');
614
590
 
615
- case 29:
591
+ case 25:
616
592
  case 'end':
617
593
  return _context.stop();
618
594
  }
@@ -639,7 +615,6 @@ var Recommended = function Recommended(props) {
639
615
  }, [articles]);
640
616
 
641
617
  React.useEffect(function () {
642
-
643
618
  try {
644
619
  analytics.ready(function () {
645
620
  setSegmentLoaded(function () {
@@ -940,11 +915,7 @@ var Article = React__default['default'].memo(React.forwardRef(function (props, r
940
915
  _props$downloadCitati = props.downloadCitation,
941
916
  downloadCitation = _props$downloadCitati === undefined ? false : _props$downloadCitati,
942
917
  _props$useSegmentReco = props.useSegmentRecommendedArticles,
943
- useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco,
944
- _props$segmentData = props.segmentData,
945
- segmentData = _props$segmentData === undefined ? null : _props$segmentData,
946
- _props$setSegmentData = props.setSegmentData,
947
- setSegmentData = _props$setSegmentData === undefined ? function () {} : _props$setSegmentData;
918
+ useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco;
948
919
  var sliderData = props.sliderData;
949
920
 
950
921
 
@@ -1179,7 +1150,7 @@ var Article = React__default['default'].memo(React.forwardRef(function (props, r
1179
1150
  return React__default['default'].createElement(
1180
1151
  'div',
1181
1152
  null,
1182
- useSegmentRecommendedArticles ? React__default['default'].createElement(Recommended, { segmentData: segmentData, setSegmentData: setSegmentData, client: client, article: article, index: props.index, Settings: props.Settings, showRelatedArticleFallbackImage: props.showRelatedArticleFallbackImage, cpModificationRequired: cpModificationRequired }) : React__default['default'].createElement(
1153
+ useSegmentRecommendedArticles ? React__default['default'].createElement(Recommended, { client: client, article: article, index: props.index, Settings: props.Settings, showRelatedArticleFallbackImage: props.showRelatedArticleFallbackImage, cpModificationRequired: cpModificationRequired }) : React__default['default'].createElement(
1183
1154
  'section',
1184
1155
  { id: 'related-content-section', className: 'my-1' },
1185
1156
  (article.relatedArticle || RelevantTopics()) && React__default['default'].createElement(
@@ -1878,11 +1849,6 @@ var ArticleQueue = function ArticleQueue(props) {
1878
1849
  active = _useState6[0],
1879
1850
  setActive = _useState6[1];
1880
1851
 
1881
- var _useState7 = React.useState(null),
1882
- _useState8 = slicedToArray._slicedToArray(_useState7, 2),
1883
- segmentData = _useState8[0],
1884
- setSegmentData = _useState8[1];
1885
-
1886
1852
  var refreshAD = function refreshAD(path) {
1887
1853
  var activeArticle = queueData.find(function (item) {
1888
1854
  return item.url.current === path;
@@ -2104,9 +2070,7 @@ var ArticleQueue = function ArticleQueue(props) {
2104
2070
  // Passing queueData to check for single article
2105
2071
  , queueData: queueData,
2106
2072
  showRelatedArticles: showRelatedArticles,
2107
- index: index,
2108
- segmentData: segmentData,
2109
- setSegmentData: setSegmentData
2073
+ index: index
2110
2074
  }))
2111
2075
  );
2112
2076
  })
package/dist/esm/View.js CHANGED
@@ -450,9 +450,7 @@ var Recommended = function Recommended(props) {
450
450
  client = props.client,
451
451
  _props$index = props.index,
452
452
  index = _props$index === undefined ? 0 : _props$index,
453
- cpModificationRequired = props.cpModificationRequired,
454
- segmentData = props.segmentData,
455
- setSegmentData = props.setSegmentData;
453
+ cpModificationRequired = props.cpModificationRequired;
456
454
 
457
455
  var _useState = useState(false),
458
456
  _useState2 = _slicedToArray(_useState, 2),
@@ -485,7 +483,6 @@ var Recommended = function Recommended(props) {
485
483
 
486
484
  useEffect(function () {
487
485
  try {
488
-
489
486
  if (!segmentLoaded) {
490
487
  return;
491
488
  }
@@ -499,55 +496,29 @@ var Recommended = function Recommended(props) {
499
496
  // get users traits
500
497
  var getSegmentProfile = function () {
501
498
  var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee() {
502
- var data, anonymousId, response, addTaxonomyName, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
499
+ var anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesQuery, videosQuery, podcastQuery, params, _ref2, _ref3, _articles, videos, podcasts;
503
500
 
504
501
  return regenerator.wrap(function _callee$(_context) {
505
502
  while (1) {
506
503
  switch (_context.prev = _context.next) {
507
504
  case 0:
508
- data = void 0;
509
-
510
- if (segmentData) {
511
- _context.next = 12;
512
- break;
513
- }
514
-
515
505
  anonymousId = analytics.user().anonymousId();
516
- _context.next = 5;
506
+ _context.next = 3;
517
507
  return fetch('/api/getSegmentProfile', {
518
508
  method: 'POST',
519
509
  body: _JSON$stringify({ anonymousId: anonymousId })
520
510
  });
521
511
 
522
- case 5:
512
+ case 3:
523
513
  response = _context.sent;
524
- _context.next = 8;
514
+ _context.next = 6;
525
515
  return response.json();
526
516
 
527
- case 8:
517
+ case 6:
528
518
  data = _context.sent;
529
519
 
530
- if (data) {
531
- setSegmentData(data);
532
- } else {
533
- setLoaded('failed');
534
- }
535
-
536
- _context.next = 13;
537
- break;
538
-
539
- case 12:
540
- data = segmentData;
541
-
542
- case 13:
543
- if (!data || data.error || !data.traits) {
544
- setLoaded('failed');
545
- }
546
-
547
- // console.log('persona result:', data)
548
-
549
520
  if (!(data && data.traits && data.traits.favorite_article_category)) {
550
- _context.next = 29;
521
+ _context.next = 24;
551
522
  break;
552
523
  }
553
524
 
@@ -578,10 +549,10 @@ var Recommended = function Recommended(props) {
578
549
  params = {
579
550
  id: article._id
580
551
  };
581
- _context.next = 23;
552
+ _context.next = 16;
582
553
  return _Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
583
554
 
584
- case 23:
555
+ case 16:
585
556
  _ref2 = _context.sent;
586
557
  _ref3 = _slicedToArray(_ref2, 3);
587
558
  _articles = _ref3[0];
@@ -600,8 +571,13 @@ var Recommended = function Recommended(props) {
600
571
  }
601
572
  setArticles(_articles);
602
573
  }
574
+ _context.next = 25;
575
+ break;
576
+
577
+ case 24:
578
+ setLoaded('failed');
603
579
 
604
- case 29:
580
+ case 25:
605
581
  case 'end':
606
582
  return _context.stop();
607
583
  }
@@ -628,7 +604,6 @@ var Recommended = function Recommended(props) {
628
604
  }, [articles]);
629
605
 
630
606
  useEffect(function () {
631
-
632
607
  try {
633
608
  analytics.ready(function () {
634
609
  setSegmentLoaded(function () {
@@ -929,11 +904,7 @@ var Article = React__default.memo(forwardRef(function (props, ref) {
929
904
  _props$downloadCitati = props.downloadCitation,
930
905
  downloadCitation = _props$downloadCitati === undefined ? false : _props$downloadCitati,
931
906
  _props$useSegmentReco = props.useSegmentRecommendedArticles,
932
- useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco,
933
- _props$segmentData = props.segmentData,
934
- segmentData = _props$segmentData === undefined ? null : _props$segmentData,
935
- _props$setSegmentData = props.setSegmentData,
936
- setSegmentData = _props$setSegmentData === undefined ? function () {} : _props$setSegmentData;
907
+ useSegmentRecommendedArticles = _props$useSegmentReco === undefined ? false : _props$useSegmentReco;
937
908
  var sliderData = props.sliderData;
938
909
 
939
910
 
@@ -1168,7 +1139,7 @@ var Article = React__default.memo(forwardRef(function (props, ref) {
1168
1139
  return React__default.createElement(
1169
1140
  'div',
1170
1141
  null,
1171
- useSegmentRecommendedArticles ? React__default.createElement(Recommended, { segmentData: segmentData, setSegmentData: setSegmentData, client: client, article: article, index: props.index, Settings: props.Settings, showRelatedArticleFallbackImage: props.showRelatedArticleFallbackImage, cpModificationRequired: cpModificationRequired }) : React__default.createElement(
1142
+ useSegmentRecommendedArticles ? React__default.createElement(Recommended, { client: client, article: article, index: props.index, Settings: props.Settings, showRelatedArticleFallbackImage: props.showRelatedArticleFallbackImage, cpModificationRequired: cpModificationRequired }) : React__default.createElement(
1172
1143
  'section',
1173
1144
  { id: 'related-content-section', className: 'my-1' },
1174
1145
  (article.relatedArticle || RelevantTopics()) && React__default.createElement(
@@ -1867,11 +1838,6 @@ var ArticleQueue = function ArticleQueue(props) {
1867
1838
  active = _useState6[0],
1868
1839
  setActive = _useState6[1];
1869
1840
 
1870
- var _useState7 = useState(null),
1871
- _useState8 = _slicedToArray(_useState7, 2),
1872
- segmentData = _useState8[0],
1873
- setSegmentData = _useState8[1];
1874
-
1875
1841
  var refreshAD = function refreshAD(path) {
1876
1842
  var activeArticle = queueData.find(function (item) {
1877
1843
  return item.url.current === path;
@@ -2093,9 +2059,7 @@ var ArticleQueue = function ArticleQueue(props) {
2093
2059
  // Passing queueData to check for single article
2094
2060
  , queueData: queueData,
2095
2061
  showRelatedArticles: showRelatedArticles,
2096
- index: index,
2097
- segmentData: segmentData,
2098
- setSegmentData: setSegmentData
2062
+ index: index
2099
2063
  }))
2100
2064
  );
2101
2065
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.939-segment-test-v5",
3
+ "version": "1.0.939-segment-test-v7",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",