Skip to content

Commit 3696d9c

Browse files
authoredFeb 13, 2025··
refactor: 스크립트가 아닌 npm 모듈로 채널톡 SDK 연동 (#74)
* feat: @channel.io/channel-web-sdk-loader 의존성 추가 * feat: ChannelTalk 스크립트 로드 기능 추가 * feat: Workflow에 채널톡 플러그인 키 환경 변수 추가
1 parent aafd6bf commit 3696d9c

File tree

6 files changed

+25
-7
lines changed

6 files changed

+25
-7
lines changed
 

‎.github/workflows/deploy.yml

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
env:
3131
VITE_API_URL: ${{ secrets.VITE_API_URL }}
3232
VITE_MIXPANEL_TOKEN: ${{ secrets.VITE_MIXPANEL_TOKEN }}
33+
VITE_CHANNEL_TALK_PLUGIN_KEY: ${{ secrets.VITE_CHANNEL_TALK_PLUGIN_KEY }}
3334

3435
- name: Configure AWS credentials
3536
uses: aws-actions/configure-aws-credentials@v4

‎index.html

-6
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@
4242
/>
4343
</head>
4444
<body>
45-
<script>
46-
(function(){var w=window;if(w.ChannelIO){return w.console.error("ChannelIO script included twice.");}var ch=function(){ch.c(arguments);};ch.q=[];ch.c=function(args){ch.q.push(args);};w.ChannelIO=ch;function l(){if(w.ChannelIOInitialized){return;}w.ChannelIOInitialized=true;var s=document.createElement("script");s.type="text/javascript";s.async=true;s.src="https://cdn.channel.io/plugin/ch-plugin-web.js";var x=document.getElementsByTagName("script")[0];if(x.parentNode){x.parentNode.insertBefore(s,x);}}if(document.readyState==="complete"){l();}else{w.addEventListener("DOMContentLoaded",l);w.addEventListener("load",l);}})();
47-
ChannelIO('boot', {
48-
"pluginKey": "00974094-3eae-441f-91e4-7f3404f44380"
49-
});
50-
</script>
5145
<div id="root"></div>
5246
<script type="module" src="/src/main.tsx"></script>
5347
</body>

‎package.json

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"prepare": "husky"
1212
},
1313
"dependencies": {
14+
"@channel.io/channel-web-sdk-loader": "^2.0.0",
1415
"@radix-ui/react-popover": "^1.1.5",
1516
"@radix-ui/react-toast": "^1.2.6",
1617
"@stackflow/core": "^1.1.1",

‎pnpm-lock.yaml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/App.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
import { useEffect } from 'react';
22
import { StudentMachineContext } from './machines/studentMachine';
33
import { Stack } from './stackflow';
4+
import { ChannelTalk } from './utils/channelTalk';
45
import { Mixpanel } from './utils/mixpanel';
56

67
const App = () => {
78
useEffect(() => {
8-
// MixPanel에 사용자 식별
9+
// MixPanel 사용자 식별
910
Mixpanel.identify();
11+
// ChannelTalk 채팅 초기화
12+
ChannelTalk.boot();
1013
}, []);
1114

1215
return (

‎src/utils/channelTalk.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as ChannelService from '@channel.io/channel-web-sdk-loader';
2+
3+
ChannelService.loadScript();
4+
5+
export const ChannelTalk = {
6+
boot: () => {
7+
ChannelService.boot({
8+
pluginKey: import.meta.env.VITE_CHANNEL_TALK_PLUGIN_KEY,
9+
});
10+
},
11+
};

0 commit comments

Comments
 (0)
Please sign in to comment.