From 9393464e317735657a6170a2e87ee8b8673defb7 Mon Sep 17 00:00:00 2001 From: junghyeonsu Date: Tue, 31 Oct 2023 17:16:46 +0900 Subject: [PATCH] chore: june-so-client-react --- ...-react-npm-0.0.1-94c8fd6a71-af9ed338e6.zip | Bin 0 -> 7064 bytes ...-types-npm-0.0.1-554faf9c0f-d6ff8e5bfc.zip | Bin 0 -> 1484 bytes figma-plugin/package.json | 1 + figma-plugin/ui-src/contexts/JuneContext.tsx | 98 ------------------ figma-plugin/ui-src/main.tsx | 2 +- figma-plugin/ui-src/pages/App.tsx | 2 +- figma-plugin/ui-src/pages/Deploy.tsx | 2 +- yarn.lock | 19 ++++ 8 files changed, 23 insertions(+), 101 deletions(-) create mode 100644 .yarn/cache/june-so-client-react-npm-0.0.1-94c8fd6a71-af9ed338e6.zip create mode 100644 .yarn/cache/june-so-client-types-npm-0.0.1-554faf9c0f-d6ff8e5bfc.zip delete mode 100644 figma-plugin/ui-src/contexts/JuneContext.tsx diff --git a/.yarn/cache/june-so-client-react-npm-0.0.1-94c8fd6a71-af9ed338e6.zip b/.yarn/cache/june-so-client-react-npm-0.0.1-94c8fd6a71-af9ed338e6.zip new file mode 100644 index 0000000000000000000000000000000000000000..d8acbe3775dfd8ed7f90aef1776f96c4f23dad76 GIT binary patch literal 7064 zcmbVR1z40@yB&t1Q(#1-QDSHWDM=BAZV`~~uAy{LT1vVbq*FkoB&54UYDhskB&4J+ z91o9I@45fw+;^V&X3z6{d%f@M*?aA^*QY3h3?c$thDh-U`d^K|FE|&UHnv8_y4JQv zPFBV+HpTz-R+>L=wQ#aAW`WtV7+RSd+c>f~80#B4{)hhb*XnO%4!Z&Y0?_}e7mP{w zWEBVic%lFRY}W@dw=ptyWwn64SCtE$;Kr|8dNN?87Y1Oed_p1{W(8ZW2p|rIYl1Y2 zxdN-0A{qJ0iaLILBj->X#X(FuY>Dn}FV@9FcUgf!x2!zf>Ucc&p2N-oC??_n?=XW_ zGN$x0TpKT2YQ0nk9@r+~?B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-*|r;}X!hWF-;awa3YWKX<6h9OE^R|B}Qm!J?6MW;^34TeItNJft z{(LZWsZ6e7L)86R@IQ6R<&6C2k}pa2Dl$EruZ?-7TdwN8nvj3WlV8}31lJjkKg7zP l@PF|*%7umk0B|l|0T))((ap)N`Fala(-S~X1ZQhaem(FXF&l0Ugys1o;c&F z`$=Ep#vh6s^*%Qa$Rm(JE$Z3u z9tDMk8C)>FV9c^{iYSwi_atMHImSYtFF8)y#nqh0%cC*}ghMt;o8RrMXq@1q zI^|5uNtfs&yJtUg(tLFO+u7s_`Myq9#R-ePTvL=ex+_tCj!_IR!@P-G8rKND*s{*S z`N$fxW!oC(hR%sRsWCS{-qhPC_{k)3o2%zFqzuAq9F9LS?|;q3#d}2j*136)qfB0@ zzf9xNdu<(G>}+q#{^#Pdq~^MpRp$SfU$aIHbMt8N=Nv$vT?b;~!n`0cIXf{u6&&}W z6YTSW{ySQ3*ZQ<^=~2cddXbs!=VAj@ljToNJ+iIFOv$O{`!D|`2h#R_uP*;y6K{B| zSEg}$&wp2D=}pq63NtovPG)}ee&&uQ^(|`7(Hli~ugX$*da?E9%0)d3x7W#C|0*2e zyfKPd%OE7I_P@+3GcTP)6RA9>ZiD9elKJ0;a7BKNW%BkI<*7`I zgw8ZXF-fhP|3Jaih^sM<`-=YQjraLCivLy(o0~4PqG3VR>ApXwt6xW_>6~U$X6HK3 z@$1CRsaP%CDF#HQqh9l=+bhFX(9m4D`U|J;{5QtoeZZdkB eN0^+!M2yMEIUvBBl?|ky4G4b$-L;1q!~+0{;PcD? literal 0 HcmV?d00001 diff --git a/figma-plugin/package.json b/figma-plugin/package.json index af94c02..c36aabc 100644 --- a/figma-plugin/package.json +++ b/figma-plugin/package.json @@ -22,6 +22,7 @@ "@vitejs/plugin-react-refresh": "^1.3.6", "axios": "^1.6.0", "framer-motion": "^10.12.11", + "june-so-client-react": "^0.0.1", "react": "^18.2.0", "react-dom": "^18.2.0", "ts-dedent": "^2.2.0", diff --git a/figma-plugin/ui-src/contexts/JuneContext.tsx b/figma-plugin/ui-src/contexts/JuneContext.tsx deleted file mode 100644 index b9ca69e..0000000 --- a/figma-plugin/ui-src/contexts/JuneContext.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import React from "react"; - -interface JuneContextType { - identify: (props: IdentifyProps) => Promise; - track: (props: TrackProps) => Promise; -} - -interface JuneProviderProps { - writeKey: string; - children: React.ReactNode; - - disabled?: boolean; -} - -interface TrackProps { - event: string; - timestamp?: Date; - userId?: string; - anonymousId?: string; - properties?: Record; - context?: Record; -} - -interface IdentifyProps { - userId?: string; - anonymousId?: string; - traits?: Record; - timestamp?: Date; - context?: Record; -} - -const BASE_URL = "https://api.june.so/sdk"; - -const JuneContext = React.createContext({ - identify: async () => {}, - track: async () => {}, -}); - -export const JuneProvider: React.FC = ({ - children, - writeKey, - disabled = false, -}) => { - if (!writeKey) { - throw new Error("[useJune] writeKey is required"); - } - - const headers = { - Authorization: `Basic ${writeKey}`, - "Content-Type": "application/json", - }; - - const track = async (props: TrackProps) => { - if (disabled) return; - - try { - await fetch(`${BASE_URL}/track`, { - method: "POST", - headers, - body: JSON.stringify({ - ...props, - }), - }); - } catch (error) { - console.error(error); - } - }; - - const identify = async (props: IdentifyProps) => { - if (!props.userId || disabled) return; - - try { - await fetch(`${BASE_URL}/identify`, { - method: "POST", - headers, - body: JSON.stringify({ - ...props, - }), - }); - } catch (error) { - console.error(error); - } - }; - - return ( - - {children} - - ); -}; - -export const useJune = () => { - const context = React.useContext(JuneContext); - if (!context) { - throw new Error("[useJune] must be used within a JuneProvider"); - } - return context; -}; diff --git a/figma-plugin/ui-src/main.tsx b/figma-plugin/ui-src/main.tsx index 484c306..792d1cf 100644 --- a/figma-plugin/ui-src/main.tsx +++ b/figma-plugin/ui-src/main.tsx @@ -2,11 +2,11 @@ import "./styles/global.css"; import { ChakraProvider } from "@chakra-ui/react"; +import { JuneProvider } from "june-so-client-react"; import * as React from "react"; import { createRoot } from "react-dom/client"; import { AppProvider } from "./contexts/AppContext"; -import { JuneProvider } from "./contexts/JuneContext"; import App from "./pages/App"; const root = createRoot(document.getElementById("root")!); diff --git a/figma-plugin/ui-src/pages/App.tsx b/figma-plugin/ui-src/pages/App.tsx index 030cc2c..919ec01 100644 --- a/figma-plugin/ui-src/pages/App.tsx +++ b/figma-plugin/ui-src/pages/App.tsx @@ -1,8 +1,8 @@ import { Box, Tab, TabList, TabPanel, TabPanels, Tabs } from "@chakra-ui/react"; +import { useJune } from "june-so-client-react"; import * as React from "react"; import { useAppState } from "../contexts/AppContext"; -import { useJune } from "../contexts/JuneContext"; import * as styles from "./App.css"; import Deploy from "./Deploy"; import Setting from "./Setting"; diff --git a/figma-plugin/ui-src/pages/Deploy.tsx b/figma-plugin/ui-src/pages/Deploy.tsx index 4740239..288ca31 100644 --- a/figma-plugin/ui-src/pages/Deploy.tsx +++ b/figma-plugin/ui-src/pages/Deploy.tsx @@ -1,9 +1,9 @@ import { Box, Button, Spinner, Text, Tooltip } from "@chakra-ui/react"; +import { useJune } from "june-so-client-react"; import * as React from "react"; import { ACTION, DATA, STATUS } from "../../common/constants"; import { useAppDispatch, useAppState } from "../contexts/AppContext"; -import { useJune } from "../contexts/JuneContext"; import * as styles from "./Deploy.css"; const Deploy = () => { diff --git a/yarn.lock b/yarn.lock index be46f4f..16a02b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3622,6 +3622,7 @@ __metadata: axios: ^1.6.0 esbuild: ^0.17.19 framer-motion: ^10.12.11 + june-so-client-react: ^0.0.1 react: ^18.2.0 react-dom: ^18.2.0 ts-dedent: ^2.2.0 @@ -7952,6 +7953,24 @@ __metadata: languageName: node linkType: hard +"june-so-client-react@npm:^0.0.1": + version: 0.0.1 + resolution: "june-so-client-react@npm:0.0.1" + dependencies: + june-so-client-types: ^0.0.1 + peerDependencies: + react: ^17.0.0 || ^18.0.0 + checksum: af9ed338e65b450f9e15842cb7fe30f5e2783ddf099421b05fd4ce641bfccc14949f96c51ccc336a446e0a094ef2da61da5f3939c5896b251f8c0d44fcef7c8a + languageName: node + linkType: hard + +"june-so-client-types@npm:^0.0.1": + version: 0.0.1 + resolution: "june-so-client-types@npm:0.0.1" + checksum: d6ff8e5bfc4abeefa4b35fb15bb4ffa1819d072bebbaadc50a4851203ac954647ef2310924a3939d446d4e8e7c9781ad91a690ed65594925fcee01ea8b9fcd17 + languageName: node + linkType: hard + "kind-of@npm:^6.0.3": version: 6.0.3 resolution: "kind-of@npm:6.0.3"