Documentation
¶
Overview ¶
Package support lets the app's users report a problem and support its development.
Report opens a form whose reports become GitHub issues through a small relay you deploy (see support/relay: a Cloudflare Worker), so users need no GitHub account and the token never ships in the app. Donate opens your donation page (Ko-fi, say), or, where the store requires its own payments (the App Store, the Mac App Store, Google Play), a sheet of tips sold as consumable in-app purchases.
help := support.New(app, support.Options{
ReportURL: "https://support.example.workers.dev/report",
App: "sonora",
DonateURL: "https://ko-fi.com/you",
Tips: []string{"tip_small", "tip_medium", "tip_large"},
})
reportButton := giode.Button("Report a problem").OnClick(help.Report)
donateButton := giode.Button("Donate").OnClick(help.Donate)
// In the view: the button where it belongs, and help anywhere (it
// takes no space, and paints its sheets over the window).
giode.Stack(giode.Styles{}, page, help)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("support: invalid report")
ErrInvalid is returned for a report the relay would turn away: no app or title, or a description too long.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// ReportURL is the relay's report address, ending in /report.
ReportURL string
// App names the app to the relay, which maps it to a repository:
// one relay serves all your apps. Default giode.AppID.
App string
// Key, when set, is sent with each report for the relay's KEY to
// check: it keeps out reports not sent by your apps. It ships in the
// app, so it stops casual spam, not a determined sender.
Key string
// Name is the app's name in the forms; default giode.AppName.
Name string
// DonateURL is the page Donate opens: "https://ko-fi.com/you".
DonateURL string
// Tips are the ids of consumable in-app products Donate offers
// instead of DonateURL where the store requires its own payments
// (store.BillingRequired). Create them in App Store Connect and the
// Play Console; they're shown in this order, with the store's
// titles and prices.
Tips []string
// Logs, when set, returns recent log lines the form offers to
// attach.
Logs func() string
// Toasts shows the forms' confirmations and errors; by default
// Support shows them in a toaster of its own.
Toasts *giode.ToasterElement
}
Options configures the report form and Donate.
type Report ¶
type Report struct {
App string `json:"app"`
Title string `json:"title"`
Description string `json:"description"`
// Email is for replies: the relay keeps it out of the issue.
Email string `json:"email,omitempty"`
// The app and system, when the user agrees to include them.
Version string `json:"version,omitempty"`
Build string `json:"build,omitempty"`
OS string `json:"os,omitempty"`
OSVersion string `json:"os_version,omitempty"`
Arch string `json:"arch,omitempty"`
Model string `json:"model,omitempty"`
Locale string `json:"locale,omitempty"`
// Crash is the text of a crash report (see package crash), Logs
// recent log lines.
Crash string `json:"crash,omitempty"`
Logs string `json:"logs,omitempty"`
}
Report is a problem report, as the relay receives it.
type Support ¶
type Support struct {
// contains filtered or unexported fields
}
Support is the report form and the tips sheet. Lay it out anywhere in the view: it takes no space and paints its sheets over the window.
func (*Support) CanDonate ¶
CanDonate reports whether Donate has something to offer here: tips where the store requires its own payments, the donation page elsewhere. Hide the Donate button when it's false.
func (*Support) Donate ¶
func (s *Support) Donate()
Donate opens the tips sheet where the store requires its own payments, and the donation page elsewhere.
func (*Support) FinishTip ¶
FinishTip finishes p if it's a tip, consuming it so it can be given again, and thanks the user; it reports whether p was a tip.
func (*Support) Layout ¶
func (s *Support) Layout(gtx layout.Context) layout.Dimensions
Layout lays out the open sheets and, unless Options.Toasts was given, the toasts.