feat: label the product page links with a fixed UTM per button (#525)

purchaseUrl(language, link) now appends utm_source=app, utm_medium=desktop,
utm_campaign=simpl-resultat and utm_content=<link>, built by URLSearchParams
in that order. `link` is the closed type ProductPageLink: locked-module,
license-card, update-locked, update-locked-download. The path and the choice
of the language do not change: the path stays the contract with the site.

PurchaseButton takes a required `link` ("locked-module" | "update-locked"):
UpsellGate passes locked-module, UpdateCard and ErrorPage update-locked.
DownloadLatestButton takes no label and always opens update-locked-download.
The License card opens license-card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-11-02 21:57:15 -05:00
commit 2a2d8f1e72
7 changed files with 55 additions and 22 deletions

View file

@ -56,7 +56,7 @@ function LicenseCardBody() {
};
const handlePurchase = () => {
void openUrl(purchaseUrl(i18n.language)).catch((e) =>
void openUrl(purchaseUrl(i18n.language, "license-card")).catch((e) =>
logError("Product page: openUrl failed", e),
);
};

View file

@ -94,7 +94,10 @@ export default function UpdateCard() {
</p>
)}
<div className="flex flex-wrap items-center gap-3">
<PurchaseButton className="inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm" />
<PurchaseButton
link="update-locked"
className="inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm"
/>
<HaveKeyButton className="inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm" />
</div>
<DownloadLatestButton />

View file

@ -15,9 +15,10 @@ interface DownloadLatestButtonProps {
/**
* "Download the latest version", shown in the free edition where automatic updates
* are locked (issue #346). It opens the product page, which serves the latest
* installers directly (la-compagnie-maximus#153). No update check runs here: the
* free edition makes no network call for updates. A failure to open the browser
* is logged, like PurchaseButton's.
* installers directly (la-compagnie-maximus#153), always labelled
* `update-locked-download` (#525): the update card and the error page share it. No
* update check runs here: the free edition makes no network call for updates. A
* failure to open the browser is logged, like PurchaseButton's.
*/
export default function DownloadLatestButton({
className = DEFAULT_LAYOUT,
@ -27,7 +28,7 @@ export default function DownloadLatestButton({
<button
type="button"
onClick={() =>
void openUrl(purchaseUrl(i18n.language)).catch((e) =>
void openUrl(purchaseUrl(i18n.language, "update-locked-download")).catch((e) =>
logError("Product page: openUrl failed", e),
)
}

View file

@ -105,7 +105,7 @@ export default function ErrorPage({ error }: ErrorPageProps) {
<p className="text-sm text-[var(--muted-foreground)]">
{t("error.updateNotEntitled")}
</p>
<PurchaseButton />
<PurchaseButton link="update-locked" />
<DownloadLatestButton />
</div>
)}

View file

@ -9,24 +9,31 @@ const COLOURS =
"bg-[var(--primary)] text-[var(--primary-foreground)] hover:opacity-90 transition-opacity";
interface PurchaseButtonProps {
/**
* The screen the button sits on, sent as the `utm_content` of the product page
* (#525): the locked screen of a module, or the update card and the error page of
* the free edition. A fixed label of the caller, never a value of the user.
*/
link: "locked-module" | "update-locked";
/** Replaces the default layout classes (width, padding, radius); colours stay fixed. */
className?: string;
}
/**
* "Get Base": opens the localized product page in the system browser (issue #346).
* Needs no router, so it also works on ErrorPage and in modals rendered outside
* BrowserRouter. It never calls a modal host's onNavigate: the page opens in the
* browser and the app stays where it was. A failure to open the browser is
* logged, so it shows up in the in-app logs instead of vanishing.
* "Get Base": opens the localized product page in the system browser (issue #346),
* labelled with the caller's `link` (#525). Needs no router, so it also works on
* ErrorPage and in modals rendered outside BrowserRouter. It never calls a modal
* host's onNavigate: the page opens in the browser and the app stays where it was.
* A failure to open the browser is logged, so it shows up in the in-app logs
* instead of vanishing.
*/
export default function PurchaseButton({ className = DEFAULT_LAYOUT }: PurchaseButtonProps) {
export default function PurchaseButton({ link, className = DEFAULT_LAYOUT }: PurchaseButtonProps) {
const { t, i18n } = useTranslation();
return (
<button
type="button"
onClick={() =>
void openUrl(purchaseUrl(i18n.language)).catch((e) =>
void openUrl(purchaseUrl(i18n.language, link)).catch((e) =>
logError("Product page: openUrl failed", e),
)
}

View file

@ -66,7 +66,7 @@ export default function UpsellGate({ feature, requiredTier, onNavigate }: Upsell
<div className="flex flex-col gap-3">
{cta.purchasable ? (
<PurchaseButton />
<PurchaseButton link="locked-module" />
) : (
<div>
<button

View file

@ -1,19 +1,41 @@
// Product page on the vitrine, where Simpl'Résultat Base is sold.
//
// Contract with the site: this path is compiled into every released binary,
// Contract with the site: the path is compiled into every released binary,
// and an install without a key never updates past v0.15.0 (auto-update is
// Base+), so a URL shipped here must keep answering for years. Renaming the
// Base+), so a path shipped here must keep answering for years. Renaming the
// page on the site requires a 308 redirect — see
// maximus/la-compagnie-maximus#153, which also redirects the old
// `/simpl-resultat` path baked into v0.14.0 and v0.15.0 (issue #270).
//
// The query is not part of that contract: it is a fixed UTM label set by the
// button that opens the page (#525), so the site can tell a visit from the app
// apart from a direct one. It never carries a value taken from the user or the
// install (version, edition, module, key, machine, error state): `link` is one
// of the four constants of `ProductPageLink`, written in the code of each button.
const PRODUCT_PAGE = "https://lacompagniemaximus.com/{locale}/produits/simpl-resultat";
/** The button that opens the product page, sent as the `utm_content` of its URL (#525). */
export type ProductPageLink =
| "locked-module"
| "license-card"
| "update-locked"
| "update-locked-download";
/**
* Localized product page for the app language. `i18n.language` is `fr` or
* `en` in practice; any English variant opens the English page, anything else
* falls back to French (the app's default language).
* Localized product page for the app language, labelled with the button that
* opens it. `i18n.language` is `fr` or `en` in practice; any English variant
* opens the English page, anything else falls back to French (the app's
* default language). The query always holds these four keys, in this order:
* `utm_source=app`, `utm_medium=desktop`, `utm_campaign=simpl-resultat`,
* `utm_content=<link>`.
*/
export function purchaseUrl(language: string): string {
export function purchaseUrl(language: string, link: ProductPageLink): string {
const locale = language.toLowerCase().startsWith("en") ? "en" : "fr";
return PRODUCT_PAGE.replace("{locale}", locale);
const query = new URLSearchParams([
["utm_source", "app"],
["utm_medium", "desktop"],
["utm_campaign", "simpl-resultat"],
["utm_content", link],
]);
return `${PRODUCT_PAGE.replace("{locale}", locale)}?${query.toString()}`;
}