mountainash / posthog-managed-component

A Managed Component for sending events to PostHog
Other
11 stars 2 forks source link

change to name #11

Closed agcty closed 1 day ago

agcty commented 4 months ago

First of all, thanks for taking time to create this managed component! Very valuable work.

Current behaviour Currently, when you track an event, the name that shows up in the posthog dashboard will always be "event" which doesn't make sense.

image

Expected behaviour Instead of the type that is now used as the event name, the actual event name should be used as described in the docs: https://posthog.com/tutorials/api-capture-events

Then you'll also be able to see the correct event name in the ph dashboard:

image

Shortcomings of this PR

1 test case currently fails but it's too complex for me right now to dig into.

mountainash commented 4 months ago

Thanks for the contribution @agcty (you are the first!). I'm away for a week; I'll take a look soon and merge if ok. Thank you; free l feel free to add some more 🙏

mountainash commented 4 months ago

@agcty I've looked into this and I've made some changes to handle the vagueness of the WebMC event and how Zaraz is currently sending the payload.

  1. the called "MCEvent" from the WebMC has the following keys - so name is not always there
    type: 'track',
    defaultPrevented: false,
    cancelable: false,
    timeStamp: 483.952333
    }
  2. The PostHog "EVENT" column for the "Activities" table lists event types. "Page View" is an event type (but it could also be the event name...)? 🤷🏼

I've made some changes to your suggested code to allow it to handle both.

mountainash commented 1 day ago

Done in ef6a8ebe99f77d6b5bb7436feeb0c8e4c31b4769 (as I don't have edit rights on this PR).