GoWindGoWind
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
  • Introduction

    • GoWind UBA Product Introduction
  • Architecture Reference

    • UBA System Architecture
    • UBA Backend Module Overview
    • UBA Backend API Contract
    • UBA Frontend Architecture
  • Developer Guide

    • UBA Installation Guide
    • UBA Code Generation Pipeline Tutorial
    • Adding an External Service Tutorial
    • Adding a Business Entity Tutorial
    • Adding a Frontend Page Tutorial
  • Operations Guide

    • UBA Docker Deployment Guide
    • UBA Configuration Reference & Security Checklist
    • UBA PM2 Deployment Guide
    • UBA Superset BI Deployment Guide
  • Analyst Guide

    • Data Analyst Getting Started Guide
    • Basic Aggregation

      • Event Trend Analysis
      • Active Users Analysis
      • Group By Aggregation
    • Conversion & Paths

      • Funnel Analysis
      • Retention Analysis
      • Top Conversion Paths
      • Behavior Sequence Analysis
    • User Depth

      • Attribution Analysis
      • Distribution Analysis
      • User Segmentation
      • Click Heatmap
      • Interval Analysis
    • Lifecycle

      • User Lifecycle
      • Churn & Reactivation Analysis
      • New vs Returning Users
      • Matrix Quadrant Analysis
    • Revenue & Value

      • Revenue Analysis
      • Whale Tier (Payer Segmentation)
      • Historical LTV Analysis
    • Sessions & Anomalies

      • Session Analysis
      • Period-over-Period Comparison and Anomaly Detection
    • Gaming

      • Level Analysis (Game)
      • Server Retention (Game)
      • Online Stats Analysis (Game)
      • Economy Analysis (Game)
    • OLAP Cookbook
  • SDK Integration

    • Web SDK Integration Guide
    • C# SDK Integration Guide (Unity / Godot / .NET)
  • Appendix

    • UBA Appendix: Ports, Glossary, Known Limitations & FAQ

UBA Backend API Contract

This document organizes the UBA external/internal API contracts based on the actual Protobuf definitions (backend/api/protos/), serving as the authoritative reference for secondary development and SDK integration.

Interface contract first: all APIs are defined in .proto files, with Go / TypeScript / OpenAPI code generated via buf. See Code Generation Pipeline for details.


1. Proto Layering

api/protos/
├── uba/service/v1/        # UBA domain messages + gRPC service contracts (implemented by Core)
│   ├── analytics.proto     # Analytics aggregations
│   ├── behavior_event.proto# Behavior events
│   ├── report.proto        # Report service (implemented by Collector)
│   ├── session.proto / event_path.proto
│   ├── risk_event.proto / risk_rule.proto
│   ├── application.proto / event_schema.proto / object.proto
│   ├── tag_definition.proto / user_tag.proto / id_mapping.proto
│   ├── user_behavior_profile.proto / webhook.proto
│   ├── common.proto / uba_error.proto
├── admin/service/v1/      # Admin console HTTP gateway (forwarding implemented by Admin, i_ prefix)
│   ├── i_analytics.proto / i_behavior_event.proto / i_application.proto
│   ├── i_session.proto / i_event_path.proto / i_event_schema.proto
│   ├── i_risk_event.proto / i_risk_rule.proto / i_webhook.proto
│   ├── i_tag_definition.proto / i_user_tag.proto / i_id_mapping.proto
│   ├── i_user.proto / i_role.proto / i_permission*.proto / i_menu.proto
│   ├── i_authentication.proto / i_login_policy.proto / i_tenant.proto
│   ├── i_dict_*.proto / i_language.proto / i_file*.proto / i_task.proto
│   ├── i_internal_message*.proto / i_org_unit.proto / i_position.proto
│   └── i_*_audit_log.proto / i_admin_portal.proto
└── <other domains>/            # authentication / permission / dict / identity ...

