sendCustomEventToSnowPlow static method
Implementation
static Future<void> sendCustomEventToSnowPlow(
Map<String, dynamic> eventObject) async {
final snowplowTrackingEnabled =
await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.isSnowplowTrackingEnabled)!);
if (snowplowTrackingEnabled == 'false') return;
final mid = (await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkMerchantIdKey)!)) ?? '';
final environment = await _getEnvironment();
final shopDomain =
(await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.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();
final schemas = cdnConfigInstance.getSnowplowSchema();
final structuredSchema = (schemas is Map<String, String>)
? (schemas['structured'] ?? 'structured/jsonschema/1-0-0')
: 'structured/jsonschema/1-0-0';
await snowplow?.track(
SelfDescribing(
schema:
'iglu:${SdkConfig.getSchemaVendor(environment)}/$structuredSchema',
data: filteredData,
),
contexts: contexts,
);
}