getShopifyAnalyticsContext static method

Future<SelfDescribing?> getShopifyAnalyticsContext()

Implementation

static Future<SelfDescribing?> getShopifyAnalyticsContext() async {
  final requestId =
      (await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkRequestIdKey)!)) ?? '';
  final merchantType =
      (await cacheInstance.getValue(cdnConfigInstance.getKeys(StorageKeyKeys.gkMerchantTypeKey)!)) ?? 'shopify';

  // String integrationType = 'CUSTOM';
  // if (['shopify', 'custom_shopify'].contains(merchantType.toLowerCase())) {
  //   integrationType = 'APP_MAKER';
  // }

  final integrationType = cacheInstance
      .getValue(cdnConfigInstance.getKeys(StorageKeyKeys.integrationType)!);

  final schemas = cdnConfigInstance.getSnowplowSchema();
  final shopifyAnalyticsSchema = (schemas is Map<String, String>)
      ? (schemas[SnowplowSchemaKeys.shopifyAnalytics] ??
          'shopifyAnalytics/jsonschema/1-0-3')
      : 'shopifyAnalytics/jsonschema/1-0-3';

  return _createContext(shopifyAnalyticsSchema, {
    'appId': 'kwik_pass',
    'request_id': requestId,
    'session_id': requestId,
    'gk_platform': merchantType,
    'kp_integration_type': integrationType,
  });
}