MCPcopy Create free account
hub / github.com/dailydotdev/apps / useSlack

Function useSlack

packages/shared/src/hooks/integrations/slack/useSlack.ts:24–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22};
23
24export const useSlack = (): UseSlack => {
25 const { logEvent } = useLogContext();
26
27 const connect = useCallback<UseSlack['connect']>(({ redirectPath }) => {
28 // apiUrl is a relative proxy path on localhost, hence the base
29 const url = new URL(
30 `${apiUrl}/integrations/slack/auth/authorize`,
31 globalThis.location?.origin,
32 );
33 url.searchParams.set('redirectPath', redirectPath);
34
35 window.location.href = url.toString();
36 }, []);
37
38 const connectSource = useCallback<UseSlack['connectSource']>(
39 async ({ integrationId, channelId, sourceId }) => {
40 logEvent({
41 event_name: LogEvent.SetIntegration,
42 target_id: UserIntegrationType.Slack,
43 extra: JSON.stringify({
44 source: sourceId,
45 }),
46 });
47
48 await gqlClient.request(SLACK_CONNECT_SOURCE_MUTATION, {
49 integrationId,
50 channelId,
51 sourceId,
52 });
53 },
54 [logEvent],
55 );
56
57 return {
58 connect,
59 connectSource,
60 };
61};

Callers 6

NewSquadModalFunction · 0.90
useSlackIntegrationModalFunction · 0.90
useSlack.spec.tsFile · 0.90
useSlackConnectFunction · 0.90
AccountIntegrationsPageFunction · 0.90

Calls 2

useLogContextFunction · 0.90
logEventFunction · 0.85

Tested by

no test coverage detected