pixelarraythirdparty 1.2.9__py3-none-any.whl → 1.3.2__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.
@@ -12,11 +12,15 @@ PixelArray 第三方微服务客户端
12
12
  - feedback: 客户反馈模块
13
13
  - project: 项目管理模块
14
14
  - support_chat: 在线客服(临时会话链接)
15
+ - custom_events: 自定义事件(新建定义与上报)
16
+ - project_dashboard: 项目看板(按 scope 查询 DNU/DAU/留存)
15
17
  """
16
18
 
17
19
  from .support_chat.support_chat import SupportChatManagerAsync
20
+ from .custom_events.custom_events import CustomEventsManagerAsync
21
+ from .project_dashboard.project_dashboard import ProjectDashboardManagerAsync
18
22
 
19
- __version__ = "1.2.9"
23
+ __version__ = "1.3.2"
20
24
  __author__ = "Lu qi"
21
25
  __email__ = "qi.lu@pixelarrayai.com"
22
26
 
@@ -29,5 +33,9 @@ __all__ = [
29
33
  "feedback",
30
34
  "project",
31
35
  "support_chat",
36
+ "custom_events",
37
+ "project_dashboard",
32
38
  "SupportChatManagerAsync",
39
+ "CustomEventsManagerAsync",
40
+ "ProjectDashboardManagerAsync",
33
41
  ]
@@ -0,0 +1,3 @@
1
+ from .custom_events import CustomEventsManagerAsync
2
+
3
+ __all__ = ["CustomEventsManagerAsync"]
@@ -0,0 +1,92 @@
1
+ from pixelarraythirdparty.client import AsyncClient
2
+ from typing import Any, Dict, List, Optional, Tuple
3
+
4
+
5
+ class CustomEventsManagerAsync(AsyncClient):
6
+ """自定义事件:新建定义与上报(上报前须存在对应事件定义与字段 schema)。"""
7
+
8
+ async def create_custom_event_definition(
9
+ self,
10
+ project_name: str,
11
+ event_key: str,
12
+ display_name: str,
13
+ *,
14
+ description: Optional[str] = None,
15
+ category: str = "custom",
16
+ field_schema: Optional[List[Dict[str, Any]]] = None,
17
+ is_active: bool = True,
18
+ ) -> Tuple[Dict[str, Any], bool]:
19
+ """
20
+ description:
21
+ 新建自定义事件定义(需 API Key;与 Portal「新建定义」一致,对应 POST /api/custom-events/definitions/create)
22
+ parameters:
23
+ project_name(str): 项目名称(与 projects.name 一致)
24
+ event_key(str): 事件键(1~64 字符)
25
+ display_name(str): 展示名
26
+ description(str, optional): 说明
27
+ category(str): 分类白名单,默认 custom
28
+ field_schema(list, optional): 字段定义列表,每项含 name、type(string|number|boolean)、required、description
29
+ is_active(bool): 是否启用,默认 True
30
+ return:
31
+ data(dict): 成功时为定义记录;失败时含 message 等
32
+ success(bool): 是否成功
33
+ """
34
+ body: Dict[str, Any] = {
35
+ "project_name": project_name,
36
+ "event_key": event_key,
37
+ "display_name": display_name,
38
+ "category": category,
39
+ "field_schema": field_schema or [],
40
+ "is_active": is_active,
41
+ }
42
+ if description is not None:
43
+ body["description"] = description
44
+ return await self._request(
45
+ "POST", "/api/custom-events/definitions/create", json=body
46
+ )
47
+
48
+ async def report_custom_event(
49
+ self,
50
+ project_name: str,
51
+ event_key: str,
52
+ payload: Dict[str, Any],
53
+ client_occurred_at: Optional[str] = None,
54
+ ) -> Tuple[Dict[str, Any], bool]:
55
+ """
56
+ description:
57
+ 上报单条自定义事件日志(JSON 载荷须符合 Portal 中配置的 field_schema)
58
+ parameters:
59
+ project_name(str): 项目名称(与 projects.name 一致)
60
+ event_key(str): 事件键
61
+ payload(dict): JSON 对象,键与类型须与定义一致
62
+ client_occurred_at(str, optional): 客户端事件发生时间,ISO8601 字符串
63
+ return:
64
+ data(dict): 成功时为日志记录;失败时含 message 等
65
+ success(bool): 是否成功
66
+ """
67
+ data: Dict[str, Any] = {
68
+ "project_name": project_name,
69
+ "event_key": event_key,
70
+ "payload": payload,
71
+ }
72
+ if client_occurred_at is not None:
73
+ data["client_occurred_at"] = client_occurred_at
74
+ return await self._request("POST", "/api/custom-events/report", json=data)
75
+
76
+ async def report_custom_events_batch(
77
+ self,
78
+ project_name: str,
79
+ items: List[Dict[str, Any]],
80
+ ) -> Tuple[Dict[str, Any], bool]:
81
+ """
82
+ description:
83
+ 批量上报自定义事件(同一 project_name;任一条校验失败则整批失败)
84
+ parameters:
85
+ project_name(str): 项目名称(与 projects.name 一致)
86
+ items(list): 每项为 dict,须含 event_key、payload;可选 client_occurred_at(字符串)
87
+ return:
88
+ data(dict): 成功时为日志列表;失败时含 message
89
+ success(bool): 是否成功
90
+ """
91
+ body = {"project_name": project_name, "items": items}
92
+ return await self._request("POST", "/api/custom-events/report/batch", json=body)
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ from pixelarraythirdparty.project_dashboard.project_dashboard import (
3
+ ProjectDashboardManagerAsync,
4
+ )
5
+
6
+ __all__ = ["ProjectDashboardManagerAsync"]
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+ from typing import Any, Dict, Optional, Tuple
3
+
4
+ from pixelarraythirdparty.client import AsyncClient
5
+
6
+
7
+ def _resolve_dashboard_path(scope: str) -> Optional[str]:
8
+ s = (scope or "").strip()
9
+ if s.upper() == "DNU":
10
+ return "/api/project-dashboard/dashboard/dnu"
11
+ if s.upper() == "DAU":
12
+ return "/api/project-dashboard/dashboard/dau"
13
+ if s.upper() == "RETENTION" or s == "留存":
14
+ return "/api/project-dashboard/dashboard/retention"
15
+ return None
16
+
17
+
18
+ class ProjectDashboardManagerAsync(AsyncClient):
19
+ """项目看板:按 scope 查询 DNU / DAU / 留存(与 Portal 同源接口,需 API Key)。"""
20
+
21
+ async def query_dashboard(
22
+ self,
23
+ project_name: str,
24
+ scope: str,
25
+ start_date: Optional[str] = None,
26
+ end_date: Optional[str] = None,
27
+ ) -> Tuple[Dict[str, Any], bool]:
28
+ """
29
+ description:
30
+ 查询项目看板指标;scope 为 DNU、DAU、RETENTION 或中文「留存」。
31
+ parameters:
32
+ project_name(str): 项目名称(与统一登录 project_name 一致)
33
+ scope(str): DNU | DAU | RETENTION | 留存
34
+ start_date(str, optional): 开始日期 YYYY-MM-DD;不传则服务端默认 T-7
35
+ end_date(str, optional): 结束日期 YYYY-MM-DD;不传则服务端默认 T-0
36
+ return:
37
+ data(dict): 成功时为 DauData / DnuData / RetentionData 结构(见接口文档)
38
+ success(bool): 是否成功
39
+ """
40
+ path = _resolve_dashboard_path(scope)
41
+ if not path:
42
+ return (
43
+ {"message": "scope 无效,应为 DNU、DAU、RETENTION 或 留存"},
44
+ False,
45
+ )
46
+ params: Dict[str, Any] = {"project_name": project_name}
47
+ if start_date:
48
+ params["start_date"] = start_date
49
+ if end_date:
50
+ params["end_date"] = end_date
51
+ return await self._request("GET", path, params=params)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pixelarraythirdparty
3
- Version: 1.2.9
3
+ Version: 1.3.2
4
4
  Summary: PixelArray 第三方微服务客户端
5
5
  Author-email: Lu qi <qi.lu@pixelarrayai.com>
6
6
  License-Expression: MIT
@@ -1,7 +1,9 @@
1
- pixelarraythirdparty/__init__.py,sha256=nh2-eWE-1U8t_Pq_DAqfNZpeNW6Dc_x0dC0P1vDGN0M,750
1
+ pixelarraythirdparty/__init__.py,sha256=u4nKGTU7GeD4kMRPtf0w8_ok_HcgBDV0mpIVCZYGgKE,1139
2
2
  pixelarraythirdparty/client.py,sha256=hICdd1MSBrxtoo4BgXSdmKchLehbpJcQ486SO9_fmuI,4459
3
3
  pixelarraythirdparty/cron/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  pixelarraythirdparty/cron/cron.py,sha256=Cm5J1XppXh1raqtlWwpkdcsztWpQZIGY7FOt1VH9Pz0,3152
5
+ pixelarraythirdparty/custom_events/__init__.py,sha256=dwB0mRElWp--5KmDVT7ZhGZ5xZdrO_ZKybngfAHm0zw,92
6
+ pixelarraythirdparty/custom_events/custom_events.py,sha256=3IygHeJ4pcw2JqKS-DO4ubzoZiEPFeOiLw7zx76m9k4,3843
5
7
  pixelarraythirdparty/feedback/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
8
  pixelarraythirdparty/feedback/feedback.py,sha256=bwR2qeors_G2zFoKkefsJrPrLzCxndoXGru-aVsiRSI,11596
7
9
  pixelarraythirdparty/order/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -10,14 +12,16 @@ pixelarraythirdparty/product/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
10
12
  pixelarraythirdparty/product/product.py,sha256=fELowDk073SAmNJ2iW14UjyePH5g1X5YDJMTkVysA3E,7509
11
13
  pixelarraythirdparty/project/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
14
  pixelarraythirdparty/project/project.py,sha256=lEeGvSH6yl-O9AmpNtRNtcu1y2FzHmVWeofbYPCZfa0,2461
15
+ pixelarraythirdparty/project_dashboard/__init__.py,sha256=yeVhw4smnQ8-xN-BG3aZ7sbU4hYGQfAduLIEr_8nXQQ,175
16
+ pixelarraythirdparty/project_dashboard/project_dashboard.py,sha256=3Y4-N0xVsE8-jH7-WhJTFhLJoJuvch0Ms8rH0ZzjXN8,1985
13
17
  pixelarraythirdparty/support_chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
18
  pixelarraythirdparty/support_chat/support_chat.py,sha256=M2YD4tWUKt1xRAEZy-znvxFnU8KIxKoHtYnVuUiE_kY,1128
15
19
  pixelarraythirdparty/unified_login/__init__.py,sha256=bWG_I7GMHilWZvnxjVJFmHgxioRdFFvpi95XJunl_fY,403
16
20
  pixelarraythirdparty/unified_login/unified_login.py,sha256=15fNyhm6HKgjPMO1RCqpxzlAzBAJuGZbRMr4gABh4MA,40575
17
21
  pixelarraythirdparty/user/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
22
  pixelarraythirdparty/user/user.py,sha256=G-dldmbuUQN1JPicuC2G4qvIY4Mq7pZIPh3lOyWpSqo,5773
19
- pixelarraythirdparty-1.2.9.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
20
- pixelarraythirdparty-1.2.9.dist-info/METADATA,sha256=SKKzeaqsB1E27ypF9y4ORxMTE5b1Pym1Yk8lWEdjvsY,993
21
- pixelarraythirdparty-1.2.9.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
22
- pixelarraythirdparty-1.2.9.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
23
- pixelarraythirdparty-1.2.9.dist-info/RECORD,,
23
+ pixelarraythirdparty-1.3.2.dist-info/licenses/LICENSE,sha256=O-g1dUr0U50rSIvmWE9toiVkSgFpVt72_MHITbWvAqA,1067
24
+ pixelarraythirdparty-1.3.2.dist-info/METADATA,sha256=Ci2RXCHVCOWcQxjoNLP4mdTbYynMrV5VGpeguFBO5Z8,993
25
+ pixelarraythirdparty-1.3.2.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
26
+ pixelarraythirdparty-1.3.2.dist-info/top_level.txt,sha256=dzG2Ut8j7noUqj_0ZQjcIDAeHYCh_9WtlxjAxtoyufo,21
27
+ pixelarraythirdparty-1.3.2.dist-info/RECORD,,