Only admin/service/v1/*.proto generates the frontend TypeScript client (see inputs.paths in api/buf.admin.typescript.gen.yaml).


2. Report Service (Collector)

ReportService (uba/service/v1/report.proto)

RPCDescription
PostReport(PostReportRequest) returns (PostReportResponse)Unified reporting interface, supports mixed reporting of behavior/risk events

HTTP Endpoint

  • POST /uba/v1/report

Authentication

  • appId + appSecret are placed in the request body (not headers); no Authorization token.
  • Authentication failure returns 401; the SDK does not retry.

Request Body Structure (camelCase, protojson encoding)

{
  "appId": "your_app_id",
  "appSecret": "your_app_secret",
  "clientInfo": { "userAgent": "...", "referer": "..." },
  "events": [
    {
      "eventType": "BEHAVIOR",        // BEHAVIOR | RISK
      "eventId": "uuid",              // auto-generated by the SDK, unique
      "eventName": "click",           // required
      "eventTime": "RFC3339",         // auto-completed by the SDK
      "deviceId": "...",              // persisted by the SDK, stable per device
      "sessionId": "...",             // session level
      "platform": "web",              // detected by the SDK
      "userId": 1001,                 // carried automatically after identify
      "properties": { "button": "buy" },
      "behavior": { "objectType": "button", "objectId": "btn_buy" }
    }
  ]
}

tenantId is not reported; the server authoritatively identifies and overrides it based on appId, ensuring multi-tenant isolation.

Event Types (oneof payload of the events element)

TypeFieldsTriggering API
Behavior event (BEHAVIOR)behavior + propertiesSDK track / trackBehavior
Risk event (RISK)risk (riskType / riskLevel / riskScore / description)SDK trackRisk

Response Conventions

  • HTTP 200 may still contain partial failures: when the response body has failedCount > 0 or a non-empty errorsByType, the SDK logs a warning.
  • Error codes: 400 validation failure, 401 authentication failure (no retry), 500 server error (retry).
  • Error bodies follow the Kratos error envelope format.

3. Analytics Aggregation Service

AnalyticsService (uba/service/v1/analytics.proto)

A total of 25 analysis model RPCs (grouped by scenario, corresponding to lines 11-83 of the proto):

ScenarioRPCPurpose
Basic aggregationsEventTrendEvent volume trend (time bucketing)
GroupByDimension group aggregation (whitelisted dimensions + metrics)
ActiveUsersDAU / WAU / MAU (daily-level true values via HLL rolling windows)
Conversion & pathsFunnelFunnel analysis (multi-step conversion)
RetentionCohort retention matrix
PathSankeyTop conversion paths (Sankey diagram)
BehaviorSequenceBehavior sequence analysis
In-depth user insightsAttributionAttribution analysis (first-touch/last-touch)
DistributionDistribution analysis (duration bucketing + percentiles)
SegmentationUser segmentation / targeting
ClickClick heatmaps
IntervalInterval time analysis
LifecycleLifecycleUser lifecycle
ChurnChurn and win-back analysis
NewVsOldNew vs. returning user comparison
MatrixMatrix / quadrant analysis
Revenue & valueRevenueRevenue analysis (ARPU/ARPPU/GMV)
WhaleTierPaying-user tiers (whale users)
LTVHistorical lifetime value
Sessions & anomaliesSessionAnalysisSession analysis (bounce rate/depth/percentiles)
AnomalyYear-over-year / month-over-month, anomaly detection
Game-specificLevelAnalysisLevel / numeric balance analysis
ServerRetentionMerged-server retention (by server)
OnlineStatsConcurrent online PCU / ACU
EconomyEconomy system / token flows

Common Messages

  • AnalyticsGranularity enum: UNSPECIFIED=0, HOUR=1, DAY=2, WEEK=3, MONTH=4.
  • TimeRange: start_ms (inclusive), end_ms (inclusive), Unix milliseconds. When omitted, the default is end = now and start = 7 days ago.
  • TimeSeriesPoint: timestamp (ms), value (double).

Request Essentials

The request messages (*Request) of the 25 models follow unified conventions:

  • Common fields: time_range (TimeRange), optional app_id (used in the repository as a tenant_id isolation predicate; 0/absent means all tenants). Time-series models also carry granularity (AnalyticsGranularity).
  • Filter fields: event_name / platform / dimension etc. are carried according to each model's semantics. GroupBy's dimension uses a whitelist: platform/channel/country/app_version/event_name/event_category/os/network (game models additionally support server_id/level etc.).
  • Model-specific parameters: e.g. FunnelRequest.steps (repeated string, ≥2), RetentionRequest.retention_type (ACTIVE/EVENT) + max_offset_days, GroupByRequest.metric (COUNT/UNIQUE_USER/SUM_AMOUNT), etc.

For the complete field-by-field definitions of the 25 models, consult backend/api/protos/uba/service/v1/analytics.proto (request/response messages with full field comments), or the Swagger docs generated by running make openapi.

Admin HTTP Endpoints (admin/service/v1/i_analytics.proto)

All are POST with body: "*", forwarded to Core gRPC; the path convention is uniformly POST /admin/v1/analytics/<kebab-case method name>:

MethodHTTP Path
EventTrendPOST /admin/v1/analytics/event-trend
FunnelPOST /admin/v1/analytics/funnel
RetentionPOST /admin/v1/analytics/retention
GroupByPOST /admin/v1/analytics/group-by
ActiveUsersPOST /admin/v1/analytics/active-users
AttributionPOST /admin/v1/analytics/attribution
DistributionPOST /admin/v1/analytics/distribution
BehaviorSequencePOST /admin/v1/analytics/behavior-sequence
SegmentationPOST /admin/v1/analytics/segmentation
ClickPOST /admin/v1/analytics/click
LifecyclePOST /admin/v1/analytics/lifecycle
ChurnPOST /admin/v1/analytics/churn
IntervalPOST /admin/v1/analytics/interval
MatrixPOST /admin/v1/analytics/matrix
RevenuePOST /admin/v1/analytics/revenue
SessionAnalysisPOST /admin/v1/analytics/session-analysis
AnomalyPOST /admin/v1/analytics/anomaly
NewVsOldPOST /admin/v1/analytics/new-vs-old
PathSankeyPOST /admin/v1/analytics/path-sankey
LevelAnalysisPOST /admin/v1/analytics/level-analysis
WhaleTierPOST /admin/v1/analytics/whale-tier
LTVPOST /admin/v1/analytics/ltv
ServerRetentionPOST /admin/v1/analytics/server-retention
OnlineStatsPOST /admin/v1/analytics/online-stats
EconomyPOST /admin/v1/analytics/economy

⚠️ Known limitation: ActiveUsers's wau/mau already output true values at the daily level based on HLL rolling windows; only HOUR granularity degrades to equal DAU due to the lack of hourly state. See Appendix for details.


4. Behavior Event Service

BehaviorEventService (uba/service/v1/behavior_event.proto)

RPCDescription
Create(BehaviorEvent) returns (Empty)Insert a single event
BatchCreate(BatchCreateBehaviorEventRequest) returns (Empty)Batch insert
List(PagingRequest) returns (ListBehaviorEventResponse)Paginated query
Get(GetBehaviorEventRequest) returns (BehaviorEvent)Query a single event

Full Set of BehaviorEvent Fields (corresponds to events_fact)

FieldTypeGroup
event_id, tenant_idstring / uint32Routing/identity
user_id, device_id, account_id, global_user_iduint32 / stringSubject (Who)
event_time, event_ts, server_timeTimestamp / int64Time
event_category, event_name, event_actionstringBehavior (What)
object_type, object_id, object_namestringObject
session_id, session_seqstring / uint32Session context
platform, os, app_version, channelstringEnvironment
ip, ip_city, country, network, geo, user_agent, refererstringNetwork/location
contextmap<string,string>Business context
duration_ms, amount, quantity, score, metricsuint32/string/int32/mapMetrics
propertiesmap<string,string>Extended properties
op_result, error_code, risk_level, trace_idstringEnterprise/operations
click_x, click_y, element_xpath, page_url, viewport_widthuint32 / stringHeatmap (filled by autotrack)
server_id, levelstring / uint32Game-specific dimensions (server ID / player level)
created_at, updated_atTimestampTimestamps

5. CRUD Services Overview

The following services all provide standard CRUD (List/Count/Get/Create/Update/Delete, some with BatchCreate), forwarded one-to-one by the Admin layer:

DomainCore service / protoAdmin proto
SessionsSessionService / session.protoi_session.proto
User pathsEventPathService / event_path.protoi_event_path.proto
Event schemasEventSchemaService / event_schema.protoi_event_schema.proto
Behavior objectsObjectService / object.protoi_object.proto
UBA appsApplicationService / application.protoi_application.proto
Risk eventsRiskEventService / risk_event.protoi_risk_event.proto
Risk rulesRiskRuleService / risk_rule.protoi_risk_rule.proto
WebhooksWebhookService / webhook.protoi_webhook.proto
Tag definitionsTagDefinitionService / tag_definition.protoi_tag_definition.proto
User tagsUserTagService / user_tag.protoi_user_tag.proto
ID mappingIdMappingService / id_mapping.protoi_id_mapping.proto
User behavior profilesUserBehaviorProfileService / user_behavior_profile.protoi_user_behavior_profile.proto
Users / user profilesUserService etc.i_user.proto / i_user_profile.proto
Tenants/organizations/positionsTenantService / OrgUnitService / PositionServicei_tenant.proto / i_org_unit.proto / i_position.proto
Roles/permissions/menusRoleService / PermissionService / MenuServicei_role.proto / i_permission*.proto / i_menu.proto
Dictionaries/languagesDictTypeService / DictEntryService / LanguageServicei_dict_*.proto / i_language.proto
Authentication/login policyAuthenticationService / LoginPolicyServicei_authentication.proto / i_login_policy.proto
FilesFileService / FileTransferServicei_file.proto / i_file_transfer.proto
Internal messagesInternalMessageService (+ Category/Recipient)i_internal_message*.proto
TasksTaskServicei_task.proto
Audit logs (6 types)*AuditLogService / PolicyEvaluationLogServicei_*_audit_log.proto etc.
API metadataApiServicei_api.proto

For the complete request/response message definitions, consult the corresponding .proto files directly in backend/api/protos/, or the Swagger docs generated by running make openapi.


6. Getting Interactive Documentation

cd backend
make openapi   # generate OpenAPI / Swagger (based on admin / collector protos)

After starting the Admin / Collector services (enable_swagger: true), visit each service's Swagger UI to browse and try out the APIs.


7. Related Documentation

  • System Architecture
  • Backend Module Overview
  • Code Generation Pipeline
  • OLAP Query Cookbook
Edit this page
Last Updated:: 11/3/26, 2:14 PM
Contributors: Bobo
Prev
UBA Backend Module Overview
Next
UBA Frontend Architecture