diff --git a/packages/shared/src/features/squads/components/manage/SquadManageAnalytics.tsx b/packages/shared/src/features/squads/components/manage/SquadManageAnalytics.tsx index 8751b763f2..db2f332ff7 100644 --- a/packages/shared/src/features/squads/components/manage/SquadManageAnalytics.tsx +++ b/packages/shared/src/features/squads/components/manage/SquadManageAnalytics.tsx @@ -34,6 +34,7 @@ import type { CreatorPostSort } from '../../../../components/analytics/creator/C import { CreatorPostPerformanceTable } from '../../../../components/analytics/creator/CreatorPostPerformanceTable'; import { CreatorDashboardError } from '../../../../components/analytics/creator/CreatorDashboardError'; import { AgentViewsSection } from '../../../../components/analytics/AgentViewsSection'; +import { StartupsAgentAnalyticsPromo } from '../promos/StartupsAgentAnalyticsPromo'; import { CreatorAnalyticsAudience } from '../../../../components/analytics/creator/common'; import { CreatorPerformancePeriod, @@ -86,10 +87,12 @@ export const SquadManageAnalytics = (): ReactElement => { ...squadAnalyticsQueryOptions({ sourceId: squad?.id }), enabled: !!squad?.id && canViewAnalytics, }); - const { data: agentAnalytics } = useQuery({ - ...squadAgentAnalyticsQueryOptions({ sourceId: squad?.id }), - enabled: !!squad?.id && canViewAnalytics, - }); + const { data: agentAnalytics, isSuccess: isAgentAnalyticsFetched } = useQuery( + { + ...squadAgentAnalyticsQueryOptions({ sourceId: squad?.id }), + enabled: !!squad?.id && canViewAnalytics, + }, + ); const canViewAgentViews = typeof agentAnalytics?.agentViews === 'number'; const { data: agentHistory } = useQuery({ ...squadAgentAnalyticsHistoryQueryOptions({ sourceId: squad?.id }), @@ -228,6 +231,18 @@ export const SquadManageAnalytics = (): ReactElement => { )} + {isAgentAnalyticsFetched && !canViewAgentViews && ( + ( + <> + +
{promo}
+ + )} + /> + )}
{isPostsError && ( diff --git a/packages/shared/src/features/squads/components/promos/StartupsAgentAnalyticsPromo.tsx b/packages/shared/src/features/squads/components/promos/StartupsAgentAnalyticsPromo.tsx new file mode 100644 index 0000000000..7e195b9b76 --- /dev/null +++ b/packages/shared/src/features/squads/components/promos/StartupsAgentAnalyticsPromo.tsx @@ -0,0 +1,159 @@ +import type { ReactElement, ReactNode } from 'react'; +import React, { useMemo } from 'react'; +import dynamic from 'next/dynamic'; +import subDays from 'date-fns/subDays'; +import { + Button, + ButtonSize, + ButtonVariant, +} from '../../../../components/buttons/Button'; +import { DataTile } from '../../../../components/DataTile'; +import { LockIcon } from '../../../../components/icons'; +import { IconSize } from '../../../../components/Icon'; +import { + Typography, + TypographyColor, + TypographyTag, + TypographyType, +} from '../../../../components/typography/Typography'; +import type { AgentViewsHistoryItem } from '../../../../components/analytics/agentViews'; +import { + AgentViewsSeries, + agentViewsVendorSeries, +} from '../../../../components/analytics/agentViews'; +import { postAnalyticsHistoryLimit } from '../../../../graphql/posts'; +import { + StartupsPromoSpot, + useStartupsPromo, +} from '../../hooks/useStartupsPromo'; +import { MonthlyCredits } from './StartupsPromo'; + +const AgentViewsChart = dynamic( + () => + import('../../../../components/analytics/AgentViewsChart').then( + (mod) => mod.AgentViewsChart, + ), + { + loading: () =>
, + }, +); + +const previewVeil = + 'radial-gradient(70% 70% at 50% 50%, color-mix(in srgb, var(--theme-background-default) 85%, transparent) 0%, color-mix(in srgb, var(--theme-background-default) 40%, transparent) 100%)'; + +const previewSeries = [ + AgentViewsSeries.Chatgpt, + AgentViewsSeries.Claude, + AgentViewsSeries.Perplexity, +]; + +// Made-up numbers: the chart only shows blurred, behind the plan +const getPreviewHistory = (): AgentViewsHistoryItem[] => + Array.from({ length: postAnalyticsHistoryLimit }, (_, index) => { + const wave = (offset: number, scale: number) => + Math.round(scale * (2 + Math.sin(index / 4 + offset) + index / 30)); + + return { + date: subDays(new Date(), postAnalyticsHistoryLimit - 1 - index), + [AgentViewsSeries.Chatgpt]: wave(0, 6), + [AgentViewsSeries.Claude]: wave(2, 4), + [AgentViewsSeries.Perplexity]: wave(4, 2), + agentViewsChatgptBot: wave(1, 14), + agentViewsClaudeBot: wave(3, 10), + agentViewsPerplexityBot: wave(5, 5), + }; + }); + +const agentNames = agentViewsVendorSeries + .slice(0, 4) + .map(({ label }) => label) + .join(', '); + +/** + * Stands in for the AI agents section of post and squad analytics when the + * squad has no daily.dev for Startups plan: a blurred preview and the pitch. + */ +export const StartupsAgentAnalyticsPromo = ({ + sourceId, + isSquadAnalytics = false, + wrapper, +}: { + /** The squad the analytics are for, or the post's squad */ + sourceId?: string; + isSquadAnalytics?: boolean; + /** The page's section around it, so nothing renders when it doesn't show */ + wrapper: (promo: ReactNode) => ReactElement; +}): ReactElement | null => { + const promo = useStartupsPromo({ + spot: isSquadAnalytics + ? StartupsPromoSpot.SquadAnalytics + : StartupsPromoSpot.PostAnalytics, + sourceId, + isPersonalAllowed: !isSquadAnalytics, + isDismissible: false, + }); + const history = useMemo(getPreviewHistory, []); + + if (!promo.isShown) { + return null; + } + + const name = promo.squad?.name; + + return wrapper( +
+
+
+ + +
+ +
+
+ + + + + {isSquadAnalytics + ? 'See which AI agents read this squad' + : 'See which AI agents read your post'} + + + {`${agentNames} read posts on daily.dev when someone asks them about a topic. `} + {name + ? `Make ${name} your company page for ${promo.starterPrice} a month to see every read and crawl, day by day, with ` + : `Get a company page for ${promo.starterPrice} a month to see every read and crawl, day by day, with `} + every month. + + +
+
, + ); +}; diff --git a/packages/shared/src/features/squads/hooks/useStartupsPromo.ts b/packages/shared/src/features/squads/hooks/useStartupsPromo.ts index ff1b4492f2..34bbf5a98b 100644 --- a/packages/shared/src/features/squads/hooks/useStartupsPromo.ts +++ b/packages/shared/src/features/squads/hooks/useStartupsPromo.ts @@ -30,6 +30,8 @@ export enum StartupsPromoSpot { Wallet = 'wallet promo', AdsDashboard = 'ads dashboard promo', NewSquadModal = 'new squad modal promo', + SquadAnalytics = 'squad analytics promo', + PostAnalytics = 'post analytics promo', } interface UseStartupsPromoProps { @@ -42,6 +44,8 @@ interface UseStartupsPromoProps { isVisible?: boolean; /** Pitches the squad about to be created, not one the viewer runs */ isNewSquad?: boolean; + /** False for a locked feature, which shows even after a dismissed promo */ + isDismissible?: boolean; } /** What Starter gives back each month, the launch promo's while it is on */ @@ -101,6 +105,7 @@ export const useStartupsPromo = ({ isPersonalAllowed = true, isVisible = true, isNewSquad = false, + isDismissible = true, }: UseStartupsPromoProps): StartupsPromo => { const { user, squads } = useAuthContext(); const { checkHasCompleted, completeAction, isActionsFetched } = useActions(); @@ -154,7 +159,7 @@ export const useStartupsPromo = ({ const isShown = isCandidate && isActionsFetched && - !isDismissed && + (!isDismissible || !isDismissed) && (!squad || (!isPending && !!subscription && !subscription.plan)); const extra = useMemo( () => ({ source_id: squad?.id, has_squad: !!squad }), diff --git a/packages/shared/src/features/squads/lib/plans.ts b/packages/shared/src/features/squads/lib/plans.ts index c6459d7a00..23741cc8ed 100644 --- a/packages/shared/src/features/squads/lib/plans.ts +++ b/packages/shared/src/features/squads/lib/plans.ts @@ -134,6 +134,7 @@ export const squadPlanDetails: Record = { 'Company page with a link to your site', 'In developers’ feeds, by topic', 'On Google and in AI answers', + 'See which AI agents read your posts', 'Weekly intel on up to 5 topics', 'Reach notes when a post needs work', 'Skills for Claude Code and any agent', diff --git a/packages/webapp/pages/posts/[id]/analytics/index.tsx b/packages/webapp/pages/posts/[id]/analytics/index.tsx index 1f314b9fd2..733d247aaa 100644 --- a/packages/webapp/pages/posts/[id]/analytics/index.tsx +++ b/packages/webapp/pages/posts/[id]/analytics/index.tsx @@ -98,6 +98,7 @@ import { BoostIcon } from '@dailydotdev/shared/src/components/icons/Boost'; import { useCampaignEstimation } from '@dailydotdev/shared/src/features/boost/useCampaignEstimation'; import { useCampaigns } from '@dailydotdev/shared/src/features/boost/useCampaigns'; import { AgentViewsSection } from '@dailydotdev/shared/src/components/analytics/AgentViewsSection'; +import { StartupsAgentAnalyticsPromo } from '@dailydotdev/shared/src/features/squads/components/promos/StartupsAgentAnalyticsPromo'; import { LegendToggle } from '@dailydotdev/shared/src/components/analytics/LegendToggle'; import { getSeoDescription } from '../../../../components/PostSEOSchema'; import type { Props } from '../index'; @@ -221,7 +222,7 @@ const PostAnalyticsPage = ({ }); const isAuthor = !!user?.id && user.id === post?.author?.id; - const { data: postAnalytics } = useQuery({ + const { data: postAnalytics, isSuccess: isPostAnalyticsFetched } = useQuery({ ...postAnalyticsQueryOptions({ id: post?.id }), enabled: canViewPostAnalytics({ post, user }), }); @@ -583,6 +584,20 @@ const PostAnalyticsPage = ({ )} + {isPostAnalyticsFetched && !canViewAgentViews && ( + ( + <> + + + AI agents + {promo} + + + )} + /> + )} {canBoost && !campaign && ( <>