Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

refactor(types)!: make Platform YouTube or Instagram

spacesdrive899ca0f947dc
diff --git a/backend/lib/analyticsMath.ts b/backend/lib/analyticsMath.ts
index 3f2ab9e..9993ef4 100644
--- a/backend/lib/analyticsMath.ts
+++ b/backend/lib/analyticsMath.ts
@@ -1,4 +1,4 @@
-import type { PostFrequency } from '../../shared/types/reddit.ts';
+import type { PostFrequency } from '../../shared/types/domain.ts';
export const DAY_NAMES = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
export const DAY_MS = 86400000;
diff --git a/backend/lib/safeAccount.ts b/backend/lib/safeAccount.ts
index 3762b44..d18aa22 100644
--- a/backend/lib/safeAccount.ts
+++ b/backend/lib/safeAccount.ts
@@ -1,10 +1,9 @@
import type { Account, SafeAccount } from '../../shared/types/domain.ts';
-// hasCookie shows reddit session status without sending the cookie
-const SECRET_FIELDS: (keyof Account)[] = ['accessToken', 'cookie', 'encryptedPassword', 'encryptedTotpSecret', 'authToken', 'ct0'];
+const SECRET_FIELDS: (keyof Account)[] = ['accessToken'];
export function safeAccount(account: Account): SafeAccount {
- const copy: Partial<Account> & { hasCookie: boolean } = { ...account, hasCookie: !!account.cookie };
+ const copy: Partial<Account> = { ...account };
for (const field of SECRET_FIELDS) delete copy[field];
return copy as SafeAccount;
}
diff --git a/backend/tests/fixtures/accountsRoutes.addInstagram.golden.json b/backend/tests/fixtures/accountsRoutes.addInstagram.golden.json
index 814a063..6b5a5c2 100644
--- a/backend/tests/fixtures/accountsRoutes.addInstagram.golden.json
+++ b/backend/tests/fixtures/accountsRoutes.addInstagram.golden.json
@@ -6,11 +6,11 @@
},
{
"status": 200,
- "body": "{\"success\":true,\"account\":{\"id\":\"00000000-0000-4000-8000-000000000001\",\"platform\":\"instagram\",\"igUserId\":\"3000\",\"username\":\"fresh\",\"title\":\"fresh\",\"biography\":\"\",\"website\":\"\",\"profilePictureUrl\":\"\",\"followersCount\":5,\"followsCount\":0,\"mediaCount\":1,\"tokenExpiresAt\":\"2026-09-01T13:23:20.000Z\",\"addedAt\":\"2026-09-01T12:00:00.000Z\",\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"hasCookie\":false}}"
+ "body": "{\"success\":true,\"account\":{\"id\":\"00000000-0000-4000-8000-000000000001\",\"platform\":\"instagram\",\"igUserId\":\"3000\",\"username\":\"fresh\",\"title\":\"fresh\",\"biography\":\"\",\"website\":\"\",\"profilePictureUrl\":\"\",\"followersCount\":5,\"followsCount\":0,\"mediaCount\":1,\"tokenExpiresAt\":\"2026-09-01T13:23:20.000Z\",\"addedAt\":\"2026-09-01T12:00:00.000Z\",\"lastUpdated\":\"2026-09-01T12:00:00.000Z\"}}"
},
{
"status": 200,
- "body": "{\"success\":true,\"account\":{\"id\":\"00000000-0000-4000-8000-000000000002\",\"platform\":\"instagram\",\"igUserId\":\"3001\",\"username\":\"shorty\",\"title\":\"Shorty\",\"biography\":\"\",\"website\":\"\",\"profilePictureUrl\":\"\",\"followersCount\":0,\"followsCount\":0,\"mediaCount\":0,\"tokenExpiresAt\":null,\"addedAt\":\"2026-09-01T12:00:00.000Z\",\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"hasCookie\":false}}"
+ "body": "{\"success\":true,\"account\":{\"id\":\"00000000-0000-4000-8000-000000000002\",\"platform\":\"instagram\",\"igUserId\":\"3001\",\"username\":\"shorty\",\"title\":\"Shorty\",\"biography\":\"\",\"website\":\"\",\"profilePictureUrl\":\"\",\"followersCount\":0,\"followsCount\":0,\"mediaCount\":0,\"tokenExpiresAt\":null,\"addedAt\":\"2026-09-01T12:00:00.000Z\",\"lastUpdated\":\"2026-09-01T12:00:00.000Z\"}}"
},
{
"status": 409,
diff --git a/backend/tests/fixtures/accountsRoutes.delete.golden.json b/backend/tests/fixtures/accountsRoutes.delete.golden.json
index 83213a3..7d53fbc 100644
--- a/backend/tests/fixtures/accountsRoutes.delete.golden.json
+++ b/backend/tests/fixtures/accountsRoutes.delete.golden.json
@@ -18,7 +18,7 @@
},
{
"status": 200,
- "body": "[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Old title\",\"subscriberCount\":1,\"hasCookie\":false},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":1,\"hasCookie\":false},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\",\"hasCookie\":false}]"
+ "body": "[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Old title\",\"subscriberCount\":1},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":1},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\"}]"
}
],
"requests": [],
diff --git a/backend/tests/fixtures/accountsRoutes.listResolve.golden.json b/backend/tests/fixtures/accountsRoutes.listResolve.golden.json
index 248e6d0..f98d8a4 100644
--- a/backend/tests/fixtures/accountsRoutes.listResolve.golden.json
+++ b/backend/tests/fixtures/accountsRoutes.listResolve.golden.json
@@ -2,7 +2,7 @@
"responses": [
{
"status": 200,
- "body": "[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Old title\",\"subscriberCount\":1,\"hasCookie\":false},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":1,\"hasCookie\":false},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\",\"hasCookie\":false},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\",\"hasCookie\":false}]"
+ "body": "[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Old title\",\"subscriberCount\":1},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":1},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\"},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\"}]"
},
{
"status": 200,
diff --git a/backend/tests/fixtures/accountsRoutes.refreshAll.golden.json b/backend/tests/fixtures/accountsRoutes.refreshAll.golden.json
index 040f24c..0db6e94 100644
--- a/backend/tests/fixtures/accountsRoutes.refreshAll.golden.json
+++ b/backend/tests/fixtures/accountsRoutes.refreshAll.golden.json
@@ -2,15 +2,15 @@
"responses": [
{
"status": 200,
- "body": "{\"success\":true,\"accounts\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"},\"hasCookie\":false},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\",\"hasCookie\":false},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\",\"hasCookie\":false},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\",\"hasCookie\":false}],\"results\":[{\"id\":\"yt1\",\"success\":true},{\"id\":\"ig1\",\"success\":true},{\"id\":\"ig2\",\"success\":false,\"error\":\"No access token stored - reconnect this Instagram account\"},{\"id\":\"yt2\",\"success\":false,\"error\":\"Channel not found\"}],\"updatedAt\":\"2026-09-01T12:00:00.000Z\"}"
+ "body": "{\"success\":true,\"accounts\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"}},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\"},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\"},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\"}],\"results\":[{\"id\":\"yt1\",\"success\":true},{\"id\":\"ig1\",\"success\":true},{\"id\":\"ig2\",\"success\":false,\"error\":\"No access token stored - reconnect this Instagram account\"},{\"id\":\"yt2\",\"success\":false,\"error\":\"Channel not found\"}],\"updatedAt\":\"2026-09-01T12:00:00.000Z\"}"
},
{
"status": 200,
- "body": "{\"success\":true,\"accounts\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"},\"hasCookie\":false},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\",\"hasCookie\":false},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\",\"hasCookie\":false},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\",\"hasCookie\":false}],\"results\":[{\"id\":\"yt1\",\"success\":false,\"error\":\"YouTube API key not configured on server\"},{\"id\":\"ig1\",\"success\":true},{\"id\":\"ig2\",\"success\":false,\"error\":\"No access token stored - reconnect this Instagram account\"},{\"id\":\"yt2\",\"success\":false,\"error\":\"YouTube API key not configured on server\"}],\"updatedAt\":\"2026-09-01T12:00:00.000Z\"}"
+ "body": "{\"success\":true,\"accounts\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"}},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\"},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\"},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\"}],\"results\":[{\"id\":\"yt1\",\"success\":false,\"error\":\"YouTube API key not configured on server\"},{\"id\":\"ig1\",\"success\":true},{\"id\":\"ig2\",\"success\":false,\"error\":\"No access token stored - reconnect this Instagram account\"},{\"id\":\"yt2\",\"success\":false,\"error\":\"YouTube API key not configured on server\"}],\"updatedAt\":\"2026-09-01T12:00:00.000Z\"}"
},
{
"status": 200,
- "body": "{\"success\":true,\"accounts\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"},\"hasCookie\":false},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\",\"hasCookie\":false},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\",\"hasCookie\":false},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\",\"hasCookie\":false}],\"results\":[{\"id\":\"yt1\",\"success\":true},{\"id\":\"ig1\",\"success\":true},{\"id\":\"ig2\",\"success\":false,\"error\":\"No access token stored - reconnect this Instagram account\"},{\"id\":\"yt2\",\"success\":false,\"error\":\"Channel not found\"}],\"updatedAt\":\"2026-09-01T12:00:00.000Z\"}"
+ "body": "{\"success\":true,\"accounts\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"}},{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\"},{\"id\":\"ig2\",\"platform\":\"instagram\",\"igUserId\":\"2000\",\"username\":\"notoken\"},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UCmissingmissingmissing0\"}],\"results\":[{\"id\":\"yt1\",\"success\":true},{\"id\":\"ig1\",\"success\":true},{\"id\":\"ig2\",\"success\":false,\"error\":\"No access token stored - reconnect this Instagram account\"},{\"id\":\"yt2\",\"success\":false,\"error\":\"Channel not found\"}],\"updatedAt\":\"2026-09-01T12:00:00.000Z\"}"
}
],
"requests": [
diff --git a/backend/tests/fixtures/accountsRoutes.refreshOne.golden.json b/backend/tests/fixtures/accountsRoutes.refreshOne.golden.json
index 3ba2961..aa380d7 100644
--- a/backend/tests/fixtures/accountsRoutes.refreshOne.golden.json
+++ b/backend/tests/fixtures/accountsRoutes.refreshOne.golden.json
@@ -6,7 +6,7 @@
},
{
"status": 200,
- "body": "{\"success\":true,\"account\":{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\",\"biography\":\"Bio\",\"website\":\"https://r.example\",\"hasCookie\":false}}"
+ "body": "{\"success\":true,\"account\":{\"id\":\"ig1\",\"platform\":\"instagram\",\"igUserId\":\"1789\",\"username\":\"ribbon\",\"tokenExpiresAt\":\"2026-09-05T00:00:00.000Z\",\"followersCount\":2500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"followsCount\":10,\"mediaCount\":140,\"title\":\"Ribbon\",\"profilePictureUrl\":\"https://p\",\"biography\":\"Bio\",\"website\":\"https://r.example\"}}"
},
{
"status": 400,
@@ -18,7 +18,7 @@
},
{
"status": 200,
- "body": "{\"success\":true,\"account\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"description\":\"Desc\",\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"},\"customUrl\":\"@chan\",\"country\":\"GB\",\"keywords\":\"k\",\"topicCategories\":[\"t\"],\"hasCookie\":false}}"
+ "body": "{\"success\":true,\"account\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UCaaaaaaaaaaaaaaaaaaaaaa\",\"title\":\"Channel UCaa\",\"subscriberCount\":500,\"lastUpdated\":\"2026-09-01T12:00:00.000Z\",\"viewCount\":9000,\"videoCount\":12,\"description\":\"Desc\",\"thumbnails\":{\"default\":\"d\",\"medium\":\"m\",\"high\":\"h\"},\"customUrl\":\"@chan\",\"country\":\"GB\",\"keywords\":\"k\",\"topicCategories\":[\"t\"]}}"
},
{
"status": 503,
diff --git a/backend/tests/fixtures/analyticsRoutes.youtube.golden.json b/backend/tests/fixtures/analyticsRoutes.youtube.golden.json
index 2f9f1eb..a09e017 100644
--- a/backend/tests/fixtures/analyticsRoutes.youtube.golden.json
+++ b/backend/tests/fixtures/analyticsRoutes.youtube.golden.json
@@ -4,7 +4,7 @@
{
"call": "GET /comparison",
"status": 200,
- "body": "{\"success\":true,\"comparison\":{\"rankings\":{\"bySubscribers\":[{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0,\"hasCookie\":false},{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"hasCookie\":false},{\"id\":\"yt3\",\"platform\":\"youtube\",\"channelId\":\"UC3\",\"title\":\"Gamma\",\"hasCookie\":false}],\"byViews\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"hasCookie\":false},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0,\"hasCookie\":false},{\"id\":\"yt3\",\"platform\":\"youtube\",\"channelId\":\"UC3\",\"title\":\"Gamma\",\"hasCookie\":false}],\"byVideos\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"hasCookie\":false},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0,\"hasCookie\":false},{\"id\":\"yt3\",\"platform\":\"youtube\",\"channelId\":\"UC3\",\"title\":\"Gamma\",\"hasCookie\":false}]},\"totals\":{\"subscribers\":400,\"views\":6000,\"videos\":10},\"accountCount\":3,\"bestBySubscribers\":{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0,\"hasCookie\":false},\"bestByViews\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"hasCookie\":false},\"bestByVideos\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"hasCookie\":false}}}"
+ "body": "{\"success\":true,\"comparison\":{\"rankings\":{\"bySubscribers\":[{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0},{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"}},{\"id\":\"yt3\",\"platform\":\"youtube\",\"channelId\":\"UC3\",\"title\":\"Gamma\"}],\"byViews\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"}},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0},{\"id\":\"yt3\",\"platform\":\"youtube\",\"channelId\":\"UC3\",\"title\":\"Gamma\"}],\"byVideos\":[{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"}},{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0},{\"id\":\"yt3\",\"platform\":\"youtube\",\"channelId\":\"UC3\",\"title\":\"Gamma\"}]},\"totals\":{\"subscribers\":400,\"views\":6000,\"videos\":10},\"accountCount\":3,\"bestBySubscribers\":{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0},\"bestByViews\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"}},\"bestByVideos\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"}}}}"
},
{
"call": "GET /videos/all",
@@ -29,12 +29,12 @@
{
"call": "GET /accounts/yt1/analytics",
"status": 200,
- "body": "{\"success\":true,\"channel\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"hasCookie\":false,\"channelAge\":730,\"channelAgeYears\":\"2.0\",\"viewsPerSubscriber\":50,\"subscriberToViewRatio\":2,\"avgViewsPerVideo\":500,\"avgSubGainPerDay\":0,\"avgViewsPerDay\":7,\"estimatedMonthlyViews\":210,\"estimatedMonthlySubGain\":0,\"estimatedYearlyViews\":2555,\"estimatedYearlySubGain\":0},\"analytics\":{\"totalVideos\":1,\"totalViews\":70,\"totalLikes\":7,\"totalComments\":1,\"avgViews\":70,\"avgLikes\":7,\"avgComments\":1,\"medianViews\":70,\"totalEngagement\":8,\"overallEngagementRate\":\"11.43\",\"avgDurationSeconds\":45,\"avgDurationFormatted\":\"0m 45s\",\"totalDurationSeconds\":45,\"totalDurationFormatted\":\"0m 45s\",\"estimatedTotalWatchTimeHours\":1,\"bestByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByLikes\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByComments\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByEngagement\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"worstByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"mostRecent\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"oldest\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"top10ByViews\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByLikes\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByComments\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByEngagement\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"shortsCount\":1,\"regularCount\":0,\"avgShortViews\":70,\"avgRegularViews\":0,\"avgShortLikes\":7,\"avgRegularLikes\":0,\"hdCount\":1,\"sdCount\":0,\"hdPercentage\":\"100.0\",\"captionCount\":0,\"captionPercentage\":\"0.0\",\"licensedCount\":0,\"licensedPercentage\":\"0.0\",\"madeForKidsCount\":0,\"embeddableCount\":0,\"embeddablePercentage\":\"0.0\",\"publishDayDistribution\":{\"Thursday\":1},\"publishHourDistribution\":{\"10\":1},\"peakPublishDay\":\"Thursday\",\"peakPublishHour\":10,\"durationDistribution\":{\"short\":1,\"medium\":0,\"long\":0,\"veryLong\":0},\"categoryDistribution\":{\"Unknown\":1},\"tagFrequency\":[],\"videosLast7Days\":0,\"videosLast30Days\":1,\"videosLast90Days\":1,\"videosLast365Days\":1,\"uploadFrequencyPerWeek\":\"0.6\",\"uploadFrequencyPerMonth\":\"1.0\",\"consistencyScore\":100,\"viralityScore\":1,\"viewsDistribution\":{\"ranges\":[\"0-7\",\"7-14\",\"14-21\",\"21-28\",\"28-35\",\"35-42\",\"42-49\",\"49-56\",\"56-63\",\"63-70\"],\"counts\":[0,0,0,0,0,0,0,0,0,0]},\"viewsTrend\":[{\"month\":\"2026-08\",\"value\":70,\"count\":1}],\"engagementTrend\":[{\"month\":\"2026-08\",\"value\":\"11.43\"}],\"likeRateTrend\":[{\"month\":\"2026-08\",\"value\":\"10.00\"}]},\"videoCount\":1}"
+ "body": "{\"success\":true,\"channel\":{\"id\":\"yt1\",\"platform\":\"youtube\",\"channelId\":\"UC1\",\"uploadsPlaylistId\":\"UU1\",\"title\":\"Alpha\",\"subscriberCount\":100,\"viewCount\":5000,\"videoCount\":10,\"publishedAt\":\"2024-09-01T00:00:00Z\",\"thumbnails\":{\"default\":\"a.jpg\"},\"channelAge\":730,\"channelAgeYears\":\"2.0\",\"viewsPerSubscriber\":50,\"subscriberToViewRatio\":2,\"avgViewsPerVideo\":500,\"avgSubGainPerDay\":0,\"avgViewsPerDay\":7,\"estimatedMonthlyViews\":210,\"estimatedMonthlySubGain\":0,\"estimatedYearlyViews\":2555,\"estimatedYearlySubGain\":0},\"analytics\":{\"totalVideos\":1,\"totalViews\":70,\"totalLikes\":7,\"totalComments\":1,\"avgViews\":70,\"avgLikes\":7,\"avgComments\":1,\"medianViews\":70,\"totalEngagement\":8,\"overallEngagementRate\":\"11.43\",\"avgDurationSeconds\":45,\"avgDurationFormatted\":\"0m 45s\",\"totalDurationSeconds\":45,\"totalDurationFormatted\":\"0m 45s\",\"estimatedTotalWatchTimeHours\":1,\"bestByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByLikes\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByComments\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByEngagement\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"worstByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"mostRecent\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"oldest\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"top10ByViews\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByLikes\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByComments\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByEngagement\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"shortsCount\":1,\"regularCount\":0,\"avgShortViews\":70,\"avgRegularViews\":0,\"avgShortLikes\":7,\"avgRegularLikes\":0,\"hdCount\":1,\"sdCount\":0,\"hdPercentage\":\"100.0\",\"captionCount\":0,\"captionPercentage\":\"0.0\",\"licensedCount\":0,\"licensedPercentage\":\"0.0\",\"madeForKidsCount\":0,\"embeddableCount\":0,\"embeddablePercentage\":\"0.0\",\"publishDayDistribution\":{\"Thursday\":1},\"publishHourDistribution\":{\"10\":1},\"peakPublishDay\":\"Thursday\",\"peakPublishHour\":10,\"durationDistribution\":{\"short\":1,\"medium\":0,\"long\":0,\"veryLong\":0},\"categoryDistribution\":{\"Unknown\":1},\"tagFrequency\":[],\"videosLast7Days\":0,\"videosLast30Days\":1,\"videosLast90Days\":1,\"videosLast365Days\":1,\"uploadFrequencyPerWeek\":\"0.6\",\"uploadFrequencyPerMonth\":\"1.0\",\"consistencyScore\":100,\"viralityScore\":1,\"viewsDistribution\":{\"ranges\":[\"0-7\",\"7-14\",\"14-21\",\"21-28\",\"28-35\",\"35-42\",\"42-49\",\"49-56\",\"56-63\",\"63-70\"],\"counts\":[0,0,0,0,0,0,0,0,0,0]},\"viewsTrend\":[{\"month\":\"2026-08\",\"value\":70,\"count\":1}],\"engagementTrend\":[{\"month\":\"2026-08\",\"value\":\"11.43\"}],\"likeRateTrend\":[{\"month\":\"2026-08\",\"value\":\"10.00\"}]},\"videoCount\":1}"
},
{
"call": "GET /accounts/yt2/analytics",
"status": 200,
- "body": "{\"success\":true,\"channel\":{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0,\"hasCookie\":false,\"channelAge\":365,\"channelAgeYears\":\"1.0\",\"viewsPerSubscriber\":3.3,\"subscriberToViewRatio\":30,\"avgViewsPerVideo\":0,\"avgSubGainPerDay\":1,\"avgViewsPerDay\":3,\"estimatedMonthlyViews\":90,\"estimatedMonthlySubGain\":30,\"estimatedYearlyViews\":1095,\"estimatedYearlySubGain\":365},\"analytics\":{\"totalVideos\":1,\"totalViews\":70,\"totalLikes\":7,\"totalComments\":1,\"avgViews\":70,\"avgLikes\":7,\"avgComments\":1,\"medianViews\":70,\"totalEngagement\":8,\"overallEngagementRate\":\"11.43\",\"avgDurationSeconds\":45,\"avgDurationFormatted\":\"0m 45s\",\"totalDurationSeconds\":45,\"totalDurationFormatted\":\"0m 45s\",\"estimatedTotalWatchTimeHours\":1,\"bestByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByLikes\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByComments\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByEngagement\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"worstByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"mostRecent\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"oldest\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"top10ByViews\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByLikes\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByComments\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByEngagement\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"shortsCount\":1,\"regularCount\":0,\"avgShortViews\":70,\"avgRegularViews\":0,\"avgShortLikes\":7,\"avgRegularLikes\":0,\"hdCount\":1,\"sdCount\":0,\"hdPercentage\":\"100.0\",\"captionCount\":0,\"captionPercentage\":\"0.0\",\"licensedCount\":0,\"licensedPercentage\":\"0.0\",\"madeForKidsCount\":0,\"embeddableCount\":0,\"embeddablePercentage\":\"0.0\",\"publishDayDistribution\":{\"Thursday\":1},\"publishHourDistribution\":{\"10\":1},\"peakPublishDay\":\"Thursday\",\"peakPublishHour\":10,\"durationDistribution\":{\"short\":1,\"medium\":0,\"long\":0,\"veryLong\":0},\"categoryDistribution\":{\"Unknown\":1},\"tagFrequency\":[],\"videosLast7Days\":0,\"videosLast30Days\":1,\"videosLast90Days\":1,\"videosLast365Days\":1,\"uploadFrequencyPerWeek\":\"0.6\",\"uploadFrequencyPerMonth\":\"1.0\",\"consistencyScore\":100,\"viralityScore\":1,\"viewsDistribution\":{\"ranges\":[\"0-7\",\"7-14\",\"14-21\",\"21-28\",\"28-35\",\"35-42\",\"42-49\",\"49-56\",\"56-63\",\"63-70\"],\"counts\":[0,0,0,0,0,0,0,0,0,0]},\"viewsTrend\":[{\"month\":\"2026-08\",\"value\":70,\"count\":1}],\"engagementTrend\":[{\"month\":\"2026-08\",\"value\":\"11.43\"}],\"likeRateTrend\":[{\"month\":\"2026-08\",\"value\":\"10.00\"}]},\"videoCount\":1}"
+ "body": "{\"success\":true,\"channel\":{\"id\":\"yt2\",\"platform\":\"youtube\",\"channelId\":\"UC2\",\"uploadsPlaylistId\":\"UU2\",\"title\":\"Beta\",\"subscriberCount\":300,\"viewCount\":1000,\"videoCount\":0,\"channelAge\":365,\"channelAgeYears\":\"1.0\",\"viewsPerSubscriber\":3.3,\"subscriberToViewRatio\":30,\"avgViewsPerVideo\":0,\"avgSubGainPerDay\":1,\"avgViewsPerDay\":3,\"estimatedMonthlyViews\":90,\"estimatedMonthlySubGain\":30,\"estimatedYearlyViews\":1095,\"estimatedYearlySubGain\":365},\"analytics\":{\"totalVideos\":1,\"totalViews\":70,\"totalLikes\":7,\"totalComments\":1,\"avgViews\":70,\"avgLikes\":7,\"avgComments\":1,\"medianViews\":70,\"totalEngagement\":8,\"overallEngagementRate\":\"11.43\",\"avgDurationSeconds\":45,\"avgDurationFormatted\":\"0m 45s\",\"totalDurationSeconds\":45,\"totalDurationFormatted\":\"0m 45s\",\"estimatedTotalWatchTimeHours\":1,\"bestByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByLikes\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByComments\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"bestByEngagement\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"worstByViews\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"mostRecent\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"oldest\":{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45},\"top10ByViews\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByLikes\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByComments\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"top10ByEngagement\":[{\"videoId\":\"v1\",\"title\":\"Fresh\",\"viewCount\":70,\"likeCount\":7,\"commentCount\":1,\"publishedAt\":\"2026-08-20T10:00:00Z\",\"thumbnail\":\"\",\"engagementRate\":\"11.43\",\"durationSeconds\":45}],\"shortsCount\":1,\"regularCount\":0,\"avgShortViews\":70,\"avgRegularViews\":0,\"avgShortLikes\":7,\"avgRegularLikes\":0,\"hdCount\":1,\"sdCount\":0,\"hdPercentage\":\"100.0\",\"captionCount\":0,\"captionPercentage\":\"0.0\",\"licensedCount\":0,\"licensedPercentage\":\"0.0\",\"madeForKidsCount\":0,\"embeddableCount\":0,\"embeddablePercentage\":\"0.0\",\"publishDayDistribution\":{\"Thursday\":1},\"publishHourDistribution\":{\"10\":1},\"peakPublishDay\":\"Thursday\",\"peakPublishHour\":10,\"durationDistribution\":{\"short\":1,\"medium\":0,\"long\":0,\"veryLong\":0},\"categoryDistribution\":{\"Unknown\":1},\"tagFrequency\":[],\"videosLast7Days\":0,\"videosLast30Days\":1,\"videosLast90Days\":1,\"videosLast365Days\":1,\"uploadFrequencyPerWeek\":\"0.6\",\"uploadFrequencyPerMonth\":\"1.0\",\"consistencyScore\":100,\"viralityScore\":1,\"viewsDistribution\":{\"ranges\":[\"0-7\",\"7-14\",\"14-21\",\"21-28\",\"28-35\",\"35-42\",\"42-49\",\"49-56\",\"56-63\",\"63-70\"],\"counts\":[0,0,0,0,0,0,0,0,0,0]},\"viewsTrend\":[{\"month\":\"2026-08\",\"value\":70,\"count\":1}],\"engagementTrend\":[{\"month\":\"2026-08\",\"value\":\"11.43\"}],\"likeRateTrend\":[{\"month\":\"2026-08\",\"value\":\"10.00\"}]},\"videoCount\":1}"
},
{
"call": "GET /accounts/yt3/analytics",
diff --git a/backend/tests/lib/safeAccount.test.ts b/backend/tests/lib/safeAccount.test.ts
index 7390bb0..9da6e65 100644
--- a/backend/tests/lib/safeAccount.test.ts
+++ b/backend/tests/lib/safeAccount.test.ts
@@ -4,12 +4,9 @@ import { safeAccount } from '../../lib/safeAccount.ts';
import { buildMediaParams } from '../../services/instagram/instagramPublishing.ts';
import type { Account } from '../../../shared/types/domain.ts';
-test('safeAccount strips every credential and reports cookie presence', () => {
- const out = safeAccount({
- id: 'a1', platform: 'reddit', username: 'ribbon', cookie: 'secret', accessToken: 't',
- encryptedPassword: 'p', encryptedTotpSecret: 's', authToken: 'x', ct0: 'y',
- });
- assert.deepEqual(out, { id: 'a1', platform: 'reddit', username: 'ribbon', hasCookie: true });
+test('safeAccount strips the access token and keeps every other field', () => {
+ const out = safeAccount({ id: 'a1', platform: 'instagram', username: 'ribbon', accessToken: 't', tokenExpiresAt: null });
+ assert.deepEqual(out, { id: 'a1', platform: 'instagram', username: 'ribbon', tokenExpiresAt: null });
});
test('safeAccount does not mutate its input', () => {
diff --git a/backend/tests/routes/analyticsRoutes.test.ts b/backend/tests/routes/analyticsRoutes.test.ts
index 58d02fa..6ce0eab 100644
--- a/backend/tests/routes/analyticsRoutes.test.ts
+++ b/backend/tests/routes/analyticsRoutes.test.ts
@@ -176,9 +176,7 @@ describe('analytics and overview routes golden output', () => {
const body = JSON.parse(response.body) as YouTubeComparisonResponse;
const ranked = body.comparison!.rankings.bySubscribers;
assert.deepEqual(ranked.map(account => account.id), ['yt2', 'yt1', 'yt3']);
- for (const secret of ['accessToken', 'cookie', 'encryptedPassword', 'encryptedTotpSecret', 'authToken', 'ct0']) {
- assert.equal(response.body.includes(`"${secret}"`), false, `${secret} leaked`);
- }
+ assert.equal(response.body.includes('"accessToken"'), false, 'accessToken leaked');
});
test('an empty account list has no comparison', async () => {
diff --git a/frontend/src/components/brand/platform-icons.tsx b/frontend/src/components/brand/platform-icons.tsx
index e23a979..0d214c1 100644
--- a/frontend/src/components/brand/platform-icons.tsx
+++ b/frontend/src/components/brand/platform-icons.tsx
@@ -17,11 +17,3 @@ export function InstagramIcon({ className, ...props }: PlatformIconProps) {
</svg>
);
}
-
-export function RedditIcon({ className, ...props }: PlatformIconProps) {
- return (
- <svg viewBox="0 0 24 24" className={className} fill="currentColor" aria-hidden="true" {...props}>
- <path d="M12 0A12 12 0 0 0 0 12a12 12 0 0 0 12 12 12 12 0 0 0 12-12A12 12 0 0 0 12 0zm5.01 4.744c.688 0 1.25.561 1.25 1.249a1.25 1.25 0 0 1-2.498.056l-2.597-.547-.8 3.747c1.824.07 3.48.632 4.674 1.488.308-.309.73-.491 1.207-.491.968 0 1.754.786 1.754 1.754 0 .716-.435 1.333-1.01 1.614a3.111 3.111 0 0 1 .042.52c0 2.694-3.13 4.87-7.004 4.87-3.874 0-7.004-2.176-7.004-4.87 0-.183.015-.366.043-.534A1.748 1.748 0 0 1 4.028 12c0-.968.786-1.754 1.754-1.754.463 0 .898.196 1.207.49 1.207-.883 2.878-1.43 4.744-1.487l.885-4.182a.342.342 0 0 1 .14-.197.35.35 0 0 1 .238-.042l2.906.617a1.214 1.214 0 0 1 1.108-.701zM9.25 12C8.561 12 8 12.562 8 13.25c0 .687.561 1.248 1.25 1.248.687 0 1.248-.561 1.248-1.249 0-.688-.561-1.249-1.249-1.249zm5.5 0c-.687 0-1.248.561-1.248 1.25 0 .687.561 1.248 1.249 1.248.688 0 1.249-.561 1.249-1.249 0-.687-.562-1.249-1.25-1.249zm-5.466 3.99a.327.327 0 0 0-.231.094.33.33 0 0 0 0 .463c.842.842 2.484.913 2.961.913.477 0 2.105-.056 2.961-.913a.361.361 0 0 0 .029-.463.33.33 0 0 0-.464 0c-.547.533-1.684.73-2.512.73-.828 0-1.979-.196-2.512-.73a.326.326 0 0 0-.232-.095z" />
- </svg>
- );
-}
diff --git a/frontend/src/components/platform.tsx b/frontend/src/components/platform.tsx
index 741dad2..e03a839 100644
--- a/frontend/src/components/platform.tsx
+++ b/frontend/src/components/platform.tsx
@@ -1,13 +1,13 @@
import React from 'react';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
-import { YouTubeIcon, InstagramIcon, RedditIcon } from '@/components/brand/platform-icons';
+import { YouTubeIcon, InstagramIcon } from '@/components/brand/platform-icons';
import type { PlatformIconProps as SvgIconProps } from '@/components/brand/platform-icons';
import { PLATFORM_META, platformOf, accountImage, accountInitials, accountName } from '@/lib/accounts';
import { cn } from '@/lib/utils';
import type { AccountFields } from '@/lib/accounts';
import type { Platform } from '@shared/types/domain.ts';
-const ICONS: Record<Platform, React.ComponentType<SvgIconProps>> = { youtube: YouTubeIcon, instagram: InstagramIcon, reddit: RedditIcon };
+const ICONS: Record<Platform, React.ComponentType<SvgIconProps>> = { youtube: YouTubeIcon, instagram: InstagramIcon };
export type AccountAvatarSize = 'xs' | 'sm' | 'default' | 'lg' | 'xl';
diff --git a/frontend/src/features/accounts/AccountCard.tsx b/frontend/src/features/accounts/AccountCard.tsx
index e8960ce..ca9279e 100644
--- a/frontend/src/features/accounts/AccountCard.tsx
+++ b/frontend/src/features/accounts/AccountCard.tsx
@@ -1,6 +1,6 @@
import React from 'react';
import { Link } from 'react-router-dom';
-import { ArrowUpRight, Lock, RefreshCw, Trash2 } from 'lucide-react';
+import { ArrowUpRight, RefreshCw, Trash2 } from 'lucide-react';
import { Button } from '@/components/ui/button';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { AccountAvatar } from '@/components/platform';
@@ -12,10 +12,6 @@ import { accountCardHandle, accountMetrics } from './accountManagerData';
import type { Platform } from '@shared/types/domain.ts';
import type { AppAccount } from '../../utils/formatters';
-interface CookieStatusProps {
- hasCookie: boolean;
-}
-
export interface AccountCardProps {
acct: AppAccount;
platform: Platform;
@@ -24,18 +20,6 @@ export interface AccountCardProps {
onDelete: () => void;
}
-function CookieStatus({ hasCookie }: CookieStatusProps) {
- if (hasCookie) {
- return <span className="flex items-center gap-1 text-success"><Lock className="size-3" />Session cookie stored</span>;
- }
- return (
- <span className="flex items-center gap-1 text-danger">
- <Lock className="size-3" aria-hidden="true" />
- <span><span className="sr-only">Error: </span>No session cookie is stored. Remove the account and add it again with its cookie.</span>
- </span>
- );
-}
-
export default function AccountCard({ acct, platform, refreshing, onRefresh, onDelete }: AccountCardProps) {
const metrics = accountMetrics(platform, acct);
return (
@@ -44,7 +28,7 @@ export default function AccountCard({ acct, platform, refreshing, onRefresh, onD
<AccountAvatar account={acct} size="lg" showPlatform decorative />
<div className="min-w-0 flex-1">
<Link to={accountPath(acct)} className="block truncate text-sm font-semibold text-ink hover:underline">{accountName(acct)}</Link>
- <p className="truncate text-caption text-ink-faint">{accountCardHandle(acct, platform)}</p>
+ <p className="truncate text-caption text-ink-faint">{accountCardHandle(acct)}</p>
</div>
<Tooltip>
<TooltipTrigger render={<Button variant="ghost" size="icon-sm" render={<Link to={accountPath(acct)} aria-label={`Open analytics for ${accountName(acct)}`} />} />}>
@@ -64,7 +48,6 @@ export default function AccountCard({ acct, platform, refreshing, onRefresh, onD
</dl>
<div className="flex flex-wrap items-center gap-x-3 gap-y-1 text-caption text-ink-faint">
- {platform === 'reddit' && <CookieStatus hasCookie={acct.hasCookie} />}
{acct.lastUpdated && <span>Updated <RelativeTime date={acct.lastUpdated} /></span>}
</div>
diff --git a/frontend/src/features/accounts/AddAccountDialog.tsx b/frontend/src/features/accounts/AddAccountDialog.tsx
index a15a19e..0d7ae5f 100644
--- a/frontend/src/features/accounts/AddAccountDialog.tsx
+++ b/frontend/src/features/accounts/AddAccountDialog.tsx
@@ -22,7 +22,6 @@ export interface AddAccountDialogProps {
const STEP_DESCRIPTION: Record<Platform, string> = {
youtube: 'Find the channel to check it is the right one, then add it.',
instagram: 'Instagram opens so you can sign in and approve access.',
- reddit: 'Add the username and the session cookie from your browser.',
};
// each card moves on to its platform's step, so these are plain buttons, not radios
diff --git a/frontend/src/features/accounts/accountManagerData.ts b/frontend/src/features/accounts/accountManagerData.ts
index f480961..b7436ce 100644
--- a/frontend/src/features/accounts/accountManagerData.ts
+++ b/frontend/src/features/accounts/accountManagerData.ts
@@ -13,9 +13,6 @@ export interface AccountMetricFields {
followersCount?: number;
followsCount?: number;
mediaCount?: number;
- totalKarma?: number;
- postKarma?: number;
- commentKarma?: number;
}
export type AccountMetric = [label: string, value: number | undefined];
@@ -44,13 +41,11 @@ const IG_ERRORS: Record<string, string> = {
const METRICS: Record<Platform, (acct: AccountMetricFields) => AccountMetric[]> = {
youtube: acct => [['Subscribers', acct.subscriberCount], ['Views', acct.viewCount], ['Videos', acct.videoCount]],
instagram: acct => [['Followers', acct.followersCount], ['Following', acct.followsCount], ['Posts', acct.mediaCount]],
- reddit: acct => [['Karma', acct.totalKarma], ['Post karma', acct.postKarma], ['Comment karma', acct.commentKarma]],
};
const ACCOUNT_SECTIONS: AccountSectionInfo[] = [
{ key: 'youtube', title: 'YouTube channels' },
{ key: 'instagram', title: 'Instagram accounts' },
- { key: 'reddit', title: 'Reddit accounts' },
];
export function instagramErrorMessage(code: string): string {
@@ -76,8 +71,7 @@ export function accountMetrics(platform: Platform, account: AccountMetricFields)
return METRICS[platform](account);
}
-export function accountCardHandle(account: AccountFields, platform: Platform): string {
- if (platform === 'reddit') return `u/${account.username || ''}`;
+export function accountCardHandle(account: AccountFields): string {
return accountHandle(account);
}
diff --git a/frontend/src/features/analytics/overview/overviewCharts.ts b/frontend/src/features/analytics/overview/overviewCharts.ts
index 3f4de51..434cf46 100644
--- a/frontend/src/features/analytics/overview/overviewCharts.ts
+++ b/frontend/src/features/analytics/overview/overviewCharts.ts
@@ -67,7 +67,6 @@ export function audienceLegendOf(groups: AccountGroups): AudienceLegendItem[] {
export const AUDIENCE_KIND: Record<AudiencePointType, string> = {
youtube: 'YouTube subscribers',
instagram: 'Instagram followers',
- reddit: 'Reddit karma',
};
// subscribers and followers share one line, so each point is read with what it counts
diff --git a/frontend/src/lib/accounts.ts b/frontend/src/lib/accounts.ts
index ebda184..fa55c06 100644
--- a/frontend/src/lib/accounts.ts
+++ b/frontend/src/lib/accounts.ts
@@ -17,36 +17,31 @@ export interface AccountFields {
thumbnail?: string;
profilePictureUrl?: string;
thumbnails?: { default?: string };
- iconUrl?: string;
followersCount?: number;
- totalKarma?: number;
subscriberCount?: number;
}
-export const PLATFORMS: Platform[] = ['youtube', 'instagram', 'reddit'];
+export const PLATFORMS: Platform[] = ['youtube', 'instagram'];
export const PLATFORM_META: Record<Platform, PlatformMeta> = {
youtube: { label: 'YouTube', audienceLabel: 'subscribers', series: 'var(--chart-1)' },
instagram: { label: 'Instagram', audienceLabel: 'followers', series: 'var(--chart-3)' },
- reddit: { label: 'Reddit', audienceLabel: 'karma', series: 'var(--chart-4)' },
};
// Accounts saved before multi-platform support have no platform field and are YouTube channels
export function platformOf(account: AccountFields | null | undefined): Platform {
const platform = account?.platform;
- return platform === 'instagram' || platform === 'reddit' ? platform : 'youtube';
+ return platform === 'instagram' ? platform : 'youtube';
}
export function accountPath(account: AccountFields): string {
const platform = platformOf(account);
if (platform === 'instagram') return `/instagram/${account.id}`;
- if (platform === 'reddit') return `/reddit/${account.id}`;
return `/channel/${account.id}`;
}
export function accountName(account: AccountFields | null | undefined): string {
if (!account) return '';
- if (platformOf(account) === 'reddit') return `u/${account.username || ''}`;
return account.title || account.username || account.channelId || '';
}
@@ -54,29 +49,27 @@ export function accountHandle(account: AccountFields | null | undefined): string
if (!account) return '';
const platform = platformOf(account);
if (platform === 'instagram') return account.username ? `@${account.username}` : '';
- if (platform === 'reddit') return 'Reddit';
return account.customUrl || account.channelId || '';
}
export function accountImage(account: AccountFields | null | undefined): string {
if (!account) return '';
- return account.thumbnail || account.profilePictureUrl || account.thumbnails?.default || account.iconUrl || '';
+ return account.thumbnail || account.profilePictureUrl || account.thumbnails?.default || '';
}
export function accountInitials(account: AccountFields | null | undefined): string {
const source = account?.title || account?.username || '?';
- return source.replace(/^u\//, '').slice(0, 2).toUpperCase();
+ return source.slice(0, 2).toUpperCase();
}
export function audienceOf(account: AccountFields): number {
const platform = platformOf(account);
if (platform === 'instagram') return account.followersCount || 0;
- if (platform === 'reddit') return account.totalKarma || 0;
return account.subscriberCount || 0;
}
export function groupByPlatform<T extends AccountFields>(accounts: T[] | null | undefined): Record<Platform, T[]> {
- const groups: Record<Platform, T[]> = { youtube: [], instagram: [], reddit: [] };
+ const groups: Record<Platform, T[]> = { youtube: [], instagram: [] };
for (const account of accounts || []) groups[platformOf(account)].push(account);
return groups;
}
diff --git a/frontend/src/utils/formatters.ts b/frontend/src/utils/formatters.ts
index 6d6c689..825d37b 100644
--- a/frontend/src/utils/formatters.ts
+++ b/frontend/src/utils/formatters.ts
@@ -105,7 +105,7 @@ export type AppAccount = Omit<AccountInput, 'title' | 'thumbnail'> & {
thumbnail: string;
};
-// Normalize account data (handles YouTube, Instagram, and Reddit)
+// Normalize account data (handles YouTube and Instagram)
export function normalizeAccount(acct: AccountInput): AppAccount {
if (!acct) return acct;
if (acct.platform === 'instagram') {
@@ -118,16 +118,6 @@ export function normalizeAccount(acct: AccountInput): AppAccount {
mediaCount: acct.mediaCount || 0,
};
}
- if (acct.platform === 'reddit') {
- return {
- ...acct,
- title: acct.title || `u/${acct.username}`,
- thumbnail: acct.iconUrl || '',
- totalKarma: acct.totalKarma || 0,
- postKarma: acct.postKarma || 0,
- commentKarma: acct.commentKarma || 0,
- };
- }
return {
...acct,
title: acct.title || acct.name || acct.channelTitle || acct.channelId,
diff --git a/frontend/src/utils/instagramContent.ts b/frontend/src/utils/instagramContent.ts
index d50869e..23937fa 100644
--- a/frontend/src/utils/instagramContent.ts
+++ b/frontend/src/utils/instagramContent.ts
@@ -9,7 +9,7 @@ export interface IGContentTypeMeta {
export const IG_CONTENT_TYPES: InstagramContentType[] = ['reel', 'post', 'video'];
-// chart series that follow the theme; the YouTube (chart-1) and Reddit (chart-4) hues are left out so a colour
+// chart series that follow the theme; the YouTube (chart-1) hue is left out so a colour
// never names two platforms
export const IG_CONTENT_TYPE_META: Record<InstagramContentType, IGContentTypeMeta> = {
reel: { label: 'Reel', plural: 'Reels', color: 'var(--chart-5)' },
diff --git a/frontend/tests/features/accounts/accountManagerData.test.ts b/frontend/tests/features/accounts/accountManagerData.test.ts
index 2ef84d7..5210ca3 100644
--- a/frontend/tests/features/accounts/accountManagerData.test.ts
+++ b/frontend/tests/features/accounts/accountManagerData.test.ts
@@ -41,18 +41,16 @@ test('errors and the add flag are read together', () => {
test('each platform card shows its own three metrics', () => {
assert.deepEqual(accountMetrics('youtube', { subscriberCount: 1, viewCount: 2, videoCount: 3 }), [['Subscribers', 1], ['Views', 2], ['Videos', 3]]);
assert.deepEqual(accountMetrics('instagram', { followersCount: 4 }).map(([label]) => label), ['Followers', 'Following', 'Posts']);
- assert.deepEqual(accountMetrics('reddit', { totalKarma: 9 })[0], ['Karma', 9]);
});
-test('card handles use u/ for Reddit and the platform handle otherwise', () => {
- assert.equal(accountCardHandle({ username: 'ribbon' }, 'reddit'), 'u/ribbon');
- assert.equal(accountCardHandle({}, 'reddit'), 'u/');
- assert.equal(accountCardHandle({ customUrl: '@dusk' }, 'youtube'), '@dusk');
+test('card handles use the platform handle', () => {
+ assert.equal(accountCardHandle({ platform: 'instagram', username: 'ribbon' }), '@ribbon');
+ assert.equal(accountCardHandle({ customUrl: '@dusk' }), '@dusk');
});
test('only platforms with accounts get a section, in a fixed order', () => {
- const groups = { youtube: [], instagram: [{ id: 1 }], reddit: [{ id: 2 }] };
- assert.deepEqual(visibleSections(groups).map(section => section.key), ['instagram', 'reddit']);
+ assert.deepEqual(visibleSections({ youtube: [], instagram: [{ id: 1 }] }).map(section => section.key), ['instagram']);
+ assert.deepEqual(visibleSections({ youtube: [{ id: 2 }], instagram: [{ id: 1 }] }).map(section => section.key), ['youtube', 'instagram']);
});
test('adding a channel with nothing typed points at the channel field', () => {
diff --git a/frontend/tests/features/analytics/overview/overviewCharts.test.ts b/frontend/tests/features/analytics/overview/overviewCharts.test.ts
index 64f3dd2..4c17d16 100644
--- a/frontend/tests/features/analytics/overview/overviewCharts.test.ts
+++ b/frontend/tests/features/analytics/overview/overviewCharts.test.ts
@@ -8,7 +8,6 @@ import {
const groups = {
youtube: [{ title: 'A channel with a long name', subscriberCount: 10 }],
instagram: [{ username: 'fold', followersCount: 5 }, { title: 'Paper' }],
- reddit: [],
};
const categoryStats = [
{ category: 'Technology news', views: 10, likes: 3, comments: 3 },
@@ -30,7 +29,7 @@ test('the audience description names what each point counts, in full', () => {
});
test('legend lists only platforms with data', () => {
- const labels = audienceLegendOf({ youtube: [], instagram: [{}], reddit: [] }).map(item => item.label);
+ const labels = audienceLegendOf({ youtube: [], instagram: [{}] }).map(item => item.label);
assert.deepEqual(labels, ['Instagram followers']);
assert.equal(audienceDotColor('youtube'), 'var(--chart-1)');
assert.equal(audienceDotColor('instagram'), 'var(--chart-3)');
diff --git a/frontend/tests/lib/accounts.test.ts b/frontend/tests/lib/accounts.test.ts
index 17a0199..6fd5b54 100644
--- a/frontend/tests/lib/accounts.test.ts
+++ b/frontend/tests/lib/accounts.test.ts
@@ -4,36 +4,32 @@ import { platformOf, accountPath, accountName, accountHandle, accountInitials, a
const youtubeAccount = { id: 'y1', title: 'Studio Dusk', customUrl: '@studiodusk', subscriberCount: 1200 };
const instagramAccount = { id: 'i1', platform: 'instagram', title: 'Paper Fold', username: 'paperfold', followersCount: 800 };
-const redditAccount = { id: 'r1', platform: 'reddit', username: 'ribbon', totalKarma: 50 };
test('accounts without a platform are YouTube channels', () => {
assert.equal(platformOf(youtubeAccount), 'youtube');
assert.equal(platformOf(instagramAccount), 'instagram');
- assert.equal(platformOf(redditAccount), 'reddit');
});
test('each platform routes to its own analytics page', () => {
assert.equal(accountPath(youtubeAccount), '/channel/y1');
assert.equal(accountPath(instagramAccount), '/instagram/i1');
- assert.equal(accountPath(redditAccount), '/reddit/r1');
});
test('names and handles follow each platform convention', () => {
- assert.equal(accountName(redditAccount), 'u/ribbon');
assert.equal(accountName(instagramAccount), 'Paper Fold');
+ assert.equal(accountName({ username: 'fold' }), 'fold');
assert.equal(accountHandle(instagramAccount), '@paperfold');
assert.equal(accountHandle(youtubeAccount), '@studiodusk');
- assert.equal(accountHandle(redditAccount), 'Reddit');
});
test('initials come from the title or username', () => {
assert.equal(accountInitials(youtubeAccount), 'ST');
- assert.equal(accountInitials({ title: 'u/ribbon' }), 'RI');
+ assert.equal(accountInitials({ username: 'ribbon' }), 'RI');
assert.equal(accountInitials({}), '?');
});
-test('audience uses subscribers, followers or karma', () => {
- assert.deepEqual([youtubeAccount, instagramAccount, redditAccount].map(audienceOf), [1200, 800, 50]);
+test('audience uses subscribers or followers', () => {
+ assert.deepEqual([youtubeAccount, instagramAccount].map(audienceOf), [1200, 800]);
});
test('the platform summary lists only platforms that have accounts', () => {
diff --git a/shared/types/domain.ts b/shared/types/domain.ts
index 81c3c73..d7530cf 100644
--- a/shared/types/domain.ts
+++ b/shared/types/domain.ts
@@ -1,7 +1,7 @@
import type { InstagramContentTypeSummary } from './instagram.ts';
import type { YouTubeTrackedVideoData } from './youtube.ts';
-export type Platform = 'youtube' | 'instagram' | 'reddit';
+export type Platform = 'youtube' | 'instagram';
export interface YouTubeThumbnail {
url: string;
@@ -42,10 +42,8 @@ export interface Account {
topicCategories?: string[];
madeForKids?: boolean;
- // instagram and reddit
- username?: string;
-
// instagram
+ username?: string;
// null when neither the profile nor the request had an id
igUserId?: string | null;
biography?: string;
@@ -56,27 +54,19 @@ export interface Account {
mediaCount?: number;
accessToken?: string;
tokenExpiresAt?: string | null;
-
- // reddit
- totalKarma?: number;
- postKarma?: number;
- commentKarma?: number;
- iconUrl?: string;
- createdAt?: string | number;
- cookie?: string;
- encryptedPassword?: string;
- encryptedTotpSecret?: string;
- authToken?: string;
- ct0?: string;
}
// youtube accounts are created without a platform field; createAccount stores them as 'youtube'
export type NewAccount = Omit<Account, 'platform'> & { platform?: Platform };
-// what an account looks like in a response: secrets removed, cookie presence kept
-export type SafeAccount = Omit<Account, 'accessToken' | 'cookie' | 'encryptedPassword' | 'encryptedTotpSecret' | 'authToken' | 'ct0'> & {
- hasCookie: boolean;
-};
+// what an account looks like in a response: the access token removed
+export type SafeAccount = Omit<Account, 'accessToken'>;
+
+// how often an account posts, from its fetched posts
+export interface PostFrequency {
+ perWeek: number;
+ perMonth: number;
+}
export type PostStatus = 'pending' | 'publishing' | 'published' | 'failed';
@@ -162,15 +152,6 @@ export interface PendingAccountSummary {
}
// fetchedAt is when the cached numbers came from the platform, so the Overview can say how old they are
-export interface RedditAccountSummary {
- id: string;
- cacheWarmed: true;
- fetchedAt?: string;
- fetchedPosts: number;
- totalScore: number;
- totalComments: number;
-}
-
export interface InstagramAccountSummary {
id: string;
cacheWarmed: true;
@@ -189,7 +170,7 @@ export interface YouTubeAccountSummary {
totalComments: number;
}
-export type AccountSummary = PendingAccountSummary | RedditAccountSummary | InstagramAccountSummary | YouTubeAccountSummary;
+export type AccountSummary = PendingAccountSummary | InstagramAccountSummary | YouTubeAccountSummary;
// the overview's analyticsCache, keyed by account id; accounts whose cache read failed are left out
export type OverviewAnalyticsCache = Record<string, AccountSummary>;
@@ -197,7 +178,7 @@ export type OverviewAnalyticsCache = Record<string, AccountSummary>;
// GET /api/accounts
export type AccountListResponse = SafeAccount[];
-// the reddit, instagram and single refresh account routes
+// the instagram and single refresh account routes
export interface AccountResponse {
success: true;
account: SafeAccount;
diff --git a/shared/types/instagram.ts b/shared/types/instagram.ts
index 6586e43..49f99f6 100644
--- a/shared/types/instagram.ts
+++ b/shared/types/instagram.ts
@@ -1,5 +1,4 @@
-import type { MediaType, SafeAccount, UserTag } from './domain.ts';
-import type { PostFrequency } from './reddit.ts';
+import type { MediaType, PostFrequency, SafeAccount, UserTag } from './domain.ts';
export type InstagramContentType = 'reel' | 'post' | 'video';
diff --git a/shared/types/reddit.ts b/shared/types/reddit.ts
deleted file mode 100644
index 8fa25fe..0000000
--- a/shared/types/reddit.ts
+++ /dev/null
@@ -1,125 +0,0 @@
-export interface RedditProfile {
- username: string;
- totalKarma: number;
- postKarma: number;
- commentKarma: number;
- awardeeKarma: number;
- awarderKarma: number;
- iconUrl: string;
- createdAt: string;
- isGold: boolean;
- isMod: boolean;
- verified: boolean;
-}
-
-export type RedditMediaType = 'video' | 'image' | 'text' | 'link';
-
-export interface RedditPost {
- id: string;
- title: string;
- subreddit: string;
- subredditPrefixed: string;
- score: number;
- upvoteRatio: number;
- numComments: number;
- url: string;
- permalink: string;
- thumbnail: string;
- mediaType: RedditMediaType;
- isSelf: boolean;
- isVideo: boolean;
- isNsfw: boolean;
- createdAt: string;
- flair: string;
- awardsCount: number;
-}
-
-export interface RedditSubredditStats {
- subreddit: string;
- posts: number;
- totalScore: number;
- totalComments: number;
- avgScore: number;
- avgComments: number;
-}
-
-export interface RedditDayStats {
- day: string;
- shortDay: string;
- posts: number;
- avgScore: number;
- avgComments: number;
-}
-
-export interface RedditHourStats {
- hour: number;
- label: string;
- posts: number;
- avgScore: number;
-}
-
-export interface RedditMonthStats {
- month: string;
- posts: number;
- score: number;
- comments: number;
- avgScore: number;
-}
-
-export interface PostFrequency {
- perWeek: number;
- perMonth: number;
-}
-
-// computeRedditAnalytics() output, stored in the reddit: cache and returned by the analytics route
-export interface RedditAnalytics {
- fetchedPosts: number;
- totalScore: number;
- avgScore: number;
- medianScore: number;
- totalComments: number;
- avgComments: number;
- avgUpvoteRatio: number;
- totalAwards: number;
- avgAwards: number;
- topPosts: RedditPost[];
- worstPosts: RedditPost[];
- subredditBreakdown: RedditSubredditStats[];
- mediaTypeDistribution: Partial<Record<RedditMediaType, number>>;
- postsByDayOfWeek: RedditDayStats[];
- postsByHour: RedditHourStats[];
- monthlyBreakdown: RedditMonthStats[];
- engagementTimeline: RedditMonthStats[];
- postsLast7Days: number;
- postsLast30Days: number;
- postsLast90Days: number;
- postFrequency: PostFrequency;
- viralityScore: number;
- consistencyScore: number;
- bestPostingDay: string;
- bestPostingHour: string;
-}
-
-export interface RedditCacheData {
- profile: RedditProfile;
- analytics: RedditAnalytics;
- posts: RedditPost[];
- // when the posts were fetched from Reddit; missing on entries cached before it was recorded
- fetchedAt?: string;
-}
-
-// fetchTrackedPostData() output, patched into a reddit tracked post's data on add and refresh
-export interface RedditTrackedPostData {
- postId: string;
- title: string;
- subreddit: string;
- subredditPrefixed: string;
- author: string;
- score: number;
- upvoteRatio: number;
- numComments: number;
- permalink: string;
- isNsfw: boolean;
- createdAt: string;
- lastFetchedAt: string;
-}