/*
 * @Author: Nian Yi
 * @Date: 2022-05-13 16:01:30
 * @LastEditTime: 2022-05-19 15:48:44
 * @LastEditors: Nian Yi
 * @Description: 埋点相关
 * @FilePath: /easyvadmin/src/scripts/models/event-tracking.ts
 * 奥利给
 */
import { collectData } from 'utils/utils';

export function eventTracking<T = any>(data: T) {
  return async (dispatch, getState) => {
    const { user } = getState();
    const { userInfo = {} } = user;
    const { tenantId, userName, edition = {} } = userInfo;
    if (!window.appConfig.LOCAL) {
      let common = {};
      if (tenantId && edition?.id) {
        common = {
          tenantId,
          userName,
          version: edition.id,
        };
      }
      collectData({
        ...data,
        ...common,
      });
    }
  };
}
