Skip to content

Show TikTok post metrics on the post screen - #363

Merged
paulocastellano merged 8 commits into
mainfrom
feat/tiktok-post-analytics
Sep 18, 2026
Merged

paulocastellano merged 8 commits into
mainfrom
feat/tiktok-post-analytics

Conversation

@paulocastellano

@paulocastellano paulocastellano commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wire TikTok into PostMetricsFetcher so the post show card can load views, likes, comments, and shares via POST /v2/video/query/.
  • When TikTok's status fetch never returns publicaly_available_post_id (common after PUBLISH_COMPLETE), match the video on video/list by caption and persist the numeric id + /video/{id} URL — at publish time for public posts, and again when metrics load.
  • Centralize TikTok privacy (PUBLIC_TO_EVERYONE, MUTUAL_FOLLOW_FRIENDS, FOLLOWER_OF_CREATOR, SELF_ONLY) in a PrivacyLevel enum across web, API, MCP and the editor. SELF_ONLY + branded content is rejected everywhere. SELF_ONLY is never looked up on video/list.

Test plan

Publish only to TikTok (other networks just add noise). Use a unique caption each time so the video/list match cannot grab an older post. After each publish, wait until the card is published, then open the post show screen.

1. Editor — privacy + branded (no publish needed)

  • Privacy dropdown lists Public / Friends / Followers / Private (only the options TikTok returned for the account).
  • Publish is blocked until a privacy level is picked.
  • Turn on Disclose → Branded content while privacy is Private: Private clears, toast explains why, Private is disabled in the dropdown, amber hint shows.
  • With branded still on, pick Public (or Friends / Followers) — that is allowed.
  • Turn branded off: Private becomes selectable again.
  • Video variant shows Comments + Duet + Stitch + “Made with AI”. Photo variant hides Duet / Stitch / AI and shows Auto add music.

2. Publish matrix

Do these 6 posts. Comments / Duet / Stitch / AI / auto-music do not change analytics — flip them once on the first video and first carousel so the payload still goes through, then leave them.

# Format Privacy Disclose After it publishes, check
1 Video Public off Show card has views / likes / comments / shares. Link opens tiktok.com/@user/video/{id}, not the profile.
2 Video Friends off Publishes. Metrics / /video/{id} only if TikTok exposes a public id — empty card + profile link is OK. Page must not error.
3 Video Followers off Same as #2.
4 Video Private off Publishes. Card stays empty (no metrics). Link stays the profile. Page must not error.
5 Carousel (2+ photos) Public off Same as #1 — metrics + /video/{id} (photo posts also get an item id). Auto add music = yes on this one.
6 Carousel Private off Same as #4.

Then one branded publish (TikTok forbids Private + branded, already covered in §1):

3. Show screen / cache

  • Open an older public TikTok that still points at the profile: first load may rewrite platform_url to /video/{id} and then show metrics. Reload once if the first paint was empty.
  • A still-in-review card stays empty instead of breaking the page. Reload after TikTok finishes — metrics should appear without waiting on a 5-minute unsupported cache.

4. Automated

  • php artisan test --compact tests/Feature/Services/Social/TikTokAnalyticsTest.php tests/Feature/Services/Social/TikTokPublisherTest.php tests/Unit/Enums/TikTok/PrivacyLevelTest.php tests/Feature/Services/Social/TikTokCreatorInfoTest.php

@paulocastellano
paulocastellano merged commit 90ca56a into main Sep 18, 2026
5 checks passed
@paulocastellano
paulocastellano deleted the feat/tiktok-post-analytics branch September 18, 2026 16:12
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