Skip to content

Commit bfa5966

Browse files
committed
more wip stuff
1 parent 57ac0a2 commit bfa5966

File tree

3 files changed

+109
-65
lines changed

3 files changed

+109
-65
lines changed

docs/platforms/javascript/common/apis.mdx

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,66 @@ Sentry.setTag("tag", "value");
1717

1818
<TableOfContents ignoreIds={["available-options"]} />
1919

20+
## Capturing Events
21+
22+
<SdkApi
23+
name="captureException"
24+
signature={`function captureException(
25+
exception: unknown,
26+
captureContext?: CaptureContext
27+
): Promise<EventId>`}
28+
parameters={[
29+
{
30+
name: "exception",
31+
required: true,
32+
type: "unknown",
33+
description: "The exception to capture. This is usually an Error object.",
34+
},
35+
{
36+
name: "captureContext",
37+
type: {
38+
name: "CaptureContext",
39+
properties: [
40+
{
41+
name: "user",
42+
type: {
43+
name: "User",
44+
properties: [
45+
{ name: "id", type: "string | number" },
46+
{ name: "email", type: "string" },
47+
{ name: "ip_address", type: "string" },
48+
{ name: "username", type: "string" },
49+
],
50+
},
51+
},
52+
{
53+
name: "level",
54+
type: '"fatal" | "error" | "warning" | "log" | "info" | "debug"',
55+
},
56+
{
57+
name: "extra",
58+
type: "Record<string, unknown>",
59+
description:
60+
"Additional data that should be sent with the exception.",
61+
},
62+
{
63+
name: "tags",
64+
type: "Record<string, string>",
65+
description:
66+
"Additional tags that should be sent with the exception.",
67+
},
68+
{ name: "contexts", type: "Record<string, Record<string, unknown>>" },
69+
{ name: "fingerprint", type: "string[]" },
70+
],
71+
},
72+
description:
73+
"A hint object containing additional information about the exception.",
74+
},
75+
]}
76+
>
77+
Capture an exception event and send it to Sentry.
78+
</SdkApi>
79+
2080
## Enriching Events
2181

2282
<SdkApi
@@ -76,24 +136,3 @@ Sentry.setTag("tag", "value");
76136
example, you might manually record a breadcrumb if the user authenticates or
77137
another state change occurs.
78138
</SdkApi>
79-
80-
<SdkApi
81-
name="captureException"
82-
signature="function captureException(exception: Exception, hint?: Hint): Promise<EventId>"
83-
parameters={[
84-
{
85-
name: "exception",
86-
required: true,
87-
type: "unknown",
88-
description: "The exception to capture.",
89-
},
90-
{
91-
name: "hint",
92-
type: "Record<string, unknown>",
93-
description:
94-
"A hint object containing additional information about the exception.",
95-
},
96-
]}
97-
>
98-
Capture an exception and send it to Sentry.
99-
</SdkApi>

src/components/nestedObject.tsx

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,50 +26,53 @@ export function RenderNestedObject({
2626

2727
return (
2828
<div>
29-
<pre className="m-0 pt-1 pb-1">
30-
<div className="flex items-center gap-2">
31-
<code>{name ? name : 'Object'}</code>
32-
<button className="flex items-center" onClick={() => setExpanded(!expanded)}>
33-
{expanded ? (
34-
<Fragment>
35-
{'{'}
36-
<MinusCircledIcon />
37-
</Fragment>
38-
) : (
39-
<Fragment>
40-
{'{'}
41-
<PlusCircledIcon />
42-
{'...}'}
43-
</Fragment>
44-
)}
45-
</button>
46-
</div>
47-
{expanded ? (
48-
<Fragment>
49-
<div className="flex flex-col gap-2 pl-4">
50-
{objProps.map(prop => (
51-
<div key={prop.name}>
52-
{prop.description && (
53-
<div>
54-
<code>{codeToJsx(`// ${prop.description}`, language)}</code>
55-
</div>
56-
)}
29+
<div className="flex items-center gap-2">
30+
<code>{name ? name : 'Object'}</code>
31+
<button className="flex items-center" onClick={() => setExpanded(!expanded)}>
32+
{expanded ? (
33+
<Fragment>
34+
{'{'}
35+
<MinusCircledIcon />
36+
</Fragment>
37+
) : (
38+
<Fragment>
39+
{'{'}
40+
<PlusCircledIcon />
41+
{'...}'}
42+
</Fragment>
43+
)}
44+
</button>
45+
</div>
46+
{expanded ? (
47+
<Fragment>
48+
<div className="flex flex-col gap-2 pl-4">
49+
{objProps.map(prop => (
50+
<div key={prop.name}>
51+
{prop.description && (
52+
<div>
53+
<code>{codeToJsx(`// ${prop.description}`, language)}</code>
54+
</div>
55+
)}
56+
<div>
5757
{typeof prop.type === 'string' ? (
58-
<code>{prop.name}: {codeToJsx(prop.type, language)},</code>
58+
<Fragment>
59+
<code>{prop.name}{!prop.required ? '?' : ''}: </code>
60+
<code>{codeToJsx(prop.type, language)},</code>
61+
</Fragment>
5962
) : (
6063
<RenderNestedObject
61-
name={prop.type.name}
64+
name={`${prop.name}${!prop.required ? '?' : ''}: ${prop.type.name || 'Object'}`}
6265
objProps={prop.type.properties}
63-
language={'json'}
66+
language={language}
6467
/>
6568
)}
6669
</div>
67-
))}
68-
</div>
69-
<div>{'}'}</div>
70-
</Fragment>
71-
) : null}
72-
</pre>
70+
</div>
71+
))}
72+
</div>
73+
<div>{'}'}</div>
74+
</Fragment>
75+
) : null}
7376
</div>
7477
);
7578
}

src/components/sdkApi.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function SdkApi({
5454
}: Props) {
5555
return (
5656
<SdkDefinition name={name} categorySupported={categorySupported}>
57-
<pre className="mt-2 mb-2">{codeToJsx(signature, language)}</pre>
57+
<pre className="mt-2 mb-2 text-sm">{codeToJsx(signature, language)}</pre>
5858

5959
{parameters.length ? (
6060
<Expandable title="Parameters">
@@ -87,15 +87,17 @@ function ApiParameterDef({
8787
<div className="space-y-1">
8888
<div>
8989
{typeof type === 'string' ? (
90-
<pre className="m-0 pt-1 pb-1">
90+
<pre className="m-0 pt-1 pb-1 text-sm">
9191
<code>{codeToJsx(type, language)}</code>
9292
</pre>
9393
) : (
94-
<RenderNestedObject
95-
name={type.name}
96-
objProps={type.properties}
97-
language={language}
98-
/>
94+
<pre className="m-0 pt-1 pb-1 text-sm">
95+
<RenderNestedObject
96+
name={type.name}
97+
objProps={type.properties}
98+
language={language}
99+
/>
100+
</pre>
99101
)}
100102
</div>
101103

0 commit comments

Comments
 (0)