Skip to content

Commit

Permalink
build improvements
Browse files Browse the repository at this point in the history
- remove sentry.io
- .gitignore 'dist'
- include 'embed.html' in the output
  • Loading branch information
judeallred committed Nov 21, 2023
1 parent 41ca5b0 commit a38c762
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 242 deletions.
1 change: 1 addition & 0 deletions apps/sim-core/packages/core/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
coverage
dist

# auto-generated types for API queries
src/util/api/auto-types.ts
5 changes: 1 addition & 4 deletions apps/sim-core/packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"/node_modules/(?!monaco-editor).+\\.js$"
]
},
"browserslist": [
"browserslist": [
"edge >= 88",
"firefox >= 78",
"chrome >= 87",
Expand All @@ -63,9 +63,6 @@
"@msrvida/sanddance-explorer": "3.1.0",
"@react-three/drei": "1.5.9",
"@reduxjs/toolkit": "1.5.0",
"@sentry/browser": "6.2.0",
"@sentry/fullstory": "1.1.5",
"@sentry/integrations": "6.2.0",
"@svgr/core": "5.5.0",
"@types/node": "14.14.7",
"bowser": "2.11.0",
Expand Down
6 changes: 1 addition & 5 deletions apps/sim-core/packages/core/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,7 @@ async function buildAndStageAssets(): Promise<string> {
});

// 4. Notify relevant apps:
// Notify Sentry.io that a new deploy exists
await request.post(
"https://sentry.io/api/hooks/release/builtin/1509252/efc0273443d500ecd145d41ac4e0b48999648d378b828dca8b4a1b8fb3d42ef8/",
{ json: { version: stamp } }
);
// (nothing to do at the moment)

return stamp;
}
Expand Down
2 changes: 0 additions & 2 deletions apps/sim-core/packages/core/src/boot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { enableMapSet } from "immer";
import * as api from "./util/api";
import { buildSimulationProvider } from "./features/simulator/simulate/buildprovider";
import { configureMonaco } from "./util/monaco-config";
import { initSentry } from "./util/initSentry";
import { resizeObserverPromise } from "./util/resizeObserverPromise";
import { simulatorStore } from "./features/simulator/store";
import { store } from "./features/store";
Expand All @@ -25,7 +24,6 @@ export const boot = async (forExperiments: boolean) => {
simulatorStore,
});

initSentry();
configureTheme();
enableMapSet();
configureMonaco();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import React, {
useMemo,
useState,
} from "react";
import * as Sentry from "@sentry/browser";
import { customAlphabet } from "nanoid";

import { BasicDiscordWidget } from "../DiscordWidget/DiscordWidget";
import { BigModal } from "../Modal";
import { ErrorDetails } from "../ErrorDetails";
import { FancyButton } from "../Fancy";
import { IS_LOCAL } from "../../util/api";
import { sentryConsoleLogAbortController } from "../../util/initSentry";

import "./ErrorBoundary.css";

Expand Down Expand Up @@ -134,19 +132,6 @@ export class ErrorBoundary extends Component<

componentDidCatch(error: Error, errorInfo: ErrorInfo) {
const { hashEventId } = this.state;

/**
* Cancel the in-flight sentry log of this error caused by React calling
* console.error before notifying the error boundary
*/
sentryConsoleLogAbortController.abort();

Sentry.withScope((scope) => {
scope.setTag("hashId", hashEventId);
scope.setExtras(errorInfo as any);
const eventId = Sentry.captureException(error);
this.setState({ eventId });
});
}

