From d907f472b69749148a0b8194bec1c2402efcb53b Mon Sep 17 00:00:00 2001 From: JagadishPujari Date: Tue, 19 Jan 2021 12:07:24 +0530 Subject: [PATCH 01/11] Issue #SB-22454 fix: Chatbot: Unit test cases for bot(router) --- router/appRest.js | 7 +---- router/package.json | 17 +++++++---- router/test/appRest.spec.js | 55 +++++++++++++++++++++++++++++++++++ router/test/mock.data.spec.js | 44 ++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 11 deletions(-) create mode 100644 router/test/appRest.spec.js create mode 100644 router/test/mock.data.spec.js diff --git a/router/appRest.js b/router/appRest.js index d5c185f..1ced3aa 100644 --- a/router/appRest.js +++ b/router/appRest.js @@ -532,9 +532,4 @@ function replaceUserSpecficData(str) { } return str; } - - - - - - +module.exports = appBot; diff --git a/router/package.json b/router/package.json index f820767..e3abbd4 100644 --- a/router/package.json +++ b/router/package.json @@ -4,12 +4,16 @@ "description": "thor bot router", "main": "app.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "router-test": "nyc mocha 'test/**/*.spec.js'", + "coverage": "nyc --reporter=lcov --reporter=text-lcov npm run router-test" }, "author": "waibhav", "license": "ISC", "dependencies": { "axios": "^0.19.2", + "body-parser": "^1.19.0", + "chai": "^4.2.0", + "chai-http": "^4.3.0", "cors": "^2.8.5", "dateformat": "^3.0.3", "elasticsearch": "^16.6.0", @@ -18,15 +22,18 @@ "helmet": "^3.21.2", "lodash": "^4.17.20", "method-override": "^3.0.0", - "ua-parser-js": "^0.7.13", - "sb_telemetry_util": "file:libs/sb_telemetry_util", - "sb_config_util": "file:libs/sb-config-util", - "sb_logger_util": "file:libs/sb_logger_util", + "mocha": "^8.2.1", + "nock": "^13.0.5", + "nyc": "^15.1.0", "redis": "^3.0.2", "request": "^2.88.0", "require-reload": "^0.2.2", + "sb_config_util": "file:libs/sb-config-util", + "sb_logger_util": "file:libs/sb_logger_util", + "sb_telemetry_util": "file:libs/sb_telemetry_util", "socket.io": "^2.3.0", "tz-lookup": "^6.1.25", + "ua-parser-js": "^0.7.13", "uuid": "^3.4.0", "winston": "^3.2.1" } diff --git a/router/test/appRest.spec.js b/router/test/appRest.spec.js new file mode 100644 index 0000000..b88ba6e --- /dev/null +++ b/router/test/appRest.spec.js @@ -0,0 +1,55 @@ +const chai = require('chai'); +let chaiHttp = require('chai-http'); +chai.should(); +chai.use(chaiHttp); +let server = require('../appRest'); +const nock = require('nock'); +const mockData = require('./mock.data.spec'); +var expect = require('chai').expect; + +describe('Chatbot router APIs', () => { + it('it should get bot response fot user input', (done) => { + nock('https://dev.sunbirded.org/chatapi') + .post('/bot') + .reply(200, mockData.botResponse); + const response = { + "type": "button", + "data": { + "text": " Hello, I am Tara!
I am your DIKSHA guide
Please select your preference from the options I provide or type your query directly.", + "buttons": [ + { + "text": "Digital content", + "value": "1" + }, + { + "text": "Courses", + "value": "2" + }, + { + "text": "DIKSHA mobile app", + "value": "3" + }, + { + "text": "Content contribution", + "value": "4" + }, + { + "text": "Other DIKSHA queries", + "value": "5" + } + ] + } + }; + chai.request(server) + .post('/bot') + .end((err, res) => { + expect(res).to.be.a('object'); + // expect(res.body.tags).to.be.a('Array'); + // expect(res.status).to.equal(200); + console.log("Jags====", res); + // expect(JSON.stringify(res)).to.equal(JSON.stringify(response)); + done(); + }); + }); + +}); \ No newline at end of file diff --git a/router/test/mock.data.spec.js b/router/test/mock.data.spec.js new file mode 100644 index 0000000..a96f077 --- /dev/null +++ b/router/test/mock.data.spec.js @@ -0,0 +1,44 @@ +module.exports = { + botResponse:{ + "type": "button", + "data": { + "text": " Hello, I am Tara!
I am your DIKSHA guide
Please select your preference from the options I provide or type your query directly.", + "buttons": [ + { + "text": "Digital content", + "value": "1" + }, + { + "text": "Courses", + "value": "2" + }, + { + "text": "DIKSHA mobile app", + "value": "3" + }, + { + "text": "Content contribution", + "value": "4" + }, + { + "text": "Other DIKSHA queries", + "value": "5" + } + ] + } + }, + postRes: { + "code": "ok", + "payload": {} + }, + errorResponse: { + "code": "params-missing", + "message": "Something was wrong with the request payload you passed in. | Required parameters were missing from this API call, please see the \"params\" property", + "params": {} + }, + errorMessage: { + "code": "not-found", + "message": "Invalid API call", + "params": {} +} +} \ No newline at end of file From 092a702f43bcf9e505946757b4f0385495c911b5 Mon Sep 17 00:00:00 2001 From: JagadishPujari Date: Mon, 25 Jan 2021 19:17:25 +0530 Subject: [PATCH 02/11] Issue #SB-22454 feat: Test cases for router --- router/test/appRest.spec.js | 87 ++++++++++++++++++++++------------- router/test/mock.data.spec.js | 9 ++++ 2 files changed, 64 insertions(+), 32 deletions(-) diff --git a/router/test/appRest.spec.js b/router/test/appRest.spec.js index b88ba6e..11f6556 100644 --- a/router/test/appRest.spec.js +++ b/router/test/appRest.spec.js @@ -8,46 +8,69 @@ const mockData = require('./mock.data.spec'); var expect = require('chai').expect; describe('Chatbot router APIs', () => { - it('it should get bot response fot user input', (done) => { + it('it should get bot response fot user input on web portal', (done) => { nock('https://dev.sunbirded.org/chatapi') .post('/bot') .reply(200, mockData.botResponse); + const response = {"type":"button","data":{"text":" Hello, I am Tara!
I am your DIKSHA guide
Please select your preference from the options I provide or type your query directly.","buttons":[{"text":"Digital content","value":"1"},{"text":"Courses","value":"2"},{"text":"DIKSHA mobile app","value":"3"},{"text":"Content contribution","value":"4"},{"text":"Other DIKSHA queries","value":"5"}]}} + chai.request(server) + .post('/bot') + .send({ + "Body": "0", + "userId": "449c94833e1caa71aaadfe2567bea945", + "appId": "prod.diksha.portal", + "channel": "505c7c48ac6dc1edc9b08f21db5a571d", + "From": "449c94833e1caa71aaadfe2567bea945" + }) + .end((err, res) => { + expect(res).to.be.a('object'); + expect(res.body).to.be.a('Object'); + expect(JSON.stringify(res.body)).to.equal(JSON.stringify(response)); + done(); + }); + }); + + xit('it should get bot response fot user input in whats app', (done) => { + nock('https://preprod.ntp.net.in/chatapi') + .post('/whatsapp') + .reply(200, mockData.whatsappResponse); const response = { - "type": "button", - "data": { - "text": " Hello, I am Tara!
I am your DIKSHA guide
Please select your preference from the options I provide or type your query directly.", - "buttons": [ - { - "text": "Digital content", - "value": "1" - }, - { - "text": "Courses", - "value": "2" - }, - { - "text": "DIKSHA mobile app", - "value": "3" - }, - { - "text": "Content contribution", - "value": "4" - }, - { - "text": "Other DIKSHA queries", - "value": "5" - } - ] - } + "text": "Hi, I’m TARA, your DIKSHA assistant. How may I help you today? \n Select from one of the following options. Send the number corresponding to your choice \n 1- To find and play content \n 2- To download/update the DIKSHA mobile app \n 3- Other Queries", + "intent": "greet", + "type": "buttons", + "buttons": [] }; chai.request(server) - .post('/bot') + .post('/whatsapp') + .send({ + "incoming_message": [{ + "from": "9611654628", + "text_type": { + "text": "0" + } + }] + }) + .end((err, res) => { + expect(res).to.be.a('object'); + expect(res.body).to.be.a('Object'); + expect(JSON.stringify(res.body)).to.equal(JSON.stringify(response)); + done(); + }); + }); + + it('refresh the config', (done) => { + nock('https://dev.sunbirded.org/chatapi') + .post('/refresh') + .reply(200, mockData.refreshAPIResponse); + const response = { + "msg": "ENV configuration blob path is not defined" + } + chai.request(server) + .post('/refresh') .end((err, res) => { expect(res).to.be.a('object'); - // expect(res.body.tags).to.be.a('Array'); - // expect(res.status).to.equal(200); - console.log("Jags====", res); - // expect(JSON.stringify(res)).to.equal(JSON.stringify(response)); + expect(res.body).to.be.a('Object'); + expect(JSON.stringify(res.body)).to.equal(JSON.stringify(response)); done(); }); }); diff --git a/router/test/mock.data.spec.js b/router/test/mock.data.spec.js index a96f077..a030897 100644 --- a/router/test/mock.data.spec.js +++ b/router/test/mock.data.spec.js @@ -27,6 +27,15 @@ module.exports = { ] } }, + whatsappResponse:{ + "text": "Hi, I’m TARA, your DIKSHA assistant. How may I help you today? \n Select from one of the following options. Send the number corresponding to your choice \n 1- To find and play content \n 2- To download/update the DIKSHA mobile app \n 3- Other Queries", + "intent": "greet", + "type": "buttons", + "buttons": [] + }, + refreshAPIResponse: { + "msg": "ENV configuration blob path is not defined" + }, postRes: { "code": "ok", "payload": {} From a85f13e57da02b527d9c2d1f829f9495f27f67d4 Mon Sep 17 00:00:00 2001 From: G33tha Date: Wed, 3 Feb 2021 15:49:56 +0530 Subject: [PATCH 03/11] Update Jenkinsfile --- bot/Jenkinsfile | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/bot/Jenkinsfile b/bot/Jenkinsfile index f176aa9..8c48c34 100644 --- a/bot/Jenkinsfile +++ b/bot/Jenkinsfile @@ -29,26 +29,33 @@ node('build-slave') { println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag specified, building from github_release_tag: " + params.github_release_tag + ANSI_NORMAL) } echo "public_repo_commit_hash: " + public_repo_commit_hash - bot_repo_url = params.diksha_bot_repo - dir('bot_repo') { - if (params.diksha_bot_tag == "") { - def scmVars = checkout scm - checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/heads/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) - private_repo_commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() - } - else { - def scmVars = checkout scm - checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.diksha_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) - private_repo_commit_hash = params.diksha_bot_tag - } - } + bot_repo_url = params.private_bot_repo + + if (params.private_bot_repo && params.private_bot_tag) { + dir('bot_repo') { + if (params.private_bot_tag == "") { + def scmVars = checkout scm + checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/heads/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) + private_repo_commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + } + else { + def scmVars = checkout scm + checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.private_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) + private_repo_commit_hash = params.private_bot_tag + } + } + + } + } stage('Build') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" - sh('cp -r bot_repo/* .') + if (params.private_bot_repo && params.private_bot_tag) { + sh('cp -r bot_repo/* .') + } dir('bot') { sh('chmod 777 build.sh') sh("./build.sh ${build_tag} ${env.NODE_NAME} ${hub_org}") From c11541e7134a4f10373a68dd95035f01690b7339 Mon Sep 17 00:00:00 2001 From: G33tha Date: Wed, 3 Feb 2021 16:21:20 +0530 Subject: [PATCH 04/11] Update Jenkinsfile --- bot/Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bot/Jenkinsfile b/bot/Jenkinsfile index 8c48c34..57ee21a 100644 --- a/bot/Jenkinsfile +++ b/bot/Jenkinsfile @@ -31,7 +31,7 @@ node('build-slave') { echo "public_repo_commit_hash: " + public_repo_commit_hash bot_repo_url = params.private_bot_repo - if (params.private_bot_repo && params.private_bot_tag) { + if (params.private_bot_repo || params.private_bot_tag) { dir('bot_repo') { if (params.private_bot_tag == "") { def scmVars = checkout scm @@ -52,9 +52,10 @@ node('build-slave') { stage('Build') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" - build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + build_tag = public_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" if (params.private_bot_repo && params.private_bot_tag) { sh('cp -r bot_repo/* .') + build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" } dir('bot') { sh('chmod 777 build.sh') From fc315a8db23d07893fe561b9f5a5af727a8a950a Mon Sep 17 00:00:00 2001 From: G33tha Date: Wed, 3 Feb 2021 18:26:16 +0530 Subject: [PATCH 05/11] Update Jenkinsfile --- router/Jenkinsfile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/router/Jenkinsfile b/router/Jenkinsfile index a6ae9e2..a3c935b 100644 --- a/router/Jenkinsfile +++ b/router/Jenkinsfile @@ -30,26 +30,34 @@ node('build-slave') { } echo "public_repo_commit_hash: " + public_repo_commit_hash - bot_repo_url = params.diksha_bot_repo - dir('bot_repo') { - if (params.diksha_bot_tag == "") { + bot_repo_url = params.private_bot_repo + + if (params.private_bot_repo || params.private_bot_tag) { + dir('bot_repo') { + if (params.private_bot_tag == "") { def scmVars = checkout scm checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/heads/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) private_repo_commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() } else { def scmVars = checkout scm - checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.diksha_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) - private_repo_commit_hash = params.diksha_bot_tag + checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.private_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) + private_repo_commit_hash = params.private_bot_tag } } + + } } stage('Build') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" - build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_router" - sh('cp -r bot_repo/* .') + + build_tag = public_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + if (params.private_bot_repo && params.private_bot_tag) { + sh('cp -r bot_repo/* .') + build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + } dir('router') { sh('chmod 777 build.sh') sh("./build.sh ${build_tag} ${env.NODE_NAME} ${hub_org}") From 6aeac23c34d0d9be6200a1a3acf64783f69f4f8e Mon Sep 17 00:00:00 2001 From: G33tha Date: Thu, 4 Feb 2021 13:35:41 +0530 Subject: [PATCH 06/11] Update Jenkinsfile --- bot/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/Jenkinsfile b/bot/Jenkinsfile index 57ee21a..0deb795 100644 --- a/bot/Jenkinsfile +++ b/bot/Jenkinsfile @@ -31,7 +31,7 @@ node('build-slave') { echo "public_repo_commit_hash: " + public_repo_commit_hash bot_repo_url = params.private_bot_repo - if (params.private_bot_repo || params.private_bot_tag) { + if (params.private_bot_repo) { dir('bot_repo') { if (params.private_bot_tag == "") { def scmVars = checkout scm @@ -53,7 +53,7 @@ node('build-slave') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" build_tag = public_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" - if (params.private_bot_repo && params.private_bot_tag) { + if (params.private_bot_repo) { sh('cp -r bot_repo/* .') build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" } From e32221683292c3d0d509b31fee80467fdac149ec Mon Sep 17 00:00:00 2001 From: G33tha Date: Thu, 4 Feb 2021 13:36:24 +0530 Subject: [PATCH 07/11] Update Jenkinsfile --- router/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/router/Jenkinsfile b/router/Jenkinsfile index a3c935b..b1d16bf 100644 --- a/router/Jenkinsfile +++ b/router/Jenkinsfile @@ -32,7 +32,7 @@ node('build-slave') { echo "public_repo_commit_hash: " + public_repo_commit_hash bot_repo_url = params.private_bot_repo - if (params.private_bot_repo || params.private_bot_tag) { + if (params.private_bot_repo) { dir('bot_repo') { if (params.private_bot_tag == "") { def scmVars = checkout scm @@ -54,7 +54,7 @@ node('build-slave') { print "Environment will be : ${env.NODE_ENV}" build_tag = public_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" - if (params.private_bot_repo && params.private_bot_tag) { + if (params.private_bot_repo) { sh('cp -r bot_repo/* .') build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" } From c97fbd0926ddebeb81812f7f2c5cec734918d9cb Mon Sep 17 00:00:00 2001 From: G33tha Date: Thu, 4 Feb 2021 13:37:15 +0530 Subject: [PATCH 08/11] Update Jenkinsfile --- router/Jenkinsfile | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/router/Jenkinsfile b/router/Jenkinsfile index a6ae9e2..b1d16bf 100644 --- a/router/Jenkinsfile +++ b/router/Jenkinsfile @@ -30,26 +30,34 @@ node('build-slave') { } echo "public_repo_commit_hash: " + public_repo_commit_hash - bot_repo_url = params.diksha_bot_repo - dir('bot_repo') { - if (params.diksha_bot_tag == "") { + bot_repo_url = params.private_bot_repo + + if (params.private_bot_repo) { + dir('bot_repo') { + if (params.private_bot_tag == "") { def scmVars = checkout scm checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/heads/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) private_repo_commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() } else { def scmVars = checkout scm - checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.diksha_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) - private_repo_commit_hash = params.diksha_bot_tag + checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.private_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) + private_repo_commit_hash = params.private_bot_tag } } + + } } stage('Build') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" - build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_router" - sh('cp -r bot_repo/* .') + + build_tag = public_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + if (params.private_bot_repo) { + sh('cp -r bot_repo/* .') + build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + } dir('router') { sh('chmod 777 build.sh') sh("./build.sh ${build_tag} ${env.NODE_NAME} ${hub_org}") From 6c7e4cce4a7b0d8448219afa4ecdfd85f895e0d4 Mon Sep 17 00:00:00 2001 From: G33tha Date: Thu, 4 Feb 2021 13:38:01 +0530 Subject: [PATCH 09/11] Update Jenkinsfile --- bot/Jenkinsfile | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/bot/Jenkinsfile b/bot/Jenkinsfile index f176aa9..0deb795 100644 --- a/bot/Jenkinsfile +++ b/bot/Jenkinsfile @@ -29,26 +29,34 @@ node('build-slave') { println(ANSI_BOLD + ANSI_YELLOW + "github_release_tag specified, building from github_release_tag: " + params.github_release_tag + ANSI_NORMAL) } echo "public_repo_commit_hash: " + public_repo_commit_hash - bot_repo_url = params.diksha_bot_repo - dir('bot_repo') { - if (params.diksha_bot_tag == "") { - def scmVars = checkout scm - checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/heads/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) - private_repo_commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() - } - else { - def scmVars = checkout scm - checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.diksha_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) - private_repo_commit_hash = params.diksha_bot_tag - } - } + bot_repo_url = params.private_bot_repo + + if (params.private_bot_repo) { + dir('bot_repo') { + if (params.private_bot_tag == "") { + def scmVars = checkout scm + checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/heads/master"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) + private_repo_commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() + } + else { + def scmVars = checkout scm + checkout scm: ([$class: 'GitSCM', branches: [[name: "refs/tags/params.private_bot_tag"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'CloneOption', depth: 0, noTags: false, reference: '', shallow: true]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'private_repo_credentials', url: "$bot_repo_url"]]]) + private_repo_commit_hash = params.private_bot_tag + } + } + + } + } stage('Build') { env.NODE_ENV = "build" print "Environment will be : ${env.NODE_ENV}" - build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" - sh('cp -r bot_repo/* .') + build_tag = public_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + if (params.private_bot_repo) { + sh('cp -r bot_repo/* .') + build_tag = public_repo_commit_hash + "_" + private_repo_commit_hash + "_" + env.BUILD_NUMBER + "_bot" + } dir('bot') { sh('chmod 777 build.sh') sh("./build.sh ${build_tag} ${env.NODE_NAME} ${hub_org}") From 348eb57f79c439763604e83945e290020e734f9d Mon Sep 17 00:00:00 2001 From: JagadishPujari Date: Tue, 16 Feb 2021 12:00:31 +0530 Subject: [PATCH 10/11] Issue #SB-23126 feat:Telemetry evenst are not getting generated when the user clicks on go back and main menu in portal chatBot. --- router/appRest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/router/appRest.js b/router/appRest.js index d5c185f..e4f9642 100644 --- a/router/appRest.js +++ b/router/appRest.js @@ -268,14 +268,14 @@ function menuDrivenLogic(data, res, chatflowConfig) { responseKey = chatflowConfig[currentFlowStep].messageKey menuIntentKnown = true // TODO : Don't call function inside each if/else if it should be called once. - telemetryData = createInteractionData({ currentStep: currentFlowStep, responseKey: responseKey }, data, false) + telemetryData = createInteractionData({ currentStep: currentFlowStep, responseKey: 'MAIN_MENU' }, data, false) } else if (data.message === '99') { if (currentFlowStep.lastIndexOf("_") > 0) { currentFlowStep = currentFlowStep.substring(0, currentFlowStep.lastIndexOf("_")) responseKey = chatflowConfig[currentFlowStep].messageKey menuIntentKnown = true // TODO : Don't call function inside each if/else if it should be called once. - telemetryData = createInteractionData({ currentStep: currentFlowStep, responseKey: responseKey }, data, false) + telemetryData = createInteractionData({ currentStep: 'step_99', responseKey: 'GO_BACK' }, data, false) } } else { responseKey = getErrorMessageForInvalidInput(currentFlowStep, chatflowConfig, true) From 58c7f17d2735b60247f2972f8c436a2c1bbcccb4 Mon Sep 17 00:00:00 2001 From: JagadishPujari Date: Tue, 16 Feb 2021 15:51:46 +0530 Subject: [PATCH 11/11] Issue #SB-23126 feat:Telemetry evenst are not getting generated when the user clicks on go back and main menu in portal chatBot. --- router/appRest.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/router/appRest.js b/router/appRest.js index e4f9642..7cd038c 100644 --- a/router/appRest.js +++ b/router/appRest.js @@ -268,14 +268,20 @@ function menuDrivenLogic(data, res, chatflowConfig) { responseKey = chatflowConfig[currentFlowStep].messageKey menuIntentKnown = true // TODO : Don't call function inside each if/else if it should be called once. - telemetryData = createInteractionData({ currentStep: currentFlowStep, responseKey: 'MAIN_MENU' }, data, false) + telemetryData = createInteractionData({ currentStep: currentFlowStep, responseKey: responseKey }, data, false) + // Telemetry event for Main menu button + var mainMenuEventData = createInteractionData({ currentStep: 'step_0', responseKey: 'MAIN_MENU' }, data, false) + telemetry.logInteraction(mainMenuEventData); } else if (data.message === '99') { if (currentFlowStep.lastIndexOf("_") > 0) { currentFlowStep = currentFlowStep.substring(0, currentFlowStep.lastIndexOf("_")) responseKey = chatflowConfig[currentFlowStep].messageKey menuIntentKnown = true // TODO : Don't call function inside each if/else if it should be called once. - telemetryData = createInteractionData({ currentStep: 'step_99', responseKey: 'GO_BACK' }, data, false) + telemetryData = createInteractionData({ currentStep: currentFlowStep, responseKey: responseKey }, data, false) + // Telemetry event for Go-back button + var goBackEventData = createInteractionData({ currentStep: 'step_99', responseKey: 'GO_BACK' }, data, false) + telemetry.logInteraction(goBackEventData); } } else { responseKey = getErrorMessageForInvalidInput(currentFlowStep, chatflowConfig, true)