createTracker static method

Future<SnowplowTracker> createTracker({
  1. required String namespace,
  2. required String endpoint,
  3. Method? method,
  4. String? customPostPath,
  5. Map<String, String>? requestHeaders,
  6. TrackerConfiguration? trackerConfig,
  7. SubjectConfiguration? subjectConfig,
  8. GdprConfiguration? gdprConfig,
  9. EmitterConfiguration? emitterConfig,
})

Creates a new tracker instance with the given unique namespace.

endpoint refers to the Snowplow collector endpoint. method is the HTTP method used to send events to collector and it defaults to POST. customPostPath is an optional string for custom POST collector paths. requestHeaders is an optional map of custom HTTP headers to add to requests to the collector.

Implementation

static Future<SnowplowTracker> createTracker(
    {required String namespace,
    required String endpoint,
    Method? method,
    String? customPostPath,
    Map<String, String>? requestHeaders,
    TrackerConfiguration? trackerConfig,
    SubjectConfiguration? subjectConfig,
    GdprConfiguration? gdprConfig,
    EmitterConfiguration? emitterConfig}) async {
  final configuration = Configuration(
      namespace: namespace,
      networkConfig: NetworkConfiguration(
          endpoint: endpoint,
          method: method,
          customPostPath: customPostPath,
          requestHeaders: requestHeaders),
      trackerConfig: trackerConfig,
      subjectConfig: subjectConfig,
      gdprConfig: gdprConfig,
      emitterConfig: emitterConfig);
  await _channel.invokeMethod('createTracker', configuration.toMap());
  return SnowplowTracker(configuration: configuration);
}