Skip to content

Commit

Permalink
chore(analytics): remove feature flag [MA-2027] (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihai-peteu authored Sep 8, 2023
1 parent 0b6ccdd commit 64fc24b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 50 deletions.
38 changes: 3 additions & 35 deletions cypress/e2e/specs/contextual-analytics.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { apps, productRegistration, productRegistrations, versions } from '../fixtures/consts'
import { apps, productRegistrations, versions } from '../fixtures/consts'

describe('Contextual Developer Analytics', () => {
beforeEach(() => {
Expand All @@ -21,9 +21,7 @@ describe('Contextual Developer Analytics', () => {
viewAnalyticsButton: '[data-testid="application-dashboard-button"]'
}

it('My Apps – displays displays metric cards if the feature flag is on', () => {
cy.mockLaunchDarklyFlags([{ name: 'ma-1002-dev-portal-contextual-analytics', value: true }])

it('My Apps – displays displays metric cards', () => {
cy.mockApplications(apps, 4)

cy.visit('/', { useOriginalFn: true })
Expand All @@ -36,38 +34,8 @@ describe('Contextual Developer Analytics', () => {
cy.get(selectors.dashboardDropdownLink).should('exist')
})

it('My Apps – does not display metric cards or the analytics dropdown link if the feature flag is off', () => {
cy.mockLaunchDarklyFlags([{ name: 'ma-1002-dev-portal-contextual-analytics', value: false }])

cy.mockApplications(apps, 5)
cy.visit('/my-apps')

cy.get(selectors.metricCardsParent).should('not.exist')
cy.get('[data-testid="applications-table"]').find('.actions-badge').first().click()
cy.get(selectors.dashboardDropdownLink).should('not.exist')
})

it('My App details page – does not display Metrics Card, View Analytics button if the feature flag is off', () => {
cy.mockLaunchDarklyFlags([{ name: 'ma-1002-dev-portal-contextual-analytics', value: true }])
cy.mockApplications(apps, 4)

cy.intercept(
'GET',
`**/api/v2/applications/${apps[0].id}`, {
statusCode: 200,
body: { ...apps[0] }
}
).as('getSingleApplication')

cy.mockApplicationWithCredAndReg(apps[0])

cy.visit(`/application/${apps[0].id}`)
cy.get('[data-testid="analytics-metric-cards"]').should('not.exist')
cy.get('[data-testid="application-dashboard-button"]').should('not.exist')
})

it('App Dashboard - vitals elements load when contextual analytics feature flag is on', () => {
cy.mockLaunchDarklyFlags([{ name: 'ma-1002-dev-portal-contextual-analytics', value: true }])
it('App Dashboard - vitals elements load', () => {
cy.mockApplications(apps, 4)

cy.intercept('GET', `**/api/v2/applications/${apps[0].id}`, {
Expand Down
2 changes: 1 addition & 1 deletion src/constants/feature-flags.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export enum FeatureFlags {
PortalContextualAnalytics = 'ma-1002-dev-portal-contextual-analytics'
//
}
7 changes: 1 addition & 6 deletions src/views/Applications/ApplicationDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class="mb-5"
:title="helpText.analytics.dashboard"
/>
<div v-if="contextualAnalytics && hasProductVersions">
<div v-if="hasProductVersions">
<div
class="analytics-filters d-flex flex-grow-1 justify-content-between align-items-baseline mb-6"
>
Expand Down Expand Up @@ -112,8 +112,6 @@ import getMessageFromError from '@/helpers/getMessageFromError'
import usePortalApi from '@/hooks/usePortalApi'
import useToaster from '@/composables/useToaster'
import useAllowedTimeframes from '@/composables/useAllowedTimeframes'
import { FeatureFlags } from '@/constants/feature-flags'
import useLDFeatureFlag from '@/hooks/useLDFeatureFlag'
import {
datePickerSelectionToTimeframe,
Timeframe,
Expand All @@ -131,9 +129,6 @@ import { useAppStore, useI18nStore } from '@/stores'
import cloneDeep from 'lodash.clonedeep'
import { PortalTimeframeKeys } from '@/types/vitals'
// @ts-ignore
const contextualAnalytics = useLDFeatureFlag(FeatureFlags.PortalContextualAnalytics, false)
const { notify } = useToaster()
const errorMessage = ref('')
const application = ref(null)
Expand Down
9 changes: 1 addition & 8 deletions src/views/MyApps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</template>
</PageTitle>
<div
v-if="contextualAnalytics && !vitalsLoading && myAppsReady"
v-if="!vitalsLoading && myAppsReady"
>
<MetricsProvider
v-slot="{ timeframe }"
Expand Down Expand Up @@ -76,7 +76,6 @@
<ActionsDropdown :key="row.id">
<template #content>
<div
v-if="contextualAnalytics"
data-testid="dropdown-analytics-dashboard"
class="py-2 px-3 type-md cursor-pointer"
@click="$router.push({ name: 'application-dashboard', params: { application_id: row.id }})"
Expand Down Expand Up @@ -182,8 +181,6 @@
import { defineComponent, computed, ref, onMounted } from 'vue'
import { useMachine } from '@xstate/vue'
import { createMachine } from 'xstate'
import { FeatureFlags } from '@/constants/feature-flags'
import useLDFeatureFlag from '@/hooks/useLDFeatureFlag'
import getMessageFromError from '@/helpers/getMessageFromError'
import RefreshTokenModal from '@/components/RefreshTokenModal.vue'
import PageTitle from '@/components/PageTitle.vue'
Expand Down Expand Up @@ -219,9 +216,6 @@ export default defineComponent({
const helpTextVitals = useI18nStore().state.helpText.analytics
const vitalsLoading = ref(true)
// @ts-ignore: Dev Portal doesn't have TS for feature flags.
const contextualAnalytics = useLDFeatureFlag(FeatureFlags.PortalContextualAnalytics, false)
const paginationConfig = ref({
paginationPageSizes: [25, 50, 100],
initialPageSize: 25
Expand Down Expand Up @@ -365,7 +359,6 @@ export default defineComponent({
helpText,
helpTextVitals,
analyticsCardTitle,
contextualAnalytics,
vitalsLoading,
metricProviderProps,
myAppsReady
Expand Down

0 comments on commit 64fc24b

Please sign in to comment.