11import { Fragment , useMemo } from 'react' ;
22import styled from '@emotion/styled' ;
33
4- import { CodeBlock } from 'sentry/components/core/code/codeBlock' ;
54import { ExternalLink , Link } from 'sentry/components/core/link' ;
65import { TabList , Tabs } from 'sentry/components/core/tabs' ;
76import FieldGroup from 'sentry/components/forms/fieldGroup' ;
@@ -11,6 +10,8 @@ import type {ProjectKey} from 'sentry/types/project';
1110import { decodeScalar } from 'sentry/utils/queryString' ;
1211import { useLocation } from 'sentry/utils/useLocation' ;
1312import { useNavigate } from 'sentry/utils/useNavigate' ;
13+ import { OtlpTab } from 'sentry/views/settings/project/projectKeys/credentials/otlp' ;
14+ import { VercelTab } from 'sentry/views/settings/project/projectKeys/credentials/vercel' ;
1415
1516type Props = {
1617 data : ProjectKey ;
@@ -25,142 +26,17 @@ type Props = {
2526 showSecretKey ?: boolean ;
2627 showSecurityEndpoint ?: boolean ;
2728 showUnreal ?: boolean ;
29+ showVercelLogDrainEndpoint ?: boolean ;
2830} ;
2931
30- type TabValue = 'otlp' | 'security' | 'minidump' | 'unreal' | 'credentials' ;
32+ type TabValue = 'otlp' | 'security' | 'minidump' | 'unreal' | 'vercel' | ' credentials';
3133
3234interface TabConfig {
3335 key : TabValue ;
3436 label : string ;
3537 visible : boolean ;
3638}
3739
38- interface OtlpTabProps {
39- logsEndpoint : string ;
40- publicKey : string ;
41- showOtlpLogs : boolean ;
42- showOtlpTraces : boolean ;
43- tracesEndpoint : string ;
44- }
45-
46- function OtlpTab ( {
47- logsEndpoint,
48- tracesEndpoint,
49- publicKey,
50- showOtlpLogs,
51- showOtlpTraces,
52- } : OtlpTabProps ) {
53- // Build the OTEL collector config example
54- const buildCollectorConfig = useMemo ( ( ) => {
55- const lines = [ 'exporters:' , ' otlphttp:' ] ;
56-
57- if ( showOtlpLogs ) {
58- lines . push ( ` logs_endpoint: ${ logsEndpoint } ` ) ;
59- }
60-
61- if ( showOtlpTraces ) {
62- lines . push ( ` traces_endpoint: ${ tracesEndpoint } ` ) ;
63- }
64-
65- lines . push (
66- ' headers:' ,
67- ` x-sentry-auth: "sentry sentry_key=${ publicKey } "` ,
68- ' compression: gzip' ,
69- ' encoding: proto' ,
70- ' timeout: 30s'
71- ) ;
72-
73- return lines . join ( '\n' ) ;
74- } , [ showOtlpLogs , showOtlpTraces , logsEndpoint , tracesEndpoint , publicKey ] ) ;
75-
76- if ( ! showOtlpLogs && ! showOtlpTraces ) {
77- return undefined ;
78- }
79-
80- return (
81- < Fragment >
82- { showOtlpLogs && (
83- < Fragment >
84- < FieldGroup
85- label = { t ( 'OTLP Logs Endpoint' ) }
86- help = { tct (
87- `Set this URL as your OTLP exporter's log endpoint. [link:Learn more]` ,
88- {
89- link : (
90- < ExternalLink href = "https://docs.sentry.io/concepts/otlp/#opentelemetry-logs" />
91- ) ,
92- }
93- ) }
94- inline = { false }
95- flexibleControlStateSize
96- >
97- < TextCopyInput aria-label = { t ( 'OTLP Logs Endpoint' ) } >
98- { logsEndpoint }
99- </ TextCopyInput >
100- </ FieldGroup >
101-
102- < FieldGroup
103- label = { t ( 'OTLP Logs Endpoint Headers' ) }
104- help = { t ( `Set these security headers when configuring your OTLP exporter.` ) }
105- inline = { false }
106- flexibleControlStateSize
107- >
108- < TextCopyInput aria-label = { t ( 'OTLP Logs Endpoint Headers' ) } >
109- { `x-sentry-auth=sentry sentry_key=${ publicKey } ` }
110- </ TextCopyInput >
111- </ FieldGroup >
112- </ Fragment >
113- ) }
114-
115- { showOtlpTraces && (
116- < Fragment >
117- < FieldGroup
118- label = { t ( 'OTLP Traces Endpoint' ) }
119- help = { tct (
120- `Set this URL as your OTLP exporter's trace endpoint. [link:Learn more]` ,
121- {
122- link : (
123- < ExternalLink href = "https://docs.sentry.io/concepts/otlp/#opentelemetry-traces" />
124- ) ,
125- }
126- ) }
127- inline = { false }
128- flexibleControlStateSize
129- >
130- < TextCopyInput aria-label = { t ( 'OTLP Traces Endpoint' ) } >
131- { tracesEndpoint }
132- </ TextCopyInput >
133- </ FieldGroup >
134-
135- < FieldGroup
136- label = { t ( 'OTLP Traces Endpoint Headers' ) }
137- help = { t ( `Set these security headers when configuring your OTLP exporter.` ) }
138- inline = { false }
139- flexibleControlStateSize
140- >
141- < TextCopyInput aria-label = { t ( 'OTLP Traces Endpoint Headers' ) } >
142- { `x-sentry-auth=sentry sentry_key=${ publicKey } ` }
143- </ TextCopyInput >
144- </ FieldGroup >
145- </ Fragment >
146- ) }
147-
148- < FieldGroup
149- label = { t ( 'OpenTelemetry Collector Exporter Configuration' ) }
150- help = { t (
151- 'Use this example configuration in your OpenTelemetry Collector config file to export OTLP data to Sentry.'
152- ) }
153- inline = { false }
154- flexibleControlStateSize
155- >
156- < CodeBlock language = "yaml" filename = "config.yaml" >
157- { buildCollectorConfig }
158- </ CodeBlock >
159- </ FieldGroup >
160- </ Fragment >
161- ) ;
162- }
163-
16440interface SecurityTabProps {
16541 securityEndpoint : string ;
16642}
@@ -299,6 +175,7 @@ function ProjectKeyCredentials({
299175 showSecretKey = false ,
300176 showOtlpTraces = false ,
301177 showOtlpLogs = false ,
178+ showVercelLogDrainEndpoint = false ,
302179 showSecurityEndpoint = true ,
303180 showUnreal = true ,
304181} : Props ) {
@@ -333,12 +210,18 @@ function ProjectKeyCredentials({
333210 label : t ( 'Unreal Engine' ) ,
334211 visible : showUnreal ,
335212 } ,
213+ {
214+ key : 'vercel' ,
215+ label : t ( 'Vercel Drains' ) ,
216+ visible : showVercelLogDrainEndpoint || showOtlpTraces ,
217+ } ,
336218 ] ;
337219 return tabs . filter ( tab => tab . visible ) ;
338220 } , [
339221 showOtlpTraces ,
340222 showOtlpLogs ,
341223 showSecurityEndpoint ,
224+ showVercelLogDrainEndpoint ,
342225 showMinidump ,
343226 showUnreal ,
344227 showPublicKey ,
@@ -399,6 +282,16 @@ function ProjectKeyCredentials({
399282 showProjectId = { showProjectId }
400283 />
401284 ) ;
285+ case 'vercel' :
286+ return (
287+ < VercelTab
288+ showVercelLogDrainEndpoint = { showVercelLogDrainEndpoint }
289+ integrationEndpoint = { data . dsn . integration }
290+ publicKey = { data . public }
291+ showOtlpTraces = { showOtlpTraces }
292+ tracesEndpoint = { data . dsn . otlp_traces }
293+ />
294+ ) ;
402295 default :
403296 return undefined ;
404297 }
0 commit comments