Skip to main content

Emitter

Using Snowplow.Tracker (.NET Standard) or Snowplow.Tracker.PlatformExtensions (PCL)โ€‹

The Emitter object is responsible for sending and storing all events.

We have one emitter available currently:

  • AsyncEmitterย : Fully asynchronous operation which uses threads to perform all of its operations.

The Emitter depends on four other objects being built:

  • IEndpoint
  • IStorage
  • IPersistentBlockingQueue
  • IPayloadToString

Emitter Constructorโ€‹

Using Snowplow.Tracker (.NET Standard) or Snowplow.Tracker.PlatformExtensions (PCL)โ€‹

Argument NameDescriptionRequired?Default
endpointThe endpoint object configured for sending eventsYesNull
queueThe queue to be used to push and pop events fromYesNull
sendLimitThe amount of events to get from the queue at a timeNo100
stopPollIntervalMsThe amount of time to wait before checking for more eventsNo300
sendSuccessMethodAn optional callback function which will report event success and failure countsNoNull
deviceOnlineMethodAn optional delegate function which will be used to check if the device is onlineNoNull
loggerThe logger to use within the applicationNoNull

A full Emitter construction should look like the following:

var endpoint = new SnowplowHttpCollectorEndpoint(emitterUri, method: method, port: port, protocol: protocol, l: logger);
var storage = new LiteDBStorage("events.db");
var queue = new PersistentBlockingQueue(storage, new PayloadToJsonString());

AsyncEmitter emitter = new AsyncEmitter(endpoint, queue, l: logger);

NOTE: The send limit can impact performance greatly as it determines how often we need to perform I/O to the disk and how big the POSTed event batches can be.

WARNING: If you are sending events via GET note that each event is sent as its own task, so this has the potential to launch 100 outbound tasks in parallel. It is recommended to lower this range if using GET to 10-15 as a maximum.

Endpoint Constructorโ€‹

Using Snowplow.Tracker (.NET Standard) or Snowplow.Tracker.PlatformExtensions (PCL)โ€‹

This is a container for information about how to reach your collector.

Argument NameDescriptionRequired?Default
hostThe collector uri to send events toYesNull
protocolThe protocol to use when sending events (HTTP / HTTPs)NoHttpProtocol.HTTP
portIf the collector is not on port 80NoNull
methodThe method to use when sending (GET / POST)NoHttpMethod.GET
postMethodCustom method for sending events via POSTNoNull
getMethodCustom method for sending events via GETNoNull
byteLimitPostMaximum byte limit when sending a POST requestNo40000
byteLimitGetMaximum byte limit when sending a GET requestNo40000
loggerThe logger to use within the applicationNoNull

We have one endpoint available currently:

  • SnowplowHttpCollectorEndpoint

A full Endpoint construction should look like the following:

SnowplowHttpCollectorEndpoint endpoint = new SnowplowHttpCollectorEndpoint("com.acme-collector", protocol: HttpProtocol.HTTPS, method: HttpMethod.GET, l: logger);

NOTE: If any individual event exceeds the byte limits set then this event will be sent - but it will be assumed to have succeeded. This is to prevent constanstly attempting to send overly large events.

Storage Constructorโ€‹

Using Snowplow.Tracker (.NET Standard) or Snowplow.Tracker.PlatformExtensions (PCL)โ€‹

Argument NameDescriptionRequired?Default
pathThe file path to store the database file atYesNull

We have one storage target available currently:

  • LiteDBStorage

A full Storage construction should look like the following:

LiteDBStorage storage = new LiteDBStorage("events.db");

NOTE: When using the Tracker within Xamarin you will need to fetch a correct path for internal storage. Some example code for fetching this path:

// Android
public string GetLocalFilePath(string filename)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
return Path.Combine(path, filename);
}

// iOS
public string GetLocalFilePath(string filename)
{
string docFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string libFolder = Path.Combine(docFolder, "..", "Library", "Databases");

if (!Directory.Exists(libFolder))
{
Directory.CreateDirectory(libFolder);
}

return Path.Combine(libFolder, filename);
}

Queue Constructorโ€‹

Using Snowplow.Tracker (.NET Standard) or Snowplow.Tracker.PlatformExtensions (PCL)โ€‹

Argument NameDescriptionRequired?Default
storageThe storage object to use with the queueYesNull
payloadToStringSerializer for Payload objectsYesNull

We have one queue available currently:

  • PersistentBlockingQueue

A full queue construction should look like the following:

PersistentBlockingQueue queue = new PersistentBlockingQueue(storage, new PayloadToJsonString());

Payload Serializer Constructorโ€‹

Using Snowplow.Tracker (.NET Standard) or Snowplow.Tracker.PlatformExtensions (PCL)โ€‹

We have one payload serializer available currently:

  • PayloadToJsonString

A full queue construction should look like the following:

PayloadToJsonString serializer = new PayloadToJsonString();

This controls how we queue information for internal use.

Was this page helpful?