Pricing - Bill per workspace ($12/mo or $120/yr each); Stripe quantity tracks the workspace count and syncs on workspace create/delete. - 2,500 AI credits per workspace, pooled at the account level; monthly reset on the billing anniversary, annual granted upfront (no rollover). - One social account per network per workspace; remove all count-based limits (workspace/social/member) and the legacy plan tiers (single Workspace plan). Onboarding (cloud only: SELF_HOSTED=false + PostHog) - Replace the /subscribe plan picker with /onboarding persona selection (Creator/Freelancer/Startup/Agency/Small business/Other), saved on the user (users.persona) and mirrored to PostHog, then Stripe Checkout on the monthly price. 8-day trial so Stripe displays 7. Billing screen - Remove the Change Plan dialog (dead with a single plan); add an annual-upgrade banner for monthly subscribers (swapToYearly). - Current-plan card shows the workspace count instead of the plan name. System AI - Brand analyzer / workspace autofill is always allowed and never debits credits (system feature, not the user's usage). Self-hosted (SELF_HOSTED=true) bypasses all billing, credit, limit, network, and onboarding logic.
62 lines
2.2 KiB
PHP
62 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Ai;
|
|
|
|
use App\Services\Brand\BrandAnalyzerRunner;
|
|
use App\Services\Brand\BrandMetadata;
|
|
use App\Services\Brand\HomepageMetaExtractor;
|
|
use App\Services\Brand\LogoColorExtractor;
|
|
use App\Services\Brand\SafeHttpFetcher;
|
|
|
|
final class AutofillBrand
|
|
{
|
|
public function __construct(
|
|
private readonly SafeHttpFetcher $fetcher,
|
|
private readonly HomepageMetaExtractor $extractor,
|
|
private readonly BrandAnalyzerRunner $analyzer,
|
|
private readonly LogoColorExtractor $logoColors,
|
|
) {}
|
|
|
|
public function __invoke(string $url): BrandMetadata
|
|
{
|
|
$url = $this->fetcher->normalizeUrl($url);
|
|
|
|
$html = $this->fetcher->get($url)->body();
|
|
|
|
// Pull up to 3 external stylesheets so the deterministic color
|
|
// extractor can find brand/background/text colors that aren't inlined.
|
|
$extraCss = '';
|
|
$stylesheetUrls = array_slice($this->extractor->extractStylesheetUrls($html, $url), 0, 3);
|
|
foreach ($stylesheetUrls as $cssUrl) {
|
|
$response = $this->fetcher->tryGet($cssUrl);
|
|
if ($response !== null && $response->successful()) {
|
|
$extraCss .= "\n".$response->body();
|
|
}
|
|
}
|
|
|
|
$metadata = $this->extractor->extract($html, $url, $extraCss);
|
|
|
|
// If the deterministic CSS scan didn't yield a brand color, pull the
|
|
// dominant non-neutral color out of the logo image itself. This works
|
|
// even when the site uses utility CSS (Tailwind, etc.) where no
|
|
// semantic --primary var or body { background } rule exists.
|
|
if ($metadata->brandColor === null && $metadata->logoUrl !== null) {
|
|
$logoColor = $this->logoColors->extractFromUrl($metadata->logoUrl);
|
|
if ($logoColor !== null) {
|
|
$metadata = $metadata->withBrandColor($logoColor);
|
|
}
|
|
}
|
|
|
|
if (! $this->analyzer->isAvailable()) {
|
|
return $metadata;
|
|
}
|
|
|
|
$analysis = $this->analyzer->analyze($this->extractor->extractBodyHtml($html));
|
|
|
|
return $analysis === null
|
|
? $metadata
|
|
: $metadata->mergeLlm($analysis);
|
|
}
|
|
}
|