Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Harden Pulse trial entitlements and CTA flows

rcourtman8aa5390883f8
diff --git a/docs/release-control/v6/internal/subsystems/cloud-paid.md b/docs/release-control/v6/internal/subsystems/cloud-paid.md
index ec6f5da494..84c73362eb 100644
--- a/docs/release-control/v6/internal/subsystems/cloud-paid.md
+++ b/docs/release-control/v6/internal/subsystems/cloud-paid.md
@@ -218,6 +218,19 @@ presentation helpers through `frontend-modern/src/utils/licensePresentation.ts`
and `frontend-modern/src/utils/upgradePresentation.ts`. Commercial tier labels,
feature minimum-tier messaging, migration/trial notices, billing-admin status
labels, and upgrade CTA styling must extend those helpers instead of being
+forked into per-surface status-code branches that drift from backend error
+truth. Trial initiation surfaces must preserve backend denial messages when the
+request is blocked for migration, active commercial state, or other operational
+reasons, and only map the explicit canonical cases (`trial_already_used`,
+rate-limit retry) to fixed copy.
+Hosted self-serve trial leases are also part of that same contract. A redeemed
+hosted trial must carry the canonical Pro capability set and the authoritative
+`limits.max_monitored_systems` cap inside the signed lease rather than relying
+on downstream runtime fallback to infer a limit from trial state alone.
+The top-level authenticated shell is part of that same customer-facing
+boundary: cloud-paid trial prompts may appear in owned commercial surfaces, but
+the app shell must not force a global, persistent Pro trial nudge that
+overrides the primary runtime chrome for every signed-in user.
redefined inline in settings feature gates, Pro license panels, or trial
upgrade nudges.
That same disclosure copy must stay professional and customer-facing. The
diff --git a/frontend-modern/src/App.tsx b/frontend-modern/src/App.tsx
index 4bf2e9a9d1..18b8617712 100644
--- a/frontend-modern/src/App.tsx
+++ b/frontend-modern/src/App.tsx
@@ -22,7 +22,6 @@ import { DemoBanner } from './components/DemoBanner';
import { GitHubStarBanner } from './components/GitHubStarBanner';
import { TrialBanner } from './components/shared/TrialBanner';
import { MonitoredSystemLimitWarningBanner } from './components/shared/MonitoredSystemLimitWarningBanner';
-import { ActiveUseTrialNudge } from './components/shared/ActiveUseTrialNudge';
import { WhatsNewModal } from './components/shared/WhatsNewModal';
import { KeyboardShortcutsModal } from './components/shared/KeyboardShortcutsModal';
import { CommandPaletteModal } from './components/shared/CommandPaletteModal';
@@ -313,7 +312,6 @@ function App() {
<UpdateBanner />
<TrialBanner />
<MonitoredSystemLimitWarningBanner />
- <ActiveUseTrialNudge />
<GitHubStarBanner />
<WhatsNewModal />
<GlobalUpdateProgressWatcher />
diff --git a/frontend-modern/src/__tests__/App.architecture.test.ts b/frontend-modern/src/__tests__/App.architecture.test.ts
index e23a350be8..3c6ea3e18e 100644
--- a/frontend-modern/src/__tests__/App.architecture.test.ts
+++ b/frontend-modern/src/__tests__/App.architecture.test.ts
@@ -15,6 +15,7 @@ describe('App architecture', () => {
);
expect(appSource).not.toContain('function ConnectionStatusBadge(');
expect(appSource).not.toContain('function AppLayout(');
+ expect(appSource).not.toContain('ActiveUseTrialNudge');
expect(appSource).not.toContain('const [organizations, setOrganizations] = createSignal(');
expect(appSource).not.toContain('const [themePreference, setThemePreference] =');
expect(appSource).not.toContain('const [activeOrgID, setActiveOrgID] = createSignal(');
diff --git a/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx b/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx
index 69956664af..923bdcfa76 100644
--- a/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx
+++ b/frontend-modern/src/components/Dashboard/__tests__/RelayOnboardingCard.test.tsx
@@ -350,10 +350,9 @@ describe('RelayOnboardingCard', () => {
}
});
- it('shows error toast and redirects to upgrade URL when trial fails', async () => {
+ it('shows the backend error and does not redirect when trial fails', async () => {
setupWithoutRelayFeature();
startProTrialMock.mockRejectedValue(new Error('server error'));
- getUpgradeActionUrlOrFallbackMock.mockReturnValue('/pricing?feature=relay');
const originalLocation = window.location;
Object.defineProperty(window, 'location', {
@@ -371,12 +370,10 @@ describe('RelayOnboardingCard', () => {
fireEvent.click(screen.getByText(/or start a Pro trial/));
await waitFor(() => {
- expect(showErrorMock).toHaveBeenCalledWith(
- 'Unable to start trial. Redirecting to upgrade options...',
- );
+ expect(showErrorMock).toHaveBeenCalledWith('server error');
});
- expect(window.location.href).toBe('/pricing?feature=relay');
+ expect(window.location.href).toBe('');
} finally {
Object.defineProperty(window, 'location', {
writable: true,
diff --git a/frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts b/frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts
index 6f1d29b545..f8ffa6815d 100644
--- a/frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts
+++ b/frontend-modern/src/components/Dashboard/useRelayOnboardingCardState.ts
@@ -2,7 +2,6 @@ import { createEffect, createMemo, createSignal, onMount } from 'solid-js';
import { useNavigate } from '@solidjs/router';
import { RelayAPI, type RelayStatus } from '@/api/relay';
import {
- getUpgradeActionUrlOrFallback,
hasFeature,
licenseLoaded,
loadLicenseStatus,
@@ -12,6 +11,7 @@ import { logger } from '@/utils/logger';
import { isUpsellSnoozed, snoozeUpsell } from '@/utils/snooze';
import { showError, showSuccess } from '@/utils/toast';
import { trackPaywallViewed, trackUpgradeClicked } from '@/utils/upgradeMetrics';
+import { getTrialStartErrorMessage } from '@/utils/upgradePresentation';
const SNOOZE_KEY = 'pulse_relay_onboarding_snoozed';
const RELAY_SETTINGS_PATH = '/settings/system-relay';
@@ -122,12 +122,8 @@ export function useRelayOnboardingCardState() {
setStatusLoaded(false);
void loadRelayStatusOnce();
} catch (error) {
- logger.warn('[RelayOnboardingCard] Failed to start trial; falling back to upgrade URL', error);
- showError('Unable to start trial. Redirecting to upgrade options...');
- const upgradeUrl = getUpgradeActionUrlOrFallback('relay');
- if (typeof window !== 'undefined') {
- window.location.href = upgradeUrl;
- }
+ logger.warn('[RelayOnboardingCard] Failed to start trial', error);
+ showError(getTrialStartErrorMessage(error, { branded: true }));
} finally {
setTrialStarting(false);
}
diff --git a/frontend-modern/src/pages/PricingV6.tsx b/frontend-modern/src/pages/PricingV6.tsx
index ca1d05d70e..78bc851493 100644
--- a/frontend-modern/src/pages/PricingV6.tsx
+++ b/frontend-modern/src/pages/PricingV6.tsx
@@ -18,6 +18,7 @@ import {
} from '@/stores/license';
import { showToast } from '@/utils/toast';
import { logger } from '@/utils/logger';
+import { getTrialStartErrorMessage } from '@/utils/upgradePresentation';
import {
SELF_HOSTED_FEATURE_ROWS,
SELF_HOSTED_PLAN_BY_TIER,
@@ -190,18 +191,12 @@ export default function PricingV6() {
showToast('success', 'Pro trial started (14 days).');
await loadLicenseStatus(true);
} catch (error) {
- const statusCode = (error as { status?: number } | null)?.status;
- if (statusCode === 429) {
- setTrialMessage('Try again later.');
- return;
- }
- if (statusCode === 409) {
+ const trialError = error as { code?: string } | null;
+ if (trialError?.code === 'trial_already_used') {
setTrialCtaMode('upgrade');
- setTrialMessage('Trial already used.');
- return;
}
logger.warn('[PricingV6] Trial start request failed', error);
- setTrialMessage('Failed to start trial.');
+ setTrialMessage(getTrialStartErrorMessage(error));
} finally {
setStartingTrial(false);
}
diff --git a/frontend-modern/src/pages/__tests__/PricingV6.test.tsx b/frontend-modern/src/pages/__tests__/PricingV6.test.tsx
index 237c84648b..2ef5e8c87d 100644
--- a/frontend-modern/src/pages/__tests__/PricingV6.test.tsx
+++ b/frontend-modern/src/pages/__tests__/PricingV6.test.tsx
@@ -73,7 +73,9 @@ describe('PricingV6', () => {
it('imports the shared self-hosted pricing model instead of redefining it locally', () => {
expect(pricingV6Source).toContain("@/utils/selfHostedPlans");
+ expect(pricingV6Source).toContain("@/utils/upgradePresentation");
expect(pricingV6Source).not.toContain('const TIERS =');
expect(pricingV6Source).not.toContain('const FEATURE_ROWS');
+ expect(pricingV6Source).not.toContain("setTrialMessage('Trial already used.')");
});
});
diff --git a/frontend-modern/src/stores/__tests__/license.test.ts b/frontend-modern/src/stores/__tests__/license.test.ts
index 48b0c79ce2..c3380d126b 100644
--- a/frontend-modern/src/stores/__tests__/license.test.ts
+++ b/frontend-modern/src/stores/__tests__/license.test.ts
@@ -89,7 +89,7 @@ describe('license store', () => {
upgrade_reasons: [],
tier: 'free',
hosted_mode: false,
- trial_eligible: true,
+ trial_eligible: false,
legacy_connections: {
proxmox_nodes: 0,
docker_hosts: 0,
diff --git a/frontend-modern/src/stores/license.ts b/frontend-modern/src/stores/license.ts
index d1727923e7..1b33957ce8 100644
--- a/frontend-modern/src/stores/license.ts
+++ b/frontend-modern/src/stores/license.ts
@@ -59,7 +59,7 @@ export async function loadLicenseStatus(force = false): Promise<void> {
upgrade_reasons: [],
tier: 'free',
hosted_mode: false,
- trial_eligible: true,
+ trial_eligible: false,
legacy_connections: {
proxmox_nodes: 0,
docker_hosts: 0,
diff --git a/frontend-modern/src/utils/__tests__/upgradePresentation.test.ts b/frontend-modern/src/utils/__tests__/upgradePresentation.test.ts
index ea2e698ba8..085aa03fce 100644
--- a/frontend-modern/src/utils/__tests__/upgradePresentation.test.ts
+++ b/frontend-modern/src/utils/__tests__/upgradePresentation.test.ts
@@ -26,6 +26,14 @@ describe('upgradePresentation', () => {
'Failed to start Pro trial',
);
expect(getTrialStartErrorMessage('temporary failure')).toBe('temporary failure');
+ expect(getTrialStartErrorMessage({ code: 'trial_already_used' })).toBe('Trial already used');
+ expect(getTrialStartErrorMessage({ status: 429 })).toBe('Try again later');
+ expect(
+ getTrialStartErrorMessage({
+ code: 'trial_not_available',
+ message: 'Trial cannot be started while migration is pending',
+ }),
+ ).toBe('Trial cannot be started while migration is pending');
});
it('returns the primary upgrade action button classes by default', () => {
diff --git a/frontend-modern/src/utils/upgradePresentation.ts b/frontend-modern/src/utils/upgradePresentation.ts
index 729d4aba6a..b7cb2db618 100644
--- a/frontend-modern/src/utils/upgradePresentation.ts
+++ b/frontend-modern/src/utils/upgradePresentation.ts
@@ -14,6 +14,12 @@ export interface TrialStartErrorOptions {
branded?: boolean;
}
+export interface TrialStartErrorLike {
+ status?: number;
+ code?: string;
+ message?: string;
+}
+
export function getProTrialStartedMessage(): string {
return 'Pro trial started';
}
@@ -26,11 +32,33 @@ export function getTrialTryAgainLaterMessage(): string {
return 'Try again later';
}
+function normalizeTrialStartError(error?: unknown): TrialStartErrorLike | null {
+ if (!error) return null;
+ if (typeof error === 'string') return { message: error };
+ if (typeof error !== 'object') return null;
+
+ const value = error as TrialStartErrorLike;
+ return {
+ status: value.status,
+ code: value.code,
+ message: value.message,
+ };
+}
+
export function getTrialStartErrorMessage(
- message?: string,
+ error?: unknown,
options: TrialStartErrorOptions = {},
): string {
- if (message) return message;
+ const normalized = normalizeTrialStartError(error);
+ if (normalized?.code === 'trial_already_used') {
+ return getTrialAlreadyUsedMessage();
+ }
+ if (normalized?.status === 429) {
+ return getTrialTryAgainLaterMessage();
+ }
+ if (normalized?.message?.trim()) {
+ return normalized.message.trim();
+ }
return options.branded ? 'Failed to start Pro trial' : 'Failed to start trial';
}
diff --git a/internal/cloudcp/entitlements/service.go b/internal/cloudcp/entitlements/service.go
index 91ff42e723..ca2a0386f1 100644
--- a/internal/cloudcp/entitlements/service.go
+++ b/internal/cloudcp/entitlements/service.go
@@ -575,7 +575,13 @@ func buildPaidEntitlementLeaseClaims(ctx *tenantLeaseContext, instanceHost strin
}
func buildTrialLeaseClaims(ctx trialEntitlementContext, now time.Time) pkglicensing.EntitlementLeaseClaims {
- trialState := pkglicensing.BuildTrialBillingState(ctx.trialStartedAt.UTC(), pkglicensing.TierFeatures[pkglicensing.TierPro])
+ trialCapabilities, trialLimits := pkglicensing.DeriveEntitlements(
+ pkglicensing.TierPro,
+ nil,
+ pkglicensing.TierMonitoredSystemLimits[pkglicensing.TierPro],
+ 0,
+ )
+ trialState := pkglicensing.BuildTrialBillingState(ctx.trialStartedAt.UTC(), trialCapabilities)
return pkglicensing.EntitlementLeaseClaims{
OrgID: strings.TrimSpace(ctx.orgID),
Email: strings.TrimSpace(ctx.email),
@@ -583,7 +589,7 @@ func buildTrialLeaseClaims(ctx trialEntitlementContext, now time.Time) pkglicens
PlanVersion: trialState.PlanVersion,
SubscriptionState: trialState.SubscriptionState,
Capabilities: append([]string(nil), trialState.Capabilities...),
- Limits: map[string]int64{},
+ Limits: trialLimits,
MetersEnabled: []string{},
TrialStartedAt: trialState.TrialStartedAt,
TrialEndsAt: trialState.TrialEndsAt,
diff --git a/internal/cloudcp/entitlements/service_test.go b/internal/cloudcp/entitlements/service_test.go
index f6187dadf4..9c9ef6d328 100644
--- a/internal/cloudcp/entitlements/service_test.go
+++ b/internal/cloudcp/entitlements/service_test.go
@@ -284,4 +284,12 @@ func TestRedeemTrialEntitlementAndRefresh(t *testing.T) {
if claims.SubscriptionState != pkglicensing.SubStateTrial {
t.Fatalf("claims.SubscriptionState=%q, want %q", claims.SubscriptionState, pkglicensing.SubStateTrial)
}
+ if got := claims.Limits[pkglicensing.MaxMonitoredSystemsLicenseGateKey]; got != int64(pkglicensing.TierMonitoredSystemLimits[pkglicensing.TierPro]) {
+ t.Fatalf(
+ "claims.Limits[%s]=%d, want %d",
+ pkglicensing.MaxMonitoredSystemsLicenseGateKey,
+ got,
+ pkglicensing.TierMonitoredSystemLimits[pkglicensing.TierPro],
+ )
+ }
}