71 lines
3.5 KiB
Python
71 lines
3.5 KiB
Python
from datetime import datetime
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from .base import Base, IP4, to_alias
|
|
|
|
__all__ = ('EventModel',)
|
|
|
|
|
|
class Preset(BaseModel):
|
|
ip: IP4 = Field(None, title='ipv4',description='不传该字段默认使用源ip')
|
|
country: str = Field(None, title='国家',description='')
|
|
country_code: str = Field(None, title='国家代码',description='')
|
|
province: str = Field(None, title='省份',description='')
|
|
city: str = Field(None, title='城市',description='')
|
|
os_version: str = Field(None, title='操作系统版本',description='')
|
|
manufacturer: str = Field(None, title='设备制造商',description='')
|
|
os: str = Field(None, title='操作系统',description='')
|
|
device_id: str = Field(None, title='设备 ID',description='')
|
|
screen_height: int = Field(None, title='屏幕高度',description='')
|
|
screen_width: int = Field(None, title='屏幕宽度',description='')
|
|
device_model: str = Field(None, title='设备型号',description='')
|
|
app_version: str = Field(None, title='APP 版本',description='')
|
|
bundle_id: str = Field(None, title='APP包名',description='')
|
|
lib: str = Field(None, title='SDK 类型',description='')
|
|
lib_version: str = Field(None, title='SDK 版本',description='')
|
|
network_type: str = Field(None, title='网络状态',description='')
|
|
carrier: str = Field(None, title='网络运营商',description='')
|
|
browser: str = Field(None, title='浏览器类型',description='')
|
|
browser_version: str = Field(None, title='浏览器版本',description='')
|
|
duration: int = Field(None, title='事件时长',description='')
|
|
url: str = Field(None, title='页面地址',description='')
|
|
url_path: str = Field(None, title='页面路径',description='')
|
|
referrer: str = Field(None, title='前向地址',description='')
|
|
referrer_host: str = Field(None, title='前向路径',description='')
|
|
title: str = Field(None, title='页面标题',description='')
|
|
screen_name: str = Field(None, title='页面名称',description='')
|
|
element_id: str = Field(None, title='元素 ID',description='')
|
|
element_type: str = Field(None, title='元素类型',description='')
|
|
resume_from_background: str = Field(None, title='是否从后台唤醒',description='')
|
|
element_selector: str = Field(None, title='元素选择器',description='')
|
|
element_position: str = Field(None, title='元素位置',description='')
|
|
element_content: str = Field(None, title='元素内容',description='')
|
|
scene: str = Field(None, title='场景值',description='')
|
|
mp_platform: str = Field(None, title='小程序平台',description='')
|
|
app_crashed_reason: str = Field(None, title='异常信息',description='')
|
|
zone_offset: str = Field(None, title='时区偏移',description='')
|
|
|
|
user_id: str = Field(..., title='用户唯一 ID',description='')
|
|
account_id: str = Field(..., title='账户 ID', description='')
|
|
distinct_id: str = Field(..., title='访客 ID',description='')
|
|
event_name: str = Field(..., title='事件名称',description='')
|
|
|
|
# 事件
|
|
app_id: str = Field(None, description='')
|
|
event_time: datetime = Field(None,title='事件时间', description='')
|
|
server_time: datetime = Field(None,title='服务端时间', description='')
|
|
|
|
|
|
def dict(self, **kwargs):
|
|
res = super().dict(**kwargs)
|
|
return {'#' + k: v for k, v in res.items() if v is not None}
|
|
|
|
class Config:
|
|
alias_generator = to_alias
|
|
|
|
|
|
class EventModel(Base):
|
|
preset: Preset = Field(..., title='系统属性')
|
|
|