snowplowStructuredEvent static method
Future<void>
snowplowStructuredEvent(
- dynamic args
)
Implementation
static Future<void> snowplowStructuredEvent(dynamic args) async {
try {
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'),
);
await snowplow?.track(
SelfDescribing(
schema:
'iglu:com.snowplowanalytics.snowplow/structured_event/jsonschema/1-0-0',
data: {
'category': args['category'],
'action': args['action'],
'label': args['label'],
'property': args['property'],
'value': args['value'],
},
),
);
} catch (error) {
rethrow;
}
}