Repository navigation
feat(brands): detect the site type when a brand is created, and say so in Brand settings - #1767
Merged
gkhngyk merged 6 commits intoOct 29, 2026
Merged
Conversation
Step 0 of the action plan by business type. A brand's site type was only ever chosen by hand, and the app guessed B2B for nearly everyone, shops included: page types, quality rules and opportunities all read it. - site-type-detect.js reads the brand's own home page (free): products, a cart and checkout make a shop; a demo, seat pricing or trial a SaaS; bookings a consumer service. When the page doesn't settle it, one small model call (SITE_TYPE_MODEL) names the type and the industry from the app's list. - POST /api/brands/:id/detect-site-type keeps the result, for admins and managers; it counts among onboarding's daily calls for a workspace that never subscribed. - 00379: brands.site_type_source (auto | manual) and site_type_detected_at. A trigger marks any type change that doesn't stamp a detection as a person's, so a manual choice always wins; another makes a brand with a new catalog source a shop, unless a person chose its type. Existing types are marked manual; brands with a catalog become shops. - scripts/detect-site-types.js detects the brands that have no type yet (--limit, --dry-run), printing counts only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ger signs Review follow-ups on the site type detection. - Detection only fills an empty type now: a type a person chose, or one a catalog or an earlier detection set, is left alone (skipped 'manual' or 'set'). A brand in Shopping mode becomes a shop without a read, and 00379 types the brands already in Shopping mode as shops too, so a shop can't be detected back to B2B. The industry is written by its own update, only while still empty. - A shop platform counts from asset addresses, classes and scripts, never the page's words (an agency writing "we build WooCommerce stores"); an offer counts only on a product, not an event, a course or a product only reviewed; a shop needs two signals of its own. Scripts and styles are left out of the words read. - The home page is read at the host as added, then with "www."; the model call has a 30 s limit. - Nothing is stamped when the type can't be told, so a later try reads the brand again. The backfill skips inactive brands and organizations without an active plan, logs each failure, and asks no model on a dry run. - The catalog trigger runs as the person who adds the source (admins and managers may update the brand too), not as its owner. - Route tests: roles that may not change a brand get 403, another organization's brand 404. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…in its settings Step 0, web side. Right after onboarding or "Add a brand" makes the brand, setup asks the API to detect its kind of site from its home page (in the background; setup never waits on it, and the app goes on guessing when it can't tell), and takes the type and industry into the brand. - Setup's competitor research finding an online store is a detection too: markBrandAsEcommerce now also makes the site type e-commerce, stamped as detected, unless a person chose one. - Brand settings say "Detected automatically from your website. Pick another if it's wrong." under a type that was detected; choosing another makes it the person's (00379's trigger). - Brand.siteTypeSource, the types for 00379's columns, the content-editor guide. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preview approval requiredThis pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit |
Wrapping each element in $(el), and removing scripts and styles one by one, grow with the square of the page's elements: a page of tens of thousands of them took seconds to a minute. The links, traces and visible text are now read straight off the parsed elements.
8 tasks done
gkhngyk
approved these changes
Oct 29, 2026
gkhngyk
left a comment
Contributor
There was a problem hiding this comment.
Looks good with 6c1d342: that's this PR's head with my #1761 change merged in (one-pass page reading). Nothing in this PR's own diff needed changing.
What I checked (this PR's own diff against #1761)
- Setup. Both the onboarding wizard and the new-brand page call
detectBrandTypein the background right aftercreateBrandreturns.createBrandinserts the domains before it returns, so the server sees the domain. A failure is caught and logged, and setup goes on. A result only updates the store when it's for the brand being set up. markBrandAsEcommerce. It still starts withassertWritable({ onboarding: true }). It writessite_type = 'ecommerce'withsite_type_detected_at, so the 00379 trigger keeps itauto, and it does that only when the type isn't manual and isn't already ecommerce. An update that touches 0 rows throws, as the industry write does. A brand already in Shopping mode still keeps its industry and mode, and now gets the type too.- Brand settings. "Detected automatically…" shows only while the select still holds the stored type and its source is
auto. Picking another type hides it, and saving marks it manual through the trigger. mapBrandRow. It mapssite_type_sourceonly toauto/manual. The brand reads already select*, so no select changed.- Read-only workspace. No new server action.
read-only.test.tsandsubscription-guard-coverage.test.tspass. - No PostgREST embeds are added or changed (the existing
brand_domains(*)embed is untouched). - Copy: the new
en.jsonline and the content-editor doc change read well. - Tests: the onboarding and new-brand page tests,
brand-ecommerce,read-only,ai-brand-setupand the subscription guard pass (37). Webtscpasses. The server suite runs as noted on #1761. - Merges clean on current main, and
build-schema.shleavesschema.sqlunchanged on the merge.
Follow-up
onboarding_site_type_detectedis tracked in the wizard but not on the new-brand page. That's fine if that's on purpose (other events differ between the two pages too).
4 of 5 tasks
gkhngyk
added a commit
that referenced
this pull request
Oct 29, 2026
…1778) #1761 and #1767 read brands.site_type_source and write site_type_detected_at (00379). If the code is deployed before the migration, markBrandAsEcommerce threw during onboarding's competitor step for any shop, and detection errored. Both now treat Postgres' undefined-column error (42703) as 'not yet': Shopping mode still goes on and the site type is left for detection once 00379 is applied. Co-authored-by: Cihan <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Gökhan Geyik <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Step 0, web part: call the site type detection (#1761) when a brand is created, and say in Brand settings when the type was detected.
ai-brand-setup.ts: newdetectSiteType(brandId)callsPOST /api/brands/:id/detect-site-type.onboarding_daily_limitbecomesSetupDailyLimitError.skippedgives{ siteType: null, industry: null }.createBrandsucceeds, detection runs in the background (void detectBrandType(brand.id)), so setup never waits.siteType,siteTypeSource: 'auto'and the industry when one comes back.onboarding_site_type_detected.markBrandAsEcommerceruns when competitor research finds a shop. It now also sets the type to e-commerce, unless a person picked one, and stampssite_type_detected_at, which keeps itauto. RLS refusing the row is an error. It returnssiteTypefor both pages' stores.brands.settings.siteTypeDetected). Saving another pick makes itmanualthrough feat(brands): detect a brand's site type and industry from its home page #1761's trigger.Brand.siteTypeSource;site_type_sourceandsite_type_detected_atinsupabase.ts.content-editor.mdx› Site type covers detection, the switch to e-commerce with a catalog, and that a manual pick never changes.Related issue
None (AC business-type action plan, step 0).
Stacked on #1761 (detection, server and 00379). The diff against it holds only this change.
Type of change
feat— New featureHow to test
Checklist
markBrandAsEcommerce, Add a brand, onboarding, read-only)🤖 Generated with Claude Code