mixpanel / mixpanel-utils

Other
85 stars 62 forks source link

Final event in export_events removed #7

Closed kathmath closed 6 years ago

kathmath commented 6 years ago

It appears the final event in an exported range is removed when export_events is used. For example, if I run the following in the module:

from mixpanel_api import Mixpanel
  if __name__ == '__main__':

    m = Mixpanel('api_secret','token')

    m.export_events('api_module_export_ricky.txt',{'from_date':'2017-12-01','to_date':'2017-12-01', 'event':'["App Install"]'})

I'll get one fewer events than the corresponding curl request:

curl https://data.mixpanel.com/api/2.0/export/ -u api_secret: -d from_date="2017-12-01" -d to_date="2017-12-01" -d event='["App Install"]'

Also get same count as curl using module with query_jql instead: from mixpanel_api import Mixpanel

if __name__ == '__main__':

    m = Mixpanel('api_secret','token')

       jql_script = '''
            function main() {
              return Events({
                from_date: '2017-12-01',
                to_date:   '2017-12-01',
                event_selectors: [
                    {event: 'App Install'}
                ]
              })
            }
        '''

    res = m.query_jql(jql_script)
    m.export_data(res, 'jql_export.txt')

Similarly, if I curl (or query /jql) for all events that day and then compare that result to the corresponding module export, the events counts (by name) match up except for the final event in the curl request.

I think this is related to: https://github.com/mixpanel/mixpanel_api/blob/master/__init__.py#L747

jaredmixpanel commented 6 years ago

Nice find @kathmath. Raw exports used to include a newline at the very end, probably changed when we switched to the new /export servers. I've removed the pop() call, we'll get this update pushed to pip asap.

kathmath commented 6 years ago

thanks @jaredmixpanel 👍