Skip to content

Instantly share code, notes, and snippets.

@minhchu
Created December 18, 2018 10:32
Show Gist options
  • Save minhchu/3c9f26121f1a67e25ca75d12b50ece6a to your computer and use it in GitHub Desktop.
Save minhchu/3c9f26121f1a67e25ca75d12b50ece6a to your computer and use it in GitHub Desktop.
Mixpanel delete profiles
from mixpanel_api import Mixpanel
if __name__ == '__main__':
# API_Secret and Token of a Beeketing platform project
secret = ''
token = ''
mixpanel = Mixpanel(secret, token, pool_size=4, debug=True)
selector = '(properties["to_delete"] == true)'
parameters = {'selector': selector}
mixpanel.people_delete(query_params=parameters, backup=True)
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;
return [year, month, day].join('-');
}
function addMonths(date, months) {
date.setMonth(date.getMonth() + months);
return date;
}
function main() {
var today = new Date();
return join(
Events({
from_date: formatDate(addMonths(today, -6)),
to_date: formatDate(today)
}),
People()
)
.filter(function(record){
return record.user && !record.event;
})
.map(function(record){
return {
id: record.user.distinct_id,
name: record.user.properties.$name
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment