Skip to content

Commit 2a9450e

Browse files
Sakshithakaresakshi121
authored andcommitted
remove console logs and debugger
2 parents fc5e6df + 7d2b9ea commit 2a9450e

35 files changed

Lines changed: 1246 additions & 611 deletions

cloudbuild.yaml

Lines changed: 179 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,184 @@
11
options:
22
logging: CLOUD_LOGGING_ONLY
33

4-
substitutions:
5-
_BUILD_ENV: "test" # Set this to the target environment (test, release, etc.)
6-
_BRANCH: "${BRANCH_NAME}" # Branch name from the trigger
7-
_FIREBASE_PROJECT_ID: "your-project-id" # Replacing with dynamic project ID
8-
_FIREBASE_SITE_ID: "${_BUILD_ENV}_site_id" # Placeholder for Firebase site ID
4+
substitutions:
5+
_BUILD_ENV: "test"
6+
_BRANCH: "branch-value"
7+
_DEPLOY_CDN: "false"
8+
_CDN_BUCKET: "your-cdn-bucket"
9+
_FIREBASE_PROJECT_ID: "your-project-id"
10+
_FIREBASE_SITE_ID: "your-site-id"
911

1012
steps:
11-
# Step 1: Install Node.js dependencies
12-
- name: 'gcr.io/cloud-builders/npm'
13-
entrypoint: 'sh'
14-
args:
15-
- '-c'
16-
- |
17-
echo clean
18-
npm cache clean --force
19-
echo remove
20-
rm -rf node_modules package-lock.json
21-
echo Installing source NPM dependencies...
22-
npm install
23-
24-
# Step 2: Conditionally run builds based on _BUILD_ENV
25-
- name: 'gcr.io/cloud-builders/npm'
26-
entrypoint: 'sh'
27-
env:
28-
- '_BRANCH=${_BRANCH}'
29-
- '_BUILD_ENV=${_BUILD_ENV}'
30-
args:
31-
- '-c'
32-
- |
33-
echo "Build env:" ${_BUILD_ENV}
34-
if [ "${_BUILD_ENV}" = "test" ]; then
35-
npm run build-test;
36-
elif [ "${_BUILD_ENV}" = "release" ]; then
37-
npm run build-release;
38-
elif [ "${_BUILD_ENV}" = "staging" ]; then
39-
npm run build-staging;
40-
elif [ "${_BUILD_ENV}" = "prod" ]; then
41-
npm run build-prod;
42-
elif [ "${_BUILD_ENV}" = "prod-enterprise" ]; then
43-
npm run build-prod-enterprise;
44-
elif [ "${_BUILD_ENV}" = "prod-in" ]; then
45-
npm run build-prod-in;
46-
elif [ "${_BUILD_ENV}" = "prod_agenticfirst" ]; then
47-
npm run build-prod-agenticfirst;
48-
elif [ "${_BUILD_ENV}" = "prod-eu" ]; then
49-
npm run build-prod-eu;
50-
elif [ "${_BUILD_ENV}" = "prod_cn" ]; then
51-
npm run build-prod-cn;
52-
elif [ "${_BUILD_ENV}" = "prod_beta" ]; then
53-
npm run build-beta;
54-
else
55-
npm run build-test;
56-
fi
57-
58-
# Step 3: Updated firebase.json dynamically
59-
- name: 'alpine'
60-
entrypoint: 'sh'
61-
args:
62-
- '-c'
63-
- |
64-
echo "Updating firebase.json with site ID..."
65-
# Update the site ID dynamically
66-
sed -i 's/"site": ".*"/"site": "'"${_FIREBASE_SITE_ID}"'"/' firebase.json
67-
68-
# Step 4: Validating the build directory contains index.html
69-
- name: 'alpine'
70-
entrypoint: 'sh'
71-
args:
72-
- '-c'
73-
- |
74-
echo "Checking if webplugin/build contains index.html..."
75-
if [ ! -f "webplugin/build/index.html" ]; then
76-
echo "Error: index.html not found in webplugin/build. Build process might have failed."
77-
exit 1
78-
fi
79-
echo "firebase.json exists, now validating its structure..."
80-
if [ ! -f "firebase.json" ]; then
81-
echo "Error: firebase.json file does not exist."
82-
exit 1
83-
fi
84-
85-
# Step 5: Deploy to Firebase Hosting
86-
- name: 'gcr.io/$PROJECT_ID/firebase'
87-
args:
88-
- 'deploy'
89-
- '--only'
90-
- 'hosting:${_FIREBASE_SITE_ID}'
91-
- '--project'
92-
- '${_FIREBASE_PROJECT_ID}'
93-
- '--token'
94-
- '${_FIREBASE_TOKEN}'
13+
# ------------------------------------------------------------
14+
# Step 1: Install Node.js dependencies
15+
# ------------------------------------------------------------
16+
- name: 'gcr.io/cloud-builders/npm'
17+
entrypoint: 'sh'
18+
args:
19+
- '-c'
20+
- |
21+
echo "Cleaning npm cache"
22+
npm cache clean --force
23+
rm -rf node_modules package-lock.json
24+
echo "Installing dependencies"
25+
npm install
26+
27+
# ------------------------------------------------------------
28+
# Step 2: Build based on environment
29+
# ------------------------------------------------------------
30+
- name: 'gcr.io/cloud-builders/npm'
31+
entrypoint: 'sh'
32+
env:
33+
- '_BRANCH=${_BRANCH}'
34+
- '_BUILD_ENV=${_BUILD_ENV}'
35+
36+
args:
37+
- '-c'
38+
- |
39+
echo "Build env: $_BUILD_ENV"
40+
if [ "$_BUILD_ENV" = "test" ]; then
41+
npm run build-test
42+
elif [ "$_BUILD_ENV" = "release" ]; then
43+
npm run build-release
44+
elif [ "$_BUILD_ENV" = "staging" ]; then
45+
npm run build-staging
46+
elif [ "$_BUILD_ENV" = "prod" ]; then
47+
npm run build-prod
48+
elif [ "$_BUILD_ENV" = "prod-enterprise" ]; then
49+
npm run build-prod-enterprise
50+
elif [ "$_BUILD_ENV" = "prod-in" ]; then
51+
npm run build-prod-in
52+
elif [ "$_BUILD_ENV" = "prod_agenticfirst" ]; then
53+
npm run build-prod-agenticfirst
54+
elif [ "$_BUILD_ENV" = "prod-eu" ]; then
55+
npm run build-prod-eu
56+
elif [ "$_BUILD_ENV" = "prod_cn" ]; then
57+
npm run build-prod-cn
58+
elif [ "$_BUILD_ENV" = "prod_beta" ]; then
59+
npm run build-beta
60+
else
61+
npm run build-test
62+
fi
63+
64+
# ------------------------------------------------------------
65+
# Step 2.1: Inject branch & env into index.html
66+
# ------------------------------------------------------------
67+
- name: 'alpine'
68+
entrypoint: 'sh'
69+
args:
70+
- '-c'
71+
- |
72+
echo "Injecting branch and env into index.html"
73+
sed -i "s/__KM_BRANCH__/${_BRANCH}/g" webplugin/build/index.html
74+
sed -i "s/__KM_ENV__/${_BUILD_ENV}/g" webplugin/build/index.html
75+
76+
echo "Updated index.html:"
77+
grep "Welcome to kommunicate" webplugin/build/index.html
78+
79+
80+
# ------------------------------------------------------------
81+
# Step 3: Update firebase.json dynamically
82+
# ------------------------------------------------------------
83+
- name: 'alpine'
84+
entrypoint: 'sh'
85+
args:
86+
- '-c'
87+
- |
88+
echo "Updating firebase.json site ID"
89+
sed -i 's/"site": ".*"/"site": "'"$_FIREBASE_SITE_ID"'"/' firebase.json
90+
91+
# ------------------------------------------------------------
92+
# Step 4: Validate build output
93+
# ------------------------------------------------------------
94+
- name: 'alpine'
95+
entrypoint: 'sh'
96+
args:
97+
- '-c'
98+
- |
99+
if [ ! -f "webplugin/build/index.html" ]; then
100+
echo "ERROR: index.html not found in webplugin/build"
101+
exit 1
102+
fi
103+
if [ ! -f "firebase.json" ]; then
104+
echo "ERROR: firebase.json not found"
105+
exit 1
106+
fi
107+
echo "Build validation successful"
108+
109+
# ------------------------------------------------------------
110+
# Step 5: Firebase deploy (skipped when CDN enabled)
111+
# ------------------------------------------------------------
112+
- name: 'gcr.io/$PROJECT_ID/firebase'
113+
entrypoint: 'sh'
114+
args:
115+
- '-c'
116+
- |
117+
if [ "$_DEPLOY_CDN" = "true" ]; then
118+
echo "Skipping Firebase deploy (_DEPLOY_CDN=true)"
119+
exit 0
120+
fi
121+
firebase deploy \
122+
--only hosting:$_FIREBASE_SITE_ID \
123+
--project $_FIREBASE_PROJECT_ID \
124+
--token $_FIREBASE_TOKEN
125+
126+
# ------------------------------------------------------------
127+
# Step 6: Sync build output to CDN bucket
128+
# ------------------------------------------------------------
129+
- name: 'gcr.io/cloud-builders/gsutil'
130+
entrypoint: 'sh'
131+
args:
132+
- '-c'
133+
- |
134+
if [ "$_DEPLOY_CDN" = "true" ]; then
135+
echo "Syncing widget build to CDN bucket root"
136+
gsutil -m rsync -r webplugin/build gs://$_CDN_BUCKET
137+
else
138+
echo "Skipping CDN sync"
139+
fi
140+
141+
# ------------------------------------------------------------
142+
# Step 7: Apply CDN cache headers
143+
# ------------------------------------------------------------
144+
- name: 'gcr.io/cloud-builders/gsutil'
145+
entrypoint: 'sh'
146+
args:
147+
- '-c'
148+
- |
149+
if [ "$_DEPLOY_CDN" = "true" ]; then
150+
echo "Applying CDN cache headers (default=300, explicit long)"
151+
152+
# Default cache = 300s for EVERYTHING
153+
gsutil -m setmeta -r \
154+
-h "Cache-Control:public,max-age=300" \
155+
gs://$_CDN_BUCKET/ || true
156+
157+
# Long cache ONLY for versioned resource assets
158+
gsutil -m setmeta \
159+
-h "Cache-Control:public,max-age=31536000,immutable" \
160+
gs://$_CDN_BUCKET/*/resources/** || true
161+
162+
# Long cache for shared static assets
163+
gsutil -m setmeta \
164+
-h "Cache-Control:public,max-age=31536000,immutable" \
165+
gs://$_CDN_BUCKET/css/** \
166+
gs://$_CDN_BUCKET/plugin/** \
167+
gs://$_CDN_BUCKET/resources/third-party-scripts/** || true
168+
169+
# Long cache for fonts
170+
gsutil -m setmeta \
171+
-h "Cache-Control:public,max-age=31536000,immutable" \
172+
gs://$_CDN_BUCKET/*/css/app/fonts/** || true
173+
174+
#
175+
gsutil setmeta -h "Cache-Control:public,max-age=300" gs://$_CDN_BUCKET/index.html
176+
gsutil setmeta -h "Cache-Control:public,max-age=300" gs://$_CDN_BUCKET/kommunicate-widget-3.0.min.js
177+
gsutil setmeta -h "Cache-Control:public,max-age=300" gs://$_CDN_BUCKET/v2/kommunicate.app
178+
gsutil setmeta -h "Cache-Control:public,max-age=300" gs://$_CDN_BUCKET/v3/kommunicate.app
179+
180+
echo "CDN cache headers applied successfully"
181+
else
182+
echo "Skipping CDN cache headers"
183+
fi
184+

