Documentation
¶
Overview ¶
Package client ports the matomo/device-detector client parsers (Parser/Client/*) to Go: browsers, feed readers, libraries, media players, mobile apps and PIMs. It implements the pure user-agent detection path; client-hints handling is out of scope for v0.1.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BrowserFamily ¶
BrowserFamily mirrors Browser::getBrowserFamily(): it accepts either a short code or a full browser name and returns the family it belongs to.
func IsMobileOnlyBrowser ¶
IsMobileOnlyBrowser mirrors Browser::isMobileOnlyBrowser(): it accepts either a short code or a full browser name.
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser ports Parser/Client/Browser.php: it detects browsers together with their rendering engine and engine version.
func NewBrowser ¶
NewBrowser loads the browser database (and the engine database it depends on) from fsys.
func (*Browser) SetVersionTruncation ¶
SetVersionTruncation sets the version truncation level.
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine ports Parser/Client/Browser/Engine.php: it detects a browser engine from the user agent using the browser_engine.yml regexes.
type FeedReader ¶
type FeedReader struct {
// contains filtered or unexported fields
}
FeedReader detects feed readers (Parser/Client/FeedReader.php).
func NewFeedReader ¶
func NewFeedReader(fsys fs.FS) (*FeedReader, error)
NewFeedReader loads the feed reader database from fsys.
func (FeedReader) Parse ¶
func (p FeedReader) Parse(ua string, _ *parser.ClientHints) (*Result, error)
Parse mirrors AbstractClientParser::parse().
func (FeedReader) SetVersionTruncation ¶
func (p FeedReader) SetVersionTruncation(t int)
SetVersionTruncation sets the version truncation level.
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library detects tools and software libraries (Parser/Client/Library.php).
func NewLibrary ¶
NewLibrary loads the library database from fsys.
func (Library) Parse ¶
func (p Library) Parse(ua string, _ *parser.ClientHints) (*Result, error)
Parse mirrors AbstractClientParser::parse().
func (Library) SetVersionTruncation ¶
func (p Library) SetVersionTruncation(t int)
SetVersionTruncation sets the version truncation level.
type MediaPlayer ¶
type MediaPlayer struct {
// contains filtered or unexported fields
}
MediaPlayer detects media players (Parser/Client/MediaPlayer.php).
func NewMediaPlayer ¶
func NewMediaPlayer(fsys fs.FS) (*MediaPlayer, error)
NewMediaPlayer loads the media player database from fsys.
func (MediaPlayer) Parse ¶
func (p MediaPlayer) Parse(ua string, _ *parser.ClientHints) (*Result, error)
Parse mirrors AbstractClientParser::parse().
func (MediaPlayer) SetVersionTruncation ¶
func (p MediaPlayer) SetVersionTruncation(t int)
SetVersionTruncation sets the version truncation level.
type MobileApp ¶
type MobileApp struct {
// contains filtered or unexported fields
}
MobileApp detects mobile applications (Parser/Client/MobileApp.php), augmenting the user-agent result with the client-hints app id (AppHints).
func NewMobileApp ¶
NewMobileApp loads the mobile app database from fsys.
func (*MobileApp) Parse ¶
Parse mirrors MobileApp::parse: the generic user-agent result refined by the client-hints app id.
func (MobileApp) SetVersionTruncation ¶
func (p MobileApp) SetVersionTruncation(t int)
SetVersionTruncation sets the version truncation level.
type PIM ¶
type PIM struct {
// contains filtered or unexported fields
}
PIM detects personal information managers (Parser/Client/PIM.php).
func (PIM) Parse ¶
func (p PIM) Parse(ua string, _ *parser.ClientHints) (*Result, error)
Parse mirrors AbstractClientParser::parse().
func (PIM) SetVersionTruncation ¶
func (p PIM) SetVersionTruncation(t int)
SetVersionTruncation sets the version truncation level.
type Parser ¶
type Parser interface {
// Parse returns the detected client, or nil,nil when the user agent does
// not match this parser.
Parse(ua string, hints *parser.ClientHints) (*Result, error)
// Name returns the parser name as used in PHP ($parserName).
Name() string
// SetVersionTruncation controls how deep versions are reported. It must be
// called before the parser is used concurrently.
SetVersionTruncation(t int)
// Warm eagerly compiles every regex the parser owns so a broken pattern
// surfaces at construction rather than at first match.
Warm() error
}
Parser is the common interface implemented by every client parser.
type Result ¶
type Result struct {
Type string // "browser", "feed reader", "library", "mediaplayer", "mobile app", "pim"
Name string
Version string
Engine string // browser only
EngineVersion string // browser only
Family string // browser only
ShortName string // browser only (internal short code)
}
Result holds a detected client. Engine, EngineVersion, Family and ShortName are only populated for the browser parser.