Skip to content

Commit

Permalink
Merge pull request #104 from fivetran/feature/email-event-filter
Browse files Browse the repository at this point in the history
feature/email-event-filter
  • Loading branch information
fivetran-catfritz authored May 3, 2023
2 parents e5326f9 + ea23b2d commit ac3846b
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 46 deletions.
4 changes: 3 additions & 1 deletion .buildkite/scripts/run_models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ dbt run --vars '{hubspot_marketing_enabled: true, hubspot_sales_enabled: false}'
dbt run --vars '{hubspot_marketing_enabled: true, hubspot_contact_merge_audit_enabled: true, hubspot_sales_enabled: false}' --target "$db"
dbt run --vars '{hubspot_marketing_enabled: false, hubspot_sales_enabled: true}' --target "$db"
dbt run --vars '{hubspot_marketing_enabled: false, hubspot_sales_enabled: false}' --target "$db"
dbt run --vars '{hubspot__pass_through_all_columns: true, hubspot_service_enabled: true}' --target "$db"
dbt run --vars '{hubspot__pass_through_all_columns: true, hubspot_service_enabled: true, hubspot_using_all_email_events: false}' --target "$db"
dbt test --target "$db"

dbt run-operation fivetran_utils.drop_schemas_automation --target "$db"
51 changes: 51 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/maintainer_pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## PR Overview
**This PR will address the following Issue/Feature:**

**This PR will result in the following new package version:**
<!--- Please add details around your decision for breaking vs non-breaking version upgrade. If this is a breaking change, were backwards-compatible options explored? -->

**Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:**

## PR Checklist
### Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
- [ ] dbt compile
- [ ] dbt run –full-refresh
- [ ] dbt run
- [ ] dbt test
- [ ] dbt run –vars (if applicable)

Before marking this PR as "ready for review" the following have been applied:
- [ ] The appropriate issue has been linked and tagged
- [ ] You are assigned to the corresponding issue and this PR
- [ ] BuildKite integration tests are passing

### Detailed Validation
Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":
- [ ] You have validated these changes and assure this PR will address the respective Issue/Feature.
- [ ] You are reasonably confident these changes will not impact any other components of this package or any dependent packages.
- [ ] You have provided details below around the validation steps performed to gain confidence in these changes.
<!--- Provide the steps you took to validate your changes below. -->

### Standard Updates
Please acknowledge that your PR contains the following standard updates:
- Package versioning has been appropriately indexed in the following locations:
- [ ] indexed within dbt_project.yml
- [ ] indexed within integration_tests/dbt_project.yml
- [ ] CHANGELOG has individual entries for each respective change in this PR
<!--- If there is a parallel upstream change, remember to reference the corresponding CHANGELOG as an individual entry. -->
- [ ] README updates have been applied (if applicable)
<!--- Remember to check the following README locations for common updates. →
<!--- Suggested install range (needed for breaking changes) →
<!--- Dependency matrix is appropriately updated (if applicable) →
<!--- New variable documentation (if applicable) -->
- [ ] DECISIONLOG updates have been updated (if applicable)
- [ ] Appropriate yml documentation has been added (if applicable)

### dbt Docs
Please acknowledge that after the above were all completed the below were applied to your branch:
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)

### If you had to summarize this PR in an emoji, which would it be?
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:
51 changes: 16 additions & 35 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,33 @@
**Are you a current Fivetran customer?**
<!--- Please tell us your name, title and company -->
**Please provide your name and company**

**What change(s) does this PR introduce?**
<!--- Describe what changes your PR introduces to the package and how to leverage this new feature. -->
**Link the issue/feature request which this PR is meant to address**
<!--- If an issue was not created, please create one first so we may discuss the PR prior to opening one. -->

**Did you update the CHANGELOG?**
**Detail what changes this PR introduces and how this addresses the issue/feature request linked above.**

**How did you validate the changes introduced within this PR?**

**Which warehouse did you use to develop these changes?**

**Did you update the CHANGELOG?**
<!--- Please update the new package version’s CHANGELOG entry detailing the changes included in this PR. -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes

**Does this PR introduce a breaking change?**
<!--- Does this PR introduce changes that will cause current package users' jobs to fail or require a `--full-refresh`? -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes (please provide breaking change details below.)
- [ ] No (please provide an explanation as to how the change is non-breaking below.)

**Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)**
**Did you update the dbt_project.yml files with the version upgrade (please leverage standard semantic versioning)? (In both your main project and integration_tests)**
<!--- The dbt_project.yml and the integration_tests/dbt_project.yml files contain the version number. Be sure to upgrade it accordingly -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes

