Skip to content

Commit e00e8f7

Browse files
committed
feat: Various improvements to SDK docs
- Pull package registry into graphql - Add SDK information above toc when available - Improve CDN documentation and add bundle list - Convert various Gatsby config to TypeScript (fixes awkward parsing issues) - SmartLink will now render the link as the default text - Minor cleanup here and there
1 parent 983cbaa commit e00e8f7

File tree

64 files changed

+662
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+662
-376
lines changed

gatsby-config.js

Lines changed: 1 addition & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
const axios = require("axios");
2-
31
require("ts-node").register({
42
files: true, // to that TS node hooks have access to local typings too
53
});
@@ -20,199 +18,4 @@ if (
2018
process.env.ALGOLIA_INDEX = "1";
2119
}
2220

23-
const queries = require("./src/utils/algolia");
24-
const packages = new (require("./src/utils/packageRegistry"))();
25-
26-
const getPlugins = () => {
27-
const remarkPlugins = [
28-
{
29-
resolve: require.resolve("./plugins/gatsby-remark-variables"),
30-
options: {
31-
scope: {
32-
packages,
33-
},
34-
excludeExpr: ["default"],
35-
},
36-
},
37-
{
38-
resolve: `gatsby-remark-copy-linked-files`,
39-
},
40-
{
41-
resolve: `gatsby-remark-autolink-headers`,
42-
options: {
43-
className: "anchor",
44-
icon: `<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M10.879 6.05L15 1.93A5.001 5.001 0 0 1 22.071 9l-4.121 4.121a1 1 0 0 1-1.414-1.414l4.12-4.121a3 3 0 1 0-4.242-4.243l-4.121 4.121a1 1 0 1 1-1.414-1.414zm2.242 11.9L9 22.07A5 5 0 1 1 1.929 15l4.121-4.121a1 1 0 0 1 1.414 1.414l-4.12 4.121a3 3 0 1 0 4.242 4.243l4.121-4.121a1 1 0 1 1 1.414 1.414zm-8.364-.122l13.071-13.07a1 1 0 0 1 1.415 1.414L6.172 19.242a1 1 0 1 1-1.415-1.414z" fill="currentColor"></path></svg>`,
45-
enableCustomId: true,
46-
},
47-
},
48-
{
49-
resolve: `gatsby-remark-images`,
50-
options: {
51-
maxWidth: 1200,
52-
linkImagesToOriginal: true,
53-
},
54-
},
55-
{
56-
resolve: "gatsby-remark-prismjs",
57-
options: {
58-
noInlineHighlight: true,
59-
},
60-
},
61-
// {
62-
// resolve: `gatsby-remark-check-links`
63-
// }
64-
];
65-
66-
const plugins = [
67-
{
68-
resolve: "@sentry/gatsby",
69-
options: {
70-
dsn: process.env.SENTRY_DSN,
71-
release: process.env.SENTRY_RELEASE,
72-
tracesSampleRate: activeEnv === "development" ? 0 : 1,
73-
},
74-
},
75-
"gatsby-plugin-sharp",
76-
"gatsby-plugin-sass",
77-
"gatsby-plugin-zeit-now",
78-
{
79-
resolve: `gatsby-transformer-remark`,
80-
options: {
81-
plugins: remarkPlugins,
82-
},
83-
},
84-
{
85-
resolve: "gatsby-plugin-mdx",
86-
options: {
87-
remarkPlugins: [require("remark-deflist")],
88-
gatsbyRemarkPlugins: [
89-
{
90-
resolve: require.resolve("./plugins/gatsby-plugin-code-tabs"),
91-
},
92-
{
93-
resolve: require.resolve("./plugins/gatsby-plugin-include"),
94-
},
95-
...remarkPlugins,
96-
],
97-
},
98-
},
99-
"gatsby-plugin-react-helmet",
100-
`gatsby-transformer-yaml`,
101-
{
102-
resolve: `gatsby-transformer-json`,
103-
options: {
104-
typeName: ({ node }) => {
105-
if (node.sourceInstanceName === "api") {
106-
return "ApiEndpoint";
107-
}
108-
return null;
109-
},
110-
},
111-
},
112-
`gatsby-transformer-javascript-frontmatter`,
113-
{
114-
resolve: `gatsby-source-filesystem`,
115-
options: {
116-
name: `docs`,
117-
path: `${__dirname}/src/docs`,
118-
},
119-
},
120-
{
121-
resolve: `gatsby-source-filesystem`,
122-
options: {
123-
name: `platforms`,
124-
path: `${__dirname}/src/platforms`,
125-
},
126-
},
127-
{
128-
resolve: `gatsby-source-filesystem`,
129-
options: {
130-
name: `api`,
131-
path: `${__dirname}/src/api`,
132-
},
133-
},
134-
{
135-
resolve: `gatsby-source-filesystem`,
136-
options: {
137-
name: `includes`,
138-
path: `${__dirname}/src/includes`,
139-
},
140-
},
141-
{
142-
resolve: `gatsby-source-filesystem`,
143-
options: {
144-
name: `wizard`,
145-
path: `${__dirname}/src/wizard`,
146-
ignore: [`**/README.md`],
147-
},
148-
},
149-
{
150-
resolve: `gatsby-source-filesystem`,
151-
options: {
152-
name: `pages`,
153-
path: `${__dirname}/src/pages`,
154-
},
155-
},
156-
{
157-
resolve: `gatsby-source-filesystem`,
158-
options: {
159-
name: "data",
160-
path: `${__dirname}/src/data`,
161-
},
162-
},
163-
{
164-
resolve: "./plugins/gatsby-plugin-sentry-wizard",
165-
options: {
166-
source: "wizard",
167-
output: `${__dirname}/public/_platforms`,
168-
},
169-
},
170-
{
171-
resolve: "./plugins/gatsby-redirects",
172-
options: {
173-
inputConfigFile: `${__dirname}/nginx.conf`,
174-
outputConfigFile: `${__dirname}/nginx.out.conf`,
175-
},
176-
},
177-
{
178-
resolve: "./plugins/gatsby-plugin-openapi",
179-
options: {
180-
name: "openapi",
181-
resolve: async () => {
182-
const response = await axios.get(
183-
"https://raw.githubusercontent.com/getsentry/sentry-api-schema/68bb79acfbbee062bd8d2f71ee3a07d43dc934c9/openapi-derefed.json"
184-
);
185-
return response.data;
186-
},
187-
// required, function which returns a Promise resolving Swagger JSON
188-
},
189-
},
190-
// generate normal redirects so when you're running without nginx
191-
// you receive similar behavior
192-
`gatsby-plugin-meta-redirect`,
193-
];
194-
if (process.env.ALGOLIA_INDEX === "1") {
195-
plugins.push({
196-
resolve: `gatsby-plugin-algolia`,
197-
options: {
198-
appId: process.env.GATSBY_ALGOLIA_APP_ID,
199-
apiKey: process.env.ALGOLIA_ADMIN_KEY,
200-
queries,
201-
chunkSize: 10000, // default: 1000
202-
},
203-
});
204-
}
205-
return plugins;
206-
};
207-
208-
module.exports = {
209-
// pathPrefix: `/develop`,
210-
siteMetadata: {
211-
title: "Sentry Documentation",
212-
homeUrl: "https://docs.sentry.io",
213-
sitePath: "docs.sentry.io",
214-
description: "",
215-
author: "@getsentry",
216-
},
217-
plugins: getPlugins(),
218-
};
21+
module.exports = require("./src/gatsby/config");

