Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
# dbt_intercom v1.5.0

[PR #75](https://github.com/fivetran/dbt_intercom/pull/75) includes the following updates:

## Schema/Data Change
**3 total changes • 2 possible breaking change**

| Data Model(s) | Change type | Old | New | Notes |
| ------------- | ----------- | ----| --- | ----- |
| `intercom__conversation_enhanced`<br>`intercom__conversation_metrics` | New field | | `conversation_assignee_id` | The ID of the user assigned to the conversation. This column is an alias of `assignee_id` from `stg_intercom__conversation_history` model. If you also persist `assignee_id` using the `intercom__conversation_history_pass_through_columns` variable, ensure it uses a different alias to avoid duplicate column errors. |
| `intercom__conversation_enhanced`<br>`intercom__conversation_metrics` | New field | | `is_assignee_admin` | Boolean field indicating whether the conversation assignee is an admin user, determined by joining `assignee_id` with the admin table. Returns `false` if conversation is unassigned or assigned to a non-admin user |
| `intercom__conversation_enhanced`<br>`intercom__conversation_metrics`<br>`stg_intercom__conversation_history` | Deprecated field | `assignee_type` or `conversation_assignee_type` | Marked as [DEPRECATED] | The `assignee_type` field is no longer supported by Intercom's API. Use `is_assignee_admin` instead to determine if an assignee is an admin |

## Under the Hood
- Updated `intercom__admin_metrics` to filter conversations using `is_assignee_admin` boolean instead of the deprecated `conversation_assignee_type = 'admin'` string comparison
- Enhanced `intercom__conversation_enhanced` with a left join to the admin table to determine admin assignee status
- Updates to the integrity and consistency validation tests to ensure accurate testing of model changes between versions.

# dbt_intercom v1.5.0-a1

[PR #75](https://github.com/fivetran/dbt_intercom/pull/75) includes the following updates:

## Schema/Data Change
**3 total changes • 2 possible breaking change**

| Data Model(s) | Change type | Old | New | Notes |
| ------------- | ----------- | ----| --- | ----- |
| `intercom__conversation_enhanced`<br>`intercom__conversation_metrics` | New field | | `conversation_assignee_id` | Exposes the conversation assignee ID (the ID of the user assigned to the conversation) from the staging layer for reference and joins. If you persist `assignee_id` via the `intercom__conversation_history_pass_through_columns` variable, ensure its alias does not match `conversation_assignee_id` to avoid duplicate column errors. |
| `intercom__conversation_enhanced`<br>`intercom__conversation_metrics` | New field | | `is_assignee_admin` | Boolean field indicating whether the conversation assignee is an admin user, determined by joining `assignee_id` with the admin table. Returns `false` if conversation is unassigned or assigned to a non-admin user |
| `intercom__conversation_enhanced`<br>`intercom__conversation_metrics`<br>`stg_intercom__conversation_history` | Deprecated field | `assignee_type` or `conversation_assignee_type` | Marked as [DEPRECATED] | The `assignee_type` field is no longer supported by Intercom's API. Use `is_assignee_admin` instead to determine if an assignee is an admin |

## Under the Hood
- Updated `intercom__admin_metrics` to filter conversations using `is_assignee_admin` boolean instead of the deprecated `conversation_assignee_type = 'admin'` string comparison
- Enhanced `intercom__conversation_enhanced` with a left join to the admin table to determine admin assignee status
- Updates to the integrity and consistency validation tests to ensure accurate testing of model changes between versions.

# dbt_intercom v1.4.0
[PR #74](https://github.com/fivetran/dbt_intercom/pull/74) includes the following updates:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Include the following intercom package version in your `packages.yml` file:
```yaml
packages:
- package: fivetran/intercom
version: [">=1.4.0", "<1.5.0"]
version: [">=1.5.0", "<1.6.0"]
```
### Step 3: Define database and schema variables

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: 'intercom'
version: '1.4.0'
version: '1.5.0'
require-dbt-version: [">=1.3.0", "<3.0.0"]
models:
intercom:
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 integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'intercom_integration_tests'
version: '1.4.0'
version: '1.5.0'
profile: 'integration_tests'
config-version: 2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
enabled=(var('fivetran_validation_tests_enabled', false))
) }}

{% set exclude_cols = var('consistency_test_exclude_metrics', []) %}
{% set exclude_cols = ['all_company_tags'] + var('consistency_test_exclude_metrics', []) %}

