Simpl-Resultat/src/components/shared/DownloadLatestButton.tsx
le king fu 2a2d8f1e72 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>
2026-11-02 21:57:15 -05:00

41 lines
1.5 KiB
TypeScript

import { useTranslation } from "react-i18next";
import { openUrl } from "@tauri-apps/plugin-opener";
import { Download } from "lucide-react";
import { purchaseUrl } from "../../shared/purchaseUrl";
import { logError } from "../../services/logService";
const DEFAULT_LAYOUT = "inline-flex items-center justify-center gap-2 text-sm";
const COLOURS = "text-[var(--primary)] hover:underline";
interface DownloadLatestButtonProps {
/** Replaces the default layout classes; colours stay fixed. */
className?: string;
}
/**
* "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), 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,
}: DownloadLatestButtonProps) {
const { t, i18n } = useTranslation();
return (
<button
type="button"
onClick={() =>
void openUrl(purchaseUrl(i18n.language, "update-locked-download")).catch((e) =>
logError("Product page: openUrl failed", e),
)
}
className={`${className} ${COLOURS}`}
>
<Download className="h-4 w-4" />
{t("settings.updates.downloadLatest")}
</button>
);
}