From 82c3348b1533878a834b6b14f5c7f9cf45394c60 Mon Sep 17 00:00:00 2001 From: mabashian Date: Thu, 20 May 2021 14:06:16 -0400 Subject: [PATCH 1/2] Only initialize pendo if the key is available --- awx/ui_next/src/util/issuePendoIdentity.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/awx/ui_next/src/util/issuePendoIdentity.js b/awx/ui_next/src/util/issuePendoIdentity.js index 380a796113..a1cb837e78 100644 --- a/awx/ui_next/src/util/issuePendoIdentity.js +++ b/awx/ui_next/src/util/issuePendoIdentity.js @@ -53,13 +53,15 @@ async function issuePendoIdentity(config) { const { data: { PENDO_API_KEY }, } = await RootAPI.readAssetVariables(); - bootstrapPendo(PENDO_API_KEY); - const pendoOptions = buildPendoOptions(config, PENDO_API_KEY); - const pendoOptionsWithRole = await buildPendoOptionsRole( - pendoOptions, - config - ); - window.pendo.initialize(pendoOptionsWithRole); + if (PENDO_API_KEY && PENDO_API_KEY !== '') { + bootstrapPendo(PENDO_API_KEY); + const pendoOptions = buildPendoOptions(config, PENDO_API_KEY); + const pendoOptionsWithRole = await buildPendoOptionsRole( + pendoOptions, + config + ); + window.pendo.initialize(pendoOptionsWithRole); + } } } From dd1bda3b6780949f7b5e14a0e875491a723b93a0 Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 25 May 2021 08:06:06 -0400 Subject: [PATCH 2/2] Fix broken app container test --- .../AppContainer/AppContainer.test.jsx | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx b/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx index fdbde02a75..df5039a6bb 100644 --- a/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx +++ b/awx/ui_next/src/components/AppContainer/AppContainer.test.jsx @@ -22,7 +22,7 @@ describe('', () => { RootAPI.readAssetVariables.mockResolvedValue({ data: { BRAND_NAME: 'AWX', - PENDO_API_KEY: '', + PENDO_API_KEY: 'some-pendo-key', }, }); MeAPI.read.mockResolvedValue({ data: { results: [{}] } }); @@ -37,7 +37,7 @@ describe('', () => { test('expected content is rendered', async () => { const routeConfig = [ { - groupTitle: 'Group One', + groupTitle: Group One, groupId: 'group_one', routes: [ { title: 'Foo', path: '/foo' }, @@ -45,7 +45,7 @@ describe('', () => { ], }, { - groupTitle: 'Group Two', + groupTitle: Group Two, groupId: 'group_two', routes: [{ title: 'Fiz', path: '/fiz' }], }, @@ -95,7 +95,36 @@ describe('', () => { expect(global.pendo.initialize).toHaveBeenCalledTimes(1); }); - test('expected content is rendered', async () => { + test('Pendo not initialized when key is missing', async () => { + RootAPI.readAssetVariables.mockResolvedValue({ + data: { + BRAND_NAME: 'AWX', + PENDO_API_KEY: '', + }, + }); + let wrapper; + await act(async () => { + wrapper = mountWithContexts(, { + context: { + config: { + analytics_status: 'detailed', + ansible_version: null, + custom_virtualenvs: [], + version: '9000', + me: { is_superuser: true }, + toJSON: () => '/config/', + license_info: { + valid_key: true, + }, + }, + }, + }); + }); + wrapper.update(); + expect(global.pendo.initialize).toHaveBeenCalledTimes(0); + }); + + test('Pendo not initialized when status is analytics off', async () => { let wrapper; await act(async () => { wrapper = mountWithContexts(, {