segment-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSegment Automation via Rube MCP
通过Rube MCP实现Segment自动化
Automate Segment customer data platform operations through Composio's Segment toolkit via Rube MCP.
通过Composio的Segment工具包,借助Rube MCP自动化Segment客户数据平台的操作。
Prerequisites
前提条件
- Rube MCP must be connected (RUBE_SEARCH_TOOLS available)
- Active Segment connection via with toolkit
RUBE_MANAGE_CONNECTIONSsegment - Always call first to get current tool schemas
RUBE_SEARCH_TOOLS
- 必须已连接Rube MCP(需提供RUBE_SEARCH_TOOLS)
- 通过激活Segment连接,工具包为
RUBE_MANAGE_CONNECTIONSsegment - 请始终先调用以获取当前工具架构
RUBE_SEARCH_TOOLS
Setup
设置步骤
Get Rube MCP: Add as an MCP server in your client configuration. No API keys needed — just add the endpoint and it works.
https://rube.app/mcp- Verify Rube MCP is available by confirming responds
RUBE_SEARCH_TOOLS - Call with toolkit
RUBE_MANAGE_CONNECTIONSsegment - If connection is not ACTIVE, follow the returned auth link to complete Segment authentication
- Confirm connection status shows ACTIVE before running any workflows
获取Rube MCP:在客户端配置中添加作为MCP服务器。无需API密钥——只需添加端点即可使用。
https://rube.app/mcp- 确认能正常响应,以此验证Rube MCP是否可用
RUBE_SEARCH_TOOLS - 调用,指定工具包为
RUBE_MANAGE_CONNECTIONSsegment - 如果连接未处于ACTIVE状态,请按照返回的认证链接完成Segment身份验证
- 在运行任何工作流之前,确认连接状态显示为ACTIVE
Core Workflows
核心工作流
1. Track Events
1. 跟踪事件
When to use: User wants to send event data to Segment for downstream destinations
Tool sequence:
- - Send a single track event [Required]
SEGMENT_TRACK
Key parameters:
- : User identifier (required if no
userId)anonymousId - : Anonymous identifier (required if no
anonymousId)userId - : Event name (e.g., 'Order Completed', 'Button Clicked')
event - : Object with event-specific properties
properties - : ISO 8601 timestamp (optional; defaults to server time)
timestamp - : Object with contextual metadata (IP, user agent, etc.)
context
Pitfalls:
- At least one of or
userIdis requiredanonymousId - name is required and should follow consistent naming conventions
event - Properties are freeform objects; ensure consistent schema across events
- Timestamp must be ISO 8601 format (e.g., '2024-01-15T10:30:00Z')
- Events are processed asynchronously; successful API response means accepted, not delivered
适用场景:用户需要将事件数据发送至Segment,以供下游目标系统使用
工具流程:
- - 发送单个跟踪事件 [必填]
SEGMENT_TRACK
关键参数:
- : 用户标识符(若未提供
userId则为必填)anonymousId - : 匿名用户标识符(若未提供
anonymousId则为必填)userId - : 事件名称(例如:'Order Completed'、'Button Clicked')
event - : 包含事件特定属性的对象
properties - : ISO 8601格式时间戳(可选;默认使用服务器时间)
timestamp - : 包含上下文元数据的对象(IP、用户代理等)
context
注意事项:
- 必须提供或
userId中的至少一个anonymousId - 名称为必填项,且应遵循统一的命名规范
event - 属性为自由格式对象;需确保不同事件间的架构一致性
- 时间戳必须为ISO 8601格式(例如:'2024-01-15T10:30:00Z')
- 事件为异步处理;API响应成功仅表示事件已被接收,不代表已送达目标系统
2. Identify Users
2. 识别用户
When to use: User wants to associate traits with a user profile in Segment
Tool sequence:
- - Set user traits and identity [Required]
SEGMENT_IDENTIFY
Key parameters:
- : User identifier (required if no
userId)anonymousId - : Anonymous identifier
anonymousId - : Object with user properties (email, name, plan, etc.)
traits - : ISO 8601 timestamp
timestamp - : Contextual metadata
context
Pitfalls:
- At least one of or
userIdis requiredanonymousId - Traits are merged with existing traits, not replaced
- To remove a trait, set it to
null - Identify calls should be made before track calls for new users
- Avoid sending PII in traits unless destinations are configured for it
适用场景:用户需要将用户特征关联至Segment中的用户档案
工具流程:
- - 设置用户特征与身份 [必填]
SEGMENT_IDENTIFY
关键参数:
- : 用户标识符(若未提供
userId则为必填)anonymousId - : 匿名用户标识符
anonymousId - : 包含用户属性的对象(邮箱、姓名、套餐等)
traits - : ISO 8601格式时间戳
timestamp - : 上下文元数据
context
注意事项:
- 必须提供或
userId中的至少一个anonymousId - 用户特征会与现有特征合并,而非替换
- 若要删除某个特征,需将其值设为
null - 对于新用户,应先调用IDENTIFY再调用TRACK
- 除非目标系统已配置支持,否则请勿在特征中发送个人可识别信息(PII)
3. Batch Operations
3. 批量操作
When to use: User wants to send multiple events, identifies, or other calls in a single request
Tool sequence:
- - Send multiple Segment calls in one request [Required]
SEGMENT_BATCH
Key parameters:
- : Array of message objects, each with:
batch- : Message type ('track', 'identify', 'group', 'page', 'alias')
type - /
userId: User identifieranonymousId - Additional fields based on type (event, properties, traits, etc.)
Pitfalls:
- Each message in the batch must have a valid field
type - Maximum batch size limit applies; check schema for current limit
- All messages in a batch are processed independently; one failure does not affect others
- Each message must independently satisfy its type's requirements (e.g., track needs event name)
- Batch is the most efficient way to send multiple calls; prefer over individual calls
适用场景:用户需要在单个请求中发送多个事件、识别请求或其他调用
工具流程:
- - 在一个请求中发送多个Segment调用 [必填]
SEGMENT_BATCH
关键参数:
- : 消息对象数组,每个对象包含:
batch- : 消息类型('track'、'identify'、'group'、'page'、'alias')
type - /
userId: 用户标识符anonymousId - 基于类型的其他字段(event、properties、traits等)
注意事项:
- 批量中的每条消息必须包含有效的字段
type - 存在最大批量大小限制;请查看架构获取当前限制
- 批量中的所有消息独立处理;某条消息失败不会影响其他消息
- 每条消息必须独立满足其类型的要求(例如:track类型需要event名称)
- 批量操作是发送多个调用的最高效方式;优先使用批量而非单个调用
4. Group Users
4. 用户群组管理
When to use: User wants to associate a user with a company, team, or organization
Tool sequence:
- - Associate user with a group [Required]
SEGMENT_GROUP
Key parameters:
- : User identifier (required if no
userId)anonymousId - : Anonymous identifier
anonymousId - : Group/organization identifier (required)
groupId - : Object with group properties (name, industry, size, plan)
traits - : ISO 8601 timestamp
timestamp
Pitfalls:
- is required; it identifies the company or organization
groupId - Group traits are merged with existing traits for that group
- A user can belong to multiple groups
- Group traits update the group profile, not the user profile
适用场景:用户需要将用户与公司、团队或组织关联
工具流程:
- - 将用户与群组关联 [必填]
SEGMENT_GROUP
关键参数:
- : 用户标识符(若未提供
userId则为必填)anonymousId - : 匿名用户标识符
anonymousId - : 群组/组织标识符(必填)
groupId - : 包含群组属性的对象(名称、行业、规模、套餐)
traits - : ISO 8601格式时间戳
timestamp
注意事项:
- 为必填项;用于标识公司或组织
groupId - 群组特征会与该群组的现有特征合并
- 一个用户可属于多个群组
- 群组特征会更新群组档案,而非用户档案
5. Track Page Views
5. 页面浏览跟踪
When to use: User wants to record page view events in Segment
Tool sequence:
- - Send a page view event [Required]
SEGMENT_PAGE
Key parameters:
- : User identifier (required if no
userId)anonymousId - : Anonymous identifier
anonymousId - : Page name (e.g., 'Home', 'Pricing', 'Dashboard')
name - : Page category (e.g., 'Docs', 'Marketing')
category - : Object with page-specific properties (url, title, referrer)
properties
Pitfalls:
- At least one of or
userIdis requiredanonymousId - and
nameare optional but recommended for proper analyticscategory - Standard properties include ,
url,title,referrer,pathsearch - Page calls are often automated; manual use is for server-side page tracking
适用场景:用户需要在Segment中记录页面浏览事件
工具流程:
- - 发送页面浏览事件 [必填]
SEGMENT_PAGE
关键参数:
- : 用户标识符(若未提供
userId则为必填)anonymousId - : 匿名用户标识符
anonymousId - : 页面名称(例如:'Home'、'Pricing'、'Dashboard')
name - : 页面分类(例如:'Docs'、'Marketing')
category - : 包含页面特定属性的对象(url、title、referrer)
properties
注意事项:
- 必须提供或
userId中的至少一个anonymousId - 和
name为可选,但推荐使用以确保分析准确性category - 标准属性包括、
url、title、referrer、pathsearch - 页面调用通常为自动触发;手动调用适用于服务器端页面跟踪
6. Alias Users and Manage Sources
6. 用户别名设置与源管理
When to use: User wants to merge anonymous and identified users, or manage source configuration
Tool sequence:
- - Link two user identities together [Optional]
SEGMENT_ALIAS - - View source schema settings [Optional]
SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCE - - Update source configuration [Optional]
SEGMENT_UPDATE_SOURCE
Key parameters:
- For ALIAS:
- : New user identifier (the identified ID)
userId - : Old user identifier (the anonymous ID)
previousId
- For source operations:
- : Source identifier
sourceId
Pitfalls:
- ALIAS is a one-way operation; cannot be undone
- is the anonymous/old ID,
previousIdis the new/identified IDuserId - Not all destinations support alias calls; check destination documentation
- ALIAS should be called once when a user first identifies (e.g., signs up)
- Source updates may affect data collection; review changes carefully
适用场景:用户需要合并匿名与已识别用户,或管理源配置
工具流程:
- - 关联两个用户身份 [可选]
SEGMENT_ALIAS - - 查看源架构设置 [可选]
SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCE - - 更新源配置 [可选]
SEGMENT_UPDATE_SOURCE
关键参数:
- 对于ALIAS:
- : 新用户标识符(已识别的ID)
userId - : 旧用户标识符(匿名ID)
previousId
- 对于源操作:
- : 源标识符
sourceId
注意事项:
- ALIAS为单向操作;无法撤销
- 为匿名/旧ID,
previousId为新/已识别IDuserId - 并非所有目标系统都支持alias调用;请查看目标系统文档
- 应在用户首次识别(例如注册)时调用一次ALIAS
- 源配置更新可能影响数据收集;请仔细审核更改内容
Common Patterns
常见模式
User Lifecycle
用户生命周期
Standard Segment user lifecycle:
1. Anonymous user visits -> PAGE call with anonymousId
2. User interacts -> TRACK call with anonymousId
3. User signs up -> ALIAS (anonymousId -> userId), then IDENTIFY with traits
4. User takes action -> TRACK call with userId
5. User joins org -> GROUP call linking userId to groupId标准Segment用户生命周期:
1. Anonymous user visits -> PAGE call with anonymousId
2. User interacts -> TRACK call with anonymousId
3. User signs up -> ALIAS (anonymousId -> userId), then IDENTIFY with traits
4. User takes action -> TRACK call with userId
5. User joins org -> GROUP call linking userId to groupIdBatch Optimization
批量优化
For bulk data ingestion:
1. Collect events in memory (array of message objects)
2. Each message includes type, userId/anonymousId, and type-specific fields
3. Call SEGMENT_BATCH with the collected messages
4. Check response for any individual message errors对于批量数据导入:
1. Collect events in memory (array of message objects)
2. Each message includes type, userId/anonymousId, and type-specific fields
3. Call SEGMENT_BATCH with the collected messages
4. Check response for any individual message errorsNaming Conventions
命名规范
Segment recommends consistent event naming:
- Events: Use "Object Action" format (e.g., 'Order Completed', 'Article Viewed')
- Properties: Use snake_case (e.g., 'order_total', 'product_name')
- Traits: Use snake_case (e.g., 'first_name', 'plan_type')
Segment推荐统一的命名规范:
- Events: 使用"Object Action"格式(例如:'Order Completed'、'Article Viewed')
- Properties: 使用蛇形命名法(snake_case,例如:'order_total'、'product_name')
- Traits: 使用蛇形命名法(例如:'first_name'、'plan_type')
Known Pitfalls
已知注意事项
Identity Resolution:
- Always include or
userIdon every callanonymousId - Use ALIAS only once per user identity merge
- Identify before tracking to ensure proper user association
Data Quality:
- Event names should be consistent across all sources
- Properties should follow a defined schema for downstream compatibility
- Avoid sending sensitive PII unless destinations are configured for it
Rate Limits:
- Use BATCH for bulk operations to stay within rate limits
- Individual calls are rate-limited per source
- Batch calls are more efficient and less likely to be throttled
Response Parsing:
- Successful responses indicate acceptance, not delivery to destinations
- Response data may be nested under key
data - Check for error fields in batch responses for individual message failures
Timestamps:
- Must be ISO 8601 format with timezone (e.g., '2024-01-15T10:30:00Z')
- Omitting timestamp uses server receive time
- Historical data imports should include explicit timestamps
身份解析:
- 每个调用必须包含或
userIdanonymousId - 每个用户身份合并仅调用一次ALIAS
- 先调用IDENTIFY再调用TRACK,以确保正确的用户关联
数据质量:
- 事件名称应在所有源中保持一致
- 属性应遵循定义的架构,以确保下游兼容性
- 除非目标系统已配置支持,否则请勿发送敏感的个人可识别信息(PII)
速率限制:
- 使用BATCH进行批量操作,以避免超出速率限制
- 单个调用的速率限制基于每个源
- 批量调用效率更高,更不容易被限流
响应解析:
- 响应成功仅表示事件已被接收,不代表已送达目标系统
- 响应数据可能嵌套在键下
data - 检查批量响应中的错误字段,以查看单个消息是否失败
时间戳:
- 必须为带时区的ISO 8601格式(例如:'2024-01-15T10:30:00Z')
- 若省略时间戳,则使用服务器接收时间
- 历史数据导入应包含明确的时间戳
Quick Reference
快速参考
| Task | Tool Slug | Key Params |
|---|---|---|
| Track event | SEGMENT_TRACK | userId, event, properties |
| Identify user | SEGMENT_IDENTIFY | userId, traits |
| Batch calls | SEGMENT_BATCH | batch (array of messages) |
| Group user | SEGMENT_GROUP | userId, groupId, traits |
| Page view | SEGMENT_PAGE | userId, name, properties |
| Alias identity | SEGMENT_ALIAS | userId, previousId |
| Source schema | SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCE | sourceId |
| Update source | SEGMENT_UPDATE_SOURCE | sourceId |
| Warehouses | SEGMENT_LIST_CONNECTED_WAREHOUSES_FROM_SOURCE | sourceId |
| 任务 | 工具标识 | 关键参数 |
|---|---|---|
| 跟踪事件 | SEGMENT_TRACK | userId, event, properties |
| 识别用户 | SEGMENT_IDENTIFY | userId, traits |
| 批量调用 | SEGMENT_BATCH | batch (数组形式的消息对象) |
| 用户群组关联 | SEGMENT_GROUP | userId, groupId, traits |
| 页面浏览跟踪 | SEGMENT_PAGE | userId, name, properties |
| 身份别名设置 | SEGMENT_ALIAS | userId, previousId |
| 查看源架构设置 | SEGMENT_LIST_SCHEMA_SETTINGS_IN_SOURCE | sourceId |
| 更新源配置 | SEGMENT_UPDATE_SOURCE | sourceId |
| 查看关联数据仓库 | SEGMENT_LIST_CONNECTED_WAREHOUSES_FROM_SOURCE | sourceId |