Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs #1067

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,773 changes: 951 additions & 822 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/serverless/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ PROMETHEUS_ALLOWED_SUBNET=
CLICKHOUSE_URL=http://localhost:8123
CLICKHOUSE_USER=default
CLICKHOUSE_PASSWORD=
CLICKHOUSE_DATABASE=default
2 changes: 1 addition & 1 deletion crates/serverless/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tokio-cron-scheduler = "0.9.4"
# TODO: use a specific version of dashmap when the inline feature is released
dashmap = { git = "https://github.com/xacrimon/dashmap.git", rev = "7f9522c5286cfbbb78df15f00f87b8331cb875d6", features = ["inline"] }
futures = "0.3.28"
clickhouse = "0.11.5"
clickhouse = "0.11.6"
bytes = "1.4.0"
serde = { version = "1.0", features = ["derive"] }
uuid = { version = "1.4.0", features = ["v4", "fast-rng"] }
Expand Down
3 changes: 2 additions & 1 deletion crates/serverless/src/clickhouse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ pub struct RequestRow {
pub fn create_client() -> Client {
let url = env::var("CLICKHOUSE_URL").expect("CLICKHOUSE_URL must be set");
let user = env::var("CLICKHOUSE_USER").expect("CLICKHOUSE_USER must be set");
let database = env::var("CLICKHOUSE_DATABASE").unwrap_or_else(|_| "default".to_string());

let client = Client::default()
.with_url(url)
.with_user(user)
.with_database("default");
.with_database(database);

if let Ok(password) = env::var("CLICKHOUSE_PASSWORD") {
return client.with_password(password);
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile.serverless
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ COPY . .
COPY --from=js-runtime /app/dist/index.js /app/crates/runtime_isolate/runtime.js
RUN cargo build --release --bin lagon-serverless

FROM debian:bullseye-slim AS runtime
FROM chef AS runtime
WORKDIR /app
RUN apt-get update -y \
&& apt-get install -y ca-certificates \
&& apt-get install -y ca-certificates libssl1.0 libssl-dev \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
Expand Down
4 changes: 0 additions & 4 deletions packages/dashboard/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ LAGON_BLACKLISTED_FUNCTIONS_NAMES=
NEXT_PUBLIC_LAGON_ROOT_SCHEM=http
NEXT_PUBLIC_LAGON_ROOT_DOMAIN=lagon.dev

NEXT_PUBLIC_SENTRY_DSN=
NEXT_PUBLIC_SENTRY_ENVIRONMENT=development
SENTRY_IGNORE_API_RESOLUTION_ERROR=1

S3_ENDPOINT=http://localhost:9002
S3_REGION=unkown
S3_BUCKET=lagon
Expand Down
3 changes: 0 additions & 3 deletions packages/dashboard/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,3 @@ yarn-error.log*

# local env files
.env*.local

# Sentry
.sentryclirc
7 changes: 0 additions & 7 deletions packages/dashboard/lib/pages/function/FunctionOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { ChevronDownIcon } from '@heroicons/react/24/outline';
import * as Sentry from '@sentry/nextjs';
import { useRouter } from 'next/router';
import { Suspense, useEffect, useMemo, useState } from 'react';
import { Button, Card, Chart, Description, Divider, Menu, Skeleton, Text } from '@lagon/ui';
Expand Down Expand Up @@ -98,12 +97,6 @@
time,
});
} catch (err) {
Sentry.captureException(err, {
tags: {
cron: func?.cron,
},
});

return t('usage.nextCron.label.invalid');
}
};
Expand All @@ -122,7 +115,7 @@
clearInterval(interval);
};
}
}, [func?.cron, t]);

Check warning on line 118 in packages/dashboard/lib/pages/function/FunctionOverview.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'calculateCron'. Either include it or remove the dependency array

return (
<>
Expand Down
2 changes: 0 additions & 2 deletions packages/dashboard/lib/smtp/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createTransport } from 'nodemailer';
import { ReactElement } from 'react';
import { render } from '@react-email/render';
import * as Sentry from '@sentry/nextjs';
import { Welcome } from './Welcome';

