Skip to content

Commit

Permalink
remove posthog occurrences (#1321)
Browse files Browse the repository at this point in the history
  • Loading branch information
renemennab authored Jul 3, 2024
1 parent 9d91c9a commit ea4e70c
Show file tree
Hide file tree
Showing 18 changed files with 4 additions and 288 deletions.
16 changes: 0 additions & 16 deletions apps/core/lib/core/pubsub/consumers/posthog.ex

This file was deleted.

1 change: 0 additions & 1 deletion apps/core/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ defmodule Core.MixProject do
{:ex_aws, "~> 2.4.0"},
{:ex_aws_s3, "~> 2.3.3"},
{:ex_aws_sts, "~> 2.3.0"},
{:posthog, "~> 0.1"},
{:configparser_ex, "~> 4.0"},
{:sweet_xml, "~> 0.7.3"},
{:arc_ecto, "~> 0.11.3"},
Expand Down
34 changes: 0 additions & 34 deletions apps/core/test/pubsub/posthog/repositories_test.exs

This file was deleted.

18 changes: 0 additions & 18 deletions apps/core/test/pubsub/posthog/users_test.exs

This file was deleted.

1 change: 0 additions & 1 deletion apps/core/test/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,5 @@ Mimic.copy(Core.Services.Shell.Pods)
Mimic.copy(Vault)
Mimic.copy(System)
Mimic.copy(Core.Clients.Vault)
Mimic.copy(Posthog)

{:ok, _} = Application.ensure_all_started(:ex_machina)
4 changes: 0 additions & 4 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,6 @@ config :junit_formatter,
print_report_file: true,
automatic_create_dir?: true

config :posthog,
api_url: "https://posthog.plural.sh",
api_key: "phc_r0v4jbKz8Rr27mfqgO15AN5BMuuvnU8hCFedd6zpSDy"

config :core, :oidc_providers,
github_actions: [
discovery_document_uri: "https://token.actions.githubusercontent.com/.well-known/openid-configuration",
Expand Down
1 change: 0 additions & 1 deletion config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ config :core, :consumers, [
Core.PubSub.Consumers.Audits,
Core.PubSub.Consumers.Cache,
Core.PubSub.Consumers.Usage,
Core.PubSub.Consumers.Posthog
]

config :email, :consumers, [
Expand Down
1 change: 0 additions & 1 deletion www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"moment": "2.29.4",
"phoenix": "1.7.3",
"pluralsh-absinthe-socket-apollo-link": "0.2.0",
"posthog-js": "1.66.1",
"process": "0.11.10",
"prop-types": "15.8.1",
"query-string": "8.1.0",
Expand Down
27 changes: 1 addition & 26 deletions www/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'react-toggle/style.css'
import { Suspense, lazy, useEffect } from 'react'
import { Suspense, lazy } from 'react'
import { Route, Routes } from 'react-router-dom'
import { ApolloProvider } from '@apollo/client'
import { IntercomProvider } from 'react-use-intercom'
Expand All @@ -19,14 +19,12 @@ import styled, { ThemeProvider as StyledThemeProvider } from 'styled-components'
import { mergeDeep } from '@apollo/client/utilities'
import mpRecipe from 'honorable-recipe-mp'
import { GrowthBook, GrowthBookProvider } from '@growthbook/growthbook-react'
import posthog from 'posthog-js'

import { client } from './helpers/client'
import { INTERCOM_APP_ID } from './constants'
import { DEFAULT_THEME } from './theme'
import { HistoryRouter, browserHistory } from './router'
import { growthbook } from './helpers/growthbook'
import Cookiebot from './utils/cookiebot'
import { OverlayContextProvider } from './components/layout/Overlay'
import NavContextProvider from './contexts/NavigationContext'
import { CursorPositionProvider } from './components/utils/CursorPosition'
Expand Down Expand Up @@ -79,28 +77,6 @@ const SSOCallback = lazy(() =>
}))
)

function PosthogOptInOut() {
useEffect(() => {
if (Cookiebot?.consent?.statistics) {
posthog.opt_in_capturing()
} else {
posthog.opt_out_capturing()
}
const onPrefChange = () => {
if (Cookiebot?.consent?.statistics) {
posthog.opt_in_capturing()
} else {
posthog.opt_out_capturing()
}
}

window.addEventListener('CookiebotOnAccept', onPrefChange)
window.addEventListener('CookiebotOnDecline', onPrefChange)
}, [])

return null
}

