mixpanel / mixpanel-utils

Other
87 stars 63 forks source link

delete_people method not working #21

Closed ciacicode closed 3 years ago

ciacicode commented 5 years ago

I just tried to use the delete_people method to no avail.

from mixpanel_api import Mixpanel
mixpanel = Mixpanel('mysecret','mytoken')

mixpanel.people_delete(query_params={ 'selector' : '(("olddomain.com" in properties["$email"]) and (defined (properties["$email"])))'})

The backup file is correctly generated, and there is the right number of profiles in it, yet when I go to mixpanel UI and try to do the same query to see if the profiles were actually deleted, I get the same count. The script runs fine with no errors.

LaithAmmouri commented 5 years ago

same here

anisha-rohra commented 5 years ago

Having the same problem

LaithAmmouri commented 5 years ago

@anisha-rohra @ciacicode Actually we contancted Mixpanel guys, and they said there are some changes in their api, here is the solution: (Fixed it today at my company's Mixpanel profile)

from mixpanel_api import Mixpanel

api_secret = 'MIXPANEL_API_SECRET'
project_token = 'MIXPANEL_PROJECT_TOKEN'

mixpanel = Mixpanel(api_secret,token=project_token, debug=True)

filter_by_cohort = 'TO_BE_FILLED_FROM_THE_XHR_REQUEST_VALUE'

mixpanel.people_delete(query_params={'filter_by_cohort' : filter_by_cohort})

What is happening that they changed their selector, so now you have to identify the data that you wanna delete by using filter_by_cohort param value from Mixpanel.

To get filter_by_cohort: 1- Go to Mixpanel Users->explore tab. 2- While opening the chrome inspector, keep an eye on the XHR requests in the network tab, and edit your searching filters (In my case I wanted to search the users that do not have email address and the app notification is turned off as the attached image). 3- In the engage request go to the headers and scroll down till you see filter_by_cohort, get its value and replace it in the above code, and it will work.

Screen Shot 2019-10-29 at 5 26 02 PM
anisha-rohra commented 5 years ago

Thanks for the help! The debug messages make it seem like this worked as expected, but on mixpanel itself the profiles still appear - I wonder if this is just a time issue, does it take a few minutes before the operation goes through?

LaithAmmouri commented 5 years ago

You are welcome! Yup, it should take time, logically the results should be cached in the platform. Please let me know if the users are not deleted to dig more in the case.

Cheers

anisha-rohra commented 5 years ago

Been a day and sadly nothing - the debug messages made it appear that all had been successful but I guess they were inaccurate.

LaithAmmouri commented 5 years ago

@anisha-rohra may i know what do you wanna delete? and sent me your filter_by_cohort param value pelase

jaredmixpanel commented 3 years ago

It does take time on the backend for the $delete operations to be processed. As long as you're getting successful API responses the python code for this module is not likely to be the problem. If the issue persists however and you're confident the problem is the python code making the API calls, please re-open the issue with further detail.