1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
Casey Primozic d5e06fe0c2
Add support for pulling realtime Google Analytics metrics
* Add config option `enableRealtime` that, if set to true, will cause realtime metrics to be displayed above the historicaly view counts for all view IDs
 * Add in the v3 Google API client and construct a service for it conditionally if realtime metrics are enabled
 * Update google analytics data pulling code to retrieve realtime metrics using the v3 client if realtime metrics are enabled in settings
 * Update table generation code to display fetched realtime metrics if they are available
2019-08-30 18:34:31 -07:00

32 lines
844 B
Go

package googleanalytics
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
const defaultTitle = "Google Analytics"
type Settings struct {
common *cfg.Common
months int
secretFile string `help:"Your Google client secret JSON file." values:"A string representing a file path to the JSON secret file."`
viewIds map[string]interface{}
enableRealtime bool
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
months: ymlConfig.UInt("months"),
secretFile: ymlConfig.UString("secretFile"),
viewIds: ymlConfig.UMap("viewIds"),
enableRealtime: ymlConfig.UBool("enableRealtime", false),
}
return &settings
}