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

Event Trend Analysis

Event Trend Analysis answers "what is the volume and trend of a given event over a period of time". It is the most fundamental and most frequently used analysis model, corresponding to the backend AnalyticsService.EventTrend.

This tutorial series is aimed at data analysts and includes backend APIs, the underlying SQL, and typical question examples.


1. What Questions It Answers

  • What is the trend of the "register" event over the last 30 days?
  • What is the hourly distribution of the "payment success" event, and are there peak hours?
  • How do event volumes compare across platforms (iOS/Android/Web) over time?

2. Backend API

gRPC: AnalyticsService.EventTrend

FieldTypeDescription
time_rangeTimeRangestart_ms / end_ms (Unix milliseconds, inclusive). Defaults if omitted: end = now, start = 7 days ago
granularityAnalyticsGranularityHOUR / DAY / WEEK / MONTH. If omitted (UNSPECIFIED), auto-selected: span > 3 days → DAY, otherwise HOUR
app_iduint32 (optional)Filter by app (→ tenant)
event_namestring (optional)Filter by event name, e.g. register / payment_success
platformstring (optional)Filter by platform, e.g. web / ios

Response EventTrendResponse: points[] (each TimeSeriesPoint contains timestamp + value), granularity, total.

HTTP (admin proxy)

POST /admin/v1/analytics/event-trend
Content-Type: application/json

{
  "timeRange": { "startMs": 1718169600000, "endMs": 1718774399000 },
  "granularity": "ANALYTICS_GRANULARITY_DAY",
  "eventName": "register"
}

For the full contract, see Backend API Contract.


3. Underlying SQL

Event trend is essentially "a count() aggregation bucketed by time". The backend runs native SQL on the OLAP engine, generating the time-bucketing expression according to the selected engine's dialect.

Doris (default engine)

-- Daily event trend
SELECT
    DATE_FORMAT(event_time, '%Y-%m-%d') AS day,
    count() AS event_count
FROM events_fact
WHERE event_time >= FROM_UNIXTIME(:start_ms / 1000)
  AND event_time <= FROM_UNIXTIME(:end_ms / 1000)
  AND event_name = 'register'
GROUP BY day
ORDER BY day;

Hourly:

SELECT
    DATE_FORMAT(event_time, '%Y-%m-%d %H:00') AS hour,
    count() AS event_count
FROM events_fact
WHERE event_name = 'register'
  AND event_time >= ...
GROUP BY hour
ORDER BY hour;

ClickHouse (when switched to this engine)

-- Daily
SELECT
    toDate(event_time) AS day,
    count() AS event_count
FROM events_fact
WHERE event_name = 'register'
  AND event_time >= fromUnixTimestamp64Milli(toInt64(:start_ms))
GROUP BY day
ORDER BY day;

-- Hourly
SELECT
    toStartOfHour(event_time) AS hour,
    count() AS event_count
FROM events_fact
...
GROUP BY hour;

Key dialect differences: Doris uses DATE_FORMAT, ClickHouse uses toStartOfHour / toDate. See the OLAP Cookbook for details.


4. Typical Question Examples

Q1: "Register" event trend over the last 30 days

API request:

{
  "timeRange": { "startMs": <now minus 30 days in ms>, "endMs": <now in ms> },
  "granularity": "ANALYTICS_GRANULARITY_DAY",
  "eventName": "register"
}

In the admin console's "Data Analysis / Event Trend" page, select event register, a 30-day time range, and "Day" granularity to get a line chart.

Q2: Peak hours of "Payment Success" by hour

Set granularity to ANALYTICS_GRANULARITY_HOUR, eventName to payment_success, and the time range to today. The result shows the distribution across all 24 hours of a day, letting you identify peak hours.

Q3: Comparing event volume trends across platforms

EventTrend supports only one platform filter per call. There are two ways to compare multiple platforms:

  • Make multiple calls with different platform values and overlay the curves on the frontend;
  • Write SQL directly (Superset) grouping by platform:
SELECT DATE_FORMAT(event_time, '%Y-%m-%d') AS day, platform, count() AS cnt
FROM events_fact
WHERE event_name = 'purchase'
GROUP BY day, platform
ORDER BY day;

5. Notes and Caveats

  • Time range defaults: if time_range is omitted, the backend defaults to the last 7 days.
  • Automatic granularity: if granularity is omitted, spans > 3 days use DAY, otherwise HOUR.
  • Empty data: if the query returns nothing, first confirm the data has been stored (whether the OLAP engine's Kafka consumption job is running — see Getting Started · Current State of Data Storage).
  • Large time ranges: for very long spans, prefer DAY/WEEK/MONTH to avoid returning too many hourly points.

6. Related Documents

  • Data Analyst Getting Started Guide
  • Funnel Analysis
  • Retention Analysis
  • OLAP Cookbook
  • Backend API Contract
Edit this page
Last Updated:: 11/3/26, 2:14 PM
Contributors: Bobo
Next
Active Users Analysis