Skip to content

Fix hardcoded 5% analytics growth across all providers#1327

Open
tcpsyn wants to merge 1 commit intogitroomhq:mainfrom
tcpsyn:fix/analytics-percentage-change
Open

Fix hardcoded 5% analytics growth across all providers#1327
tcpsyn wants to merge 1 commit intogitroomhq:mainfrom
tcpsyn:fix/analytics-percentage-change

Conversation

@tcpsyn
Copy link

@tcpsyn tcpsyn commented Mar 19, 2026

Summary

  • The percentageChange field in analytics data was hardcoded to 5 in five social media providers (X/Twitter, Facebook, LinkedIn Page, Instagram, Threads), causing the analytics dashboard to always display a fake 5% growth indicator regardless of actual data
  • Added a shared calculatePercentageChange() utility function that computes real percentage change by comparing the first half vs second half of time-series data
  • Applied the utility across all affected providers; metrics with only aggregated/total values (no time series) correctly return 0 instead of a misleading number

Affected Providers

Provider Lines Changed Fix
X (Twitter) x.provider.ts Was percentageChange: 5 → now calculated from metric data
Facebook facebook.provider.ts Was percentageChange: 5 → now calculated from daily insights
LinkedIn Page linkedin.page.provider.ts Was percentageChange: 5 → now calculated from page analytics
Instagram instagram.provider.ts Was percentageChange: 5 in 2 places → calculated for time-series, 0 for aggregates
Threads threads.provider.ts Was percentageChange: 5 → calculated for daily data, 0 for total_value

New File

libraries/nestjs-libraries/src/integrations/social/analytics.utils.ts — shared utility that:

  • Splits data array at midpoint into first/second half
  • Sums totals for each half (handles both string and number values)
  • Returns ((secondHalfSum - firstHalfSum) / firstHalfSum) * 100, rounded to 1 decimal
  • Returns 0 for edge cases (< 2 data points, zero first-half sum)

Test plan

  • Verified fix on a self-hosted Postiz instance with connected social accounts
  • Analytics dashboard shows real percentage changes instead of 5% across all platforms
  • Providers with aggregate-only data (no time series) correctly show 0% instead of fake growth
  • No changes to posting, scheduling, or any other functionality

🤖 Generated with Claude Code

The percentageChange field was hardcoded to 5 in X, Facebook, LinkedIn Page,
Instagram, and Threads providers, always showing fake 5% growth regardless of
actual data. Added calculatePercentageChange utility that computes real
percentage change by comparing first half vs second half of time-series data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@tcpsyn tcpsyn deployed to build-pr March 19, 2026 03:27 — with GitHub Actions Active
@vercel
Copy link

vercel bot commented Mar 19, 2026

@tcpsyn is attempting to deploy a commit to the Listinai Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant