0
export function useHeapAddEventCaseCode(caseData?: CaseEntity) {
  return useEffect(() => {
    if (caseData?.code) {
      // As a best practice, we recommend calling clearEventProperties before addEventProperties on every page
      window.heap.clearEventProperties() 
      window.heap.addEventProperties({ caseCode: caseData.code })
    }
  }, [caseData])
}

I'm using this effect on React SPA app in some page. Somehow it's only track first value, never see any other value even though I tried other case codes enter image description here heap array in console.log has other caseCode but none of those is sent to heap analysis or not appear enter image description here

Randy Casburn
  • 13,840
  • 1
  • 16
  • 31
Huy Nguyen
  • 520
  • 2
  • 7
  • 20
  • This is likely relevant: "_Note that this API may not work well with Single Page Applications, which have a tendency to change state in a way that impacts the timing of the cookie being sent to the API._" - from [the docs](https://developers.heap.io/reference/addeventproperties) – Randy Casburn Mar 08 '23 at 03:05
  • @RandyCasburn yep I saw that too but it's really weird that after a few days not using the web app, I open it with different case code but it does not track anything new. – Huy Nguyen Mar 08 '23 at 03:11
  • That does seem odd, I'm certain you are clearing the cookies from that host - right? – Randy Casburn Mar 08 '23 at 03:22
  • hmm, does not clear anything. Other thing like addUserProperties, identify work fine. Also on heap dashboard there is many other default events working, unfortunately not this custom stuff – Huy Nguyen Mar 08 '23 at 03:27

0 Answers0