@dracoonghost/trndup-sdk 1.3.17 → 1.3.18

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.mjs CHANGED
@@ -593,6 +593,304 @@ var InsightsModule = class {
593
593
  `/v1/insights/youtube/momentum/history${query}`
594
594
  );
595
595
  }
596
+ // =========================================================================
597
+ // YOUTUBE BEST PERFORMING VIDEO
598
+ // =========================================================================
599
+ /**
600
+ * Get the best performing video in a time period
601
+ *
602
+ * Identifies your top video by views and explains WHY it performed well.
603
+ *
604
+ * @param params - Query parameters
605
+ * @param params.period - Days to analyze (1-90, default: 30)
606
+ *
607
+ * @example
608
+ * ```typescript
609
+ * const result = await client.insights.getYouTubeBestVideo({ period: 30 });
610
+ *
611
+ * if (result.hasData) {
612
+ * console.log(`🏆 ${result.data.topVideo.title}`);
613
+ * console.log(`Views: ${result.data.metrics.views}`);
614
+ * console.log(`${result.data.comparison.vsChannelAverage.description}`);
615
+ * console.log(result.data.insight);
616
+ *
617
+ * // Show how it was calculated
618
+ * console.log(result._meta.howWeCalculatedThis.method);
619
+ * } else {
620
+ * console.log(result.suggestion);
621
+ * }
622
+ * ```
623
+ *
624
+ * GET /v1/insights/youtube/best-video
625
+ */
626
+ async getYouTubeBestVideo(params) {
627
+ const query = params?.period ? `?period=${params.period}` : "";
628
+ return this.client.get(
629
+ `/v1/insights/youtube/best-video${query}`
630
+ );
631
+ }
632
+ // =========================================================================
633
+ // YOUTUBE CONTENT DECAY
634
+ // =========================================================================
635
+ /**
636
+ * Find videos that are losing momentum
637
+ *
638
+ * Compares current period vs previous period to identify declining videos.
639
+ * Provides actionable suggestions for each decaying video.
640
+ *
641
+ * @param params - Query parameters
642
+ * @param params.period - Days per comparison period (3-14, default: 7)
643
+ *
644
+ * @example
645
+ * ```typescript
646
+ * const result = await client.insights.getYouTubeContentDecay({ period: 7 });
647
+ *
648
+ * if (result.hasData) {
649
+ * console.log(result.data.insight);
650
+ * console.log(`${result.data.summary.totalDecaying} videos declining`);
651
+ *
652
+ * for (const video of result.data.decayingVideos) {
653
+ * console.log(`📉 ${video.title}: ${video.decayRate}%`);
654
+ * console.log(` ${video.suggestion}`);
655
+ * }
656
+ * }
657
+ * ```
658
+ *
659
+ * GET /v1/insights/youtube/content-decay
660
+ */
661
+ async getYouTubeContentDecay(params) {
662
+ const query = params?.period ? `?period=${params.period}` : "";
663
+ return this.client.get(
664
+ `/v1/insights/youtube/content-decay${query}`
665
+ );
666
+ }
667
+ // =========================================================================
668
+ // YOUTUBE AUDIENCE ACTIVITY
669
+ // =========================================================================
670
+ /**
671
+ * Get when your audience is most active
672
+ *
673
+ * Unlike generic advice, this is based on YOUR audience's behavior.
674
+ * Analyzes first-day performance by publish day and time to identify
675
+ * when your audience is most engaged.
676
+ *
677
+ * @example
678
+ * ```typescript
679
+ * const result = await client.insights.getYouTubeAudienceActivity();
680
+ *
681
+ * if (result.hasData) {
682
+ * console.log(`📅 Most active day: ${result.data.mostActiveDay.day}`);
683
+ * console.log(`⏰ Peak time: ${result.data.mostActiveTimeSlot.label}`);
684
+ * console.log(result.data.insight);
685
+ *
686
+ * // Show day breakdown
687
+ * for (const day of result.data.dayBreakdown) {
688
+ * console.log(`${day.day}: ${day.avgFirstDayViews} avg views`);
689
+ * }
690
+ * }
691
+ * ```
692
+ *
693
+ * GET /v1/insights/youtube/audience-activity
694
+ */
695
+ async getYouTubeAudienceActivity() {
696
+ return this.client.get(
697
+ "/v1/insights/youtube/audience-activity"
698
+ );
699
+ }
700
+ /**
701
+ * @deprecated Use `getYouTubeAudienceActivity()` instead
702
+ */
703
+ async getYouTubeBestUploadTime() {
704
+ return this.getYouTubeAudienceActivity();
705
+ }
706
+ // =========================================================================
707
+ // YOUTUBE FADING HITS
708
+ // =========================================================================
709
+ /**
710
+ * Find videos that were hits but are now declining
711
+ *
712
+ * Identifies videos that performed above your channel average initially
713
+ * but have since lost momentum. These are revival opportunities.
714
+ *
715
+ * @example
716
+ * ```typescript
717
+ * const result = await client.insights.getYouTubeFadingHits();
718
+ *
719
+ * if (result.hasData) {
720
+ * console.log(result.data.insight);
721
+ * console.log(`${result.data.summary.totalFading} videos could use a boost`);
722
+ *
723
+ * for (const video of result.data.fadingHits) {
724
+ * console.log(`📉 ${video.title}`);
725
+ * console.log(` Peak: ${video.peakPeriod.avgDailyViews} views/day`);
726
+ * console.log(` Now: ${video.currentPeriod.avgDailyViews} views/day`);
727
+ * console.log(` Decline: ${video.decline.percentage}%`);
728
+ * console.log(` Revival potential: ${video.revivalPotential}`);
729
+ * console.log(` ${video.whyRevive}`);
730
+ * for (const suggestion of video.suggestions) {
731
+ * console.log(` 💡 ${suggestion}`);
732
+ * }
733
+ * }
734
+ * }
735
+ * ```
736
+ *
737
+ * GET /v1/insights/youtube/fading-hits
738
+ */
739
+ async getYouTubeFadingHits() {
740
+ return this.client.get(
741
+ "/v1/insights/youtube/fading-hits"
742
+ );
743
+ }
744
+ // =========================================================================
745
+ // YOUTUBE SUBSCRIBER QUALITY
746
+ // =========================================================================
747
+ /**
748
+ * Measure subscriber quality score (0-100)
749
+ *
750
+ * Analyzes whether new subscribers are engaged or just numbers.
751
+ * Helps identify fake growth or low-quality audiences.
752
+ *
753
+ * @param params - Query parameters
754
+ * @param params.period - Days to analyze (7-90, default: 30)
755
+ *
756
+ * @example
757
+ * ```typescript
758
+ * const result = await client.insights.getYouTubeSubscriberQuality({ period: 90 });
759
+ *
760
+ * if (result.hasData) {
761
+ * console.log(`Quality Score: ${result.data.qualityScore}/100 (${result.data.scoreLabel})`);
762
+ * console.log(`Retention: ${result.data.metrics.retentionRate}%`);
763
+ * console.log(result.data.insight);
764
+ *
765
+ * // Show recommendations
766
+ * for (const rec of result.data.recommendations) {
767
+ * console.log(`💡 ${rec}`);
768
+ * }
769
+ * }
770
+ * ```
771
+ *
772
+ * GET /v1/insights/youtube/subscriber-quality
773
+ */
774
+ async getYouTubeSubscriberQuality(params) {
775
+ const query = params?.period ? `?period=${params.period}` : "";
776
+ return this.client.get(
777
+ `/v1/insights/youtube/subscriber-quality${query}`
778
+ );
779
+ }
780
+ // =========================================================================
781
+ // YOUTUBE AUDIENCE FATIGUE
782
+ // =========================================================================
783
+ /**
784
+ * Detect if your audience is getting tired of your content
785
+ *
786
+ * Compares key engagement metrics between recent and previous periods
787
+ * to identify declining audience interest before it becomes critical.
788
+ *
789
+ * @param params - Query parameters
790
+ * @param params.period - Days per comparison period (14-90, default: 30)
791
+ *
792
+ * @example
793
+ * ```typescript
794
+ * const result = await client.insights.getYouTubeAudienceFatigue({ period: 30 });
795
+ *
796
+ * if (result.hasData) {
797
+ * console.log(`Fatigue Index: ${result.data.fatigueIndex}/100`);
798
+ * console.log(`Level: ${result.data.fatigueLevel}`);
799
+ * console.log(result.data.insight);
800
+ *
801
+ * // Check individual signals
802
+ * if (result.data.signals.watchTimePerView.indicatesFatigue) {
803
+ * console.log('⚠️ Watch time is declining');
804
+ * }
805
+ *
806
+ * // Get recommendations
807
+ * for (const rec of result.data.recommendations) {
808
+ * console.log(`💡 ${rec}`);
809
+ * }
810
+ * }
811
+ * ```
812
+ *
813
+ * GET /v1/insights/youtube/audience-fatigue
814
+ */
815
+ async getYouTubeAudienceFatigue(params) {
816
+ const query = params?.period ? `?period=${params.period}` : "";
817
+ return this.client.get(
818
+ `/v1/insights/youtube/audience-fatigue${query}`
819
+ );
820
+ }
821
+ // =========================================================================
822
+ // YOUTUBE OPTIMAL VIDEO LENGTH
823
+ // =========================================================================
824
+ /**
825
+ * Find the ideal video length for YOUR audience
826
+ *
827
+ * Unlike generic "8-12 minutes is best" advice, this is personalized
828
+ * based on how YOUR videos perform at different lengths.
829
+ *
830
+ * @example
831
+ * ```typescript
832
+ * const result = await client.insights.getYouTubeOptimalLength();
833
+ *
834
+ * if (result.hasData) {
835
+ * console.log(`Optimal: ${result.data.optimalLength.bucket}`);
836
+ * console.log(`Confidence: ${result.data.optimalLength.confidence}`);
837
+ * console.log(result.data.insight);
838
+ *
839
+ * // Show breakdown by length
840
+ * for (const bucket of result.data.breakdown) {
841
+ * const marker = bucket.isOptimal ? '🏆' : ' ';
842
+ * console.log(`${marker} ${bucket.bucket}: ${bucket.avgRetention}% retention, ${bucket.avgEngagement}% engagement`);
843
+ * }
844
+ *
845
+ * // Recommendations
846
+ * for (const rec of result.data.recommendations) {
847
+ * console.log(`💡 ${rec}`);
848
+ * }
849
+ * }
850
+ * ```
851
+ *
852
+ * GET /v1/insights/youtube/optimal-length
853
+ */
854
+ async getYouTubeOptimalLength() {
855
+ return this.client.get(
856
+ "/v1/insights/youtube/optimal-length"
857
+ );
858
+ }
859
+ // =========================================================================
860
+ // YOUTUBE ALL INSIGHTS
861
+ // =========================================================================
862
+ /**
863
+ * Get all YouTube insights in one call
864
+ *
865
+ * Efficient for dashboard display - fetches all insights in parallel.
866
+ * Each insight has `hasData: boolean` to check availability.
867
+ *
868
+ * @example
869
+ * ```typescript
870
+ * const all = await client.insights.getYouTubeAllInsights();
871
+ *
872
+ * // Check which insights are available
873
+ * console.log('Available:', all._meta.insightsAvailable);
874
+ *
875
+ * // Use each insight
876
+ * if (all.data.bestPerformingVideo.hasData) {
877
+ * console.log(`Best: ${all.data.bestPerformingVideo.data.topVideo.title}`);
878
+ * }
879
+ *
880
+ * if (all.data.audienceFatigue.hasData) {
881
+ * console.log(`Fatigue: ${all.data.audienceFatigue.data.fatigueLevel}`);
882
+ * }
883
+ *
884
+ * if (all.data.optimalLength.hasData) {
885
+ * console.log(`Optimal Length: ${all.data.optimalLength.data.optimalLength.bucket}`);
886
+ * }
887
+ * ```
888
+ *
889
+ * GET /v1/insights/youtube/all
890
+ */
891
+ async getYouTubeAllInsights() {
892
+ return this.client.get("/v1/insights/youtube/all");
893
+ }
596
894
  };
597
895
 
598
896
  // modules/activity.ts