<aside>
📍 For Segment Protocols users, we recommend managing tracking plan(s) as code
along with in any templated dbt packages in a Reflekt project, version controlled in a GitHub repository.
</aside>
Using Reflekt, you can continue to leverage Segment Protocols event validation, but are now able to develop and manage tracking plans using software engineering principles (version control, branches, pull requests, reviews, and CI/CD).
- version: 1
name: Example Event
description: This is an example event.
properties:
- name: existing_property
description: A property already tracked on product.
type: integer
required: true
- name: new_property # Adding a new property is simple!
description: A new property I am adding to be tracked.
type: string
required: false
test-plans.yml
(click to expand example)reflekt push --name my-plan
.
sync-plans.yml
(click to expand example)Run reflekt dbt --name my-plan --schema my_app_web
to template a Reflekt dbt package that models and documents the events in your tracking plan code.
Push your changes to the GitHub repo where your Reflekt project is saved.
Open a pull request to merge your templated Reflekt dbt package (e.g. reflekt_my_project
) to your main branch. Request a review from team. Merge to the main branch when approved.
In your dbt project, reference the Reflekt dbt package.
# packages.yml in your dbt project
packages:
- package: dbt-labs/dbt_utils
version: 0.8.5
- git: "<https://github.com/my-github-user/reflekt-my-project>"
subdirectory: "dbt-packages/reflekt_my_project"
revision: v0.1.0__reflekt_my_project # Git tag created by 'reflekt dbt'
Run dbt deps
in your dbt project to pull your Reflekt dbt package from GitHub.
❯ dbt deps
00:44:53 Running with dbt=1.1.0
00:45:01 Installing dbt-labs/dbt_utils
00:45:02 Installed from version 0.8.5
00:45:02 Updated version available: 0.8.6
00:45:02 Installing <https://github.com/my-github-user/reflekt-my-project>
00:45:04 Installed from revision v0.1.0__reflekt_my_project
00:45:04 and subdirectory dbt-packages/reflekt_my_project
Use the models from your Reflekt dbt package in your dbt project!
-- daily_orders.sql
{{
config(
materialized = 'view',
)
}}
with
reflekt_pkg_model as (
select * from {{ ref('reflekt_my_app_web__order_completed') }}
),
final as (
select
tstamp::date as date_day,
count(*) as count_orders
from reflekt_pkg_model
group by 1
)
select * from final