From a708140fc40a5181e34e2a6d78ccd3f8eb8ce782 Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Tue, 27 Jun 2023 14:22:14 -0700 Subject: [PATCH] chore: remove userpilot content --- src/App.tsx | 2 - .../components/onboarding/EngagementLink.tsx | 57 ------- .../components/onboarding/useGetUserStatus.ts | 148 ------------------ .../components/FeedbackBar.tsx | 10 -- src/index.tsx | 1 - src/shared/utils/mocks/usageStats.mocks.ts | 35 ----- 6 files changed, 253 deletions(-) delete mode 100644 src/cloud/components/onboarding/EngagementLink.tsx delete mode 100644 src/cloud/components/onboarding/useGetUserStatus.ts delete mode 100644 src/shared/utils/mocks/usageStats.mocks.ts diff --git a/src/App.tsx b/src/App.tsx index 6016594342..12870e1e25 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -25,7 +25,6 @@ import { OverlayController, } from 'src/overlays/components/OverlayController' import PageSpinner from 'src/perf/components/PageSpinner' -import EngagementLink from 'src/cloud/components/onboarding/EngagementLink' import {GlobalHeader} from 'src/identity/components/GlobalHeader/GlobalHeader' const SetOrg = lazy(() => import('src/shared/containers/SetOrg')) @@ -117,7 +116,6 @@ const App: FC = () => { - }> diff --git a/src/cloud/components/onboarding/EngagementLink.tsx b/src/cloud/components/onboarding/EngagementLink.tsx deleted file mode 100644 index ec6f37ccfa..0000000000 --- a/src/cloud/components/onboarding/EngagementLink.tsx +++ /dev/null @@ -1,57 +0,0 @@ -// Libraries -import {FC, useEffect, useState, memo} from 'react' -import {useLocation} from 'react-router-dom' -import {useSelector} from 'react-redux' - -// Utils -import {getOrg} from 'src/organizations/selectors' -import handleGetUserStatus from 'src/cloud/components/onboarding/useGetUserStatus' -import {isFlagEnabled} from 'src/shared/utils/featureFlag' - -// Types -import {AppState} from 'src/types' - -const EngagementLink: FC = () => { - const [dataStates, setDataStates] = useState([]) - const pathname = useLocation().pathname - const userpilot = window['userpilot'] - const org = useSelector(getOrg) - const me = useSelector((state: AppState) => state.me) - - useEffect(() => { - if (isFlagEnabled('newUsageAPI') && org?.id) { - handleGetUserStatus(org.id).then(({usageDataStates}) => - setDataStates(usageDataStates) - ) - } - }, [org?.id]) - - useEffect(() => { - if (userpilot) { - sendToUserPilot() - userpilot.reload() - } - }, [pathname, org, me]) - - const sendToUserPilot = (): void => { - const host = window?.location?.hostname.split('.') - - if (org && me) { - userpilot.identify(me.name, { - email: me.name, // User Email address - orgID: org.id, // Organization ID - region: host[0], // Cloud provider region - provider: host[1], // Cloud provider - company: { - id: org.id, // Organization ID - }, - ...(isFlagEnabled('newUsageAPI') && - dataStates.length && {UsageDataStates: dataStates}), - }) - } - } - - return null -} - -export default memo(EngagementLink) diff --git a/src/cloud/components/onboarding/useGetUserStatus.ts b/src/cloud/components/onboarding/useGetUserStatus.ts deleted file mode 100644 index a78ceb36ab..0000000000 --- a/src/cloud/components/onboarding/useGetUserStatus.ts +++ /dev/null @@ -1,148 +0,0 @@ -import {fromFlux} from '@influxdata/giraffe' -import {event} from 'src/cloud/utils/reporting' -import {isFlagEnabled} from 'src/shared/utils/featureFlag' -import {Table} from '@influxdata/giraffe' -import {CLOUD} from 'src/shared/constants' -import {usageStatsCsv} from 'src/shared/utils/mocks/usageStats.mocks' - -let getUsage = null - -if (CLOUD) { - getUsage = require('src/client').getOrgsUsage -} - -export enum USER_PILOT_USER_STATUS { - NEW_USER = 'NEW_USER', - DELETED_ALL_DATA = 'DELETED_ALL_DATA', - NON_WRITING_USER = 'NON_WRITING_USER', - ACTIVE_USER = 'ACTIVE_USER', - WRITING_NOT_READING_USER = 'WRITING_NOT_READING_USER', -} -export const getUserStatus = (table: Table): USER_PILOT_USER_STATUS[] => { - const dataStates: USER_PILOT_USER_STATUS[] = [] - - const measurement = (table.getColumn('_measurement') as string[]) ?? [] - - // this looks up storage amounts to see if the user has stored data - const storageBytes = measurement.find((_v, i) => { - return ( - measurement[i] === 'storage_usage_bucket_bytes' && - table.getColumn('_value', 'number')[i] > 0 - ) - }) - - // This looks up requests that are POSTs to our query endpoints for writing data - const requestInByte = measurement.find((_v, i) => { - return ( - measurement[i] === 'http_request' && - ['/api/v2/query', '/query'].includes( - table.getColumn('endpoint', 'string')[i] - ) && - table.getColumn('_field')[i] === 'req_bytes' && - table.getColumn('_value', 'number')[i] > 0 - ) - }) - - // This looks up a total of query counts in general to see if the user has read values - const queryCount = measurement.find((_v, i) => { - return ( - measurement[i] === 'query_count' && - table.getColumn('_value', 'number')[i] > 0 - ) - }) - - if (!storageBytes && !requestInByte) { - dataStates.push(USER_PILOT_USER_STATUS.NEW_USER) - } - if (!storageBytes && requestInByte) { - dataStates.push(USER_PILOT_USER_STATUS.DELETED_ALL_DATA) - } - if (storageBytes && !requestInByte) { - dataStates.push(USER_PILOT_USER_STATUS.NON_WRITING_USER) - } - if (storageBytes && requestInByte && !queryCount) { - dataStates.push(USER_PILOT_USER_STATUS.WRITING_NOT_READING_USER) - } - if (storageBytes && requestInByte && queryCount) { - dataStates.push(USER_PILOT_USER_STATUS.ACTIVE_USER) - } - - event('cloud.onboarding.set_user_status_success', { - context: JSON.stringify(dataStates), - }) - - return dataStates -} - -export const queryUsage = async (orgID: string, range?: string) => { - let csvToParse = '' - if (getUsage) { - const usage = await getUsage({ - orgID, - query: { - start: range ?? '-30d', - }, - }) - if (usage?.status === 200) { - csvToParse = usage.data?.trim().replace(/\r\n/g, '\n') - } else { - csvToParse = usageStatsCsv - } - } else { - csvToParse = usageStatsCsv - } - - const {table} = fromFlux(csvToParse) - return table -} - -export const getUserWriteLimitHits = async (orgID: string): Promise => { - try { - const table = await queryUsage(orgID) - - const measurement = (table.getColumn('_measurement') as string[]) ?? [] - - const queryWriteLimitHits = measurement.reduce((a, b, i) => { - if ( - b === 'event' && - table.getColumn('_field')[i] === 'event_type_limited_write' && - table.getColumn('_value', 'number')[i] > 0 - ) { - return a + table.getColumn('_value', 'number')[i] - } else { - return a - } - }, 0) - return queryWriteLimitHits - } catch (err) { - console.error(err) - } -} - -let hasCalledGetStatus = false -const handleGetUserStatus = async (orgID: string) => { - let usageDataStates = [] - - const getUserStatusDefinition = async () => { - const tables = await queryUsage(orgID) - if (tables) { - usageDataStates = getUserStatus(tables) - } - } - - try { - if (!hasCalledGetStatus && isFlagEnabled('newUsageAPI')) { - await getUserStatusDefinition() - hasCalledGetStatus = true - } - } catch (err) { - console.error(err) - event('cloud.onboarding.set_user_status_failure', { - context: JSON.stringify(err), - }) - } - - return {usageDataStates} -} - -export default handleGetUserStatus diff --git a/src/homepageExperience/components/FeedbackBar.tsx b/src/homepageExperience/components/FeedbackBar.tsx index b8eaa6c036..8a7ddfde7c 100644 --- a/src/homepageExperience/components/FeedbackBar.tsx +++ b/src/homepageExperience/components/FeedbackBar.tsx @@ -24,8 +24,6 @@ enum feedbackValue { THUMBS_UP, } -const USERPILOT_FEEDBACK_ID = '1650913576rUrz8532' - export default class FeedbackBar extends React.Component { constructor(props) { super(props) @@ -36,20 +34,12 @@ export default class FeedbackBar extends React.Component { if (this.props.selectedFeedback === null) { event(`firstMile.${this.props.wizardEventName}.thumbsUp.clicked`) this.props.onFeedbackSelection(feedbackValue.THUMBS_UP) - - if (window.userpilot) { - window.userpilot.trigger(USERPILOT_FEEDBACK_ID) - } } } private handleThumbsDownClick = () => { if (this.props.selectedFeedback === null) { event(`firstMile.${this.props.wizardEventName}.thumbsDown.clicked`) this.props.onFeedbackSelection(feedbackValue.THUMBS_DOWN) - - if (window.userpilot) { - window.userpilot.trigger(USERPILOT_FEEDBACK_ID) - } } } diff --git a/src/index.tsx b/src/index.tsx index 008136dca2..0bed664f78 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -63,7 +63,6 @@ declare global { interface Window { basepath: string dataLayer: any[] - userpilot: any } } diff --git a/src/shared/utils/mocks/usageStats.mocks.ts b/src/shared/utils/mocks/usageStats.mocks.ts deleted file mode 100644 index 215f726e50..0000000000 --- a/src/shared/utils/mocks/usageStats.mocks.ts +++ /dev/null @@ -1,35 +0,0 @@ -export const usageStatsCsv = `#group,false,false,true,true,false,false,true,true,true,true -#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,double,string,string,string,string -#default,_result,,,,,,,,, -,result,table,_start,_stop,_time,_value,_field,_measurement,bucket_id,org_id -,,0,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-14T10:00:00Z,13352776.313888889,gauge,storage_usage_bucket_bytes,d4e6fe5396d18e89,351438333495bd60 -,,0,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-14T11:00:00Z,13360066.18888889,gauge,storage_usage_bucket_bytes,d4e6fe5396d18e89,351438333495bd60 -,,0,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-14T12:00:00Z,13011240.197222224,gauge,storage_usage_bucket_bytes,d4e6fe5396d18e89,351438333495bd60 -,,0,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-14T13:00:00Z,12590111.519444447,gauge,storage_usage_bucket_bytes,d4e6fe5396d18e89,351438333495bd60 - -#group,false,false,true,true,false,false,true,true,true,true,true -#datatype,string,long,dateTime:RFC3339,dateTime:RFC3339,dateTime:RFC3339,long,string,string,string,string,string -#default,_result,,,,,,,,,, -,result,table,_start,_stop,_time,_value,_field,_measurement,endpoint,org_id,status -,,1,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-03T23:00:00Z,21667,req_bytes,http_request,/api/v2/query,351438333495bd60,200 -,,1,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-09T21:00:00Z,89576,req_bytes,http_request,/api/v2/query,351438333495bd60,200 -,,1,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,5330,req_bytes,http_request,/api/v2/query,351438333495bd60,200 -,,2,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-03T23:00:00Z,778,req_bytes,http_request,/api/v2/query,351438333495bd60,404 -,,2,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-09T21:00:00Z,4279,req_bytes,http_request,/api/v2/query,351438333495bd60,404 -,,2,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,389,req_bytes,http_request,/api/v2/query,351438333495bd60,404 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,1,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,1,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,1,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-05-28T23:00:00Z,31,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-05-29T00:00:00Z,34,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-05-29T01:00:00Z,30,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,3,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-05-29T02:00:00Z,15,req_bytes,query_count,/api/v2/query,351438333495bd60,200 -,,4,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-03T23:00:00Z,278,resp_bytes,http_request,/api/v2/query,351438333495bd60,200 -,,4,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-09T21:00:00Z,1790,resp_bytes,http_request,/api/v2/query,351438333495bd60,200 -,,4,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,145,resp_bytes,http_request,/api/v2/query,351438333495bd60,200 -,,5,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-03T23:00:00Z,212,resp_bytes,http_request,/api/v2/query,351438333495bd60,404 -,,5,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-09T21:00:00Z,1166,resp_bytes,http_request,/api/v2/query,351438333495bd60,404 -,,5,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,90,event_type_limited_write,event,/api/v2/query,351438333495bd60,400 -,,5,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,3,event_type_limited_write,event,/api/v2/query,351438333495bd60,400 -,,5,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,4,event_type_limited_write,event,/api/v2/query,351438333495bd60,400 -,,5,2021-05-15T13:33:29.743615351Z,2021-06-14T13:33:29.743615351Z,2021-06-10T19:00:00Z,1,event_type_limited_write,event,/api/v2/query,351438333495bd60,400`