import Taro from '@tarojs/taro'
import { GET_SHARE_API } from '@/constants/api'
import { fetch } from '@/utils/request'
import track from './track'

export default (options) => {
  // const page = Taro.getStorageSync('page')
  // if (!page) return;

  const { propertyName, eventType } = options

  // 保存分享表
  const url = GET_SHARE_API(eventType) + '/' + options.targetId
  fetch({ url, method: 'POST', showToast: false }).catch((err) => console.error(err))

  track({
    event: 'share',
    eventType,
    propertyName,
    data: '{}',
    ...options,
  })
}