-- this test ensures the intercom__company_enhanced end model matches the prior version
with prod as (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ with conversation_source_count as (

select count(distinct conversation_id) as stg_count
from {{ target.schema }}_intercom_dev.stg_intercom__conversation_history
where coalesce(_fivetran_active, true)
),

conversation_end_count as (
Expand Down
12 changes: 10 additions & 2 deletions models/intercom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,12 @@ models:
description: How the conversation was initially delivered to the responder.
- name: conversation_subject
description: The subject of the conversation created by the initiator.
- name: conversation_assignee_id
description: The ID of the user assigned to the conversation. If it is not assigned to a user it will return null.
- name: conversation_assignee_type
description: The type of user the conversation is assigned to. If it is not assigned to a user it will return null.
description: "[DEPRECATED] The type of user the conversation is assigned to. If it is not assigned to a user it will show 'unassigned'. Use is_assignee_admin instead."
- name: is_assignee_admin
description: Boolean indicating whether the conversation assignee is an admin user. Determined by joining assignee_id with the admin table. False if conversation is unassigned or assigned to a non-admin user.
- name: conversation_author_type
description: The type of individual who authored the first message. Will be either contact or admin.
- name: first_close_by_admin_id
Expand Down Expand Up @@ -403,8 +407,12 @@ models:
description: How the conversation was initially delivered to the responder.
- name: conversation_subject
description: The subject of the conversation created by the initiator.
- name: conversation_assignee_id
description: The ID of the user assigned to the conversation. If it is not assigned to a user it will return null.
- name: conversation_assignee_type
description: The type of user the conversation is assigned to. If it is not assigned to a user it will return null.
description: "[DEPRECATED] The type of user the conversation is assigned to. If it is not assigned to a user it will show 'unassigned'. Use is_assignee_admin instead."
- name: is_assignee_admin
description: Boolean indicating whether the conversation assignee is an admin user. Determined by joining assignee_id with the admin table. False if conversation is unassigned or assigned to a non-admin user.
- name: conversation_author_type
description: The type of individual who authored the first message. Will be either contact or admin.
- name: first_close_by_admin_id
Expand Down
2 changes: 1 addition & 1 deletion models/intercom__admin_metrics.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
with conversation_metrics as (
select *
from {{ ref('intercom__conversation_metrics') }}
where conversation_assignee_type = 'admin'
where is_assignee_admin
),

admin_table as (
Expand Down
15 changes: 13 additions & 2 deletions models/intercom__conversation_enhanced.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ conversation_part_events as (
from {{ ref('int_intercom__conversation_part_events') }}
),

admins as (
select *
from {{ ref('stg_intercom__admin') }}
),

--If you use the contact company table this will be included, if not it will be ignored.
{% if var('intercom__using_contact_company', True) %}
contact_enhanced as (
Expand Down Expand Up @@ -71,7 +76,8 @@ latest_conversation_enriched as (
source_type as conversation_type,
source_delivered_as as conversation_initiated_type,
source_subject as conversation_subject,
case when (assignee_type is not null) then assignee_type else 'unassigned' end as conversation_assignee_type,
assignee_id as conversation_assignee_id,
case when (assignee_type is not null) then assignee_type else 'unassigned' end as conversation_assignee_type, -- [DEPRECATED] use is_assignee_admin instead
source_author_type as conversation_author_type,
state as conversation_state,
is_read,
Expand All @@ -88,9 +94,10 @@ latest_conversation_enriched as (
),

--Enriches the latest conversation model with data from conversation_part_events, conversation_string_aggregates, and conversation_tags_aggregate
enriched_final as (
enriched_final as (
select
latest_conversation_enriched.*,
case when admins.admin_id is not null then true else false end as is_assignee_admin,

conversation_part_events.first_close_at,
conversation_part_events.last_close_at,
Expand Down Expand Up @@ -156,6 +163,10 @@ enriched_final as (
and last_team.source_relation = conversation_part_events.source_relation
{% endif %}

left join admins
on admins.admin_id = cast(latest_conversation_enriched.conversation_assignee_id as {{ dbt.type_string() }})
and admins.source_relation = latest_conversation_enriched.source_relation

)
select *
from enriched_final
2 changes: 1 addition & 1 deletion models/staging/src_intercom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ sources:
- name: assignee_id
description: The id of the user assigned to the conversation. If it is not assigned to a user it will return null.
- name: assignee_type
description: The type of user the conversation is assigned to. If it is not assigned to a user it will return null.
description: "[DEPRECATED] The type of user the conversation is assigned to. If it is not assigned to a user it will return null. Use is_assignee_admin in the conversation_enhanced model instead."
- name: conversation_rating_value
description: An optional field for the customer to rate the conversation which will be between 1 and 5.
- name: conversation_rating_remark
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stg_intercom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ models:
- name: assignee_id
description: The id of the user assigned to the conversation. If it is not assigned to a user it will return null.
- name: assignee_type
description: The type of user the conversation is assigned to. If it is not assigned to a user it will return null.
description: "[DEPRECATED] The type of user the conversation is assigned to. If it is not assigned to a user it will return null. Use is_assignee_admin in the conversation_enhanced model instead."
- name: conversation_rating_value
description: An optional field for the customer to rate the conversation which will be between 1 and 5.
- name: conversation_rating_remark
Expand Down
2 changes: 1 addition & 1 deletion models/staging/stg_intercom__conversation_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ final as (
id as conversation_id,
cast(created_at as {{ dbt.type_timestamp() }}) as created_at,
assignee_id,
assignee_type,
assignee_type, -- [DEPRECATED] use is_assignee_admin in the intercom__conversation_enhanced model instead.
conversation_rating_value,
conversation_rating_remark,
cast(first_contact_reply_created_at as {{ dbt.type_timestamp() }}) as first_contact_reply_created_at,
Expand Down