mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:51:59 +00:00
Make SSC base url dynamic (#62790)
* Add config item, get it to the front end * Use config on the front end * Send team=1 if the team button is clicked * Unrelated: Event logging cleanup
This commit is contained in:
parent
e2a0fd6113
commit
376a737d61
@ -6,7 +6,6 @@ import { useNavigate } from 'react-router-dom'
|
||||
|
||||
import { useQuery } from '@sourcegraph/http-client'
|
||||
import type { TelemetryV2Props } from '@sourcegraph/shared/src/telemetry'
|
||||
import { EVENT_LOGGER } from '@sourcegraph/shared/src/telemetry/web/eventLogger'
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
@ -26,10 +25,9 @@ import { Page } from '../../components/Page'
|
||||
import { PageTitle } from '../../components/PageTitle'
|
||||
import { CodySubscriptionPlan } from '../../graphql-operations'
|
||||
import type { UserCodyPlanResult, UserCodyPlanVariables } from '../../graphql-operations'
|
||||
import { EventName } from '../../util/constants'
|
||||
import { CodyColorIcon } from '../chat/CodyPageIcon'
|
||||
import { isCodyEnabled } from '../isCodyEnabled'
|
||||
import { manageSubscriptionRedirectURL, isEmbeddedCodyProUIEnabled } from '../util'
|
||||
import { isEmbeddedCodyProUIEnabled, manageSubscriptionRedirectURL } from '../util'
|
||||
|
||||
import { USER_CODY_PLAN } from './queries'
|
||||
|
||||
@ -49,7 +47,6 @@ export const CodySubscriptionPage: React.FunctionComponent<CodySubscriptionPageP
|
||||
|
||||
const utm_source = parameters.get('utm_source')
|
||||
useEffect(() => {
|
||||
EVENT_LOGGER.log(EventName.CODY_SUBSCRIPTION_PAGE_VIEWED, { utm_source }, { utm_source })
|
||||
telemetryRecorder.recordEvent('cody.planSelection', 'view')
|
||||
}, [utm_source, telemetryRecorder])
|
||||
|
||||
@ -85,7 +82,9 @@ export const CodySubscriptionPage: React.FunctionComponent<CodySubscriptionPageP
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={() => {
|
||||
EVENT_LOGGER.log(EventName.CODY_MANAGE_SUBSCRIPTION_CLICKED)
|
||||
telemetryRecorder.recordEvent('cody.manageSubscription', 'click', {
|
||||
metadata: { tier: 1 },
|
||||
})
|
||||
window.location.href = manageSubscriptionRedirectURL
|
||||
}}
|
||||
>
|
||||
@ -209,7 +208,6 @@ export const CodySubscriptionPage: React.FunctionComponent<CodySubscriptionPageP
|
||||
className="mb-0 text-muted d-inline cursor-pointer"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
EVENT_LOGGER.log(EventName.CODY_MANAGE_SUBSCRIPTION_CLICKED)
|
||||
telemetryRecorder.recordEvent('cody.planSelection', 'click', {
|
||||
metadata: { tier: 0 },
|
||||
})
|
||||
@ -227,7 +225,12 @@ export const CodySubscriptionPage: React.FunctionComponent<CodySubscriptionPageP
|
||||
telemetryRecorder.recordEvent('cody.planSelection', 'click', {
|
||||
metadata: { tier: 1, team: 1 },
|
||||
})
|
||||
window.location.href = manageSubscriptionRedirectURL // TODO: Use team link or argument
|
||||
// We add ?team=1 to the URL to indicate that the user is creating a team.
|
||||
// We can use this info to initialize the UI differently,
|
||||
// or even display an entirely different UI.
|
||||
const url = new URL(manageSubscriptionRedirectURL)
|
||||
url.searchParams.append('team', '1')
|
||||
window.location.href = url.toString()
|
||||
}}
|
||||
>
|
||||
<span className={classNames(styles.proBadge, 'mr-1')} />
|
||||
@ -364,11 +367,6 @@ export const CodySubscriptionPage: React.FunctionComponent<CodySubscriptionPageP
|
||||
to="https://sourcegraph.com/contact/request-info?utm_source=cody_subscription_page"
|
||||
target="_blank"
|
||||
onClick={() => {
|
||||
EVENT_LOGGER.log(
|
||||
EventName.CODY_SUBSCRIPTION_PLAN_CLICKED,
|
||||
{ tier: 'enterprise' },
|
||||
{ tier: 'enterprise' }
|
||||
)
|
||||
telemetryRecorder.recordEvent('cody.planSelection', 'click', {
|
||||
metadata: { tier: 2 },
|
||||
})
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
// The URL to direct users in order to manage their Cody Pro subscription.
|
||||
import { useState, useEffect } from 'react'
|
||||
|
||||
export const manageSubscriptionRedirectURL = 'https://accounts.sourcegraph.com/cody/subscription'
|
||||
export const manageSubscriptionRedirectURL = `${window.context.frontendCodyProConfig?.sscBaseUrl}/subscription`
|
||||
|
||||
/**
|
||||
* useEmbeddedCodyProUi returns if we expect the Cody Pro UI to be served from sourcegraph.com. Meaning
|
||||
|
||||
@ -306,6 +306,7 @@ export interface SourcegraphContext extends Pick<Required<SiteConfiguration>, 'e
|
||||
/** Configuration for Cody Pro-tier functionality, if applicable. */
|
||||
frontendCodyProConfig?: {
|
||||
stripePublishableKey: string
|
||||
sscBaseUrl: string
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -152,6 +152,7 @@ type LicenseInfo struct {
|
||||
// to the frontend.
|
||||
type FrontendCodyProConfig struct {
|
||||
StripePublishableKey string `json:"stripePublishableKey"`
|
||||
SscBaseUrl string `json:"sscBaseUrl"`
|
||||
}
|
||||
|
||||
// JSContext is made available to JavaScript code via the
|
||||
@ -708,5 +709,6 @@ func makeFrontendCodyProConfig(config *schema.CodyProConfig) *FrontendCodyProCon
|
||||
}
|
||||
return &FrontendCodyProConfig{
|
||||
StripePublishableKey: config.StripePublishableKey,
|
||||
SscBaseUrl: config.SscBaseUrl,
|
||||
}
|
||||
}
|
||||
|
||||
@ -652,6 +652,8 @@ type CodyProConfig struct {
|
||||
SamsBackendOrigin string `json:"samsBackendOrigin,omitempty"`
|
||||
// SscBackendOrigin description: Origin of the Self-serve Cody backend.
|
||||
SscBackendOrigin string `json:"sscBackendOrigin,omitempty"`
|
||||
// SscBaseUrl description: The base URL of the Self-Serve Cody site.
|
||||
SscBaseUrl string `json:"sscBaseUrl,omitempty"`
|
||||
// StripePublishableKey description: Stripe Publishable Key for use in Stripe Checkout, Stripe Elements. This is not considered a secret.
|
||||
StripePublishableKey string `json:"stripePublishableKey,omitempty"`
|
||||
}
|
||||
|
||||
@ -2277,6 +2277,11 @@
|
||||
"default": "",
|
||||
"description": "Origin of the Self-serve Cody backend.",
|
||||
"examples": ["https://accounts.sourcegraph.com"]
|
||||
},
|
||||
"sscBaseUrl": {
|
||||
"type": "string",
|
||||
"default": "https://accounts.sourcegraph.com/cody",
|
||||
"description": "The base URL of the Self-Serve Cody site."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user