Run purchase count analysis
run_num_of_purchases_analysisNum of Purchases Analysis (첫구매/재구매 · 구매회차)
When to use: 사용자가 '첫구매 vs 재구매' 비중, '구매 N회차별' 매출/객단가/구매자수 같은 구매 순번(num_of_purchases) 기반 분석을 원할 때. 신규/재구매 코호트, 회차별 리텐션/객단가 변화를 측정하고 싶을 때 호출.
When NOT to use: A/B 상품 함께 구매(basket) 패턴은 cross-selling. 일반 시계열 매출 추이는 query_dashboard. 코호트 LTV/리텐션은 cohort. 브랜드·상품·채널별 재구매 주기(다음 구매까지 일수)는 run_order_cycle_analysis — 이 tool 의 재구매 비중(첫구매 vs 재구매, N회차별)과는 다른 지표다.
Limitations: 회차 정의는 index_dimensions/pivot_dimensions 에 'num_of_purchase_type'(첫구매/재구매) 또는 'num_of_purchases'(N회차) 파생 차원 문자열을 직접 포함해야 결정된다. view_option 은 advisory 힌트일 뿐 서버 side-effect 가 없다(분석 기준을 바꾸지 않음). rank_method (history/freq), num_of_count_type (any/a_a), n (1..50) 로 회차 집계 방식이 달라진다. '그룹 내 구성비'(첫구매/재구매 비중 등)는 더 이상 서버 *_per SQL 컬럼으로 계산되지 않는다 — measures 는 base measure(sales, pay_cnt, aov 등)만 요청하고, 비중은 요청의 percentage_by(partitions 지정) 경로로 서버가 제공한다. 단, percentage_by(및 distance_by) 후처리는 orient="split" 요청에서만 실행되며, 기본값인 orient="pv" 요청에서는 no-op 이다 — 비중이 필요하면 반드시 orient="split" 을 함께 지정해야 한다. 레거시 호환을 위해 *_per measure 요청 자체는 orient 와 무관하게 여전히 200 을 반환하지만 동작이 orient 별로 다르다: orient="pv" 는 base/total 값에서 재구성한 실값으로 응답하고, orient="split" 은 measures/meta_data/columns/data 에서 조용히 drop 한다. 신규 호출에는 percentage_by 사용을 권장한다 — *_per 는 deprecated. 단, percentage_by 의 분모는 파티션 내 각 행의 절대값을 더한 값(x.abs().sum())이고 레거시 *_per 는 부호 있는 SUM(x) 기준이라, 파티션 내에 부호가 섞인(음수 per-group 행이 하나라도 있는) 경우 두 값이 갈릴 수 있다 — 파티션 합 자체가 양수여도 발생할 수 있다(예: [+100,-40,+60], 합계 120>0 이어도 abs 분모와 signed 분모가 달라짐). 응답은 split-pivot shape (index / columns / data 행렬).
Examples:
Q: 2024년 4분기 첫 구매와 재구매 비중, 구매 횟수별 매출과 객단가를 알려줘 params: {'body': {'freq': '-', 'data_source': 'commerce_order', 'date_filters': {'start_date_id': '2024-10-01', 'end_date_id': '2024-12-31'}, 'view_option': 'num_of_purchase_type', 'index_dimensions': ['num_of_purchase_type'], 'pivot_dimensions': [], 'measures': ['sales', 'pay_cnt', 'aov'], 'rank_method': 'history', 'num_of_count_type': 'any', 'n': 20}}
Related resources: analytics://overview, analytics://schema/data_source
Output shape: split-shape JSON: { index: [...], columns: [...], data: ..., dimensions, index_dimensions, pivot_dimensions, measures, meta_data, masked_columns, source_match_columns }
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"project-id": "<project-id>",
"date_filters": "<date_filters>"
},
"name": "run_num_of_purchases_analysis"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | 최대 구매 회차 (1..50) | |
| std | No | since_time 상한 (기준값) | |
| freq | No | 시간 빈도 (-, days, weeks, months, quarters, years) | days |
| orient | No | 응답 포맷: pv(레거시 피벗 호환, 기본) / split(커스텀 대시보드). percentage_by/distance_by 파생 컬럼 후처리는 orient=split 에서만 동작하며, 기본값 pv 에서는 no-op 이다. legacy `<base>_per` 요청도 orient 에 따라 동작이 다르다: pv 는 base/total 에서 값을 재구성해 응답하고, split 은 조용히 drop 한다. 출력 `time_id` 라벨 포맷도 orient 에 따라 다르다: split 은 acc(freq='-') 를 제외한 모든 freq 에서 default analytics 와 같은 밀리초 타임스탬프 라벨 'YYYY-MM-DD HH:MM:SS.mmm' 을 내리고(acc 는 리터럴 '-' 유지), pv 는 레거시 freq별 모양을 그대로 유지한다(years=bigint 2026, quarters='2026-Q1', months/weeks/days='YYYY-MM-DD'). | pv |
| filters | No | default analytics 와 동일한 ExpressionTree(JSON) 필터. 모든 연산자 (IN/EQ/포함/비교 등)를 raw 스캔 WHERE 로 적용한다(집계 전). | |
| measures | No | 측정 지표 목록. dashboard/meta/v1 등록 measure(또는 그 _per 비율 파생)만 허용되며, 미등록 식별자는 HTTP 400 으로 거부된다(validation.py allowlist — SQL injection 방어). sales 강제 포함 | |
| project-id | Yes | ||
| data_source | No | 데이터 소스 (commerce_order / commerce_item_order) | commerce_order |
| distance_by | No | 사분면/버블 x/y 축 measure. 그 외 차트타입은 빈 목록. | |
| is_refunded | No | 환불/취소 주문 제외 여부 (exemption=제외(기본) / inclusion=포함) | exemption |
| rank_method | No | N회차 회차집계 (history / freq) | history |
| view_option | No | 분석 기준 힌트 (advisory-only, 서버 side-effect 없음). 실제 분석 기준은 index_dimensions 또는 pivot_dimensions 에 'num_of_purchase_type'(첫구매/재구매) 또는 'num_of_purchases'(N회차) 파생 차원 문자열을 직접 포함시켜야 결정된다. | num_of_purchase_type |
| date_filters | Yes | 조회 기간 | |
| distance_from | No | 사분면/버블 거리 기준 집계 (average/median). 그 외 차트타입은 빈 목록. | |
| percentage_by | No | 파레토 누적%/ABC 그룹 기준 measure. 그 외 차트타입은 빈 목록. orient=split 요청에서만 적용되며, 기본값 orient=pv 에서는 no-op 이다. | |
| max_date_range | No | 날짜 필터 무시 (전체 범위) 여부 | |
| num_of_count_by | No | A→A 의 기준 차원(A). 미전송이면 요청 차원에서 파생 차원을 제외해 추론(deprecated). a_a 와 함께 빈 배열을 보내면 400. | |
| since_time_type | No | since_time 축 유형 | rolling |
| index_dimensions | No | pivot 행 축 (index_dimensions) | |
| pivot_dimensions | No | pivot 열 축 / 분석 단위 / BreakDown (pivot_dimensions) | |
| pop_date_filters | No | 직전 대비(PoP) 비교 기간. default DashboardRequest 와 동형. orient=split 요청에서만 prev_/prev_diff_/pct_change_ 파생 컬럼을 만든다. 최대 5개까지 허용한다 — 항목마다 이전 기간 STAT 쿼리가 한 번씩 추가로 실행되므로 무제한 허용 시 쿼리가 증폭된다. | |
| time_series_type | No | 시계열 기준 | date_range |
| num_of_count_type | No | 재구매 판단조건 (any / a_a) | any |
| num_of_purchase_type_filter | No | 첫구매/재구매 세그먼트 필터 (관점 셀렉터). None=전체 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||