Skip to content

v0.2.3

Choose a tag to compare

@jaredmixpanel jaredmixpanel released this 14 Sep 20:00
07bfe57

Patch release: report links (create, resolve, and run a Mixpanel report URL from headless params), MP_API_BASE_URL single-host routing, a limit= parameter plus run_*_params on the query methods, Filter operator validation on direct construction, a CLI exit-code change for BookmarkValidationError, and the plugin manifest catches up to the library version.

Added

  • MP_API_BASE_URL — route every API family at one alternate host. When set (trailing slash tolerated; read per request, not at import), the per-region ENDPOINTS lookup is bypassed and the four families resolve to path prefixes on that single base: query → {base}/api/query, export → {base}/api/2.0, engage → {base}/api/query/engage, app → {base}/api/app. The mp CLI inherits it with no flag. App-vs-Query timeout selection and pinned workspace_id injection key off the family, so they behave identically under the override. mp login's region probe collapses to one probe at the base (region label from MP_REGION when valid, else us). Plain http:// bases are accepted and intended for local / headless deployments only. MP_REGION remains required and meaningful for non-URL uses. Optional MP_APP_BASE_URL re-homes only the App API family at {app_base}/api/app. With both unset, behaviour is byte-identical to before. (#235)
  • limit= on the query methods, plus run_*_params. query(), query_funnel(), and query_retention() accept limit= (1 to 50000, default 3000) to raise the segment cap for high-cardinality breakdowns; check result.meta["is_segmentation_limit_hit"] to see whether the result was still truncated. New run_params(), run_funnel_params(), run_retention_params(), run_flow_params(), and run_user_params() execute a params dict that the matching build_*_params() produced (or one written by hand) and return the same result type as the typed query method, so params the typed builder cannot express can still run. (#225)
  • Report links (045, AIE-561 / AIE-562, #223). Share a headless query as a Mixpanel report URL and resolve a report URL back into runnable params.
    • Workspace.create_report_link(params_or_result, *, report_type=, name=, description=, workspace_id=, bookmark_id=, validate=) stores an unsaved report under a 12-character slug and returns a ReportLink.
    • Workspace.resolve_report_link(link) accepts a full URL, a bare slug, or a https://mixpanel.com/s/{code} shortlink and returns a ResolvedReport with the raw params. A region mismatch fails before any HTTP call; project and pinned-workspace mismatches fail before the record fetch.
    • Workspace.query_report_link(link_or_resolved, *, mode=) runs the params through query / query_funnel / query_retention / query_flow, under exactly the scope the report records (the URL wid, else the pin at resolve time, else project-wide); the current pin is never injected, so a pin cleared or set after resolve time cannot change the data view. A ResolvedReport whose recorded region or project differs from the active session, or whose recorded workspace differs from the pinned session workspace, is rejected before any query. The four LiveQueryService inline methods and MixpanelAPIClient.insights_query / arb_funnels_query accept an optional workspace_id that wins over the pin, and inject_workspace_id=False to run project-wide.
    • Workspace.saved_report_link(bookmark_id, *, report_type=, workspace_id=) builds a saved-report URL with no network call.
    • CLI: mp reports link and mp reports resolve [--run] [--mode], plus an opt-in --link flag on mp query segmentation, funnel, saved-report, and flows that adds report_url to the output. A link failure never fails the query: report_url is null and report_url_error holds the reason.
    • Types: ReportLinkType, BookmarkUrl, ReportLink, ResolvedReport, ReportLinkQueryResult.
    • Exceptions: ReportLinkError and its subclasses ReportLinkParseError, UnsupportedReportLinkError, ReportLinkNotFoundError, ReportLinkScopeMismatchError, ShortLinkResolutionError; every instance carries a hint in details. Builder and input guard codes RL1_UNKNOWN_REPORT_TYPE, RL2_INVALID_SLUG, RL3_UNKNOWN_REGION, RL4_REPORT_TYPE_CONFLICT, RL5_RESOLVED_REPORT_INCONSISTENT, RL6_INVALID_ID (raised as ParamValidationError).
    • CLI exit codes: ReportLinkNotFoundError → 4; ReportLinkParseError, UnsupportedReportLinkError, and ReportLinkScopeMismatchError → 3; ShortLinkResolutionError → 1. The CLI prints details["hint"] on a hint: line for all of them.

Changed

  • BookmarkValidationError now exits the CLI with code 3, not 1. The class is raised by about 15 pre-existing commands (mp reports create, mp reports update, the dashboard verbs, and others) when params fail the client-side schema check. handle_errors now prints error: params failed schema validation plus one line per severity="error" item and exits with INVALID_ARGS (3). Scripts that test for exit code 1 on those commands must be updated. (#223)
  • Plugin: the manifest version is now 0.2.3, in step with the library. It stayed at 0.2.1 through the 0.2.2 release.

Fixed

  • Filter(...) built positionally no longer serializes an unvalidated operator. Filter("gold", "greater_than", 10, "number") used to emit "filterOperator": "greater_than" verbatim and fail server-side with HTTP 400 (Unsupported operator for filter_type number). Filter.__post_init__ now validates _operator against the FilterOperator literal and raises ValueError immediately — naming the bad operator, listing the valid wire operators, and pointing at the factory methods — instead of surfacing a generic QueryError one HTTP round trip later. The factory-method spellings are accepted as aliases and normalized to the wire operator ("greater_than" → "is greater than", "is_set" → "is set", "not_between" → "not between", "in_the_last" → "was in the", and so on for every public Filter classmethod), so the positional call now produces byte-identical output to the equivalent factory. The two segmentation-where spellings that pre-date the literal, "is equal to" and "between", stay constructible as aliases of "equals" and "is between" (same == / >< segfilter output). On a boolean property, equals / does not equal with a True / False value collapse to true / false with filterValue: null, matching Filter.is_true() / Filter.is_false(); any other operator on a boolean property is rejected, and true / false (however spelled) reject any non-None value. A boolean InlineCustomProperty is governed by the same rules (the inline type wins, as in build_filter_entry). Non-string operators raise the same ValueError rather than TypeError. The _operator field is typed as the new FilterOperatorInput literal (wire operators plus aliases) so the positional call type-checks; the stored value is always canonical. Already-valid input is never rewritten. The Filter docstring no longer claims the class is "never instantiated directly". (#236)

Documentation

  • FrequencyFilter now documents that the query engine evaluates its threshold per query time bucket (unit), not over the whole report date range. With the default unit="day", FrequencyFilter("Login", value=5) keeps only users who logged in 5+ times on a single day and returns an empty series when nobody does, even if thousands did so across the month; choose the unit that matches the threshold period ("month" for "N times in a month"). The Workspace.query(where=...) docstring, the query guide, and the mixpanelyst skill carry the same warning. The date_range_value / date_range_unit parameters are documented as having no observable effect on inline insights filters in a 2026-09-11 probe (unverified against platform fixtures); they are unchanged on the wire. (#234)
  • Plugin: dead reference links in the setup skill are fixed. (#230)

Full Changelog: v0.2.2...v0.2.3