Files
Pulse/pkg/licensing/upgrade.go
rcourtman 107c4e29f9 Make metric history free on every plan
Community installs already stored 90 days of daily metric averages and
366 days of availability history, but the chart, availability and agent
history reads refused anything past seven days, and lapsed paid installs
had history past seven days purged 60 days after a downgrade. Locking
users out of data on their own disk is the kind of limit that drew the
loudest complaints before (the monitored-system cap, SSO), and it is not
what people pay for: 12 of 88 covered paid installs read past seven days
in the last 30 days.

The history routes now serve every supported range on every plan, and
storage retention alone decides how far back the answer goes.
long_term_metrics moves into Community as a compatibility key with no
upgrade reason. TierHistoryDays, max_history_days and the downgrade
purge (DowngradeRetentionState, the metrics store commercial ceiling and
the generated-report purge) are removed, so nothing deletes history or
reports because a plan ended. The chart and drawer lock panels, the
history plan link, the billing summary row and the plan copy that sold
history go with them. Paying users lose nothing.

The public pricing pages and licence server copy in pulse-pro change
when the release carrying this ships.
2026-11-17 20:11:48 +00:00

102 lines
3.3 KiB
Go

package licensing
import (
"strings"
"github.com/rcourtman/pulse-go-rewrite/pkg/securityutil"
)
// DefaultUpgradeURL is used when no feature-specific URL mapping exists.
const DefaultUpgradeURL = "https://pulserelay.pro/pricing?utm_source=pulse&utm_medium=app&utm_campaign=upgrade"
// DefaultProTrialSignupURL is the legacy hosted commercial base URL used by
// compatibility paths that derive hosted entitlement refresh endpoints.
const DefaultProTrialSignupURL = "https://cloud.pulserelay.pro"
// DefaultPulseAccountPortalURL is where in-app Buy sends the operator to choose
// a plan and pay. The licence server hosts it; the earlier page on the Cloud
// host stopped answering when hosted Cloud was hibernated on 2026-06-01.
const DefaultPulseAccountPortalURL = "https://license.pulserelay.pro/buy"
// ProTrialSignupURLEnvVar overrides the legacy hosted commercial base URL.
const ProTrialSignupURLEnvVar = "PULSE_PRO_TRIAL_SIGNUP_URL"
// PulseAccountPortalURLEnvVar overrides the Pulse Account portal URL.
const PulseAccountPortalURLEnvVar = "PULSE_ACCOUNT_PORTAL_URL"
// ResolveProTrialSignupURL returns the canonical legacy hosted commercial base URL.
// Invalid overrides are ignored and the default URL is returned.
func ResolveProTrialSignupURL(override string) string {
if normalized, ok := validateExternalUpgradeURLOverride(override); ok {
return normalized
}
return DefaultProTrialSignupURL
}
// ResolvePulseAccountPortalURL returns the canonical Pulse Account portal URL.
// Invalid overrides are ignored and the default URL is returned.
func ResolvePulseAccountPortalURL(override string) string {
if normalized, ok := validateExternalUpgradeURLOverride(override); ok {
return normalized
}
return DefaultPulseAccountPortalURL
}
func validateExternalUpgradeURLOverride(raw string) (string, bool) {
raw = strings.TrimSpace(raw)
if raw == "" {
return "", false
}
parsed, err := securityutil.NormalizeAbsoluteHTTPURL(raw)
if err != nil {
return "", false
}
switch strings.ToLower(parsed.Scheme) {
case "https":
parsed.Scheme = "https"
case "http":
if !securityutil.IsLoopbackHost(parsed.Hostname()) {
return "", false
}
parsed.Scheme = "http"
default:
return "", false
}
parsed.Host = strings.ToLower(parsed.Host)
parsed.Fragment = ""
return parsed.String(), true
}
// UpgradeURLForFeature returns the canonical upgrade URL for a capability key.
func UpgradeURLForFeature(feature string) string {
if IsCompatibilityOnlyFeature(feature) {
return DefaultUpgradeURL
}
switch feature {
case FeatureRelay:
return DefaultUpgradeURL + "&feature=relay"
case FeatureMobileApp:
return DefaultUpgradeURL + "&feature=mobile_app"
case FeaturePushNotifications:
return DefaultUpgradeURL + "&feature=push_notifications"
case FeatureAIAutoFix:
return DefaultUpgradeURL + "&feature=ai_autofix"
case FeatureAIAlerts:
return DefaultUpgradeURL + "&feature=ai_alerts"
case FeatureRBAC:
return DefaultUpgradeURL + "&feature=rbac"
case FeatureAgentProfiles:
return DefaultUpgradeURL + "&feature=agent_profiles"
case FeatureAuditLogging:
return DefaultUpgradeURL + "&feature=audit_logging"
case FeatureAdvancedReporting:
return DefaultUpgradeURL + "&feature=advanced_reporting"
case FeatureExternalProbe:
return DefaultUpgradeURL + "&feature=external_probe"
default:
return DefaultUpgradeURL
}
}