From 83b0c07e2287a6abf8d528ac6dfd58c620ac538c Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 11:32:46 +0530 Subject: [PATCH 1/7] Testing segments --- adapters/api/segment.js | 4 ++++ adapters/integrations/gitlab-integration.js | 3 ++- dist/index.js | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/adapters/api/segment.js b/adapters/api/segment.js index 0a0e6f2..93bd265 100644 --- a/adapters/api/segment.js +++ b/adapters/api/segment.js @@ -18,18 +18,22 @@ export async function sendSegmentEvent(action, body) { }; var response = null; + console.log("IS_DEV", IS_DEV); if (!IS_DEV) { response = await fetch( `${ATLAN_INSTANCE_URL}/api/service/segment/track`, requestOptions ) .then(() => { + console.log("inside ", response); console.log("send segment event", action, body); }) .catch((err) => { + console.log("OHHH NO", response); console.log("couldn't send segment event", err); }); } else { + console.log("Wuttt"); console.log("send segment event", action, body); } diff --git a/adapters/integrations/gitlab-integration.js b/adapters/integrations/gitlab-integration.js index 8110b19..a7db539 100644 --- a/adapters/integrations/gitlab-integration.js +++ b/adapters/integrations/gitlab-integration.js @@ -649,7 +649,8 @@ ${content}`; domain, }, }); - + console.log("Action :", action); + console.log("raw", raw); return sendSegmentEvent(action, raw); } catch (error) { logger.withError( diff --git a/dist/index.js b/dist/index.js index 7db368c..bf67747 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25386,18 +25386,22 @@ async function sendSegmentEvent(action, body) { }; var response = null; + console.log("IS_DEV", IS_DEV); if (!IS_DEV) { response = await src_fetch( `${ATLAN_INSTANCE_URL}/api/service/segment/track`, requestOptions ) .then(() => { + console.log("inside ", response); console.log("send segment event", action, body); }) .catch((err) => { + console.log("OHHH NO", response); console.log("couldn't send segment event", err); }); } else { + console.log("Wuttt"); console.log("send segment event", action, body); } @@ -34666,7 +34670,8 @@ ${content}`; domain, }, }); - + console.log("Action :", action); + console.log("raw", raw); return sendSegmentEvent(action, raw); } catch (error) { logger_logger.withError( From 24f93a24ae86da42e5817a03a2fa16e620aaffdb Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 11:43:16 +0530 Subject: [PATCH 2/7] Debugging segment --- adapters/integrations/github-integration.js | 3 ++- adapters/integrations/gitlab-integration.js | 2 +- dist/index.js | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/adapters/integrations/github-integration.js b/adapters/integrations/github-integration.js index ff51448..425d3cc 100644 --- a/adapters/integrations/github-integration.js +++ b/adapters/integrations/github-integration.js @@ -77,7 +77,8 @@ export default class GitHubIntegration extends IntegrationInterface { } if (total_assets !== 0) { - this.sendSegmentEventOfIntegration({ + console.log("Checking"); + await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { asset_count: total_assets, diff --git a/adapters/integrations/gitlab-integration.js b/adapters/integrations/gitlab-integration.js index a7db539..e092cc7 100644 --- a/adapters/integrations/gitlab-integration.js +++ b/adapters/integrations/gitlab-integration.js @@ -117,7 +117,7 @@ export default class GitLabIntegration extends IntegrationInterface { } if (total_assets !== 0) - this.sendSegmentEventOfIntegration({ + await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { asset_count: total_assets, diff --git a/dist/index.js b/dist/index.js index bf67747..c76501a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25575,7 +25575,8 @@ class GitHubIntegration extends IntegrationInterface { } if (total_assets !== 0) { - this.sendSegmentEventOfIntegration({ + console.log("Checking"); + await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { asset_count: total_assets, @@ -34138,7 +34139,7 @@ class GitLabIntegration extends IntegrationInterface { } if (total_assets !== 0) - this.sendSegmentEventOfIntegration({ + await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { asset_count: total_assets, From 458e6c1d0e2116478df0c2719d76acefabe6b7ef Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 11:48:26 +0530 Subject: [PATCH 3/7] fixing bug --- adapters/api/segment.js | 2 +- dist/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/adapters/api/segment.js b/adapters/api/segment.js index 93bd265..66eb4d8 100644 --- a/adapters/api/segment.js +++ b/adapters/api/segment.js @@ -25,13 +25,13 @@ export async function sendSegmentEvent(action, body) { requestOptions ) .then(() => { - console.log("inside ", response); console.log("send segment event", action, body); }) .catch((err) => { console.log("OHHH NO", response); console.log("couldn't send segment event", err); }); + console.log("inside ", response); } else { console.log("Wuttt"); console.log("send segment event", action, body); diff --git a/dist/index.js b/dist/index.js index c76501a..e9f3116 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25393,13 +25393,13 @@ async function sendSegmentEvent(action, body) { requestOptions ) .then(() => { - console.log("inside ", response); console.log("send segment event", action, body); }) .catch((err) => { console.log("OHHH NO", response); console.log("couldn't send segment event", err); }); + console.log("inside ", response); } else { console.log("Wuttt"); console.log("send segment event", action, body); From e3c0d434e50d3951c426ee352715be7bba04559f Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 11:49:49 +0530 Subject: [PATCH 4/7] fixing bug1 --- adapters/api/segment.js | 6 +++--- dist/index.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/adapters/api/segment.js b/adapters/api/segment.js index 66eb4d8..9f4ec7c 100644 --- a/adapters/api/segment.js +++ b/adapters/api/segment.js @@ -24,14 +24,14 @@ export async function sendSegmentEvent(action, body) { `${ATLAN_INSTANCE_URL}/api/service/segment/track`, requestOptions ) - .then(() => { + .then((resp) => { + console.log("Inside then", resp); console.log("send segment event", action, body); }) .catch((err) => { - console.log("OHHH NO", response); + console.log("Catch err", err); console.log("couldn't send segment event", err); }); - console.log("inside ", response); } else { console.log("Wuttt"); console.log("send segment event", action, body); diff --git a/dist/index.js b/dist/index.js index e9f3116..0c91834 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25392,14 +25392,14 @@ async function sendSegmentEvent(action, body) { `${ATLAN_INSTANCE_URL}/api/service/segment/track`, requestOptions ) - .then(() => { + .then((resp) => { + console.log("Inside then", resp); console.log("send segment event", action, body); }) .catch((err) => { - console.log("OHHH NO", response); + console.log("Catch err", err); console.log("couldn't send segment event", err); }); - console.log("inside ", response); } else { console.log("Wuttt"); console.log("send segment event", action, body); From 38c7ab54c73d1465b3f5c155ba8406091827335b Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 11:58:33 +0530 Subject: [PATCH 5/7] Logging for fix --- adapters/api/segment.js | 4 ++-- dist/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adapters/api/segment.js b/adapters/api/segment.js index 9f4ec7c..8beed2f 100644 --- a/adapters/api/segment.js +++ b/adapters/api/segment.js @@ -10,13 +10,13 @@ export async function sendSegmentEvent(action, body) { authorization: `Bearer ${ATLAN_API_TOKEN}`, "content-type": "application/json", }; - + console.log("MyHeaders :", myHeaders); const requestOptions = { method: "POST", headers: myHeaders, body: body, }; - + console.log("requestOptions :", requestOptions); var response = null; console.log("IS_DEV", IS_DEV); if (!IS_DEV) { diff --git a/dist/index.js b/dist/index.js index 0c91834..1a4d878 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25378,13 +25378,13 @@ async function sendSegmentEvent(action, body) { authorization: `Bearer ${ATLAN_API_TOKEN}`, "content-type": "application/json", }; - + console.log("MyHeaders :", myHeaders); const requestOptions = { method: "POST", headers: myHeaders, body: body, }; - + console.log("requestOptions :", requestOptions); var response = null; console.log("IS_DEV", IS_DEV); if (!IS_DEV) { From 31e0aa9c596a8b19ecc647683b9e4589d3114297 Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 13:23:11 +0530 Subject: [PATCH 6/7] Resolved set resource on asset issue --- adapters/api/create-resource.js | 1 + adapters/integrations/github-integration.js | 5 +++++ dist/index.js | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/adapters/api/create-resource.js b/adapters/api/create-resource.js index 95947e9..29e867e 100644 --- a/adapters/api/create-resource.js +++ b/adapters/api/create-resource.js @@ -59,5 +59,6 @@ export default async function createResource( }); }); + if (response?.errorCode) return null; return response; } diff --git a/adapters/integrations/github-integration.js b/adapters/integrations/github-integration.js index 425d3cc..94276bf 100644 --- a/adapters/integrations/github-integration.js +++ b/adapters/integrations/github-integration.js @@ -413,7 +413,9 @@ export default class GitHubIntegration extends IntegrationInterface { pull_request.html_url, this.sendSegmentEventOfIntegration ); + const md = getMDCommentForModel(ATLAN_INSTANCE_URL, model); + tableMd += getTableMD(md, resp); if (!resp) { setResourceFailed = true; @@ -434,10 +436,12 @@ export default class GitHubIntegration extends IntegrationInterface { pull_request.html_url, this.sendSegmentEventOfIntegration ); + const md = getMDCommentForMaterialisedView( ATLAN_INSTANCE_URL, materialisedView ); + tableMd += getTableMD(md, resp); if (!resp) { setResourceFailed = true; @@ -859,6 +863,7 @@ ${content}`; headSHA, "createIssueComment" ); + console.log(content); return content; } diff --git a/dist/index.js b/dist/index.js index 1a4d878..4bd8b5b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25366,6 +25366,7 @@ async function createResource( }); }); + if (response?.errorCode) return null; return response; } @@ -25911,7 +25912,9 @@ class GitHubIntegration extends IntegrationInterface { pull_request.html_url, this.sendSegmentEventOfIntegration ); + const md = getMDCommentForModel(ATLAN_INSTANCE_URL, model); + tableMd += getTableMD(md, resp); if (!resp) { setResourceFailed = true; @@ -25932,10 +25935,12 @@ class GitHubIntegration extends IntegrationInterface { pull_request.html_url, this.sendSegmentEventOfIntegration ); + const md = getMDCommentForMaterialisedView( ATLAN_INSTANCE_URL, materialisedView ); + tableMd += getTableMD(md, resp); if (!resp) { setResourceFailed = true; @@ -26357,6 +26362,7 @@ ${content}`; headSHA, "createIssueComment" ); + console.log(content); return content; } From 8ff1a358fbe71ee0ecf6a305dab3beabbebbc8f6 Mon Sep 17 00:00:00 2001 From: Arpit Shukla Date: Wed, 8 Nov 2023 16:04:02 +0530 Subject: [PATCH 7/7] Resolved segment event issue --- adapters/api/segment.js | 9 +++------ adapters/integrations/github-integration.js | 3 +-- adapters/integrations/gitlab-integration.js | 3 +-- dist/index.js | 15 +++++---------- 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/adapters/api/segment.js b/adapters/api/segment.js index 8beed2f..5a97cb3 100644 --- a/adapters/api/segment.js +++ b/adapters/api/segment.js @@ -10,30 +10,27 @@ export async function sendSegmentEvent(action, body) { authorization: `Bearer ${ATLAN_API_TOKEN}`, "content-type": "application/json", }; - console.log("MyHeaders :", myHeaders); + const requestOptions = { method: "POST", headers: myHeaders, body: body, }; - console.log("requestOptions :", requestOptions); + var response = null; - console.log("IS_DEV", IS_DEV); + if (!IS_DEV) { response = await fetch( `${ATLAN_INSTANCE_URL}/api/service/segment/track`, requestOptions ) .then((resp) => { - console.log("Inside then", resp); console.log("send segment event", action, body); }) .catch((err) => { - console.log("Catch err", err); console.log("couldn't send segment event", err); }); } else { - console.log("Wuttt"); console.log("send segment event", action, body); } diff --git a/adapters/integrations/github-integration.js b/adapters/integrations/github-integration.js index 94276bf..e7729e5 100644 --- a/adapters/integrations/github-integration.js +++ b/adapters/integrations/github-integration.js @@ -77,7 +77,6 @@ export default class GitHubIntegration extends IntegrationInterface { } if (total_assets !== 0) { - console.log("Checking"); await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { @@ -863,7 +862,7 @@ ${content}`; headSHA, "createIssueComment" ); - console.log(content); + return content; } diff --git a/adapters/integrations/gitlab-integration.js b/adapters/integrations/gitlab-integration.js index e092cc7..37ca814 100644 --- a/adapters/integrations/gitlab-integration.js +++ b/adapters/integrations/gitlab-integration.js @@ -649,8 +649,7 @@ ${content}`; domain, }, }); - console.log("Action :", action); - console.log("raw", raw); + return sendSegmentEvent(action, raw); } catch (error) { logger.withError( diff --git a/dist/index.js b/dist/index.js index 4bd8b5b..828e4ce 100644 --- a/dist/index.js +++ b/dist/index.js @@ -25379,30 +25379,27 @@ async function sendSegmentEvent(action, body) { authorization: `Bearer ${ATLAN_API_TOKEN}`, "content-type": "application/json", }; - console.log("MyHeaders :", myHeaders); + const requestOptions = { method: "POST", headers: myHeaders, body: body, }; - console.log("requestOptions :", requestOptions); + var response = null; - console.log("IS_DEV", IS_DEV); + if (!IS_DEV) { response = await src_fetch( `${ATLAN_INSTANCE_URL}/api/service/segment/track`, requestOptions ) .then((resp) => { - console.log("Inside then", resp); console.log("send segment event", action, body); }) .catch((err) => { - console.log("Catch err", err); console.log("couldn't send segment event", err); }); } else { - console.log("Wuttt"); console.log("send segment event", action, body); } @@ -25576,7 +25573,6 @@ class GitHubIntegration extends IntegrationInterface { } if (total_assets !== 0) { - console.log("Checking"); await this.sendSegmentEventOfIntegration({ action: "dbt_ci_action_run", properties: { @@ -26362,7 +26358,7 @@ ${content}`; headSHA, "createIssueComment" ); - console.log(content); + return content; } @@ -34677,8 +34673,7 @@ ${content}`; domain, }, }); - console.log("Action :", action); - console.log("raw", raw); + return sendSegmentEvent(action, raw); } catch (error) { logger_logger.withError(