From d478f8f226054a6c305e64dc3509a9077bc5df8f Mon Sep 17 00:00:00 2001 From: Rittik Dasgupta Date: Thu, 24 Oct 2024 11:43:57 +0530 Subject: [PATCH] fix(integrations): do not send segment event if totalChangedFiles is undefined --- .../atlan-contract-impact-analysis-github.js | 5 +++-- adapters/integrations/github-integration.js | 2 +- adapters/integrations/gitlab-integration.js | 3 ++- dist/index.js | 10 ++++++---- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/adapters/integrations/atlan-contract-impact-analysis-github.js b/adapters/integrations/atlan-contract-impact-analysis-github.js index 5920e3f..5ca1fa5 100644 --- a/adapters/integrations/atlan-contract-impact-analysis-github.js +++ b/adapters/integrations/atlan-contract-impact-analysis-github.js @@ -76,7 +76,7 @@ export default class ContractIntegration extends IntegrationInterface { total_assets = await this.printDownstreamAssets({ octokit, context }); } - if (total_assets !== 0) { + if (total_assets !== 0 && total_assets != undefined) { await this.sendSegmentEventOfIntegration({ action: `${actionName}_run`, properties: { @@ -112,7 +112,6 @@ export default class ContractIntegration extends IntegrationInterface { ); try { - const changedFiles = await this.getChangedFiles({ octokit, context }); let comments = ``; let warningComments = ``; let totalChangedFiles = 0; @@ -144,6 +143,8 @@ export default class ContractIntegration extends IntegrationInterface { return; } + const changedFiles = await this.getChangedFiles({ octokit, context }); + for (const { fileName, filePath, status } of changedFiles) { // Skipping non yaml files if (!filePath.endsWith('.yaml') && !filePath.endsWith('.yml')) { diff --git a/adapters/integrations/github-integration.js b/adapters/integrations/github-integration.js index 9c69ec2..d8c7b00 100644 --- a/adapters/integrations/github-integration.js +++ b/adapters/integrations/github-integration.js @@ -78,7 +78,7 @@ export default class GitHubIntegration extends IntegrationInterface { total_assets = await this.setResourceOnAsset({ octokit, context }); } - if (total_assets !== 0) { + if (total_assets !== 0 && total_assets != undefined) { await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { diff --git a/adapters/integrations/gitlab-integration.js b/adapters/integrations/gitlab-integration.js index 2ecc26e..0926b78 100644 --- a/adapters/integrations/gitlab-integration.js +++ b/adapters/integrations/gitlab-integration.js @@ -43,6 +43,7 @@ import { Gitlab } from "@gitbeaker/rest"; import IntegrationInterface from "./contract/contract.js"; import logger from "../logger/logger.js"; import stringify from "json-stringify-safe"; + const integrationName = "gitlab"; var CI_MERGE_REQUEST_IID; @@ -117,7 +118,7 @@ export default class GitLabIntegration extends IntegrationInterface { }); } - if (total_assets !== 0) + if (total_assets !== 0 && total_assets != undefined) await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { diff --git a/dist/index.js b/dist/index.js index c63786d..9f7591a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29832,7 +29832,7 @@ class ContractIntegration extends IntegrationInterface { total_assets = await this.printDownstreamAssets({ octokit, context }); } - if (total_assets !== 0) { + if (total_assets !== 0 && total_assets != undefined) { await this.sendSegmentEventOfIntegration({ action: `${actionName}_run`, properties: { @@ -29868,7 +29868,6 @@ class ContractIntegration extends IntegrationInterface { ); try { - const changedFiles = await this.getChangedFiles({ octokit, context }); let comments = ``; let warningComments = ``; let totalChangedFiles = 0; @@ -29900,6 +29899,8 @@ class ContractIntegration extends IntegrationInterface { return; } + const changedFiles = await this.getChangedFiles({ octokit, context }); + for (const { fileName, filePath, status } of changedFiles) { // Skipping non yaml files if (!filePath.endsWith('.yaml') && !filePath.endsWith('.yml')) { @@ -30685,7 +30686,7 @@ class GitHubIntegration extends IntegrationInterface { total_assets = await this.setResourceOnAsset({ octokit, context }); } - if (total_assets !== 0) { + if (total_assets !== 0 && total_assets != undefined) { await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { @@ -39182,6 +39183,7 @@ var { + const gitlab_integration_integrationName = "gitlab"; var CI_MERGE_REQUEST_IID; @@ -39256,7 +39258,7 @@ class GitLabIntegration extends IntegrationInterface { }); } - if (total_assets !== 0) + if (total_assets !== 0 && total_assets != undefined) await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: {