Appearance
Group Schema ​
Groups represent entities that can be associated with events, such as users or teams.
Configuration ​
Group ​
Field | Type | Required | Description |
---|---|---|---|
name | string | yes | Group name |
description | string | no | Group context description |
identifiedBy | string | no | Identifying property |
passthrough | boolean | no | Allow arbitrary properties |
properties | Property[] | no | Group properties |
Example ​
yaml
groups:
- name: User
description: The user that triggered the event.
identifiedBy: UserID
properties:
- name: UserID
description: The ID of the user.
type: number
- name: Role
description: The user's role.
type: [admin, member]
- name: Team
description: The team of the user.
identifiedBy: TeamID
properties:
- name: TeamID
description: The team's ID.
type: number
- name: Plan
description: The team's subscription plan.
type: [FREE, TRIAL, PAID]
Using Groups ​
Groups are strictly typed stateful buckets of properties.
Groups represent entities like users or teams. Or they can represent properties that you want to track with every event.
Group properties can be set independently of events, and are included in the onEventTracked
callback.
typescript
import { createAnalyticsTracker } from 'voltage-schema';
import { AnalyticsSchema, trackingConfig } from './__analytics_generated__/analytics';
const tracker = createAnalyticsTracker<AnalyticsSchema>(trackingConfig, {
onEventTracked: (eventName, { properties, groups, meta }) => {
// Send event with group properties
},
onGroupUpdated: (groupName, properties) => {
// Update group traits
}
});
// Set user properties
tracker.setProperties('User', {
UserID: 123,
Role: 'admin'
});
// Set team properties
tracker.setProperties('Team', {
TeamID: 456,
Plan: 'PAID'
});
View our global properties doc for information on how to auto-track properties with every event.