sendCustomEventToSnowPlow static method
Implementation
static Future<void> sendCustomEventToSnowPlow(
Map<String, dynamic> eventObject) async {
final snowplowTrackingEnabled =
await cacheInstance.getValue(KeyConfig.isSnowplowTrackingEnabled);
if (snowplowTrackingEnabled == 'false') return;
final mid = (await cacheInstance.getValue(KeyConfig.gkMerchantIdKey)) ?? '';
final environment = await _getEnvironment();
final shopDomain =
(await cacheInstance.getValue(KeyConfig.gkMerchantUrlKey)) ?? '';
final snowplow = await SnowplowClient.getSnowplowClient(
InitializeSdkProps(
mid: mid,
environment:
Environment.values.firstWhere((e) => e.name == environment),
shopDomain: shopDomain,
isSnowplowTrackingEnabled: snowplowTrackingEnabled == 'true'),
);
final filteredData = _filterEventValuesAsPerStructSchema(eventObject);
final contexts = (await Future.wait([
getUserContext(),
getDeviceInfoContext(),
])).where((context) => context != null).cast<SelfDescribing>().toList();
await snowplow?.track(
SelfDescribing(
schema:
'iglu:${SdkConfig.getSchemaVendor(environment)}/structured/jsonschema/1-0-0',
data: filteredData,
),
contexts: contexts,
);
}