@boomerang-io/webapp-spa-server 1.3.0-beta.0 → 1.3.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +46 -9
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -176,6 +176,7 @@ function injectEnvDataAndScriptsIntoHTML({ res, buildDir, appRoot, injectedDataK
176
176
  </script>
177
177
  ${getBeeheardSurveyScripts()}
178
178
  ${getGAScripts()}
179
+ ${getBluemixSegmentScripts()}
179
180
  ${getInstanaScripts()}
180
181
  ${localScriptTags}
181
182
  </head>`
@@ -191,10 +192,47 @@ function getBeeheardSurveyScripts() {
191
192
  : "";
192
193
  }
193
194
 
195
+ // Include Google Analytics based on env var
196
+ function getBluemixSegmentScripts() {
197
+ const enableSegment = process.env.SEGMENT_ENABLED;
198
+ const segmentUrl = process.env.SEGMENT_SCRIPT_URL;
199
+ const segmentKey = process.env.SEGMENT_KEY;
200
+
201
+ return Boolean(enableSegment)
202
+ ? `<script>
203
+ digitalData = {
204
+ page: {
205
+ pageInfo: {
206
+ pageID: "ibm_consulting_advantage_test",
207
+ productTitle: "IBM Consulting Advantage",
208
+ analytics: {
209
+ category: "Offering Interface"
210
+ }
211
+ }
212
+ }
213
+ };
214
+ </script>
215
+ <script type="text/javascript"> window._analytics = { "segment_key" : "${segmentKey}", "coremetrics" : false, "optimizely" : false, "googleAddServices": false, "fullStory" : false}; </script>
216
+ <script src="${segmentUrl}" crossorigin></script>
217
+ <script>
218
+ window._analytics = {
219
+ "pageProperties": {
220
+ "productCode": "694970X",
221
+ "productCodeType": "Consulting Advantage",
222
+ },
223
+ };
224
+ </script>
225
+ `
226
+ : "";
227
+ }
228
+
194
229
  // Include Google Analytics based on env var
195
230
  function getGAScripts() {
196
- const ibmInstrumentationId = process.env.GA_SITE_ID;
197
- return Boolean(ibmInstrumentationId)
231
+ const gaSiteId = process.env.GA_SITE_ID;
232
+ const gaUrl = process.env.GA_SCRIPT_URL;
233
+ const gaEnabled = process.env.GA_ENABLED;
234
+
235
+ return Boolean(gaEnabled)
198
236
  ? `<script type="text/javascript">
199
237
  window.idaPageIsSPA = true;
200
238
  window._ibmAnalytics = {
@@ -210,18 +248,17 @@ function getGAScripts() {
210
248
  digitalData = {
211
249
  page: {
212
250
  pageInfo: {
213
- pageID: ${ibmInstrumentationId},
214
- productTitle: "IBM Consulting Advantage",
215
- analytics: {
216
- category: 'Offering Interface'
251
+ ibm: {
252
+ siteID: '${gaSiteId}',
217
253
  }
254
+ },
255
+ category: {
256
+ primaryCategory: 'PC100'
218
257
  }
219
258
  }
220
259
  };
221
260
  </script>
222
- <script type="text/javascript"> window._analytics = { "segment_key" : "BdBQtVrGbCxBumrCuR2MYAARD8CA3VQp", "coremetrics" : false, "optimizely" : false, "googleAddServices": false, "fullStory" : false}; </script>
223
- <script src="https://console.test.cloud.ibm.com/analytics/build/bluemix-analytics.min.js"></script>
224
- <script async src="https://1.www.s81c.com/common/stats/ibm-common.js" type="text/javascript" crossorigin></script>`
261
+ <script async src="${gaUrl}" type="text/javascript" crossorigin></script>`
225
262
  : "";
226
263
  }
227
264
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@boomerang-io/webapp-spa-server",
3
3
  "description": "Webapp Server for React-based SPA w/ client-side routing",
4
- "version": "1.3.0-beta.0",
4
+ "version": "1.3.0-beta.10",
5
5
  "author": {
6
6
  "name": "Tim Bula",
7
7
  "email": "timrbula@gmail.com"
@@ -31,7 +31,7 @@
31
31
  "compression": "^1.7.4",
32
32
  "cors": "^2.8.5",
33
33
  "dotenv": "^16.0.3",
34
- "express": "^4.18.2",
34
+ "express": "^4.19.2",
35
35
  "helmet": "^6.0.0",
36
36
  "newrelic": "^9.15.0",
37
37
  "serialize-javascript": "^6.0.0",