Skip to content

Commit

Permalink
feat: 로깅 적용되지 않은 필드들 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
pepperdad committed Nov 9, 2024
1 parent 00e5784 commit 0232b43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/components/eventLogger/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type UserProperties = {
job: string;
part: string[];
generation: number[];
coffeeChatStatus: string;
receivedCoffeeChatCount: number;
sentCoffeeChatCount: number;
};

type GotoCoffeechat = {
Expand Down
31 changes: 14 additions & 17 deletions src/components/eventLogger/providers/AmplitudeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC, ReactNode, useEffect, useState } from 'react';

import { useGetMemberOfMe } from '@/api/endpoint/members/getMemberOfMe';
import { getMemberProfileOfMe } from '@/api/endpoint_LEGACY/members';
import { useGetMemberProperty } from '@/api/endpoint/members/\bgetMemberProperty';
import { EventLoggerContext } from '@/components/eventLogger/context';
import { createConsoleLogController } from '@/components/eventLogger/controllers/consoleLog';

Expand All @@ -13,6 +13,7 @@ interface EventLoggerProviderProps {
const AmplitudeProvider: FC<EventLoggerProviderProps> = ({ children, apiKey }) => {
const [controller, setController] = useState(createConsoleLogController());
const { data } = useGetMemberOfMe();
const { data: property } = useGetMemberProperty();

useEffect(() => {
if (!apiKey) {
Expand All @@ -21,25 +22,21 @@ const AmplitudeProvider: FC<EventLoggerProviderProps> = ({ children, apiKey }) =
}
const initializeAmplitude = async () => {
try {
const profile = await getMemberProfileOfMe();
const { createAmplitudeController } = await import('@/components/eventLogger/controllers/amplitude');

const amplitudeController = createAmplitudeController(apiKey, data?.id ? `${data.id}` : undefined);

// user_properties 설정
if (data && profile) {
// user_properties 주입
if (data && property) {
amplitudeController.setUserProperties({
id: data.id,
major: profile.major,
job: profile.careers.length > 0 ? profile.careers[0].title : '',
organization:
profile.careers.length > 0
? profile.careers[0].companyName
: profile.university
? profile.university
: '',
generation: profile.soptActivities.map((activity) => activity.generation),
part: [...new Set(profile.soptActivities.map((activity) => activity.part))],
id: property.id,
job: property.job,
major: property.major,
organization: property.organization,
generation: property.generation,
part: property.part,
coffeeChatStatus: property.coffeeChatStatus,
receivedCoffeeChatCount: property.receivedCoffeeChatCount,
sentCoffeeChatCount: property.sentCoffeeChatCount,
});
}

Expand All @@ -50,7 +47,7 @@ const AmplitudeProvider: FC<EventLoggerProviderProps> = ({ children, apiKey }) =
};

initializeAmplitude();
}, [apiKey, data]);
}, [apiKey, data, property]);

return <EventLoggerContext.Provider value={controller}>{children}</EventLoggerContext.Provider>;
};
Expand Down

0 comments on commit 0232b43

Please sign in to comment.