Class GoogleAnalytics4Provider
- java.lang.Object
- 
- ubic.gemma.rest.analytics.ga4.GoogleAnalytics4Provider
 
- 
- All Implemented Interfaces:
- DisposableBean,- InitializingBean,- AnalyticsProvider
 
 public class GoogleAnalytics4Provider extends Object implements AnalyticsProvider, InitializingBean, DisposableBean Implementation of theAnalyticsProviderinterface for Google Analytics 4 collect API.General outline: Events are queued and ordered by date. Events that share the same date within a configured time resolution, client ID and user ID are batched together. The time resolution can be configured via setResolutionMillis(long).A task is run regularly to flush pending events regardless of the queue size and can be configured with setPollingIntervalMillis(long).If a full batch can be sent after sendEvent(String, Date, Map)is invoked and no manual flush is currently in-progress, a manual flush is scheduled. This will only flush a single batch of events.When the bean is destroyed, all pending events are flushed. - Author:
- poirigui
 
- 
- 
Constructor SummaryConstructors Constructor Description GoogleAnalytics4Provider(String measurementId, String apiSecret)GoogleAnalytics4Provider(RestTemplate restTemplate, String measurementId, String apiSecret)Create a new Google Analytics 4 provider.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()voiddestroy()voidsendEvent(String eventName, Date date, Map<String,String> params)Publish an event.voidsetClientIdRetrievalStrategy(ClientIdRetrievalStrategy clientIdRetrievalStrategy)Set the strategy used to retrieve client IDs.voidsetDebug(boolean debug)Enable the debug mode.voidsetPollingIntervalMillis(long pollingIntervalMillis)Interval at which events are polled and flushed.voidsetResolutionMillis(long resolutionMillis)Time resolution for regrouping events in the same batch.voidsetUserIdRetrievalStrategy(UserIdRetrievalStrategy userIdRetrievalStrategy)Set the strategy used to retrieve user IDs.- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface ubic.gemma.rest.analytics.AnalyticsProvidersendEvent, sendEvent
 
- 
 
- 
- 
- 
Constructor Detail- 
GoogleAnalytics4Providerpublic GoogleAnalytics4Provider(RestTemplate restTemplate, String measurementId, String apiSecret) Create a new Google Analytics 4 provider.- Parameters:
- restTemplate- a REST template for performing requests with the collect API
- measurementId- a measurement ID which may be empty
- apiSecret- an API secret, must be non-empty if measurementId is supplied
 
 
- 
 - 
Method Detail- 
afterPropertiesSetpublic void afterPropertiesSet() - Specified by:
- afterPropertiesSetin interface- InitializingBean
 
 - 
destroypublic void destroy() throws Exception- Specified by:
- destroyin interface- DisposableBean
- Throws:
- Exception
 
 - 
setClientIdRetrievalStrategypublic void setClientIdRetrievalStrategy(ClientIdRetrievalStrategy clientIdRetrievalStrategy) Set the strategy used to retrieve client IDs.
 - 
setUserIdRetrievalStrategypublic void setUserIdRetrievalStrategy(UserIdRetrievalStrategy userIdRetrievalStrategy) Set the strategy used to retrieve user IDs.
 - 
setDebugpublic void setDebug(boolean debug) Enable the debug mode.When debug mode is enabled, a testing GA4 endpoint will be used and sendEvent(String, Date, Map)may raise exception instead of simply warning.
 - 
setResolutionMillispublic void setResolutionMillis(long resolutionMillis) Time resolution for regrouping events in the same batch.Events with the same client and user IDs are batched together if they are less than the resolution apart and reported at the time the first event in the batch occurred. Setting this to zero effectively disable batching of events unless they occur at exactly the same time. This can be achieved by reusing the Dateobject when sending multiple events.
 - 
setPollingIntervalMillispublic void setPollingIntervalMillis(long pollingIntervalMillis) Interval at which events are polled and flushed.
 - 
sendEventpublic void sendEvent(String eventName, Date date, Map<String,String> params) Description copied from interface:AnalyticsProviderPublish an event.- Specified by:
- sendEventin interface- AnalyticsProvider
- Parameters:
- eventName- a name for the event
- date- an exact moment when the event occurred
- params- additional parameters for the event
 
 
- 
 
-