makea-cli 0.2.8__py3-none-any.whl → 0.2.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- makea_cli/__init__.py +1 -1
- makea_cli/commands/analytics/cmd.py +7 -11
- makea_cli/config.py +3 -2
- makea_cli/posthog_client.py +12 -23
- {makea_cli-0.2.8.dist-info → makea_cli-0.2.9.dist-info}/METADATA +6 -6
- {makea_cli-0.2.8.dist-info → makea_cli-0.2.9.dist-info}/RECORD +8 -8
- {makea_cli-0.2.8.dist-info → makea_cli-0.2.9.dist-info}/WHEEL +0 -0
- {makea_cli-0.2.8.dist-info → makea_cli-0.2.9.dist-info}/entry_points.txt +0 -0
makea_cli/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.9"
|
|
@@ -4,7 +4,8 @@ Behavioural metrics (feature usage, clicks, page/feature time, active users)
|
|
|
4
4
|
backed by PostHog HogQL. Distinct from the `metrics` group, which reads the
|
|
5
5
|
Makea backend for financial figures.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Goes through the Makea backend by default (admin login is enough); a local
|
|
8
|
+
POSTHOG_API_KEY + POSTHOG_PROJECT_ID switches to querying PostHog directly.
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
from __future__ import annotations
|
|
@@ -32,8 +33,7 @@ def register(app: typer.Typer) -> None:
|
|
|
32
33
|
"get",
|
|
33
34
|
"feature-usage",
|
|
34
35
|
legacy="analytics-feature-usage",
|
|
35
|
-
api="
|
|
36
|
-
external="posthog",
|
|
36
|
+
api="POST /admin/analytics/query",
|
|
37
37
|
help=(
|
|
38
38
|
"How many distinct users used a feature recently, plus event volume. "
|
|
39
39
|
"Matches $pageview path and feature_time_spent events. "
|
|
@@ -82,8 +82,7 @@ def register(app: typer.Typer) -> None:
|
|
|
82
82
|
"get",
|
|
83
83
|
"top-features",
|
|
84
84
|
legacy="analytics-top-features",
|
|
85
|
-
api="
|
|
86
|
-
external="posthog",
|
|
85
|
+
api="POST /admin/analytics/query",
|
|
87
86
|
help=(
|
|
88
87
|
"Rank pageview paths by distinct users over the last N days — a quick "
|
|
89
88
|
"map of which features get used most."
|
|
@@ -118,8 +117,7 @@ def register(app: typer.Typer) -> None:
|
|
|
118
117
|
"get",
|
|
119
118
|
"top-clicks",
|
|
120
119
|
legacy="analytics-top-clicks",
|
|
121
|
-
api="
|
|
122
|
-
external="posthog",
|
|
120
|
+
api="POST /admin/analytics/query",
|
|
123
121
|
help=(
|
|
124
122
|
"Rank autocaptured click targets by count over the last N days — "
|
|
125
123
|
"which buttons/elements get clicked most."
|
|
@@ -156,8 +154,7 @@ def register(app: typer.Typer) -> None:
|
|
|
156
154
|
"get",
|
|
157
155
|
"active-users",
|
|
158
156
|
legacy="analytics-active-users",
|
|
159
|
-
api="
|
|
160
|
-
external="posthog",
|
|
157
|
+
api="POST /admin/analytics/query",
|
|
161
158
|
help="Distinct active users per day over the last N days (DAU series).",
|
|
162
159
|
)
|
|
163
160
|
def active_users(
|
|
@@ -184,8 +181,7 @@ def register(app: typer.Typer) -> None:
|
|
|
184
181
|
"get",
|
|
185
182
|
"analytics-query",
|
|
186
183
|
legacy="analytics-query",
|
|
187
|
-
api="
|
|
188
|
-
external="posthog",
|
|
184
|
+
api="POST /admin/analytics/query",
|
|
189
185
|
help=(
|
|
190
186
|
"Run an arbitrary HogQL query (escape hatch). "
|
|
191
187
|
'Example: analytics-query "SELECT count() FROM events"'
|
makea_cli/config.py
CHANGED
|
@@ -48,8 +48,9 @@ def redirect_uri() -> str:
|
|
|
48
48
|
|
|
49
49
|
# PostHog product-analytics (behavioural metrics: clicks, page/feature time,
|
|
50
50
|
# funnels, retention). Distinct from the financial `metrics` command group,
|
|
51
|
-
# which reads the Makea backend.
|
|
52
|
-
#
|
|
51
|
+
# which reads the Makea backend. Optional: without these the analytics commands
|
|
52
|
+
# go through the backend's /admin/analytics/query, which holds the key. Set them
|
|
53
|
+
# only to query PostHog directly:
|
|
53
54
|
# POSTHOG_API_KEY personal API key (phx_...), read-only is enough
|
|
54
55
|
# POSTHOG_PROJECT_ID numeric project id
|
|
55
56
|
# POSTHOG_HOST defaults to the EU cloud query host
|
makea_cli/posthog_client.py
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"""Minimal PostHog query client (HogQL over the Query API).
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
own auth (a personal API key from env) rather than the Cognito token used by
|
|
5
|
-
api_client.
|
|
3
|
+
Two routes to the same query:
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
- By default it goes through the Makea backend (POST /admin/analytics/query),
|
|
6
|
+
which holds the PostHog key. An admin's `makea-cli login` is all it takes.
|
|
7
|
+
- If POSTHOG_API_KEY and POSTHOG_PROJECT_ID are set locally, it talks to
|
|
8
|
+
PostHog directly instead (POST {host}/api/projects/{project_id}/query/).
|
|
8
9
|
"""
|
|
9
10
|
|
|
10
11
|
from __future__ import annotations
|
|
@@ -14,33 +15,21 @@ from typing import Any
|
|
|
14
15
|
|
|
15
16
|
import httpx
|
|
16
17
|
|
|
18
|
+
from makea_cli import api_client
|
|
17
19
|
from makea_cli.config import posthog_api_key, posthog_host, posthog_project_id
|
|
18
20
|
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
"""Raised when the required PostHog env vars are missing."""
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def _require_config() -> tuple[str, str, str]:
|
|
25
|
-
key = posthog_api_key()
|
|
26
|
-
project = posthog_project_id()
|
|
27
|
-
if not key or not project:
|
|
28
|
-
raise PostHogNotConfigured(
|
|
29
|
-
"PostHog is not configured. Set POSTHOG_API_KEY (personal API key, "
|
|
30
|
-
"phx_...) and POSTHOG_PROJECT_ID, optionally POSTHOG_HOST "
|
|
31
|
-
"(default https://eu.posthog.com)."
|
|
32
|
-
)
|
|
33
|
-
return posthog_host(), project, key
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
def run_hogql(query: str, *, timeout: float = 60.0) -> dict[str, Any]:
|
|
22
|
+
def run_hogql(query: str, *, timeout: float = 90.0) -> dict[str, Any]:
|
|
37
23
|
"""Run a HogQL query and return the raw result.
|
|
38
24
|
|
|
39
25
|
The result has ``columns`` (list of names) and ``results`` (list of rows);
|
|
40
26
|
callers usually want to zip them into dicts for display.
|
|
41
27
|
"""
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
key = posthog_api_key()
|
|
29
|
+
project = posthog_project_id()
|
|
30
|
+
if not key or not project:
|
|
31
|
+
return api_client.post_json("/admin/analytics/query", {"query": query}, timeout=timeout)
|
|
32
|
+
url = f"{posthog_host()}/api/projects/{project}/query/"
|
|
44
33
|
headers = {
|
|
45
34
|
"Authorization": f"Bearer {key}",
|
|
46
35
|
"Content-Type": "application/json",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: makea-cli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Makea admin CLI (browser login + Makea admin HTTP API)
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Requires-Dist: click<9,>=8.1
|
|
@@ -98,18 +98,18 @@ exit code:`0` 成功 · `2` 用法错 · `3` 未登录或身份与 persona 不
|
|
|
98
98
|
| `makea-cli admin download document` | read | `GET /admin/document/download` | save a document file (document id + designer user_id). | `download-document` |
|
|
99
99
|
| `makea-cli admin download product-document` | read | `GET /admin/document/download` | Resolve product via admin list product-order payload, then GET /admin/document/download. | `download-product-document` |
|
|
100
100
|
| `makea-cli admin generate pricing-groups` | write(ask) | `POST /admin/production_orders/{id}/details/update` | Lay a production order's variants into pricing groups along one axis (--by style \| colour \| variant \| all) with th… | `production-groups-generate` |
|
|
101
|
-
| `makea-cli admin get active-users` | read | `
|
|
102
|
-
| `makea-cli admin get analytics-query` | read | `
|
|
101
|
+
| `makea-cli admin get active-users` | read | `POST /admin/analytics/query` | Distinct active users per day over the last N days (DAU series). | `analytics-active-users` |
|
|
102
|
+
| `makea-cli admin get analytics-query` | read | `POST /admin/analytics/query` | Run an arbitrary HogQL query (escape hatch). Example: analytics-query "SELECT count() FROM events" | `analytics-query` |
|
|
103
103
|
| `makea-cli admin get currency-conversion` | read | `currency-api` | avoids repeated lookups. | `convert-currency` |
|
|
104
|
-
| `makea-cli admin get feature-usage` | read | `
|
|
104
|
+
| `makea-cli admin get feature-usage` | read | `POST /admin/analytics/query` | How many distinct users used a feature recently, plus event volume. Matches $pageview path and feature_time_spent eve… | `analytics-feature-usage` |
|
|
105
105
|
| `makea-cli admin get library-schema` | read | `GET /admin/library_components/schema` | the tech-pack library taxonomy: sections and their library-role field keys (run this before create/update). | `library-schema` |
|
|
106
106
|
| `makea-cli admin get production-pricing` | read | `GET /admin/production_orders/{id}/details` | show a production order's price tiers, MOQ, sizes/colours, pricing groups and cart coverage. | `production-pricing-show` |
|
|
107
107
|
| `makea-cli admin get quote-request` | read | `GET /admin/quote_requests/{quote_request_id}` | one quote request in full. | — |
|
|
108
108
|
| `makea-cli admin get revenue-metrics` | read | `GET /admin/business-metrics/cumulative-payment-and-platform-revenue` | platform-wide payment received and platform revenue (service fee + transaction fee) bucketed over a date range. | `get-cumulative-payment-and-platform-revenue` |
|
|
109
109
|
| `makea-cli admin get supplier-profile-schema` | read | `GET /admin/supplier/profile/schema` | supplier profile v2 schema (section/field taxonomy: sections, fields, options, required rules). | `get-supplier-profile-schema` |
|
|
110
110
|
| `makea-cli admin get tech-spec-extraction` | read | `GET /admin/products/{id}/extract-tech-specifications` | AI-generate specs (not saved). | `extract-ai-tech-spec` |
|
|
111
|
-
| `makea-cli admin get top-clicks` | read | `
|
|
112
|
-
| `makea-cli admin get top-features` | read | `
|
|
111
|
+
| `makea-cli admin get top-clicks` | read | `POST /admin/analytics/query` | which buttons/elements get clicked most. | `analytics-top-clicks` |
|
|
112
|
+
| `makea-cli admin get top-features` | read | `POST /admin/analytics/query` | a quick map of which features get used most. | `analytics-top-features` |
|
|
113
113
|
| `makea-cli admin list library-element` | read | `GET /admin/designer/{user_id}/library_components` | list a designer's tech-pack library (org-fanned). Optional --section scopes to one type. | `library-list` |
|
|
114
114
|
| `makea-cli admin list misc-payment` | read | `GET /admin/products/{id}/misc-payments` | misc payments for one product (admin). | `list-misc-payments-by-product` |
|
|
115
115
|
| `makea-cli admin list product-order` | read | `GET /admin/designer/get_all_product_orders` | designer product (SKU) list. For 大货 use admin list production-order or admin list production-order --product. | `list-product-orders` |
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
makea_cli/__init__.py,sha256=
|
|
1
|
+
makea_cli/__init__.py,sha256=F8OVhAhMXSkvvXYgZtbPn2SG1AQC3joK4yu-FrHt81Y,22
|
|
2
2
|
makea_cli/__main__.py,sha256=AkQjxWfKE3w9iD1d6I-2Zqvv2t9cct0oYyFF0UiA-Z0,144
|
|
3
3
|
makea_cli/api_client.py,sha256=dzMCH9KzY7NJxoop-WVyqm_JQ3eU3hvFh_ic2Zk-evc,50763
|
|
4
4
|
makea_cli/auth_pkce.py,sha256=iXSyJ7DM3qVuj-3FwPiqM25CxXz9ebFs9FNthZdw3ws,7315
|
|
5
5
|
makea_cli/broker.py,sha256=5O650nAdRuF-u9E1MuVM2jVv796iBdxJGIaJasxHij0,3019
|
|
6
|
-
makea_cli/config.py,sha256=
|
|
6
|
+
makea_cli/config.py,sha256=hz8MnJSkhxcIEZkcpHR005JrDceo1Xmi8qwIUq50cMU,3003
|
|
7
7
|
makea_cli/errors.py,sha256=_2qKjvkU8YWeBcUd04Yn62lKkZoqQY52kH8klNMyxhM,2780
|
|
8
8
|
makea_cli/identity.py,sha256=pfYT-asaY1ZTzoAzfqI-v4Eyz1RtxqR2YgvxRGx_lxg,2758
|
|
9
9
|
makea_cli/main.py,sha256=nuTQ8_P8OSdRbjMHMB4qcKdex124nS-ApCW-zfbqlI0,7169
|
|
10
10
|
makea_cli/output.py,sha256=VWvZe2Ad8zxT4ZQyBhFRc6wkFwbyYzQFPddepANGAbY,6361
|
|
11
|
-
makea_cli/posthog_client.py,sha256=
|
|
11
|
+
makea_cli/posthog_client.py,sha256=k0cy9Hq7bhdLlPvC1ZW_esJ70xHDdQzPQUlx-GpVskk,1921
|
|
12
12
|
makea_cli/registry.py,sha256=GYJK_idhwIh1X2ictwFjn8PEMaXT56hFVkoLEVYrVqw,13722
|
|
13
13
|
makea_cli/commands/__init__.py,sha256=sxDNEYDmQTASzH2uvMtqNwKLLbOQBzwPfxc-S1tHf-w,1474
|
|
14
14
|
makea_cli/commands/_util.py,sha256=zSFwWaWpncARlKxgq4WuJlJvNv7XdZ39HfHrNOELHuw,980
|
|
15
15
|
makea_cli/commands/analytics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
makea_cli/commands/analytics/cmd.py,sha256=
|
|
16
|
+
makea_cli/commands/analytics/cmd.py,sha256=KVLUtYSeyYZ8_09jIuIAmePjQqcpQS2mb5PBBzGwQYQ,6562
|
|
17
17
|
makea_cli/commands/auth/__init__.py,sha256=NXoKGfkY2X_hb8GnAyzhoI_qDXfpwKZPqt4HnOrXW3Y,73
|
|
18
18
|
makea_cli/commands/auth/cmd.py,sha256=G9ZeiaJwzUUTptIyynr0V-82wI7eV0qVX0pD6rdPSXg,1321
|
|
19
19
|
makea_cli/commands/brand/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -41,7 +41,7 @@ makea_cli/commands/production/cmd.py,sha256=s6fVAGzOvokF6Va5WKGEA2vw2x2hDQ3PrsF0
|
|
|
41
41
|
makea_cli/commands/production/pricing_spec.py,sha256=xGbj7-ps3PcKuU6Oc59A70b62FjF6Awhr5IY3ymZveU,27174
|
|
42
42
|
makea_cli/commands/supplier/__init__.py,sha256=qfQDeQdQ-B7I_uwFVfcp1vXFUTL4fAcNLu3ipsZ7dfs,77
|
|
43
43
|
makea_cli/commands/supplier/cmd.py,sha256=crRCy9WfhkryHMIL3iufoiT90_SG3-mKChAtdhd06uc,58076
|
|
44
|
-
makea_cli-0.2.
|
|
45
|
-
makea_cli-0.2.
|
|
46
|
-
makea_cli-0.2.
|
|
47
|
-
makea_cli-0.2.
|
|
44
|
+
makea_cli-0.2.9.dist-info/METADATA,sha256=Nnp67EfMAZJ0m9JEn9qhecii3iB4Xg0cEo1lUqVxn8I,31760
|
|
45
|
+
makea_cli-0.2.9.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
46
|
+
makea_cli-0.2.9.dist-info/entry_points.txt,sha256=4x-lbVa1jBbNlkNq7L-rYyfRh2spZmc3BLIzP-Dl-Qk,50
|
|
47
|
+
makea_cli-0.2.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|