Skip to content

Commit

Permalink
Merge branch 'master' of github.com:grai-io/grai-core into feature/gr…
Browse files Browse the repository at this point in the history
…a-900-server-side-api-capabilities
  • Loading branch information
ieaves committed Nov 1, 2023
2 parents c1fe5ff + 432eb73 commit 1a436d2
Show file tree
Hide file tree
Showing 104 changed files with 3,120 additions and 1,165 deletions.
9 changes: 8 additions & 1 deletion grai-frontend/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -33,5 +33,12 @@
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
<script
type="text/javascript"
id="hs-script-loader"
async
defer
src="//js.hs-scripts.com/23214137.js"
></script>
</body>
</html>
35 changes: 23 additions & 12 deletions grai-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions grai-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"@algolia/autocomplete-js": "^1.8.3",
"@apollo/client": "^3.7.2",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@graphql-tools/mock": "^9.0.0",
Expand Down
68 changes: 34 additions & 34 deletions grai-frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import {
useLocation,
useNavigationType,
} from "react-router-dom"
import { ShepherdTour } from "react-shepherd"
// import { ShepherdTour } from "react-shepherd"
import PosthogProvider from "components/PosthogProvider"
import BackendProvider from "./providers/BackendProvider"
import Routes from "./Routes"
import steps from "./steps"
// import steps from "./steps"
import theme from "./theme"
import "posthog"

const tourOptions = {
defaultStepOptions: {
cancelIcon: {
enabled: true,
},
},
useModalOverlay: true,
}
// const tourOptions = {
// defaultStepOptions: {
// cancelIcon: {
// enabled: true,
// },
// },
// useModalOverlay: true,
// }

const App: React.FC = () => {
if (process.env.REACT_APP_SENTRY_DSN)
Expand Down Expand Up @@ -72,31 +72,31 @@ const App: React.FC = () => {
</Helmet>
<ThemeProvider theme={theme}>
<LocalizationProvider dateAdapter={AdapterLuxon}>
<ShepherdTour steps={steps} tourOptions={tourOptions}>
<BackendProvider>
<ConfirmProvider
defaultOptions={{
confirmationButtonProps: { autoFocus: true },
}}
{/* <ShepherdTour steps={steps} tourOptions={tourOptions}> */}
<BackendProvider>
<ConfirmProvider
defaultOptions={{
confirmationButtonProps: { autoFocus: true },
}}
>
<SnackbarProvider
ref={notistackRef}
maxSnack={3}
hideIconVariant
action={key => (
<IconButton onClick={onClickDismiss(key)}>
<Close />
</IconButton>
)}
>
<SnackbarProvider
ref={notistackRef}
maxSnack={3}
hideIconVariant
action={key => (
<IconButton onClick={onClickDismiss(key)}>
<Close />
</IconButton>
)}
>
<BrowserRouter>
<PosthogProvider />
<Routes />
</BrowserRouter>
</SnackbarProvider>
</ConfirmProvider>
</BackendProvider>
</ShepherdTour>
<BrowserRouter>
<PosthogProvider />
<Routes />
</BrowserRouter>
</SnackbarProvider>
</ConfirmProvider>
</BackendProvider>
{/* </ShepherdTour> */}
</LocalizationProvider>
</ThemeProvider>
</HelmetProvider>
Expand Down
23 changes: 21 additions & 2 deletions grai-frontend/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* istanbul ignore file */
import { ApolloClient, from, InMemoryCache } from "@apollo/client"
import { ApolloClient, from, InMemoryCache, TypePolicies } from "@apollo/client"
import { onError } from "@apollo/client/link/error"
import DebounceLink from "apollo-link-debounce"
import { createUploadLink } from "apollo-upload-client"
Expand All @@ -12,7 +12,26 @@ declare global {

const DEFAULT_DEBOUNCE_TIMEOUT = 100

export const cache = new InMemoryCache()
export const typePolicies: TypePolicies = {
Query: {
fields: {
workspace: {
merge: true,
},
},
},
Workspace: {
fields: {
runs: {
merge: true,
},
},
},
}

export const cache = new InMemoryCache({
typePolicies,
})

export const baseURL =
window._env_?.REACT_APP_SERVER_URL ??
Expand Down
3 changes: 3 additions & 0 deletions grai-frontend/src/components/PosthogProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react"
import hubspot from "hubspot"
import posthog from "posthog-js"
import { useLocation } from "react-router-dom"

Expand All @@ -7,6 +8,8 @@ const PosthogProvider: React.FC = () => {

React.useEffect(() => {
posthog.capture("$pageview")
hubspot.push(["setPath", location.pathname + location.search])
hubspot.push(["trackPageView"])
}, [location])

return null
Expand Down
2 changes: 2 additions & 0 deletions grai-frontend/src/components/auth/login/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from "react"
import { gql, useMutation } from "@apollo/client"
import { LoadingButton } from "@mui/lab"
import { Box, InputLabel, Link, TextField, styled } from "@mui/material"
import hubspot from "hubspot"
import posthog from "posthog"
import { Link as RouterLink } from "react-router-dom"
import Form from "components/form/Form"
Expand Down Expand Up @@ -62,6 +63,7 @@ const LoginForm: React.FC<LoginFormProps> = ({ onDeviceRequest }) => {

if (res.__typename === "User") {
posthog.identify(res.id, { email: res.username })
hubspot.push(["identify", { email: res.username }])
setLoggedIn(true)
return
}
Expand Down
2 changes: 2 additions & 0 deletions grai-frontend/src/components/auth/login/TokenForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
TextField,
Typography,
} from "@mui/material"
import hubspot from "hubspot"
import posthog from "posthog"
import Form from "components/form/Form"
import GraphError from "components/utils/GraphError"
Expand Down Expand Up @@ -83,6 +84,7 @@ const TokenForm: React.FC<TokenFormProps> = ({
if (!res) return

posthog.identify(res.id, { email: res.username })
hubspot.push(["identify", { email: res.username }])
setLoggedIn(true)
})
.catch(() => {})
Expand Down
7 changes: 6 additions & 1 deletion grai-frontend/src/components/auth/register/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useState } from "react"
import { gql, useMutation } from "@apollo/client"
import { LoadingButton } from "@mui/lab"
import { InputLabel, TextField, styled } from "@mui/material"
import hubspot from "hubspot"
import posthog from "posthog"
import Form from "components/form/Form"
import GraphError from "components/utils/GraphError"
Expand Down Expand Up @@ -49,7 +50,11 @@ const RegisterForm: React.FC = () => {
const handleSubmit = async () =>
register({ variables: values })
.then(data => data.data?.register)
.then(user => user && posthog.identify(user.id, { email: user.username }))
.then(user => {
if (!user) return
posthog.identify(user.id, { email: user.username })
hubspot.push(["identify", { email: user.username }])
})
.then(() => setLoggedIn(true))
.catch(() => {})

Expand Down
Loading

0 comments on commit 1a436d2

Please sign in to comment.