example/demo2.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ <h1>Kommunicate Modern Widget Demo</h1>
1616
popupWidget: true,
1717
layout: 'modern',
1818
automaticChatOpenOnNavigation: true,
19+
onInit: function () {
20+
console.log('Kommunicate widget initialized');
21+
// var defaultSettings = {
22+
// "defaultAgentIds": ["okies-kijaq"],
23+
// "defaultBotIds": ["okies-kijaq"], // Replace <BOT_ID> with your bot ID which you can find in bot section of dashboard
24+
// "defaultAssignee": "okies-kijaq", // Replace <BOT_ID> with your bot ID which you can find in bot section of dashboard
25+
// "skipRouting": true,
26+
// };
27+
// Kommunicate.updateSettings(defaultSettings);
28+
// window.Kommunicate.startConversation();
29+
},
1930
// appSettings: {
2031
// chatWidget: {
2132
// popup: false,
@@ -79,6 +90,13 @@ <h1>Kommunicate Modern Widget Demo</h1>
7990
// required: true,
8091
// placeholder: 'Enter your email',
8192
// },
93+
// {
94+
// field: 'Phone',
95+
// type: 'phone',
96+
// required: true,
97+
// enableCountryCode: true,
98+
// placeholder: 'Enter your phone number',
99+
// },
82100
// ],
83101
};
84102
var s = document.createElement('script');
@@ -93,5 +111,14 @@ <h1>Kommunicate Modern Widget Demo</h1>
93111
m._globals = kommunicateSettings;
94112
})(document, window.kommunicate || {});
95113
</script>
114+
<!--
115+
<iframe
116+
style="border: none;"
117+
height="600px"
118+
width="400px"
119+
src="https://widget-test.kommunicate.io/chat?appId=kommunicate-support"
120+
allow="microphone; geolocation;"
121+
>
122+
</iframe> -->
96123
</body>
97124
</html>

