Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(integrations): add gitlab connection settings for web (#130459)

Dylan Martin471f82df2203
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 2eaed96ff1c4..d43cd7b386f0 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -15667,9 +15667,9 @@ snapshots:
scenes-app-settings-environment--settings-environment-heatmaps-screenshot-cookie--light:
hash: v1.k794b7964.142fea22f2fabc96771d8ab6cdb580e1184e78307e7f3f4c1f4bdfc8879ecd7c.bRI6OiTETtFBYKd16LPYjx5VzJIicT-eXu1K7-oIxGw
scenes-app-settings-environment--settings-environment-integrations--dark:
- hash: v1.k794b7964.cdf3072e3d3c6e73947c24decf5f9f9374d388a3ef59d0f566bee71bdffc8499.LrCddlTlnUIkWTBVi-518vZxO-svvRD-geuzHqV9c7U
+ hash: v1.k794b7964.b963101ce08803b8d1bfd1e4860fffc943ee9806a436a91a274f3e31e3427e65.a1R-oRoslKtAkUR7-NmpFlKQU9uR-eZyYCXl07DHZxM
scenes-app-settings-environment--settings-environment-integrations--light:
- hash: v1.k794b7964.665b9351939f4a9b8812933fa0d1060c14a6b3b036bd1b5de27ec07e46cdaece.lN8roPytpBQoGzbonkfQQ9pQLY5MAABddbq0To6JnZg
+ hash: v1.k794b7964.f66b186372277319f79c7d88bdf12701f91eb41e78f992463495d88bb362dd59.oQ5Ixd-Uy6aU4X7cFGrw0VnTwwbvL16nhpI1-k1pObM
scenes-app-settings-environment--settings-environment-marketing-analytics--dark:
hash: v1.k794b7964.038ca48993db88b1aff1c878ab4ffbf922f11e7d803c16547eecc0ce3384947e.EVc9qAR1RnWL3v0syXaGvTSxj1ivMQUjVrHbiUTaHI4
scenes-app-settings-environment--settings-environment-marketing-analytics--light:
@@ -15827,9 +15827,9 @@ snapshots:
scenes-app-settings-project--settings-project-details--light:
hash: v1.k794b7964.12ba33a1d3982fecf277dc6ac984e280bf54b694e04c535e71b2550037ebc43b.5qRQ77slU-1PztTAnTMpOwZgoyZJGVt84yVff-52zF8
scenes-app-settings-project--settings-project-integrations--dark:
- hash: v1.k794b7964.cdf3072e3d3c6e73947c24decf5f9f9374d388a3ef59d0f566bee71bdffc8499.6GbfmlkPGN8OKijBAxRhBS6SFvn0PmFGXwHQofSCZic
+ hash: v1.k794b7964.b963101ce08803b8d1bfd1e4860fffc943ee9806a436a91a274f3e31e3427e65.NaqCQtwCorZeOsjpSg1PRlGWFrAqFixDKZ-bCXiIUz4
scenes-app-settings-project--settings-project-integrations--light:
- hash: v1.k794b7964.82a4ebe15a45786d784bfa63225140b106b6a67143c22759412388761b2faaf7.gLRHe4AkhwZ0hNqLFClpdI8TEu6zc2g1-EIFN-Vivuc
+ hash: v1.k794b7964.f66b186372277319f79c7d88bdf12701f91eb41e78f992463495d88bb362dd59.H4R4nR9tiUQY1bdzi5NiX2GxHPSs4RyCUM1MEYtDD4c
scenes-app-settings-project--settings-project-logs--dark:
hash: v1.k794b7964.be5f3a70914a2b8e981be709c7c47d09546edf6e9b7396be2dd14c8edac85a7a.TInYc4-kuVKTgdEqYZQyYlIwNHR6taRwYn1274wz_FA
scenes-app-settings-project--settings-project-logs--light:
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 7127a5d2d084..a388a8973460 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -612,6 +612,7 @@ export const FEATURE_FLAGS = {
WEB_ANALYTICS_TILE_HEADER_V2: 'web-analytics-tile-header-v2', // owner: @jordanm-posthog #team-web-analytics multivariate=control,test
WEB_ANALYTICS_TILE_SKELETONS: 'web-analytics-tile-skeletons', // owner: @jordanm-posthog #team-web-analytics
WEB_ANALYTICS_TILE_TOGGLES: 'web-analytics-tile-toggles', // owner: @lricoy #team-web-analytics
+ WEB_GITLAB_INTEGRATION: 'web-gitlab-integration', // owner: #team-desktop
WIZARD_ONBOARDING_CLOUD_RUNS_ENABLED: 'wizard-onboarding-cloud-runs-enabled',
WIZARD_UI_ENABLED: 'wizard-ui-enabled', // owner: @fercgomes #team-growth — gates the /wizard/runs interface and its sidebar entry
WORKFLOW_ADD_TO_STATIC_COHORT_ACTION: 'workflow-add-to-static-cohort-action', // owner: #team-workflows
diff --git a/frontend/src/scenes/integrations/components/Integrations.tsx b/frontend/src/scenes/integrations/components/Integrations.tsx
index f4f546dbfc0d..b5474ed80391 100644
--- a/frontend/src/scenes/integrations/components/Integrations.tsx
+++ b/frontend/src/scenes/integrations/components/Integrations.tsx
@@ -1,10 +1,12 @@
-import { useValues } from 'kea'
+import { useActions, useValues } from 'kea'
import { ReactNode, useState } from 'react'
import { LemonButton } from '@posthog/lemon-ui'
import api from 'lib/api'
+import type { IntegrationConnectSurface } from 'lib/integrations/utils'
import { cn } from 'lib/utils/css-classes'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { GitLabSetupModal } from 'scenes/integrations/gitlab/GitLabSetupModal'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -15,11 +17,25 @@ import { Integration } from './Integration'
export { GithubIntegration, GitHubInstallationLink } from './GithubIntegration'
-export function GitLabIntegration({ centered }: { centered?: boolean } = {}): JSX.Element {
+export function GitLabIntegration({
+ centered,
+ connectSurface,
+}: { centered?: boolean; connectSurface?: IntegrationConnectSurface } = {}): JSX.Element {
const [isOpen, setIsOpen] = useState<boolean>(false)
+ const { reportIntegrationConnectClicked } = useActions(eventUsageLogic)
+
return (
<Integration kind="gitlab" centered={centered}>
- <LemonButton type="secondary" onClick={() => setIsOpen(true)}>
+ <LemonButton
+ type="secondary"
+ data-attr="gitlab-connect-project"
+ onClick={() => {
+ if (connectSurface) {
+ reportIntegrationConnectClicked('gitlab', 'gitlab', connectSurface)
+ }
+ setIsOpen(true)
+ }}
+ >
Connect project
</LemonButton>
<GitLabSetupModal isOpen={isOpen} onComplete={() => setIsOpen(false)} />
diff --git a/frontend/src/scenes/settings/SettingsMap.tsx b/frontend/src/scenes/settings/SettingsMap.tsx
index 9407116ba60a..49b324f855ff 100644
--- a/frontend/src/scenes/settings/SettingsMap.tsx
+++ b/frontend/src/scenes/settings/SettingsMap.tsx
@@ -21,7 +21,7 @@ import { FEATURE_SUPPORT } from 'lib/components/SupportedPlatforms/featureSuppor
import { OrganizationMembershipLevel } from 'lib/constants'
import { PersonalPosthogConnections } from 'lib/integrations/PosthogConnect'
import { DefaultMinimumDetectableEffect } from 'scenes/experiments/DefaultMinimumDetectableEffect'
-import { GitHub, Linear, Slack } from 'scenes/integrations/definitions'
+import { GitHub, GitLab, Linear, Slack } from 'scenes/integrations/definitions'
import { AgentPersonalInstructionsSettings } from 'scenes/settings/environment/AgentPersonalInstructionsSettings'
import { AgentProjectInstructionsSettings } from 'scenes/settings/environment/AgentProjectInstructionsSettings'
import { BounceRateDurationSetting } from 'scenes/settings/environment/BounceRateDuration'
@@ -91,7 +91,6 @@ import { WorkflowsEngagementEventsSettings } from 'products/workflows/frontend/s
import { WorkflowsFrequencyCapSettings } from 'products/workflows/frontend/scenes/settings/WorkflowsFrequencyCapSettings'
import { WorkflowsUtmDefaultsSettings } from 'products/workflows/frontend/scenes/settings/WorkflowsUtmDefaultsSettings'
-import { IntegrationsList } from '../../lib/integrations/IntegrationsList'
import { SettingScopeTag } from './components/SettingScopeTag'
import {
ActivityLogNotifications,
@@ -193,6 +192,7 @@ import { OrganizationVariables } from './organization/OrgVariables'
import { SSFSetting } from './organization/SSFSetting'
import { EnforceVerifiedDomains } from './organization/VerifiedDomains/EnforceVerifiedDomains'
import { VerifiedDomains } from './organization/VerifiedDomains/VerifiedDomains'
+import { OtherIntegrationsSettings } from './project/OtherIntegrationsSettings'
import { ProjectDangerZone } from './project/ProjectDangerZone'
import { ProjectDetails } from './project/ProjectDetails'
import { ProjectMove } from './project/ProjectMove'
@@ -2158,6 +2158,15 @@ export const SETTINGS_MAP: SettingSection[] = [
component: <GitHub.SettingsSection connectSurface="settings" />,
keywords: ['github', 'git', 'repository', 'issue', 'pr'],
},
+ {
+ id: 'integration-gitlab',
+ title: 'GitLab integration',
+ description: 'Connect GitLab projects to create and link issues from PostHog.',
+ docsUrl: GitLab.docsUrl,
+ component: <GitLab.SettingsSection connectSurface="settings" />,
+ flag: 'WEB_GITLAB_INTEGRATION',
+ keywords: ['gitlab', 'git', 'repository', 'project', 'issue'],
+ },
{
id: 'integration-linear',
title: 'Linear integration',
@@ -2171,32 +2180,7 @@ export const SETTINGS_MAP: SettingSection[] = [
title: 'Other integrations',
description:
'Integrations connected from other product areas, such as pipeline destinations, data warehouse sources, error tracking, and marketing analytics.',
- component: (
- <IntegrationsList
- omitKinds={['slack', 'github', 'linear']}
- titleText=""
- emptyState={
- <div className="px-4 py-6 text-center text-sm text-secondary rounded border bg-surface-primary">
- <p className="mb-1">No other integrations connected</p>
- <p className="text-xs text-muted text-balance mb-0">
- These connect from the product area that uses them:{' '}
- <Link to={urls.destinations()}>pipeline destinations</Link>,{' '}
- <Link to={urls.sources()}>data warehouse sources</Link>,{' '}
- <Link
- to={urls.settings('environment-error-tracking', 'error-tracking-integrations')}
- >
- error tracking
- </Link>{' '}
- and{' '}
- <Link to={urls.settings('environment-marketing-analytics', 'marketing-settings')}>
- marketing analytics
- </Link>
- .
- </p>
- </div>
- }
- />
- ),
+ component: <OtherIntegrationsSettings />,
keywords: ['integration', 'connect', 'third-party', 'app'],
},
{
diff --git a/frontend/src/scenes/settings/project/OtherIntegrationsSettings.test.tsx b/frontend/src/scenes/settings/project/OtherIntegrationsSettings.test.tsx
new file mode 100644
index 000000000000..a76da9252073
--- /dev/null
+++ b/frontend/src/scenes/settings/project/OtherIntegrationsSettings.test.tsx
@@ -0,0 +1,82 @@
+import '@testing-library/jest-dom'
+
+import { act, cleanup, render, screen } from '@testing-library/react'
+import userEvent from '@testing-library/user-event'
+import { Provider } from 'kea'
+import posthog from 'posthog-js'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { GitLabIntegration } from 'scenes/integrations/components/Integrations'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+import { mockIntegration } from '~/test/mocks'
+
+import { OtherIntegrationsSettings } from './OtherIntegrationsSettings'
+
+describe('GitLab connection settings', () => {
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/integrations': {
+ results: [
+ { ...mockIntegration, kind: 'gitlab', display_name: 'Example GitLab project', config: {} },
+ ],
+ },
+ },
+ })
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ cleanup()
+ jest.restoreAllMocks()
+ })
+
+ it.each([undefined, 'settings'] as const)(
+ 'opens setup and reports a click only when a surface is supplied (%s)',
+ async (connectSurface) => {
+ const capture = jest.spyOn(posthog, 'capture')
+ render(
+ <Provider>
+ <GitLabIntegration connectSurface={connectSurface} />
+ </Provider>
+ )
+
+ await userEvent.click(screen.getByText('Connect project'))
+
+ expect(await screen.findByText('Configure GitLab integration')).toBeInTheDocument()
+ const clicks = capture.mock.calls.filter(([event]) => event === 'integration_connect_clicked')
+ expect(clicks).toHaveLength(connectSurface ? 1 : 0)
+ if (connectSurface) {
+ expect(clicks[0][1]).toEqual({ integration: 'gitlab', integration_kind: 'gitlab', surface: 'settings' })
+ }
+ }
+ )
+
+ it.each([false, true])(
+ 'shows existing GitLab connections in Other integrations only with the flag off (%s)',
+ async (enabled) => {
+ featureFlagLogic.mount()
+ act(() =>
+ featureFlagLogic.actions.setFeatureFlags(enabled ? [FEATURE_FLAGS.WEB_GITLAB_INTEGRATION] : [], {
+ [FEATURE_FLAGS.WEB_GITLAB_INTEGRATION]: enabled,
+ })
+ )
+ render(
+ <Provider>
+ <OtherIntegrationsSettings />
+ </Provider>
+ )
+
+ if (enabled) {
+ expect(await screen.findByText('No other integrations connected')).toBeInTheDocument()
+ expect(screen.queryByText('Example GitLab project')).not.toBeInTheDocument()
+ } else {
+ expect(await screen.findByText('Example GitLab project')).toBeInTheDocument()
+ expect(screen.getByText('Disconnect')).toBeInTheDocument()
+ }
+ }
+ )
+})
diff --git a/frontend/src/scenes/settings/project/OtherIntegrationsSettings.tsx b/frontend/src/scenes/settings/project/OtherIntegrationsSettings.tsx
new file mode 100644
index 000000000000..95cd1151d518
--- /dev/null
+++ b/frontend/src/scenes/settings/project/OtherIntegrationsSettings.tsx
@@ -0,0 +1,41 @@
+import { useValues } from 'kea'
+
+import { Link } from '@posthog/lemon-ui'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { IntegrationsList } from 'lib/integrations/IntegrationsList'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { urls } from 'scenes/urls'
+
+export function OtherIntegrationsSettings(): JSX.Element {
+ const { featureFlags } = useValues(featureFlagLogic)
+
+ return (
+ <IntegrationsList
+ omitKinds={
+ featureFlags[FEATURE_FLAGS.WEB_GITLAB_INTEGRATION]
+ ? ['slack', 'github', 'linear', 'gitlab']
+ : ['slack', 'github', 'linear']
+ }
+ titleText=""
+ emptyState={
+ <div className="px-4 py-6 text-center text-sm text-secondary rounded border bg-surface-primary">
+ <p className="mb-1">No other integrations connected</p>
+ <p className="text-xs text-muted text-balance mb-0">
+ These connect from the product area that uses them:{' '}
+ <Link to={urls.destinations()}>pipeline destinations</Link>,{' '}
+ <Link to={urls.sources()}>data warehouse sources</Link>,{' '}
+ <Link to={urls.settings('environment-error-tracking', 'error-tracking-integrations')}>
+ error tracking
+ </Link>{' '}
+ and{' '}
+ <Link to={urls.settings('environment-marketing-analytics', 'marketing-settings')}>
+ marketing analytics
+ </Link>
+ .
+ </p>
+ </div>
+ }
+ />
+ )
+}
diff --git a/frontend/src/scenes/settings/project/owners.yaml b/frontend/src/scenes/settings/project/owners.yaml
new file mode 100644
index 000000000000..524b6913f8c7
--- /dev/null
+++ b/frontend/src/scenes/settings/project/owners.yaml
@@ -0,0 +1,5 @@
+version: 1
+owners: []
+rules:
+ - match: ['/OtherIntegrationsSettings.tsx', '/OtherIntegrationsSettings.test.tsx']
+ owners: team-surfaces
diff --git a/frontend/src/scenes/settings/types.ts b/frontend/src/scenes/settings/types.ts
index 16c344e84c83..4cfdf02ee496 100644
--- a/frontend/src/scenes/settings/types.ts
+++ b/frontend/src/scenes/settings/types.ts
@@ -217,6 +217,7 @@ export type SettingId =
| 'human-friendly-comparison-periods'
| 'integration-error-tracking'
| 'integration-github'
+ | 'integration-gitlab'
| 'integration-ip-allowlist'
| 'integration-linear'
| 'integration-other'