import { trackEvent } from "./base"

export function trackSortingChangeEvent(sortOption: string) {
  trackEvent({
    event: "sortOptionClick",
    filter: {
      sortOptions: sortOption,
    },
  })
}

export function trackFilterChangeEvent(
  facilityFilters: string[],
  surroundingsFilters: string[]
) {
  const filtersUsed = []
  if (facilityFilters.length) {
    filtersUsed.push(`hotelfacilities:${facilityFilters.join(",")}`)
  }
  if (surroundingsFilters.length) {
    filtersUsed.push(`hotelsurroundings:${surroundingsFilters.join(",")}`)
  }

  trackEvent({
    event: "filterUsed",
    filter: {
      filtersUsed: filtersUsed.join("|"),
    },
  })
}

export function trackOpenSidePeekOnDestinationPagesEvent(location: string) {
  trackEvent({
    event: "trackOpenSidePeekEvent",
    cta: {
      pageName: `explore${location}|sidepeek`,
    },
  })
}

export function trackMapClick(name: string) {
  trackEvent({
    event: "map click",
    map: {
      action: "map click",
      clickedItemName: name,
    },
  })
}

export function trackOpenMapView(pagename: string, pagetype: string) {
  trackEvent({
    event: "openMapView",
    map: {
      pagename,
      pagetype,
    },
  })
}
