-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51c7f3b
commit aacccf3
Showing
20 changed files
with
209 additions
and
8 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_JUNE_SO_WRITE_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
interface UseJuneProps { | ||
writeKey: string; | ||
devMode?: boolean; | ||
} | ||
|
||
interface IdentifyProps { | ||
userId?: string; | ||
email?: string; | ||
userName?: string; | ||
} | ||
|
||
const BASE_URL = "https://api.june.so/sdk"; | ||
|
||
export function useJune({ writeKey }: UseJuneProps) { | ||
if (!writeKey) { | ||
throw new Error("[useJune] writeKey is required"); | ||
} | ||
|
||
const headers = { | ||
Authorization: `Basic ${writeKey}`, | ||
"Content-Type": "application/json", | ||
}; | ||
|
||
const track = async (event: string) => { | ||
try { | ||
await fetch(`${BASE_URL}/track`, { | ||
method: "POST", | ||
headers, | ||
body: JSON.stringify({ | ||
event, | ||
}), | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
/** | ||
* 현재는 figma에서는 이메일을 받아올 수 있는 수단이 없음 | ||
*/ | ||
const identify = async ({ userName }: IdentifyProps) => { | ||
try { | ||
await fetch(`${BASE_URL}/identify`, { | ||
method: "POST", | ||
headers, | ||
body: JSON.stringify({ | ||
traits: { | ||
username: userName, | ||
}, | ||
}), | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
}; | ||
|
||
return { track, identify }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,8 @@ | ||
/// <reference types="vite/client" /> | ||
interface ImportMetaEnv { | ||
readonly VITE_JUNE_SO_WRITE_KEY: string; | ||
} | ||
|
||
interface ImportMeta { | ||
readonly env: ImportMetaEnv; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters