@mjhls/mjh-framework 1.0.974-rec-article-test → 1.0.974-test2

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
@@ -32,7 +32,7 @@ var disqusReact = require('disqus-react');
32
32
  var Schema = require('./Schema.js');
33
33
  var _commonjsHelpers = require('./_commonjsHelpers-06173234.js');
34
34
  var PixelTracking = require('./PixelTracking.js');
35
- require('./Segment.js');
35
+ var Segment = require('./Segment.js');
36
36
  var keys = require('./keys-e982b3fa.js');
37
37
  var index_es = require('./index.es-f3e47207.js');
38
38
  var index = require('./index-fc2f1ca2.js');
@@ -495,6 +495,11 @@ var Recommended = function Recommended(props) {
495
495
  setLoaded = _useState6[1]; // loading, loaded, failed
496
496
 
497
497
 
498
+ var _useState7 = React.useState(''),
499
+ _useState8 = slicedToArray._slicedToArray(_useState7, 2);
500
+ _useState8[0];
501
+ _useState8[1];
502
+
498
503
  var starting = index * 5;
499
504
  var contentMapping = {
500
505
  videos: 'video',
@@ -513,6 +518,7 @@ var Recommended = function Recommended(props) {
513
518
  return;
514
519
  }
515
520
  if (mainCategories.length > 0) {
521
+ console.log(mainCategories);
516
522
  analytics.track('Article Category Viewed', {
517
523
  categories: stringify._JSON$stringify(mainCategories)
518
524
  });
@@ -542,10 +548,7 @@ var Recommended = function Recommended(props) {
542
548
 
543
549
  case 8:
544
550
  externalIds = _context.sent;
545
-
546
- // console.log('externalIds', externalIds)
547
551
  slicedEmails = emails.emails;
548
- // console.log('emailData', emailData)
549
552
 
550
553
  if (externalIds && externalIds.data) {
551
554
  slicedEmails.forEach(function (obj) {
@@ -580,10 +583,10 @@ var Recommended = function Recommended(props) {
580
583
  case 2:
581
584
  articleRecs = _context2.sent;
582
585
 
583
- // console.log('articleRecs', articleRecs)
586
+ console.log('articleRecs', articleRecs);
584
587
  if (articleRecs) setArticles(articleRecs.slice(0, 5));
585
588
 
586
- case 4:
589
+ case 5:
587
590
  case 'end':
588
591
  return _context2.stop();
589
592
  }
@@ -598,61 +601,71 @@ var Recommended = function Recommended(props) {
598
601
  // get users traits
599
602
  var getSegmentProfile = function () {
600
603
  var _ref3 = asyncToGenerator._asyncToGenerator( /*#__PURE__*/asyncToGenerator.regenerator.mark(function _callee3() {
601
- var storedUsers, anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesCategory, videosCategory, podcastCategory, taxonomyCategories, taxonomies, articlesQuery, videosQuery, podcastQuery, params, _ref4, _ref5, _articles, videos, podcasts;
604
+ var storedUsers, anonymousId, traits, traitData, response, data, addTaxonomyName, favoriteCategories, articlesCategory, videosCategory, podcastCategory, taxonomyCategories, taxonomies, articlesQuery, videosQuery, podcastQuery, params, _ref4, _ref5, _articles, videos, podcasts;
602
605
 
603
606
  return asyncToGenerator.regenerator.wrap(function _callee3$(_context3) {
604
607
  while (1) {
605
608
  switch (_context3.prev = _context3.next) {
606
609
  case 0:
607
610
  storedUsers = false;
608
- // Segment.identifyWithEmail('arthur@sato.org')
611
+ // const emailData = await import('../../../emails')
609
612
 
610
613
  anonymousId = analytics.user().anonymousId();
611
- // console.log('anonymousId', anonymousId)
612
-
613
- // Segment.createGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonymousI'onclive_test3')
614
- // Segment.identifyWithGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonId)
615
- // const traits = await fetch('/api/getTraits', {
616
- // method: 'POST',
617
- // body: JSON.stringify({ anonymousId: anonymousId })
618
- // })
619
- // const traitData = await traits.json()
620
- // console.log('persona result:', traitData)
621
- // if (traitData.traits && traitData.traits.groupId) {
622
- // try {
623
- // docGroupRecs(traitData.traits.groupId)
624
- // // trackedEmailRecs(anonymousId, '')
625
- // } catch (e) {
626
- // if (e) console.log(`Error: ${e}`)
627
- // }
628
- // }
614
+
615
+ console.log('anonymousId', anonymousId);
616
+ // Segment.createGroup('test_group_2', anonymousId, 'onclive_test2')
617
+ // Segment.createGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonymousId, 'onclive_test3')
618
+ Segment.identifyWithGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonymousId);
619
+
620
+ _context3.next = 6;
621
+ return fetch('/api/getTraits', {
622
+ method: 'POST',
623
+ body: stringify._JSON$stringify({ anonymousId: anonymousId })
624
+ });
625
+
626
+ case 6:
627
+ traits = _context3.sent;
628
+ _context3.next = 9;
629
+ return traits.json();
630
+
631
+ case 9:
632
+ traitData = _context3.sent;
633
+
634
+ console.log('persona result:', traitData);
635
+
636
+ if (!(traitData.traits && traitData.traits.groupId)) {
637
+ _context3.next = 15;
638
+ break;
639
+ }
629
640
 
630
641
  try {
631
- trackedEmailRecs(anonymousId, '9e4fb278-daa9-448a-bf46-d168085d9126');
642
+ docGroupRecs(traitData.traits.groupId);
632
643
  } catch (e) {
633
644
  if (e) console.log('Error: ' + e);
634
645
  }
635
- // else {
636
- _context3.next = 5;
646
+ _context3.next = 56;
647
+ break;
648
+
649
+ case 15:
650
+ _context3.next = 17;
637
651
  return fetch('/api/getSegmentProfile', {
638
652
  method: 'POST',
639
653
  body: stringify._JSON$stringify({ anonymousId: anonymousId })
640
654
  });
641
655
 
642
- case 5:
656
+ case 17:
643
657
  response = _context3.sent;
644
- _context3.next = 8;
658
+ _context3.next = 20;
645
659
  return response.json();
646
660
 
647
- case 8:
661
+ case 20:
648
662
  data = _context3.sent;
649
663
 
650
664
  if (!(data && data.traits && data.traits.most_frequent_category)) {
651
- _context3.next = 42;
665
+ _context3.next = 55;
652
666
  break;
653
667
  }
654
668
 
655
- // console.log('%csegment user profile', 'font-size:1.5rem;color:#000000;padding:1rem;background-color:yellow;', data.traits)
656
669
  addTaxonomyName = function addTaxonomyName(taxArr) {
657
670
  if (!taxArr) return '';
658
671
  var query = ' && ( ';
@@ -669,29 +682,31 @@ var Recommended = function Recommended(props) {
669
682
  return query;
670
683
  };
671
684
 
685
+ // console.log('%csegment user profile', 'font-size:1.5rem;color:#000000;padding:1rem;background-color:yellow;', data.traits)
686
+ console.log('in data conditional');
672
687
  favoriteCategories = JSON.parse(data.traits.most_frequent_category);
673
688
 
674
689
  // grab contentCategory ID
675
690
 
676
- _context3.next = 14;
691
+ _context3.next = 27;
677
692
  return client.fetch("*[_type == 'contentCategory' && name == 'Articles'][0]{_id}");
678
693
 
679
- case 14:
694
+ case 27:
680
695
  articlesCategory = _context3.sent;
681
- _context3.next = 17;
696
+ _context3.next = 30;
682
697
  return client.fetch("*[_type == 'contentCategory' && name == 'Videos'][0]{_id}");
683
698
 
684
- case 17:
699
+ case 30:
685
700
  videosCategory = _context3.sent;
686
- _context3.next = 20;
701
+ _context3.next = 33;
687
702
  return client.fetch("*[_type == 'contentCategory' && name == 'Podcasts'][0]{_id}");
688
703
 
689
- case 20:
704
+ case 33:
690
705
  podcastCategory = _context3.sent;
691
- _context3.next = 23;
706
+ _context3.next = 36;
692
707
  return client.fetch('*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']');
693
708
 
694
- case 23:
709
+ case 36:
695
710
  taxonomyCategories = _context3.sent;
696
711
  taxonomies = '';
697
712
 
@@ -711,10 +726,10 @@ var Recommended = function Recommended(props) {
711
726
  params = {
712
727
  id: article._id
713
728
  };
714
- _context3.next = 33;
729
+ _context3.next = 46;
715
730
  return asyncToGenerator._Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
716
731
 
717
- case 33:
732
+ case 46:
718
733
  _ref4 = _context3.sent;
719
734
  _ref5 = slicedToArray._slicedToArray(_ref4, 3);
720
735
  _articles = _ref5[0];
@@ -736,13 +751,13 @@ var Recommended = function Recommended(props) {
736
751
  }
737
752
  setArticles(_articles);
738
753
  }
739
- _context3.next = 43;
754
+ _context3.next = 56;
740
755
  break;
741
756
 
742
- case 42:
757
+ case 55:
743
758
  setLoaded('failed');
744
759
 
745
- case 43:
760
+ case 56:
746
761
  case 'end':
747
762
  return _context3.stop();
748
763
  }
@@ -754,7 +769,6 @@ var Recommended = function Recommended(props) {
754
769
  return _ref3.apply(this, arguments);
755
770
  };
756
771
  }();
757
-
758
772
  getSegmentProfile();
759
773
  } catch (err) {
760
774
  console.log(err);
package/dist/esm/View.js CHANGED
@@ -30,7 +30,7 @@ import { DiscussionEmbed } from 'disqus-react';
30
30
  import Schema from './Schema.js';
31
31
  import { c as createCommonjsModule, a as commonjsGlobal } from './_commonjsHelpers-0c4b6f40.js';
32
32
  import { PixelTrackingArticle } from './PixelTracking.js';
33
- import './Segment.js';
33
+ import Segment from './Segment.js';
34
34
  import { _ as _Object$keys } from './keys-31dcdb31.js';
35
35
  import { I as InfiniteScroll } from './index.es-a6137319.js';
36
36
  import { l as lib_3 } from './index-f0fc23eb.js';
@@ -485,6 +485,11 @@ var Recommended = function Recommended(props) {
485
485
  setLoaded = _useState6[1]; // loading, loaded, failed
486
486
 
487
487
 
488
+ var _useState7 = useState(''),
489
+ _useState8 = _slicedToArray(_useState7, 2);
490
+ _useState8[0];
491
+ _useState8[1];
492
+
488
493
  var starting = index * 5;
489
494
  var contentMapping = {
490
495
  videos: 'video',
@@ -503,6 +508,7 @@ var Recommended = function Recommended(props) {
503
508
  return;
504
509
  }
505
510
  if (mainCategories.length > 0) {
511
+ console.log(mainCategories);
506
512
  analytics.track('Article Category Viewed', {
507
513
  categories: _JSON$stringify(mainCategories)
508
514
  });
@@ -532,10 +538,7 @@ var Recommended = function Recommended(props) {
532
538
 
533
539
  case 8:
534
540
  externalIds = _context.sent;
535
-
536
- // console.log('externalIds', externalIds)
537
541
  slicedEmails = emails.emails;
538
- // console.log('emailData', emailData)
539
542
 
540
543
  if (externalIds && externalIds.data) {
541
544
  slicedEmails.forEach(function (obj) {
@@ -570,10 +573,10 @@ var Recommended = function Recommended(props) {
570
573
  case 2:
571
574
  articleRecs = _context2.sent;
572
575
 
573
- // console.log('articleRecs', articleRecs)
576
+ console.log('articleRecs', articleRecs);
574
577
  if (articleRecs) setArticles(articleRecs.slice(0, 5));
575
578
 
576
- case 4:
579
+ case 5:
577
580
  case 'end':
578
581
  return _context2.stop();
579
582
  }
@@ -588,61 +591,71 @@ var Recommended = function Recommended(props) {
588
591
  // get users traits
589
592
  var getSegmentProfile = function () {
590
593
  var _ref3 = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee3() {
591
- var storedUsers, anonymousId, response, data, addTaxonomyName, favoriteCategories, articlesCategory, videosCategory, podcastCategory, taxonomyCategories, taxonomies, articlesQuery, videosQuery, podcastQuery, params, _ref4, _ref5, _articles, videos, podcasts;
594
+ var storedUsers, anonymousId, traits, traitData, response, data, addTaxonomyName, favoriteCategories, articlesCategory, videosCategory, podcastCategory, taxonomyCategories, taxonomies, articlesQuery, videosQuery, podcastQuery, params, _ref4, _ref5, _articles, videos, podcasts;
592
595
 
593
596
  return regenerator.wrap(function _callee3$(_context3) {
594
597
  while (1) {
595
598
  switch (_context3.prev = _context3.next) {
596
599
  case 0:
597
600
  storedUsers = false;
598
- // Segment.identifyWithEmail('arthur@sato.org')
601
+ // const emailData = await import('../../../emails')
599
602
 
600
603
  anonymousId = analytics.user().anonymousId();
601
- // console.log('anonymousId', anonymousId)
602
-
603
- // Segment.createGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonymousI'onclive_test3')
604
- // Segment.identifyWithGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonId)
605
- // const traits = await fetch('/api/getTraits', {
606
- // method: 'POST',
607
- // body: JSON.stringify({ anonymousId: anonymousId })
608
- // })
609
- // const traitData = await traits.json()
610
- // console.log('persona result:', traitData)
611
- // if (traitData.traits && traitData.traits.groupId) {
612
- // try {
613
- // docGroupRecs(traitData.traits.groupId)
614
- // // trackedEmailRecs(anonymousId, '')
615
- // } catch (e) {
616
- // if (e) console.log(`Error: ${e}`)
617
- // }
618
- // }
604
+
605
+ console.log('anonymousId', anonymousId);
606
+ // Segment.createGroup('test_group_2', anonymousId, 'onclive_test2')
607
+ // Segment.createGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonymousId, 'onclive_test3')
608
+ Segment.identifyWithGroup('9e4fb278-daa9-448a-bf46-d168085d9126', anonymousId);
609
+
610
+ _context3.next = 6;
611
+ return fetch('/api/getTraits', {
612
+ method: 'POST',
613
+ body: _JSON$stringify({ anonymousId: anonymousId })
614
+ });
615
+
616
+ case 6:
617
+ traits = _context3.sent;
618
+ _context3.next = 9;
619
+ return traits.json();
620
+
621
+ case 9:
622
+ traitData = _context3.sent;
623
+
624
+ console.log('persona result:', traitData);
625
+
626
+ if (!(traitData.traits && traitData.traits.groupId)) {
627
+ _context3.next = 15;
628
+ break;
629
+ }
619
630
 
620
631
  try {
621
- trackedEmailRecs(anonymousId, '9e4fb278-daa9-448a-bf46-d168085d9126');
632
+ docGroupRecs(traitData.traits.groupId);
622
633
  } catch (e) {
623
634
  if (e) console.log('Error: ' + e);
624
635
  }
625
- // else {
626
- _context3.next = 5;
636
+ _context3.next = 56;
637
+ break;
638
+
639
+ case 15:
640
+ _context3.next = 17;
627
641
  return fetch('/api/getSegmentProfile', {
628
642
  method: 'POST',
629
643
  body: _JSON$stringify({ anonymousId: anonymousId })
630
644
  });
631
645
 
632
- case 5:
646
+ case 17:
633
647
  response = _context3.sent;
634
- _context3.next = 8;
648
+ _context3.next = 20;
635
649
  return response.json();
636
650
 
637
- case 8:
651
+ case 20:
638
652
  data = _context3.sent;
639
653
 
640
654
  if (!(data && data.traits && data.traits.most_frequent_category)) {
641
- _context3.next = 42;
655
+ _context3.next = 55;
642
656
  break;
643
657
  }
644
658
 
645
- // console.log('%csegment user profile', 'font-size:1.5rem;color:#000000;padding:1rem;background-color:yellow;', data.traits)
646
659
  addTaxonomyName = function addTaxonomyName(taxArr) {
647
660
  if (!taxArr) return '';
648
661
  var query = ' && ( ';
@@ -659,29 +672,31 @@ var Recommended = function Recommended(props) {
659
672
  return query;
660
673
  };
661
674
 
675
+ // console.log('%csegment user profile', 'font-size:1.5rem;color:#000000;padding:1rem;background-color:yellow;', data.traits)
676
+ console.log('in data conditional');
662
677
  favoriteCategories = JSON.parse(data.traits.most_frequent_category);
663
678
 
664
679
  // grab contentCategory ID
665
680
 
666
- _context3.next = 14;
681
+ _context3.next = 27;
667
682
  return client.fetch("*[_type == 'contentCategory' && name == 'Articles'][0]{_id}");
668
683
 
669
- case 14:
684
+ case 27:
670
685
  articlesCategory = _context3.sent;
671
- _context3.next = 17;
686
+ _context3.next = 30;
672
687
  return client.fetch("*[_type == 'contentCategory' && name == 'Videos'][0]{_id}");
673
688
 
674
- case 17:
689
+ case 30:
675
690
  videosCategory = _context3.sent;
676
- _context3.next = 20;
691
+ _context3.next = 33;
677
692
  return client.fetch("*[_type == 'contentCategory' && name == 'Podcasts'][0]{_id}");
678
693
 
679
- case 20:
694
+ case 33:
680
695
  podcastCategory = _context3.sent;
681
- _context3.next = 23;
696
+ _context3.next = 36;
682
697
  return client.fetch('*[_type == \'taxonomy\' ' + addTaxonomyName(favoriteCategories) + ']');
683
698
 
684
- case 23:
699
+ case 36:
685
700
  taxonomyCategories = _context3.sent;
686
701
  taxonomies = '';
687
702
 
@@ -701,10 +716,10 @@ var Recommended = function Recommended(props) {
701
716
  params = {
702
717
  id: article._id
703
718
  };
704
- _context3.next = 33;
719
+ _context3.next = 46;
705
720
  return _Promise.all([client.fetch(articlesQuery, params), client.fetch(videosQuery, params), client.fetch(podcastQuery, params)]);
706
721
 
707
- case 33:
722
+ case 46:
708
723
  _ref4 = _context3.sent;
709
724
  _ref5 = _slicedToArray(_ref4, 3);
710
725
  _articles = _ref5[0];
@@ -726,13 +741,13 @@ var Recommended = function Recommended(props) {
726
741
  }
727
742
  setArticles(_articles);
728
743
  }
729
- _context3.next = 43;
744
+ _context3.next = 56;
730
745
  break;
731
746
 
732
- case 42:
747
+ case 55:
733
748
  setLoaded('failed');
734
749
 
735
- case 43:
750
+ case 56:
736
751
  case 'end':
737
752
  return _context3.stop();
738
753
  }
@@ -744,7 +759,6 @@ var Recommended = function Recommended(props) {
744
759
  return _ref3.apply(this, arguments);
745
760
  };
746
761
  }();
747
-
748
762
  getSegmentProfile();
749
763
  } catch (err) {
750
764
  console.log(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mjhls/mjh-framework",
3
- "version": "1.0.974-rec-article-test",
3
+ "version": "1.0.974-test2",
4
4
  "description": "Foundation Framework",
5
5
  "author": "mjh-framework",
6
6
  "license": "MIT",