initializeSnowplowClient static method
Implementation
static Future<void> initializeSnowplowClient(InitializeSdkProps args) async {
final environment = args.environment;
final mid = args.mid;
final collectorUrl = SdkConfig.getSnowplowUrl(environment.name);
String appId = mid;
// Initialize Snowplow tracker
_snowplowClient = await Snowplow.createTracker(
namespace: 'appTracker',
endpoint: collectorUrl,
method: Method.get,
trackerConfig: TrackerConfiguration(
appId: appId,
screenEngagementAutotracking: false,
applicationContext: true,
platformContext: true,
geoLocationContext: false,
sessionContext: true,
),
);
// Get or create user ID
_snowplowUserId = await cacheInstance.getStoredSnowplowUserId();
if (_snowplowUserId == null) {
final uuid = _generateUUID();
_snowplowUserId = uuid;
await cacheInstance.setSnowplowUserId(uuid);
}
// Set user ID for tracking
_snowplowClient?.setUserId(_snowplowUserId!);
}