render() {
Expand Down
41 changes: 41 additions & 0 deletions apps/sim-core/packages/core/src/embed.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<html>
<head>
<title>HASH Core</title>
<style>html, body { background-color: black; }</style>
<link
rel="apple-touch-icon"
sizes="180x180"
href="https://cdn-us1.hash.ai/assets/img/brand/favicon-180.png"
/>
<link
rel="icon"
type="image/png"
sizes="32x32"
href="https://cdn-us1.hash.ai/assets/img/brand/favicon.png"
/>
<link
rel="manifest"
href="https://cdn-us1.hash.ai/assets/other/site.webmanifest"
/>
<link
rel="mask-icon"
href="https://cdn-us1.hash.ai/assets/img/brand/safari-pinned-tab.svg"
color="#0094ff"
/>
<meta name="msapplication-TileColor" content="#FFFFFF" />
<meta name="theme-color" content="#ffffff" />
<meta name="description" content="HASH Core is a zero-setup environment for in-browser simulation development, viewing and experimentation. No packages to install, no config required." />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@hashintel" />
<meta name="twitter:title" content="HASH Core: in-browser simulation environment" />
<meta name="twitter:description" content="HASH Core is a zero-setup environment for in-browser simulation development, viewing and experimentation. No packages to install, no config required." />
<meta name="twitter:image" content="https://cdn-us1.hash.ai/assets/hash-card.png"/>
<meta charset="utf-8" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/embed.tsx"></script>

</body>
</html>
6 changes: 0 additions & 6 deletions apps/sim-core/packages/core/src/features/files/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,6 @@ const setters = {
state.openFileIds.push(id);
}
} else {
/**
* Diagnostics to fix sentry issue
* "Cannot append file that does not exist: initialState"
* @see https://sentry.io/organizations/hashintel/issues/2371565370/events/fd45f2d27fad4b3ca12a2e60a910ecee/?project=1509252
* @todo remove this when above issue resolved
*/
const currentState = current(state);
console.log("===== CURRENT STATE =====");
for (const [key, value] of Object.entries(currentState)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
RunnerStatus,
SimulationStates,
} from "@hashintel/engine-web";
import { addBreadcrumb } from "@sentry/browser";

import { AnalysisMode } from "./enum";
import { Commit, ProjectHistoryItemType } from "../../../util/api/auto-types";
Expand Down Expand Up @@ -494,21 +493,6 @@ const { reducer, actions } = createSlice({

const currentState = current(state);

/**
* @todo remove when sentry issue is solved
* @see https://sentry.io/organizations/hashintel/issues/2237610017
*/
addBreadcrumb({
message: "Setting simulation as selected",
data: {
currentSimulation: currentState.currentSimulation,
analysisMode: currentState.analysisMode,
payloadSimId: action.payload.simId,
payloadLatest: action.payload.latest ?? false,
simId,
},
});

state.currentSimulation = simId;
state.analysisMode = simId ? AnalysisMode.SingleRun : null;
state.history.selectedCommitGroup = null;
Expand Down
48 changes: 0 additions & 48 deletions apps/sim-core/packages/core/src/util/api/queries/basicUser.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
import * as Sentry from "@sentry/browser";
import SentryFullStory from "@sentry/fullstory";
import {
identify as fsIdentify,
init as fsInit,
setUserVars as fsSetUserVars,
} from "@fullstory/browser";
import { setupIntegration } from "@sentry/core/dist/integration";

import { BasicUser } from "../types";
import { IS_DEV, IS_LOCAL } from "../paths";
import { query } from "../query";
Expand All @@ -21,43 +12,6 @@ export const BasicUserFragment = /* GraphQL */ `
}
`;

export const identifyBasicUser = (me?: BasicUser | undefined) => {
const user = me
? {
email: me.email,
id: me.id,
name: me.fullName,
username: me.shortname,
staff: me.staffMember,
}
: null;

if (!IS_LOCAL && (user?.staff || IS_DEV)) {
fsInit({ orgId: "ZCVMD" });
if (user) {
fsIdentify(user.id, {
displayName: user.name,
email: user.email,
});
}
fsSetUserVars({ staging: IS_DEV, production: !IS_DEV });

const client = Sentry.getCurrentHub().getClient();
/**
* Using private API to add a new integration
* @todo figure out how to do this without a private API
*/
if (client) {
const sentryFullStory = new SentryFullStory("hashintel");
setupIntegration(sentryFullStory);
// @ts-ignore
client._integrations[sentryFullStory.name] = sentryFullStory;
}
}

Sentry.setUser(user);
};

export const basicUser = async () => {
const { me } = await query<{ me?: BasicUser }>(`
query basicUser {
Expand All @@ -67,7 +21,5 @@ export const basicUser = async () => {
${BasicUserFragment}
`);

identifyBasicUser(me);

return me;
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { ProjectTypeName, VisibilityLevel } from "../auto-types";
import type { User } from "../types";
import { getItem } from "../../../hooks/useLocalStorage";
import { getLocalStorageProject } from "../../../features/project/utils";
import { identifyBasicUser } from "./basicUser";
import { prepareExamples } from "./exampleSimulations";
import { prepareUserProjects } from "./myProjects";
import { setLocalStorageProject } from "../../../features/middleware/localStorage";
Expand Down Expand Up @@ -77,7 +76,6 @@ export const bootstrapQuery = async () => {
// Migration shim
return { examples: [] };
} finally {
identifyBasicUser(me);
}
};

Expand Down
11 changes: 0 additions & 11 deletions apps/sim-core/packages/core/src/util/api/query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import prettyStringify from "json-stringify-pretty-compact";
import { Severity, addBreadcrumb } from "@sentry/browser";

import { API_URL } from "./paths";

Expand Down Expand Up @@ -110,21 +109,11 @@ export async function query<T, V = {} | undefined>(
};

if (errors) {
addBreadcrumb({
...crumb,
level: Severity.Warning,
message: `Unsuccessful query ${queryName}`,
});
throw new QueryError({
graphql,
variables: variables || null,
errors: errors as ApiError[],
});
} else {
addBreadcrumb({
...crumb,
message: `Successful query ${queryName}`,
});
}

return data;
Expand Down
50 changes: 0 additions & 50 deletions apps/sim-core/packages/core/src/util/initSentry.ts

This file was deleted.

5 changes: 4 additions & 1 deletion apps/sim-core/packages/core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export default defineConfig(({ mode }) => {
rollupOptions: {
input: {
main: "./src/index.html",
embed: "./src/embed.tsx",
embed: "./src/embed.html",
},
},
reportCompressedSize: false,
minify: true,
sourcemap: false
},
define: {
BUILD_STAMP: JSON.stringify(BUILD_STAMP),
Expand Down
Loading

0 comments on commit a38c762

Please sign in to comment.