class Client

Defined at line 22 of file ../../src/lib/analytics/cpp/google_analytics_4/client.h

This is an abstract class for a GA4 client, where the actual HTTP communications are

left unimplemented. This is because to provide non-blocking HTTP communications, we have to rely

on certain async mechanism (such as message loop), which is usually chosen by the embedding app.

To use this class, the embedding app only needs to implement the SendData() method.

Public Methods

void Client (const Client & )

Defined at line 25 of file ../../src/lib/analytics/cpp/google_analytics_4/client.h

void Client (size_t batch_size)

Defined at line 97 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void ~Client ()

Defined at line 104 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void SetQueryParameters (std::string_view measurement_id, std::string_view key)

Set the query parameters needed by the GA4 Measurement Protocol.

We do not escape or validate the parameters. The tool analytics implementer is responsible

for the correctness of the parameters.

Defined at line 106 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void SetClientId (std::string client_id)

Defined at line 110 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void SetUserProperty (std::string name, Value value)

Add user property shared by all metrics.

Defined at line 112 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void AddEvent (std::unique_ptr<Event> event_ptr)

Defined at line 116 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void AddEvents (std::vector<std::unique_ptr<Event>> event_ptrs, size_t batch_size)

Defined at line 151 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void AddEventToDefaultBatch (std::unique_ptr<Event> event_ptr)

Instead of sending an event immediately, add the event to a local

buffer. When the number of events in the buffer reaches the batch

size limit, the client will send all the events in batch and then

clear the buffer.

Defined at line 160 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

void SendDefaultBatch ()

Send all the events in the local buffer/batch, regardless of

the number of events.

Defined at line 164 of file ../../src/lib/analytics/cpp/google_analytics_4/client.cc

Protected Methods

std::string & url ()

Defined at line 53 of file ../../src/lib/analytics/cpp/google_analytics_4/client.h