const createTransporter = () => {
Expand Down Expand Up @@ -29,7 +28,6 @@ const sendEmail = async ({ to, subject, email }: { to: string; subject: string;
html: render(email),
});
} catch (error) {
Sentry.captureException(error);
console.error(error);
}
};
Expand Down
13 changes: 1 addition & 12 deletions packages/dashboard/next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const { withSentryConfig } = require('@sentry/nextjs');

/** @type {import('next').NextConfig} */
const nextConfig = {
module.exports = {
reactStrictMode: true,
swcMinify: true,
i18n: {
Expand All @@ -15,14 +13,5 @@ const nextConfig = {
typescript: {
ignoreBuildErrors: true,
},
sentry: {
tunnelRoute: '/monitoring-tunnel',
},
output: process.env.NEXTJS_OUTPUT,
};

const sentryWebpackPluginOptions = {
silent: true,
};

module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions);
1 change: 0 additions & 1 deletion packages/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"@react-email/section": "^0.0.9",
"@react-email/text": "^0.0.5",
"@scaleway/use-random-name": "^0.3.0",
"@sentry/nextjs": "^7.57.0",
"@tanstack/react-query": "^4.6.1",
"@trpc/client": "^10.18.0",
"@trpc/next": "^10.18.0",
Expand Down
17 changes: 3 additions & 14 deletions packages/dashboard/pages/_error.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import NextErrorComponent from 'next/error';

import * as Sentry from '@sentry/nextjs';

const MyError = ({ statusCode, hasGetInitialPropsRun, err }) => {
if (!hasGetInitialPropsRun && err) {
// getInitialProps is not called in case of
// https://github.com/vercel/next.js/issues/8592. As a workaround, we pass
// err via _app.js so it can be captured
Sentry.captureException(err);
console.error(err); // eslint-disable-line no-console
// Flushing is not required in this case as it only happens on the client
}

Expand All @@ -17,13 +15,13 @@
MyError.getInitialProps = async context => {
const errorInitialProps = await NextErrorComponent.getInitialProps(context);

const { res, err, asPath } = context;

Check failure on line 18 in packages/dashboard/pages/_error.js

View workflow job for this annotation

GitHub Actions / Lint

'asPath' is assigned a value but never used

// Workaround for https://github.com/vercel/next.js/issues/8592, mark when
// getInitialProps has run
errorInitialProps.hasGetInitialPropsRun = true;

// Returning early because we don't want to log 404 errors to Sentry.
// Returning early because we don't want to log 404 errors.
if (res?.statusCode === 404) {
return errorInitialProps;
}
Expand All @@ -42,21 +40,12 @@
// Boundaries: https://reactjs.org/docs/error-boundaries.html

if (err) {
Sentry.captureException(err);

// Flushing before returning is necessary if deploying to Vercel, see
// https://vercel.com/docs/platform/limits#streaming-responses
await Sentry.flush(2000);

return errorInitialProps;
}

// If this point is reached, getInitialProps was called without any
// information about what the error might be. This is unexpected and may
// indicate a bug introduced in Next.js, so record it in Sentry
Sentry.captureException(new Error(`_error.js getInitialProps missing data at path: ${asPath}`));
await Sentry.flush(2000);

// indicate a bug introduced in Next.js
return errorInitialProps;
};

Expand Down
12 changes: 0 additions & 12 deletions packages/dashboard/pages/api/auth/[...nextauth].ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import GithubProvider from 'next-auth/providers/github';
import GoogleProvider from 'next-auth/providers/google';
import { PrismaAdapter } from '@next-auth/prisma-adapter';
import prisma from 'lib/prisma';
import * as Sentry from '@sentry/nextjs';
import { createOrAssignDefaultOrganization } from 'lib/api/users';
import { sendWelcomeEmail } from 'lib/smtp';

Expand Down Expand Up @@ -48,11 +47,6 @@ export const authOptions: NextAuthOptions = {
return true;
}

Sentry.captureMessage('User is not authorized to sign in', {
user: {
email: user.email,
},
});
console.log('User is not authorized to sign in:', user.email);

return false;
Expand Down Expand Up @@ -100,12 +94,6 @@ export const authOptions: NextAuthOptions = {
},
});

Sentry.setUser({
id: userFromDB.id,
username: userFromDB.name ?? 'Unknown',
email: userFromDB.email ?? 'Unknown',
});

return {
...session,
user: {
Expand Down
11 changes: 0 additions & 11 deletions packages/dashboard/pages/api/trpc/[trpc].ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { tokensRouter } from 'lib/trpc/tokensRouter';
import { deploymentsRouter } from 'lib/trpc/deploymentsRouter';
import prisma from 'lib/prisma';
import { Session } from 'next-auth';
import * as Sentry from '@sentry/nextjs';
import { accountsRouter } from 'lib/trpc/accountsRouter';
import { NextApiRequest, NextApiResponse } from 'next';
import { authOptions } from '../auth/[...nextauth]';
Expand Down Expand Up @@ -73,12 +72,6 @@ const createContext = async ({
},
});

Sentry.setUser({
id: token.user.id,
username: token.user.name ?? 'Unknown',
email: token.user.email ?? 'Unknown',
});

return {
req,
res,
Expand Down Expand Up @@ -137,9 +130,5 @@ export default trpcNext.createNextApiHandler({
createContext,
onError: ({ error }) => {
console.error(error);

if (error.code === 'INTERNAL_SERVER_ERROR') {
Sentry.captureException(error);
}
},
});
3 changes: 0 additions & 3 deletions packages/dashboard/pages/api/webhooks/stripe.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NextApiRequest, NextApiResponse } from 'next';
import * as Sentry from '@sentry/nextjs';
import { stripe } from 'lib/stripe';
import type Stripe from 'stripe';
import prisma from 'lib/prisma';
Expand Down Expand Up @@ -39,8 +38,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
);
} catch (err) {
console.log(err);
Sentry.captureException(err);

return res.status(400).end();
}

