Documentation
¶
Overview ¶
Package feedback holds what `basecamp feedback` shares with the rest of the CLI: whether Basecamp advertises the feedback endpoint to this person, the cached answer, the override that forces it, and the hint error output carries while it is advertised.
The feature ships dark. Basecamp answers GET /{account}/feedback.json with 200 when feedback is on for the person and 404 when it is off, so the CLI advertises nothing — no command in help or completions, no hint — until a detection has seen a 200 or BASECAMP_FEEDBACK forces it on.
Index ¶
- Constants
- Variables
- func Credential(storedKey string) string
- func IsNotFound(err error) bool
- func Key(baseURL, accountID, credential string) string
- func Override() (enabled, set bool)
- func ValidCategory(c string) bool
- func WantsHint(err error) bool
- type Getter
- type Store
- func (s *Store) Advertised(key string) bool
- func (s *Store) AnyAdvertised() bool
- func (s *Store) BeginRefresh(key string) bool
- func (s *Store) Detect(ctx context.Context, api Getter, key string) (bool, error)
- func (s *Store) Enabled(key string) bool
- func (s *Store) NeedsRefresh(key string) bool
- func (s *Store) Record(key string, advertised bool)
- func (s *Store) Visible() bool
Constants ¶
const EnvOverride = "BASECAMP_FEEDBACK"
EnvOverride forces the feature on (1/true/yes/on) or off (0/false/no/off), skipping detection. Any other value is ignored.
const Hint = "If this looks like a problem with Basecamp, `basecamp feedback` reports it to the Basecamp team."
Hint is the line error output carries while feedback is advertised. It describes; it never tells the reader to do anything.
const MaxDetails = 2000
MaxDetails is the server's cap on details, in characters.
const NotAvailable = "Feedback is not available."
NotAvailable is everything `basecamp feedback` says when the feature is off.
const Path = "/feedback.json"
Path is the account-relative endpoint: GET discovers, POST submits.
const RefreshTimeout = 2 * time.Second
RefreshTimeout bounds the background detection a command runs after it has already talked to Basecamp.
const Surface = "cli"
Surface is what the CLI reports itself as. `basecamp mcp` has no feedback tool, so the CLI never sends cli_mcp.
const TTL = 24 * time.Hour
TTL is how long a detection answer stands before a refresh is due.
Variables ¶
var Categories = []string{"bug", "missing_capability", "confusing", "praise", "other"}
Categories are the values the server accepts for category.
Functions ¶
func Credential ¶
Credential names the credential a request goes out with, without holding it: a BASECAMP_TOKEN, which wins over any stored credential, by a short digest of the token, and otherwise the stored credential's key (a profile, or the host for the default login).
func IsNotFound ¶
IsNotFound reports whether err is the server's 404 — the feature is off.
func Key ¶
Key names one person's view of one account on one Basecamp host. Basecamp can answer differently for two people in the same account, so the answer is kept per credential: credential names the one in use (see Credential).
func Override ¶
func Override() (enabled, set bool)
Override reports whether BASECAMP_FEEDBACK forces the feature, and which way.
func ValidCategory ¶
ValidCategory reports whether c is one the server accepts.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the cached detection state, one entry per Basecamp host, account and credential. It lives in the CLI's default cache directory rather than a profile's, because help is rendered before any profile is resolved.
func DefaultStore ¶
func DefaultStore() *Store
DefaultStore returns the store in BASECAMP_CACHE_DIR, or the default cache directory when that is unset.
func (*Store) Advertised ¶
Advertised reports the cached answer for one account. A stale answer still counts until a refresh replaces it.
func (*Store) AnyAdvertised ¶
AnyAdvertised reports whether any account has a cached 200. Help uses this: it is rendered before the account is known, and showing the command for an account where it is off costs only a "not available" when it is run.
func (*Store) BeginRefresh ¶
BeginRefresh notes a detection attempt before it is made, so the failure backoff holds even if the attempt never finishes, and reports whether the note was stored. Where the state cannot be written no answer could be kept either, and every later command would find a refresh due and probe again: a false return means skip the probe.
func (*Store) Detect ¶
Detect asks Basecamp whether feedback is on for this person and records the answer: 200 means advertised, 404 means not. Any other outcome records a failed attempt, keeps the previous answer, and is returned.
func (*Store) Enabled ¶
Enabled reports whether feedback is on for an account: the override when it is set, the cached answer otherwise.
func (*Store) NeedsRefresh ¶
NeedsRefresh reports whether the account's answer is due for a detection. A time in the future, from a clock set back since, counts as due, so a wrong clock can't hold the cached answer until it catches up.