Skip to content

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

Merged
egelhaus merged 1 commit into
gitroomhq:mainfrom
SuperGrut:fix/instagram-analytics-doubled-values
May 30, 2026
Merged

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

Conversation

@SuperGrut

@SuperGrut SuperGrut commented May 16, 2026

Copy link
Copy Markdown
Contributor

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
@egelhaus egelhaus added the contribution:evaluate Evaluate the PR again label May 30, 2026
@postiz-contribution

Copy link
Copy Markdown

Hi @SuperGrut! Before we can accept contributions to Postiz you need to sign the Contributor License Agreement. Sign here: https://contribute.postiz.com/p/postiz/cla — your PR stays open and we'll re-check automatically once signed.

@postiz-contribution postiz-contribution Bot added contribution:cla-pending Awaiting CLA signature / DCO sign-off contribution:approved Approved contributor and removed contribution:approved Approved contributor contribution:evaluate Evaluate the PR again contribution:cla-pending Awaiting CLA signature / DCO sign-off labels May 30, 2026
@egelhaus egelhaus added the contribution:evaluate Evaluate the PR again label May 30, 2026
@postiz-contribution postiz-contribution Bot removed the contribution:evaluate Evaluate the PR again label May 30, 2026
@egelhaus egelhaus added this pull request to the merge queue May 30, 2026
@egelhaus egelhaus removed this pull request from the merge queue due to a manual request May 30, 2026
@egelhaus egelhaus merged commit 8c89d9a into gitroomhq:main May 30, 2026
4 checks passed
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

2 participants