github.com/prebid/prebid-server@v0.275.0/analytics/config/config.go (about) 1 package config 2 3 import ( 4 "github.com/benbjohnson/clock" 5 "github.com/golang/glog" 6 "github.com/prebid/prebid-server/analytics" 7 "github.com/prebid/prebid-server/analytics/clients" 8 "github.com/prebid/prebid-server/analytics/filesystem" 9 "github.com/prebid/prebid-server/analytics/pubstack" 10 "github.com/prebid/prebid-server/config" 11 ) 12 13 // Modules that need to be logged to need to be initialized here 14 func NewPBSAnalytics(analytics *config.Analytics) analytics.PBSAnalyticsModule { 15 modules := make(enabledAnalytics, 0) 16 if len(analytics.File.Filename) > 0 { 17 if mod, err := filesystem.NewFileLogger(analytics.File.Filename); err == nil { 18 modules = append(modules, mod) 19 } else { 20 glog.Fatalf("Could not initialize FileLogger for file %v :%v", analytics.File.Filename, err) 21 } 22 } 23 24 if analytics.Pubstack.Enabled { 25 pubstackModule, err := pubstack.NewModule( 26 clients.GetDefaultHttpInstance(), 27 analytics.Pubstack.ScopeId, 28 analytics.Pubstack.IntakeUrl, 29 analytics.Pubstack.ConfRefresh, 30 analytics.Pubstack.Buffers.EventCount, 31 analytics.Pubstack.Buffers.BufferSize, 32 analytics.Pubstack.Buffers.Timeout, 33 clock.New()) 34 if err == nil { 35 modules = append(modules, pubstackModule) 36 } else { 37 glog.Errorf("Could not initialize PubstackModule: %v", err) 38 } 39 } 40 return modules 41 } 42 43 // Collection of all the correctly configured analytics modules - implements the PBSAnalyticsModule interface 44 type enabledAnalytics []analytics.PBSAnalyticsModule 45 46 func (ea enabledAnalytics) LogAuctionObject(ao *analytics.AuctionObject) { 47 for _, module := range ea { 48 module.LogAuctionObject(ao) 49 } 50 } 51 52 func (ea enabledAnalytics) LogVideoObject(vo *analytics.VideoObject) { 53 for _, module := range ea { 54 module.LogVideoObject(vo) 55 } 56 } 57 58 func (ea enabledAnalytics) LogCookieSyncObject(cso *analytics.CookieSyncObject) { 59 for _, module := range ea { 60 module.LogCookieSyncObject(cso) 61 } 62 } 63 64 func (ea enabledAnalytics) LogSetUIDObject(so *analytics.SetUIDObject) { 65 for _, module := range ea { 66 module.LogSetUIDObject(so) 67 } 68 } 69 70 func (ea enabledAnalytics) LogAmpObject(ao *analytics.AmpObject) { 71 for _, module := range ea { 72 module.LogAmpObject(ao) 73 } 74 } 75 76 func (ea enabledAnalytics) LogNotificationEventObject(ne *analytics.NotificationEvent) { 77 for _, module := range ea { 78 module.LogNotificationEventObject(ne) 79 } 80 }