firebase.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@
7676
}
7777
]
7878
},
79+
{
80+
"source": "**/resources/**/*.html",
81+
"headers": [
82+
{
83+
"key": "Cache-Control",
84+
"value": "public, max-age=31536000"
85+
}
86+
]
87+
},
7988
{
8089
"source": "/v2/kommunicate.app",
8190
"headers": [

webplugin/bundleFiles.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ exports.version = version;
1111
exports.KM_RELEASE_BRANCH = resolveBranch();
1212
const STORAGE_FILES = [
1313
path.resolve(__dirname, 'js/app/storage/storage-service.js'),
14-
path.resolve(__dirname, 'js/app/storage/cookie-service.js'),
1514
path.resolve(__dirname, 'js/app/storage/session-service.js'),
1615
path.resolve(__dirname, 'js/app/storage/local-service.js'),
1716
];

webplugin/css/app/mck-tab-visibility.css

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.layout-classic #mck-sidebox-content.active-tab-conversations:not(.active-subsection-conversation-individual) .mck-name-status-container,
2-
.layout-classic #mck-sidebox-content.active-tab-conversations:not(.active-subsection-conversation-individual) .mck-back-btn-container, .layout-classic #mck-sidebox-content.active-tab-conversations:not(.active-subsection-conversation-individual) #mck-tab-individual, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual .km-bottom-tab-wrapper, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual #mck-contacts-content, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual #mck-tab-conversation, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual #km-faq, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list .km-conversations-empty:not(.n-vis) ~ #mck-contacts-content, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list #mck-tab-individual, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list #km-widget-options, #mck-sidebox-content.active-tab-conversations .km-faq-back-btn-wrapper, .km-empty-conversation-active #mck-sidebox-ft, #mck-sidebox-content:not(.active-tab-conversations) #mck-sidebox-ft, #mck-sidebox-content:not(.active-tab-conversations) .mck-agent-image-container,
2+
.layout-classic #mck-sidebox-content.active-tab-conversations:not(.active-subsection-conversation-individual) .mck-back-btn-container, .layout-classic #mck-sidebox-content.active-tab-conversations:not(.active-subsection-conversation-individual) #mck-tab-individual, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual .km-bottom-tab-wrapper, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual #mck-contacts-content, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual #mck-tab-conversation, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual #km-faq, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list .km-conversations-empty:not(.n-vis) ~ #mck-contacts-content, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list #mck-sidebox-ft, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list #mck-tab-individual, #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-list #km-widget-options, #mck-sidebox-content.active-tab-conversations .km-faq-back-btn-wrapper, .km-empty-conversation-active #mck-sidebox-ft, #mck-sidebox-content:not(.active-tab-conversations) #mck-sidebox-ft, #mck-sidebox-content:not(.active-tab-conversations) .mck-agent-image-container,
33
#mck-sidebox-content:not(.active-tab-conversations) .mck-agent-status-indicator,
44
#mck-sidebox-content:not(.active-tab-conversations) #mck-agent-status-text,
55
#mck-sidebox-content:not(.active-tab-conversations) .mck-typing-box,
@@ -208,12 +208,13 @@
208208
.layout-modern #mck-sidebox-content.active-tab-faqs .km-kb-container #km-faq {
209209
display: none !important;
210210
}
211-
.layout-modern #mck-sidebox-content .mck-running-on {
212-
display: none !important;
213-
}
214-
.layout-modern #mck-sidebox-content.active-tab-conversations.active-subsection-conversation-individual .mck-running-on, .layout-modern #mck-sidebox-content.is-tab-conversations.is-subsection-conversation-individual .mck-running-on {
211+
.layout-modern #mck-sidebox-content.km-poweredby-enabled.active-tab-conversations.active-subsection-conversation-individual .mck-running-on,
212+
.layout-modern #mck-sidebox-content.km-poweredby-enabled.is-tab-conversations.is-subsection-conversation-individual .mck-running-on {
215213
display: block !important;
216214
}
215+
.layout-modern #mck-sidebox-content.km-poweredby-enabled:not(.active-tab-conversations.active-subsection-conversation-individual):not(.is-tab-conversations.is-subsection-conversation-individual) .mck-running-on {
216+
display: none !important;
217+
}
217218
.layout-modern #km-faq {
218219
display: none !important;
219220
}

0 commit comments

Comments
 (0)