Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add var to persist former-agents' roles for SLA metrics #43

Merged
merged 10 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
# dbt_zendesk_source v0.10.1
[PR #43](https://github.com/fivetran/dbt_zendesk_source/pull/43) introduces the following updates:

## Feature Updates
- Added the `internal_user_criteria` variable, which can be used to mark internal users whose `USER.role` may have changed from `agent` to `end-user` after they left your organization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be relevant to include here that this is used as a case when clause in the staging model. Just so users know the context of the variable. The example shows this well, but I feel a bit of an explanation to this would be helpful to someone new to the concept.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a brief note!

- Example usage:
```yml
# dbt_project.yml
vars:
zendesk_source:
internal_user_criteria: "lower(email) like '%@fivetran.com' or external_id = 12345 or name in ('Garrett', 'Alfredo')" # can reference any non-custom field in USER
fivetran-jamie marked this conversation as resolved.
Show resolved Hide resolved
```
- Output: In `stg_zendesk__user`, users who match your criteria and have a role of `end-user` will have their role switched to `agent`. This will ensure that downstream SLA metrics are appropriately calculated.

## Under the Hood
- Updated the way we dynamically disable sources. Previously, we used a custom `meta.is_enabled` flag, but, since we added this, dbt-core introduced a native `config.enabled` attribute. We have opted to use the dbt-native config instead.

# dbt_zendesk_source v0.10.0
[PR #42](https://github.com/fivetran/dbt_zendesk_source/pull/42) introduces the following updates:

Expand Down
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,26 @@ vars:
```

## (Optional) Step 5: Additional configurations
<details><summary>Expand to view configurations</summary>


### Add passthrough columns
This package includes all source columns defined in the staging models. However, the `stg_zendesk__ticket` model allows for additional columns to be added using a pass-through column variable. This is extremely useful if you'd like to include custom fields to the package.
```yml
vars:
zendesk__ticket_passthrough_columns: [account_custom_field_1, account_custom_field_2]
```

### Mark Former Internal Users as Agents
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminder to myself to add this to the transform README (no release needed there tho) after approval

If a team member leaves your organization and their internal account is deactivated, their `USER.role` will switch from `agent` or `admin` to `end-user`. This will skew historical ticket SLA metrics, as we calculate reply times and other metrics based on `agent` or `admin` activity only.

To persist the integrity of historical ticket SLAs and mark these former team members as agents, provide the `internal_user_criteria` variable with a SQL clause to identify them, based on fields in the `USER` table:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we include a similar update to one I suggested in the CHANGELOG here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a little something


```yml
# dbt_project.yml
vars:
zendesk_source:
internal_user_criteria: "lower(email) like '%@fivetran.com' or external_id = 12345 or name in ('Garrett', 'Alfredo')" # can reference any non-custom field in USER
fivetran-jamie marked this conversation as resolved.
Show resolved Hide resolved
```

### Change the build schema
By default, this package builds the zendesk staging models within a schema titled (`<target_schema>` + `_zendesk_source`) in your target database. If this is not where you would like your Zendesk staging data to be written to, add the following configuration to your root `dbt_project.yml` file:

Expand Down Expand Up @@ -102,8 +113,7 @@ In this package, this would apply to the `GROUP` source. If you are receiving er
vars:
zendesk_group_identifier: "Group" # as an example, must include the double-quotes and correct case!
```

</details>


## (Optional) Step 6: Orchestrate your models with Fivetran Transformations for dbt Core™
<details><summary>Expand to view details</summary>
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config-version: 2
name: 'zendesk_source'
version: '0.10.0'
version: '0.10.1'
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
zendesk_source:
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,7 +1,7 @@
config-version: 2

name: 'zendesk_source_integration_tests'
version: '0.10.0'
version: '0.10.1'

profile: 'integration_tests'

Expand Down
24 changes: 12 additions & 12 deletions models/src_zendesk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ sources:
- name: domain_name
identifier: "{{ var('zendesk_domain_name_identifier', 'domain_name')}}"
description: Domain names associated with an organization. An organization may have multiple domain names.
meta:
is_enabled: "{{ var('using_domain_names', true) }}"
config:
enabled: "{{ var('using_domain_names', true) }}"
columns:
- name: organization_id
description: Reference to the organization
Expand All @@ -119,8 +119,8 @@ sources:
- name: organization_tag
identifier: "{{ var('zendesk_organization_tag_identifier', 'organization_tag') }}"
description: The tags associated with an organization. An organization may have multiple tags.
meta:
is_enabled: "{{ var('using_organization_tags', true) }}"
config:
enabled: "{{ var('using_organization_tags', true) }}"
columns:
- name: organization_id
description: Reference to the organization
Expand Down Expand Up @@ -194,8 +194,8 @@ sources:
- name: user_tag
identifier: "{{ var('zendesk_user_tag_identifier', 'user_tag') }}"
description: Table containing all tags associated with a user. Only present if your account has user tagging enabled.
meta:
is_enabled: "{{ var('using_user_tags', true) }}"
config:
enabled: "{{ var('using_user_tags', true) }}"
columns:
- name: user_id
description: Reference to the user
Expand Down Expand Up @@ -230,8 +230,8 @@ sources:
identifier: "{{ var('zendesk_schedule_identifier', 'schedule') }}"
description: The support schedules created with different business hours and holidays.
freshness: null
meta:
is_enabled: "{{ var('using_schedules', true) }}"
config:
enabled: "{{ var('using_schedules', true) }}"
columns:
- name: id
description: ID automatically assigned to the schedule upon creation
Expand Down Expand Up @@ -261,8 +261,8 @@ sources:
- name: ticket_form_history
identifier: "{{ var('zendesk_ticket_form_history_identifier', 'ticket_form_history') }}"
description: Ticket forms allow an admin to define a subset of ticket fields for display to both agents and end users.
meta:
is_enabled: "{{ var('using_ticket_form_history', true) }}"
config:
enabled: "{{ var('using_ticket_form_history', true) }}"
columns:
- name: id
description: Automatically assigned when creating ticket form
Expand Down Expand Up @@ -336,8 +336,8 @@ sources:
identifier: "{{ var('zendesk_schedule_holiday_identifier', 'schedule_holiday') }}"
description: Information about holidays for each specified schedule.
freshness: null
meta:
is_enabled: "{{ var('using_schedules', true) }}"
config:
enabled: "{{ var('using_schedules', true) }}"
columns:
- name: end_date
description: ISO 8601 representation of the holiday end date.
Expand Down
9 changes: 8 additions & 1 deletion models/stg_zendesk__user.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,18 @@ final as (
last_login_at,
created_at,
updated_at,
{% endif %}
{% endif -%}
email,
name,
organization_id,
{% if var('internal_user_criteria', false) -%}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know that false would work in this context. I thought it would need to be [] (or something like that). Are we sure this works on all dbt versions supported by the package? It may be worthwhile to test this on dbt 1.3.0 just to make sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just ran it on dbt-bigquery==1.3.0 with and without providing internal_user_criteria: "lower(email) like '%@fivetran.com'" and it works as expected 😄

yeah i think it works similarly to how we provide false (or true i suppose) as the default value for using_<possibly missing source table> variables

case
when role in ('admin', 'agent') then role
when {{ var('internal_user_criteria', false) }} then 'agent'
else role end as role,
{% else -%}
role,
{% endif -%}
ticket_restriction,
time_zone,
locale,
Expand Down