**Is this PR in response to a previously created Bug or Feature Request**
<!--- If an Issue was created it is helpful to track the progress by linking it in the PR. -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Yes, Issue/Feature [link bug/feature number here]
- [ ] No

**How did you test the PR changes?**
<!--- Proof of testing is required in order for the PR to be approved. -->
<!--- To check a box, remove the space and insert an x in the box (eg. [x] Buildkite). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] Buildkite <!--- Buildkite testing is only applicable to Fivetran employees. -->
- [ ] Local (please provide additional testing details below)

**Select which warehouse(s) were used to test the PR**
<!--- To check a warehouse remove the space and insert an x in the box (eg. [x] Bigquery). -->
<!--- To select a checkbox you simply need to add an "x" with no spaces between the brackets (eg. [x] Yes). -->
- [ ] BigQuery
- [ ] Redshift
- [ ] Snowflake
- [ ] Postgres
- [ ] Databricks
- [ ] Other (provide details below)

**Provide an emoji that best describes your current mood**
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:

**Feedback**

We are so excited you decided to contribute to the Fivetran community dbt package! We continue to work to improve the packages and would greatly appreciate your [feedback](https://www.surveymonkey.com/r/DQ7K7WW) on our existing dbt packages or what you'd like to see next.

**PR Template**
- [Community Pull Request Template](?expand=1&template=pull_request_template.md) (default)

- [Maintainer Pull Request Template](?expand=1&template=maintainer_pull_request_template.md) (to be used by maintainers)
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# dbt_hubspot_source v0.9.1
## Feature Updates
- A new variable was added `hubspot_using_all_email_events` to allow package users to remove filtered email events from the `stg_hubspot__email_event` staging model as well as the relevant downstream reporting models. This is crucial for HubSpot users who greatly take advantage of marking events as filtered in order to provide accurate reporting. ([PR #104](https://github.com/fivetran/dbt_hubspot_source/pull/104))
- The `hubspot_using_all_email_events` variable is `true` by default. Set the variable to `false` to filter out specified email events in your staging and downstream models.

## Under the Hood
- The `email_event_data.csv` seed file was updated to include events that are listed as `true` for filtered_events. This is to effectively test the above mentioned feature update. ([PR #104](https://github.com/fivetran/dbt_hubspot_source/pull/104))
- Included `hubspot_using_all_email_events: false` as a variable declared in the final `run_models.sh` step to ensure our integration tests gain coverage over this new feature and variable. ([PR #104](https://github.com/fivetran/dbt_hubspot_source/pull/104))
- Incorporated the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job. ([PR #103](https://github.com/fivetran/dbt_hubspot_source/pull/103))
- Updated the pull request [templates](/.github). ([PR #103](https://github.com/fivetran/dbt_hubspot_source/pull/103))

# dbt_hubspot_source v0.9.0

## 🚨 Breaking Changes 🚨
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ vars:
- name: "ticket_calculated_field"
transform_sql: "total_field / other_total_field"
```
### Filter email events
When leveraging email events, HubSpot customers may take advantage of filtering out specified email events. These filtered email events are present within the `stg_hubspot__email_events` model and are identified by the `is_filtered_event` boolean field. By default, these events are included in the staging and downstream models generated from this package. However, if you wish to remove these filtered events you may do so by setting the `hubspot_using_all_email_events` variable to false. See below for exact configurations you may provide in your `dbt_project.yml` file:
```yml
vars:
hubspot_using_all_email_events: false # True by default
```

### Change the build schema
By default, this package builds the hubspot staging models within a schema titled (`<target_schema>` + `_stg_hubspot`) in your destination. If this is not where you would like your hubspot staging data to be written to, add the following configuration to your root `dbt_project.yml` file:
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'hubspot_source'
version: '0.9.0'
version: '0.9.1'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/run_results.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'hubspot_source_integration_tests'
version: '0.9.0'
version: '0.9.1'
profile: 'integration_tests'
config-version: 2
models:
Expand Down
6 changes: 3 additions & 3 deletions integration_tests/seeds/email_event_data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ c4337695-9d10-4bd1-89fe-d468407f28e3,2020-03-16 19:01:11.602,2286,,,2020-03-16 1
a9d93225-97e4-35b0-ae48-cef5c5d96d7a,2020-03-16 19:01:11.598,2286,,,2020-03-16 19:00:50.059,2,,,4727653,2020-03-16 19:00:48.934,c4337695-9d10-4bd1-89fe-d468407f28e3,DELIVERED,,o2wjpPyUfzBfq9OSt9I2NQ==
d1be99bb-0102-321a-829e-0ea6efbaf477,2020-03-16 19:01:11.610,2286,,,2020-03-16 18:59:22.346,2,,,4727653,2020-03-16 18:59:21.254,38628f09-e146-459f-880b-0159cfe55dd2,DELIVERED,,o2wjpPyUfzBfq9OSt9I2NQ==
54b21c61-62fb-3998-b434-e5389ecf6195,2020-03-16 19:01:11.612,2286,,,2020-03-16 18:58:06.531,2,,,4727653,2020-03-16 18:58:05.148,63346e66-0578-4fc7-abda-62ba815c7daa,DELIVERED,,o2wjpPyUfzBfq9OSt9I2NQ==
89067bfe-b6ef-3d09-bc35-cfef5a3e29ae,2020-03-16 19:01:11.596,2286,,,2020-03-16 19:00:50.059,2,,,4727653,2020-03-16 19:00:48.934,c4337695-9d10-4bd1-89fe-d468407f28e3,PROCESSED,,o2wjpPyUfzBfq9OSt9I2NQ==
7b114d43-154d-31f9-810b-713734c25ea8,2020-03-16 19:01:11.613,2286,,,2020-03-16 18:58:06.531,2,,,4727653,2020-03-16 18:58:05.148,63346e66-0578-4fc7-abda-62ba815c7daa,PROCESSED,,o2wjpPyUfzBfq9OSt9I2NQ==
ece508cd-a165-3f4d-9317-b642c62e7907,2020-03-16 19:01:11.611,2286,,,2020-03-16 18:59:22.346,2,,,4727653,2020-03-16 18:59:21.254,38628f09-e146-459f-880b-0159cfe55dd2,PROCESSED,,o2wjpPyUfzBfq9OSt9I2NQ==
89067bfe-b6ef-3d09-bc35-cfef5a3e29ae,2020-03-16 19:01:11.596,2286,,,2020-03-16 19:00:50.059,2,,,4727653,2020-03-16 19:00:48.934,c4337695-9d10-4bd1-89fe-d468407f28e3,PROCESSED,true,o2wjpPyUfzBfq9OSt9I2NQ==
7b114d43-154d-31f9-810b-713734c25ea8,2020-03-16 19:01:11.613,2286,,,2020-03-16 18:58:06.531,2,,,4727653,2020-03-16 18:58:05.148,63346e66-0578-4fc7-abda-62ba815c7daa,PROCESSED,true,o2wjpPyUfzBfq9OSt9I2NQ==
ece508cd-a165-3f4d-9317-b642c62e7907,2020-03-16 19:01:11.611,2286,,,2020-03-16 18:59:22.346,2,,,4727653,2020-03-16 18:59:21.254,38628f09-e146-459f-880b-0159cfe55dd2,PROCESSED,true,o2wjpPyUfzBfq9OSt9I2NQ==
8edbc608-96a9-3318-b34c-806b660ea0ad,2020-04-23 16:25:36.703,2286,,,2020-04-23 16:21:12.604,86863875,,,4727653,2020-04-23 15:55:48.891,e040e9c2-dd3d-4926-9ec3-5ace0834e4fb,OPEN,false,Q5+hDGVJvTBdAVfNDmoNzw==
5c814bf0-bd56-34b0-aea3-9effa51d3756,2020-05-01 21:10:36.803,2286,,,2020-05-01 21:06:36.623,86863875,,,4727653,2020-04-23 15:56:01.733,acd11faf-e62a-40b3-8ad8-edecbfb7463c,OPEN,false,yyFrTbWxnSxiliuJBnxvHQ==
a6e576fa-1b65-388d-9573-50ec0a64db3a,2020-05-04 13:35:36.709,2286,,,2020-05-04 13:32:11.729,86863875,,,4727653,2020-04-23 15:55:58.852,ff6dbb56-fd81-432a-a837-07feec296751,OPEN,false,KG2+j8wAdZtIHY97xIGd+Q==
Expand Down
5 changes: 3 additions & 2 deletions models/stg_hubspot__email_event.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ with base as (

select *
from fields


{% if not var('hubspot_using_all_email_events',true) -%}
where not coalesce(is_filtered_event, false)
{%- endif -%}

0 comments on commit ac3846b

Please sign in to comment.