Expand Down
6 changes: 3 additions & 3 deletions packages/dashboard/pages/auth/error.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Text, Card, Button } from '@lagon/ui';
import { GitHubIcon } from 'lib/components/GitHubIcon';
import { GoogleIcon } from 'lib/components/GoogleIcon';

Check failure on line 3 in packages/dashboard/pages/auth/error.tsx

View workflow job for this annotation

GitHub Actions / Lint

'GoogleIcon' is defined but never used
import { useScopedI18n } from 'locales';
import { signIn, useSession } from 'next-auth/react';
import { useRouter } from 'next/router';
Expand Down Expand Up @@ -32,7 +32,7 @@
</Text>
</div>
{error === 'AccessDenied' ? (
<Button variant="primary" href="https://tally.so/r/n9q1Rp">
<Button variant="primary" href="https://tally.so/r/wd9eJr">
{t('error.joinWaitlist')}
</Button>
) : (
Expand All @@ -49,7 +49,7 @@
>
{t('github')}
</Button>
<Button
{/* <Button
leftIcon={<GoogleIcon className="h-4 w-4" />}
disabled={isLoading}
onClick={() => {
Expand All @@ -60,7 +60,7 @@
}}
>
{t('google')}
</Button>
</Button> */}
</div>
)}
</div>
Expand Down
6 changes: 3 additions & 3 deletions packages/dashboard/pages/auth/signin.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Text, Card, Button } from '@lagon/ui';
import { GitHubIcon } from 'lib/components/GitHubIcon';
import { GoogleIcon } from 'lib/components/GoogleIcon';
// import { GoogleIcon } from 'lib/components/GoogleIcon';
import { useScopedI18n } from 'locales';
import { signIn, useSession } from 'next-auth/react';
import { useRouter } from 'next/router';
Expand Down Expand Up @@ -37,7 +37,7 @@ const SignIn = () => {
>
{t('github')}
</Button>
<Button
{/* <Button
leftIcon={<GoogleIcon className="h-4 w-4" />}
disabled={isLoading}
onClick={() => {
Expand All @@ -48,7 +48,7 @@ const SignIn = () => {
}}
>
{t('google')}
</Button>
</Button> */}
</div>
</div>
</Card>
Expand Down
7 changes: 0 additions & 7 deletions packages/dashboard/sentry.client.config.js

This file was deleted.

4 changes: 0 additions & 4 deletions packages/dashboard/sentry.properties

This file was deleted.

7 changes: 0 additions & 7 deletions packages/dashboard/sentry.server.config.js

This file was deleted.

Loading
Loading