sentry env modes, /viewContent disconnect button, env

This commit is contained in:
Verticool 2025-02-18 22:25:15 +06:00
parent 90d629876b
commit a58c73c112
7 changed files with 47 additions and 22 deletions

2
.env
View File

@ -1,2 +0,0 @@
VITE_API_BASE_URL=https://my-public-node-1.projscale.dev/api/v1
VITE_SENTRY_DSN=https://4ef061d22eee4876ad8bb313134ebf009ed96c9da98742289ff733a301fcd184@k1.hawk.so/0

2
.gitignore vendored
View File

@ -2,4 +2,4 @@
node_modules
.DS_Store
dist
.env
.env*

6
src/env.d.ts vendored
View File

@ -1,7 +1,11 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VITE_API_BASE_URL: string;
readonly VITE_SENTRY_DSN: string
readonly VITE_API_BASE_URL: string
readonly MODE: 'development' | 'production'
readonly PROD: boolean
readonly DEV: boolean
}
interface ImportMeta {

View File

@ -3,6 +3,7 @@ import { useTonConnectUI } from "@tonconnect/ui-react";
import { Button } from "~/shared/ui/button";
import { useAuth } from "~/shared/services/auth";
import { Address } from "@ton/core";
type WelcomeStepProps = {
nextStep(): void;
@ -12,7 +13,7 @@ export const WelcomeStep = ({ nextStep }: WelcomeStepProps) => {
const [tonConnectUI] = useTonConnectUI();
const [isLoaded, setLoaded] = useState(false);
const [isConnected, setIsConnected] = useState(tonConnectUI.connected);
const [address, setAddress] = useState('');
console.log("💩💩💩 enter WelcomeStep");
const auth = useAuth();
@ -33,6 +34,16 @@ export const WelcomeStep = ({ nextStep }: WelcomeStepProps) => {
};
}, [tonConnectUI]);
useEffect(() => {
if(tonConnectUI.account){
setAddress(Address.parse(tonConnectUI.account?.address).toString({
bounceable: false,
urlSafe: true,
testOnly: false,
}),)
}
}, [tonConnectUI.account]);
const handleNextClick = async () => {
if (tonConnectUI.connected) {
await auth.mutateAsync();
@ -122,8 +133,8 @@ export const WelcomeStep = ({ nextStep }: WelcomeStepProps) => {
<>
<div className={"mt-2"}>
<p className={"text-sm"}>
Вы зарегистрированы под кошельком:
<span className={"font-bold pl-1"}>{tonConnectUI.account?.address.slice(2, 9)}...{tonConnectUI.account?.address.slice(-4)}</span>
Вы зарегистрированы под кошельком: <br/>
<span className={"font-bold"}>{address}</span>
</p>
</div>
<div className="flex flex-col">

View File

@ -28,7 +28,7 @@ export const ErrorModal = ({
}
>
<p className="mt-12">
<span className="px-1 font-bold">Ошибка запроса транзакции</span>
<span className="font-bold">Ошибка запроса транзакции</span>
</p>
<p className="">
Не удалось отправить запрос на выполнение транзакции.

View File

@ -134,13 +134,24 @@ export const ViewContentPage = () => {
/>
}
<Button
onClick={() => {
WebApp.openTelegramLink(`https://t.me/MY_UploaderRobot`);
}}
className={"h-[48px] bg-darkred"}
label={`Загрузить свой контент`}
/>
{tonConnectUI.connected && (
<>
<Button
onClick={() => {
WebApp.openTelegramLink(`https://t.me/MY_UploaderRobot`);
}}
className={"h-[48px] bg-darkred"}
label={`Загрузить свой контент`}
/>
<Button
onClick={() => {
tonConnectUI.disconnect();
}}
className={"h-[48px] bg-darkred mt-4"}
label={`Отключить кошелек`}
/>
</>
)}
</div>
</main>
);

View File

@ -7,7 +7,7 @@ import {
useNavigationType,
} from "react-router-dom";
console.log(import.meta.env);
Sentry.init({
dsn: import.meta.env.VITE_SENTRY_DSN,
integrations: [
@ -22,22 +22,23 @@ Sentry.init({
}),
Sentry.replayIntegration(),
],
enabled: import.meta.env.PROD, // Only enable in production
environment: import.meta.env.MODE, // Set the environment
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for tracing.
// Learn more at
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
tracesSampleRate: 0,
// Set `tracePropagationTargets` to control for which URLs trace propagation should be enabled
tracePropagationTargets: [
/^\//,
new RegExp(`^${import.meta.env.VITE_API_BASE_URL}`),
// /^\//,
// new RegExp(`^${import.meta.env.VITE_API_BASE_URL}`),
],
// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
// Learn more at
// https://docs.sentry.io/platforms/javascript/session-replay/configuration/#general-integration-configuration
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
replaysSessionSampleRate: 0,
replaysOnErrorSampleRate: 0,
});