PostHog / posthog-js-lite

Reimplementation of posthog-js to be as light and modular as possible.
https://posthog.com/docs/libraries
MIT License
70 stars 36 forks source link

Delete person with posthog-node #239

Closed hunyan-io closed 5 months ago

hunyan-io commented 5 months ago

Is your feature request related to a problem?

Currently there doesn't seem to be a way to delete a person from posthog other than making a http request to the api https://posthog.com/docs/api/persons#delete-api-projects-project_id-persons-id

Describe the solution you'd like

There should be a method in posthog-node that deletes a person

Describe alternatives you've considered

I'm currently sending a http request manually

Related sub-libraries

Additional context

--

marandaneto commented 5 months ago

@hunyan-io you can also delete the person on the PostHog app https://us.posthog.com/project/{project_id}/persons

what is the use case? why would you need to delete the person directly from the SDK? For frontend SDKs, you can reset after logout, which will delete all the cookies related to the user which means no events will be associated with that user anymore.

hunyan-io commented 5 months ago

@hunyan-io you can also delete the person on the PostHog app https://us.posthog.com/project/{project_id}/persons

what is the use case? why would you need to delete the person directly from the SDK? For frontend SDKs, you can reset after logout, which will delete all the cookies related to the user which means no events will be associated with that user anymore.

@marandaneto Sometimes users request their data to be deleted, this includes deleting their data from the database and any third party services like PostHog. I have an admin dashboard where I can check these requests and apply them. It's possible for me to do everything manually, but ideally I'd like to do this automatically, i.e. handle all deletion logic in one piece of code.

If I understand correctly, using the api is the correct way of deleting user data in PostHog (through code). I was thinking there would be a method in posthog-node that does this (communicating with the api). Isn't posthog-node supposed to be kind of an admin sdk? In that case, I think it makes perfect sense for this method to be available.

Frontend SDKs aren't relevant here. I need a way for the admin to delete the data of a specific user through code.

marandaneto commented 5 months ago

I understand the use case now, but posthog-node is meant to capture events, feature flags, etc, but not an admin SDK responsible for creating orgs, projects, deleting persons, etc. When you capture an event and the person does not exist, indeed it's created automatically so I understand if you also want to have the ability to delete it but we don't have this feature in the SDKs so you have to call the API directly, for now. I'll tag it as a feature request though, thanks for the feedback.

marandaneto commented 5 months ago

hey @hunyan-io I've talked about this internally and it's not in the SDKs due to security concerns since anyone could misuse this feature to delete all of your data by just reusing your apiKey and so on. The API though requires authentication so it's safer and this is the way to go.