Reuse Event Rules across Tracking Plans using Includes
Alpha
Share event rules across Tracking Plans by using the experimental includes feature in Rudder CLI.
5 minute read
Experimental feature
includes is an experimental feature that is disabled by default. You must explicitly opt in by enabling experimental mode and the eventRuleIncludes flag before you can use it. Experimental features are functional but can change or be removed in future releases, so avoid relying on them in production workflows.
This guide shows you how to share event rules between Tracking Plans using the experimental includes feature in Rudder CLI.
Overview
The includes directive lets a Tracking Plan inherit event rules from another Tracking Plan. This eliminates duplication when multiple plans share common rules.
When you apply your project, Rudder CLI:
Expands each includes reference
Pulls in the matching event_rule entries from the referenced Tracking Plan
Merges them into the current plan before pushing to RudderStack
The resulting Tracking Plan behaves exactly as if those rules had been defined inline.
Compatibility
Spec version
Supported
rudder/v0.1 (kind: tp)
Yes
rudder/v1 (kind: tracking-plan)
No
If you use includes in a rudder/v1 (kind: tracking-plan) spec, Rudder CLI rejects validation with:
error[datacatalog/tracking-plans/spec-syntax-valid]: includes is not supported for tracking-plan v1 event rules
This is the most durable option for local development, since the setting persists across sessions.
Experimental mode must be on before the experimental subcommands will run. Enable it via the config file (above) or by exporting RUDDERSTACK_CLI_EXPERIMENTAL=true, then enable the flag:
rudder-cli experimental enable eventRuleIncludes
Verify that the flag is enabled:
rudder-cli experimental list
The output lists eventRuleIncludes as enabled.
Use environment variables in CI/CD pipelines or non-interactive shells:
All experimental settings default to false and require explicit opt-in. Experimental-flag environment variables take the form RUDDERSTACK_X_<FLAG_NAME>, where the flag name is converted to upper snake case (eventRuleIncludes → RUDDERSTACK_X_EVENT_RULE_INCLUDES).
Reference syntax
To include event rules from another Tracking Plan, add a rule with an includes block instead of an event block. The $ref value follows this pattern:
#/tp/<tracking-plan-id>/event_rule/<rule-id-or-*>
Pattern
Meaning
#/tp/common-rules-plan/event_rule/*
Include all event rules from common-rules-plan.
#/tp/common-rules-plan/event_rule/identify-rule
Include only the identify-rule from common-rules-plan.
Where:
<tracking-plan-id> is the id of the Tracking Plan whose event rules you want to reuse. It must exist in the same project (same Data Catalog directory) and must also use the rudder/v0.1 spec.
<rule-id-or-*> is the id of a specific event rule, or * to include every event rule from the referenced plan.
Include all event rules
Use the * wildcard to inherit every event rule defined in another Tracking Plan. In the example below, the crm-plan plan includes all rules from common-rules-plan alongside its own rule:
This includes only the identify-rule from common-rules-plan.
Avoid including the same event into a plan more than once — whether directly or through an includes reference. Rudder CLI flags duplicate events introduced via includes during validation.
Constraints
A rule can have eithereventorincludes, not both. Specifying both fails validation with event and includes cannot be specified together; specifying neither fails with event or includes is required.
An includes-only rule does not need an event field — the event is inherited from the referenced plan.
The $ref value must match the pattern #/tp/<id>/event_rule/<id-or-*>, where IDs contain only alphanumeric characters, hyphens, and underscores. A malformed reference fails validation with '$ref' is not valid: must be of pattern #/tp/<group>/event_rule/<id-or-*>.
Validate and deploy
Validate and deploy plans that use includes exactly as you would any other Tracking Plan. Make sure experimental mode and the eventRuleIncludes flag are enabled in the same environment that runs these commands.
Validate your definitions:
rudder-cli validate -l ~/tutorial-catalog
Review the changes before deploying:
rudder-cli apply -l ~/tutorial-catalog --dry-run
Deploy the validated Tracking Plans:
rudder-cli apply -l ~/tutorial-catalog
Use includes in CI/CD
In CI/CD environments, enable experimental mode and the flag with environment variables instead of interactive commands.
jobs:apply:runs-on:ubuntu-latestenv:RUDDERSTACK_CLI_EXPERIMENTAL:"true"RUDDERSTACK_X_EVENT_RULE_INCLUDES:"true"RUDDERSTACK_ACCESS_TOKEN:${{ secrets.RUDDERSTACK_ACCESS_TOKEN }}steps:- uses:actions/checkout@v4# ... install Rudder CLI, then validate and apply
This site uses cookies to improve your experience while you navigate through the website. Out of
these
cookies, the cookies that are categorized as necessary are stored on your browser as they are as
essential
for the working of basic functionalities of the website. We also use third-party cookies that
help
us
analyze and understand how you use this website. These cookies will be stored in your browser
only
with
your
consent. You also have the option to opt-out of these cookies. But opting out of some of these
cookies
may
have an effect on your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This
category only includes cookies that ensures basic functionalities and security
features of the website. These cookies do not store any personal information.
This site uses cookies to improve your experience. If you want to
learn more about cookies and why we use them, visit our cookie
policy. We'll assume you're ok with this, but you can opt-out if you wish Cookie Settings.