src/@types/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ declare module "*.svg" {
44
const src: string;
55
export default src;
66
}
7+
8+
declare module "sentry-global-search";

src/components/__tests__/__snapshots__/platformRedirectLink.test.js.snap

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ exports[`PlatformRedirectLink renders with to 1`] = `
44
<a
55
className=""
66
href="/platform-redirect/?next=%2Fenriching-error-data%2F"
7-
/>
7+
>
8+
/platform-redirect/?next=%2Fenriching-error-data%2F
9+
</a>
810
`;
911

1012
exports[`PlatformRedirectLink renders without to 1`] = `
1113
<a
1214
className=""
1315
href="/platform-redirect/"
14-
/>
16+
>
17+
/platform-redirect/
18+
</a>
1519
`;

src/components/basePage.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ type Props = {
5050
seoTitle?: string;
5151
sidebar?: JSX.Element;
5252
children?: JSX.Element;
53+
prependToc?: JSX.Element;
5354
};
5455

5556
export default ({
@@ -58,6 +59,7 @@ export default ({
5859
seoTitle,
5960
sidebar,
6061
children,
62+
prependToc,
6163
}: Props): JSX.Element => {
6264
const tx = Sentry.getCurrentHub()
6365
.getScope()
@@ -93,14 +95,19 @@ export default ({
9395
)}
9496
</div>
9597
</div>
96-
{hasToc && (
98+
{(hasToc || prependToc) && (
9799
<div className="col-sm-4 col-md-12 col-lg-4 col-xl-3">
98-
<div className="doc-toc">
99-
<div className="doc-toc-title">
100-
<h6>On this page</h6>
101-
</div>
102-
<TableOfContents toc={child.tableOfContents} />
103-
</div>
100+
<React.Fragment>
101+
{prependToc}
102+
{hasToc && (
103+
<div className="doc-toc">
104+
<div className="doc-toc-title">
105+
<h6>On this page</h6>
106+
</div>
107+
<TableOfContents toc={child.tableOfContents} />
108+
</div>
109+
)}
110+
</React.Fragment>
104111
</div>
105112
)}
106113
</div>

src/components/hooks/usePlatform.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const query = graphql`
1414
name
1515
title
1616
url
17+
sdk
1718
caseStyle
1819
supportLevel
1920
fallbackPlatform
@@ -22,6 +23,7 @@ const query = graphql`
2223
name
2324
title
2425
url
26+
sdk
2527
caseStyle
2628
supportLevel
2729
fallbackPlatform
@@ -69,6 +71,7 @@ export type Guide = {
6971
name: string;
7072
title: string;
7173
url: string;
74+
sdk: string;
7275
caseStyle: string;
7376
supportLevel: string;
7477
fallbackPlatform: string;
@@ -79,6 +82,7 @@ export type Platform = {
7982
name: string;
8083
title: string;
8184
url: string;
85+
sdk: string;
8286
caseStyle: string;
8387
supportLevel: string;
8488
guides?: Guide[];

src/components/jsBundleList.tsx

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from "react";
2+
import { graphql, useStaticQuery } from "gatsby";
3+
import styled from "@emotion/styled";
4+
5+
const query = graphql`
6+
query JsBundleList {
7+
package(id: { eq: "sentry.javascript.browser" }) {
8+
files {
9+
name
10+
checksums {
11+
name
12+
value
13+
}
14+
}
15+
}
16+
}
17+
`;
18+
19+
const ChecksumValue = styled.code`
20+
font-size: 0.8em;
21+
white-space: nowrap;
22+
overflow: hidden;
23+
text-overflow: ellipsis;
24+
`;
25+
26+
export default (): JSX.Element => {
27+
const {
28+
package: { files },
29+
} = useStaticQuery(query);
30+
31+
return (
32+
<table>
33+
<thead>
34+
<tr>
35+
<th>File</th>
36+
<th>Integrity Checksum</th>
37+
</tr>
38+
</thead>
39+
<tbody>
40+
{files.map(file => {
41+
return (
42+
<tr key={file.name}>
43+
<td style={{ fontSize: "0.9em", verticalAlign: "middle" }}>
44+
{file.name}
45+
</td>
46+
<td style={{ verticalAlign: "middle" }}>
47+
<ChecksumValue>
48+
{`sha384-${
49+
file.checksums.find(c => c.name === "sha384-base64").value
50+
}`}
51+
</ChecksumValue>
52+
</td>
53+
</tr>
54+
);
55+
})}
56+
</tbody>
57+
</table>
58+
);
59+
};

0 commit comments

Comments
 (0)