Skip to content

fix: stop likes/views/comments/share/save doubling#1532

Open
SuperGrut wants to merge 1 commit into
gitroomhq:mainfrom
SuperGrut:fix/instagram-analytics-doubled-values
Open

fix: stop likes/views/comments/share/save doubling#1532
SuperGrut wants to merge 1 commit into
gitroomhq:mainfrom
SuperGrut:fix/instagram-analytics-doubled-values

Conversation

@SuperGrut
Copy link
Copy Markdown

@SuperGrut SuperGrut commented May 16, 2026

Closes #1436

What kind of change does this PR introduce?

The PR introduces a bug fix appearing in Analytics Page for Instagram where the total value of metrics like likes/views/comments/share/saves are appearing in 2x values.

Why was this change needed?

Issue Link - #1436

https://github.com/gitroomhq/postiz-app/blob/main/libraries/nestjs-libraries/src/integrations/social/instagram.provider.ts

    analytics.push(
      ...data2.map((d: any) => ({
        label: this.setTitle(d.name),
        percentageChange: 5,
        data: [
          {
            total: d.total_value.value,
            date: dayjs().format('YYYY-MM-DD'),
          },
          // duplicacy to show line on chart
          {
            total: d.total_value.value,
            date: dayjs().add(1, 'day').format('YYYY-MM-DD'),
          },
        ],
      }))
    );

To make the chart render a line (which requires at least 2 points), the backend was duplicating this value into two data points. This caused the frontend to sum both entries, displaying double the actual metric. For example, if actual Like counts were 2, it would display 4(2x of actual data) on analytics chart. Similarly, if comments were 2, it would display 4(2x of actual data).

Fix

Backend: Removed the duplicate data point for total_value metrics. Now pushes a single honest data point.

    analytics.push(
      ...data2.map((d: any) => ({
        label: this.setTitle(d.name),
        percentageChange: 5,
        data: [
          {
            total: d.total_value.value,
            date: dayjs().format('YYYY-MM-DD'),
          },
        ],
      }))
    );

Frontend (ChartSocial): When a dataset has only one data point, a duplicate point is prepended so the chart can render a line and show actual data.

  const list = useMemo(() => {
    const merged = data.length < 7 ? data : mergeDataPoints(data, 7);
    if (merged.length === 1) {
      return [
        // duplicating single datapoints metrics for chart to display a line on analytics
        merged[0],
        merged[0],
      ];
    }
    return merged;
  }, [data]);

Checklist:

Put a "X" in the boxes below to indicate you have followed the checklist;

  • I have read the CONTRIBUTING guide.
  • I confirm I have not used AI to submit this PR or generate code for it.
  • I checked that there were no similar issues or PRs already open for this.
  • This PR fixes just ONE issue

@postiz-contribution postiz-contribution Bot added the contribution:approved Approved contributor label May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution:approved Approved contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instagram analytics — likes/views/comments/shares/saves/replies shown at 2× real value

1 participant