const RootBoxSC = styled.div(({ theme }) => ({
display: 'flex',
flexdirection: 'column',
Expand Down Expand Up @@ -191,7 +167,6 @@ function App() {

return (
<Suspense>
<PosthogOptInOut />
<ApolloProvider client={client}>
<IntercomProvider appId={INTERCOM_APP_ID}>
<ThemeProvider theme={honorableTheme}>
Expand Down
22 changes: 1 addition & 21 deletions www/src/components/Plural.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Suspense, lazy, useContext, useEffect, useState } from 'react'
import { Suspense, lazy, useEffect, useState } from 'react'
import { Navigate, Outlet, Route, Routes, useMatch } from 'react-router-dom'
import { Toast } from '@pluralsh/design-system'

import { growthbook } from '../helpers/growthbook'
import { useHistory } from '../router'
import CurrentUserContext from '../contexts/CurrentUserContext'
import PosthogIdentify from '../utils/posthog'

import { WrapStripe } from './WrapStripe'
import { LegacyExpirationNotice } from './login/LegacyExpiration'
Expand Down Expand Up @@ -296,23 +294,6 @@ function TestBanner() {
return null
}

function PosthogIdentifier() {
const me = useContext(CurrentUserContext)

PosthogIdentify(me)

useEffect(() => {
const onPrefChange = () => {
PosthogIdentify(me)
}

window.addEventListener('CookiebotOnAccept', onPrefChange)
window.addEventListener('CookiebotOnDecline', onPrefChange)
}, [me])

return null
}

export function PluralInner() {
return (
<WrapStripe>
Expand All @@ -321,7 +302,6 @@ export function PluralInner() {
<ApplicationLayout>
<DelinquencyToast />
<LegacyExpirationNotice />
<PosthogIdentifier />
<VerifyEmailConfirmed />
<DeviceLoginNotif />
<TestBanner />
Expand Down
14 changes: 1 addition & 13 deletions www/src/components/oidc/OAuthConsent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useLocation, useNavigate } from 'react-router-dom'
import { useMutation, useQuery } from '@apollo/client'
import queryString from 'query-string'
import { ArrowRightLeftIcon, Button, IconFrame } from '@pluralsh/design-system'
import { useCallback, useEffect } from 'react'
import { useCallback } from 'react'
import { A, Flex, Span } from 'honorable'
import StartCase from 'lodash/startCase'
import { useTheme } from 'styled-components'
Expand All @@ -13,8 +13,6 @@ import { PLURAL_MARK, PLURAL_MARK_WHITE } from '../constants'
import { useMeQuery } from '../../generated/graphql'
import { clearLocalStorage } from '../../helpers/localStorage'

import { PosthogEvent, posthogCapture } from '../../utils/posthog'

import LoadingIndicator from '../utils/LoadingIndicator'

import { GET_OIDC_CONSENT, OAUTH_CONSENT } from './queries'
Expand Down Expand Up @@ -61,16 +59,6 @@ export function OAuthConsent() {
navigate('/login')
}, [navigate])

useEffect(() => {
if (repository) {
posthogCapture(PosthogEvent.OIDCLogin, {
applicationID: repository.id,
applicationName: repository.name,
installationID: repository.installation?.id,
})
}
}, [repository])

if (!data || userLoading) return <LoadingIndicator />

if (!userData?.me?.email) {
Expand Down
14 changes: 0 additions & 14 deletions www/src/components/shell/onboarding/sections/shell/CreateShell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import {
WorkspaceProps,
} from '../../context/types'
import { toCloudProviderAttributes } from '../../../utils/provider'
import { PosthogEvent, posthogCapture } from '../../../../../utils/posthog'

import { useSectionError, useSectionState } from '../../context/hooks'

Expand Down Expand Up @@ -192,19 +191,6 @@ function CreateShell() {
setSectionState(CreateCloudShellSectionState.Finished)
}, [shell, setupShellCompleted, error, setSectionState])

// Capture errors and send to posthog
useEffect(
() =>
error &&
posthogCapture(PosthogEvent.Onboarding, {
type: cloud.type,
provider: cloud.provider,
clusterName: workspace.clusterName,
error,
}),
[cloud.provider, cloud.type, error, workspace.clusterName]
)

useEffect(() => setSectionError(!!error), [error, setSectionError])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ import {
} from '../../../../../generated/graphql'
import { OnboardingContext } from '../../context/onboarding'
import { generateString } from '../../../../../utils/string'
import { PosthogEvent, posthogCapture } from '../../../../../utils/posthog'

import { DemoStatus } from './DemoStatus'

function CreateDemo({ onBack, onNext }): JSX.Element {
const setSectionState = useSectionState()
const setSectionError = useSectionError()
const { cloud, workspace, setSCM, setCloud, setWorkspace } =
useContext(OnboardingContext)
const { setSCM, setCloud, setWorkspace } = useContext(OnboardingContext)
const [demoCreated, setDemoCreated] = useState(false)
const [shouldCreate, setShouldCreate] = useState(true)

Expand Down Expand Up @@ -95,19 +93,6 @@ function CreateDemo({ onBack, onNext }): JSX.Element {
setDemoCreated(true)
}, [demoCreated, demoProject, isProjectReady, setCloud, setSCM, setWorkspace])

// Capture errors and send to posthog
useEffect(
() =>
error &&
posthogCapture(PosthogEvent.Onboarding, {
type: cloud.type,
provider: cloud.provider,
clusterName: workspace.clusterName,
error,
}),
[cloud.provider, cloud.type, error, workspace.clusterName]
)

useEffect(() => setSectionError(!!error), [error, setSectionError])

useEffect(() => {
Expand Down
23 changes: 0 additions & 23 deletions www/src/components/shell/terminal/sidebar/installer/Installer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from 'react'
import { useSearchParams } from 'react-router-dom'

import { PosthogEvent, posthogCapture } from '../../../../../utils/posthog'
import LoadingIndicator from '../../../../utils/LoadingIndicator'
import { ImpersonationContext } from '../../../context/impersonation'
import useOnboarded from '../../../hooks/useOnboarded'
Expand Down Expand Up @@ -52,9 +51,6 @@ function Installer({ onInstallSuccess }) {
const [steps, setSteps] = useState<Array<WizardStepConfig>>([])
const [error, setError] = useState<ApolloError | undefined>()
const [defaultSteps, setDefaultSteps] = useState<Array<WizardStepConfig>>([])
const [selectedApplications, setSelectedApplications] = useState<
Array<string>
>([])
const [domains, setDomains] = useState<Record<string, string>>({})

const {
Expand Down Expand Up @@ -111,10 +107,6 @@ function Installer({ onInstallSuccess }) {
mutation()
refetch()
refetchInstalledApps()
posthogCapture(PosthogEvent.Installer, {
provider,
applications: selectedApplications,
})
onInstallSuccess()
})
.catch((err) => setError(err))
Expand All @@ -139,9 +131,6 @@ function Installer({ onInstallSuccess }) {
setSteps(steps)
}

setSelectedApplications(
selectedApplications.map((app) => app.label ?? 'unknown')
)
setStepsLoading(true)
build().finally(() => setStepsLoading(false))
},
Expand All @@ -159,18 +148,6 @@ function Installer({ onInstallSuccess }) {
[applications, preselectedApps, provider]
)

// Capture errors and send to posthog
useEffect(
() =>
error &&
posthogCapture(PosthogEvent.Installer, {
error,
applications: selectedApplications,
provider,
}),
[error, selectedApplications, provider]
)

if (!applications || defaultSteps.length === 0) {
return (
<Flex
Expand Down
3 changes: 0 additions & 3 deletions www/src/helpers/localStorage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import posthog from 'posthog-js'

import { LocalStorageKeys } from '../constants'

import { wipeToken } from './authentication'
Expand All @@ -22,7 +20,6 @@ export enum EXPIRATION_NOTICE_STATE {
// Clears the user related local storage keys during logout.
function clearLocalStorage(): void {
wipeToken()
posthog.reset()
localStorage.removeItem(LocalStorageKeys.AuthPreviousUserData)
localStorage.removeItem(LocalStorageKeys.BrowserHistory)
localStorage.removeItem(LocalStorageKeys.LegacyExpirationNotice)
Expand Down
Loading

0 comments on commit ea4e70c

Please sign in to comment.