# Mixpanel Tasks


This module contains a collection of tasks to interact with Mixpanel APIs.

# MixpanelExportTask

class

prefect.tasks.mixpanel.mixpanel_tasks.MixpanelExportTask

(api_secret=None, api_secret_env_var=None, from_date="2011-07-10", to_date="2022-09-07", limit=None, event=None, where=None, parse_response=False, use_eu_server=False, group_events=False, **kwargs)[source]

Task for performing an export using the Mixpanel Export API. More info about the API can be found at https://developer.mixpanel.com/reference/raw-event-export.

Args:

  • api_secret (str, optional): The API secret key to use to authenticate to Mixpanel. Can be provided also via env var.
  • api_secret_env_var (str, optional): The name of the env var that contains the API secret key to use to authenticate to Mixpanel. api_secret takes precedence over api_secret_env_var.
  • from_date (str, optional): Start date of the export request. If provided as a string, it should be in the format YYYY-MM-DD. Default value is 2011-07-10. This date is inclusive.
  • to_date (str, optional): End date of the export request. If provided as a string, it should be in the format YYYY-MM-DD. Default value is prefect.context.today. This date is inclusive.
  • limit (int, optional): The max number of events to return.
  • event (str, list, optional): The event, or events, that you wish to get the data for.
  • where (str, optional): An expression to filter events by. More info on expression sequence structure can be found at https://developer.mixpanel.com/reference/segmentation-expressions.
  • parse_response (bool, optional): Whether to parse the response into a JSON object. Default value is False.
  • use_eu_server (bool, optional): Whether to use the Mixpanel EU server to retrieve data. More info at https://help.mixpanel.com/hc/en-us/articles/360039135652-Data-Residency-in-EU. Default is False.
  • group_events: Whether to group events with the same name. This is taken into account only if parse_response is True.
  • **kwargs (dict, optional): Additional keyword arguments to pass to the Task constructor.

methods:                                                                                                                                                       

prefect.tasks.mixpanel.mixpanel_tasks.MixpanelExportTask.run

(api_secret=None, api_secret_env_var=None, from_date=None, to_date=None, limit=None, event=None, where=None, parse_response=False, use_eu_server=False, group_events=False)[source]

Task run method to request a data export from Mixpanel using the Export API.

Args:

  • api_secret (str, optional): The API secret key to use to authenticate to Mixpanel. Can be provided also via env var.
  • api_secret_env_var (str, optional): The name of the env var that contains the API secret key to use to authenticate to Mixpanel. api_secret takes precedence over api_secret_env_var.
  • from_date (str, optional): Start date of the export request. If provided as a string, it should be in the format YYYY-MM-DD. Default value is 2011-07-10. This date is inclusive.
  • to_date (str, optional): End date of the export request. If provided as a string, it should be in the format YYYY-MM-DD. Default value is prefect.context.today. This date is inclusive.
  • limit (int, optional): The max number of events to return.
  • event (str, list, optional): The event, or events, that you wish to get the data for.
  • where (str, optional): An expression to filter events by. More info on expression sequence structure can be found at https://developer.mixpanel.com/reference/segmentation-expressions.
  • parse_response (bool, optional): Whether to parse the response into a JSON object. Default value is False.
  • use_eu_server (bool, optional): Whether to use the Mixpanel EU server to retrieve data. More info at https://help.mixpanel.com/hc/en-us/articles/360039135652-Data-Residency-in-EU. Default is False.
  • group_events: Whether to group events with the same name. This is taken into account only if parse_response is True.
Returns:
  • if parse_response is False, then returns a str response pulled from the Export API, (which is basically a JSONL string). - if parse_response is True and group_events is True, then returns a dict where each key contains homogeneous events. - if parse_response is True and group_events is False, then returns a list of JSON objects obtained by parsing the response.
Raises:
  • ValueError if both api_secret and api_secret_env_var are missing. - ValueError if api_secret is missing and api_secret_env_var is not found. - prefect.engine.signals.FAIL if the Mixpanel API returns an error.



This documentation was auto-generated from commit e6bd04a
on September 7, 2022 at 21:06 UTC