Skip to content

feat: tnc connectors implementation [CM-1010]#3894

Open
mbani01 wants to merge 19 commits intomainfrom
feat/tnc_implementation
Open

feat: tnc connectors implementation [CM-1010]#3894
mbani01 wants to merge 19 commits intomainfrom
feat/tnc_implementation

Conversation

@mbani01
Copy link
Contributor

@mbani01 mbani01 commented Mar 4, 2026

This pull request adds support for the TNC platform in the Snowflake connectors integration. It introduces new activity types, data sources, SQL queries, and transformers to ingest and process TNC certification, enrollment, and course action data. The changes include both backend database updates and significant additions to the data ingestion pipeline.

Key changes:

1. TNC Platform Integration:

  • Added TNC as a supported platform in the Snowflake connectors, registering three new data sources: enrollments, certificates, and course actions, each with their own query builders and transformers. [1] [2] [3]

2. Data Source Query Builders:

  • Implemented buildSourceQuery functions for TNC certificates, enrollments, and course actions, providing SQL logic to extract and join relevant data from Snowflake, including handling environment-specific filters and incremental syncs. [1] [2] [3]

3. Data Transformation Logic:

  • Added transformer classes for TNC certificates, enrollments, and course actions, mapping raw query results into the unified activity schema, resolving member identities, organizations, and attributes, and handling special cases or missing data. [1] [2] [3]

4. Database Schema Update:

  • Inserted new TNC-related activity types into the activityTypes table to support tracking of certification enrollments, training enrollments, issued certifications, and course/exam attempts.

These changes lay the groundwork for ingesting and processing TNC data, enabling richer analytics and reporting for certification and training activities.


Note

Medium Risk
Adds a new production data ingestion path with complex Snowflake SQL and new activity typing, which could affect export volume, correctness, or downstream attribution if queries/field mappings are wrong.

Overview
Adds TNC support to the Snowflake connectors pipeline, registering three new exports (enrollments, certificates, and course actions) with dedicated Snowflake query builders and row transformers that emit unified activities (including member identity/org resolution, segment routing, and incremental backfill logic).

Introduces new tnc activity types/scoring (enrolled-*, issued-certification, attempted-*) and wires TNC into organization source/attribute precedence. Improves TransformerBase.safeTransformRow logging to capture error message/stack plus row keys for easier debugging when rows are skipped.

Written by Cursor Bugbot for commit bdf6faf. This will update automatically on new commits. Configure here.

@mbani01 mbani01 self-assigned this Mar 4, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Conventional Commits FTW!

@mbani01 mbani01 changed the title feat: TNC connectors implementation [CM-1010] feat: tnc connectors implementation [CM-1010] Mar 5, 2026
@mbani01 mbani01 marked this pull request as ready for review March 5, 2026 15:40
@mbani01 mbani01 requested a review from joanagmaia March 5, 2026 15:40
Comment on lines +59 to +61
if (!IS_PROD_ENV) {
select += ` AND cms.slug = 'cncf'`
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: Can we add a comment here just to explain that this is being added for staging/testing purposes?

sourceId: certificateId,
sourceParentId: (row.COURSE_ID as string | null) || undefined,
member: {
displayName: learnerName || email,
Copy link
Contributor

Choose a reason for hiding this comment

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

If we were to fallback to the email, could we remove the domain? And simply add the initial part of the email?

sourceId: courseActionId,
sourceParentId: (row.COURSE_ID as string | null) || undefined,
member: {
displayName: learnerName || email,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same thing here

sourceId: enrollmentId,
sourceParentId: (row.COURSE_ID as string | null) || undefined,
member: {
displayName: learnerName || email,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

return null
}

const certificateId = (row.CERTIFICATE_ID as string)?.trim()
Copy link

Choose a reason for hiding this comment

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

Missing sourceId validation in certificates and enrollments transformers

Medium Severity

The certificates transformer extracts certificateId via (row.CERTIFICATE_ID as string)?.trim() and the enrollments transformer extracts enrollmentId via (row.ENROLLMENT_ID as string)?.trim() — neither validates the value before assigning it to activity.sourceId. If the row value is null/undefined, the result is undefined, violating the IActivityData interface where sourceId: string is required (not optional). The courses transformer correctly validates courseActionId and returns null if missing, but the other two transformers skip this check, risking activities with undefined sourceId being passed downstream.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

SELECT account_id, account_name, website, domain_aliases, NULL AS LOGO_URL, NULL AS INDUSTRY, NULL AS N_EMPLOYEES
FROM analytics.bronze_fivetran_salesforce_b2b.accounts
WHERE website IS NOT NULL
)`
Copy link

Choose a reason for hiding this comment

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

SQL CTE constants duplicated across three files

Low Severity

The CDP_MATCHED_SEGMENTS and ORG_ACCOUNTS SQL CTE constants are identically copy-pasted across all three TNC buildSourceQuery files (certificates, courses, enrollments). LFID_COALESCE is also duplicated between certificates and enrollments. These could live in a shared TNC SQL fragments module to avoid divergence during future updates.

Additional Locations (2)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants