@daeryun/dr_components 1.2.78 → 1.2.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,8 +11,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  import React, { useEffect, useRef, useState } from 'react';
12
12
  import Image from 'next/image';
13
13
  import { useMutation } from '@tanstack/react-query';
14
- import { getCookie } from '../../../lib';
14
+ import { getCookie, setCookie } from '../../../lib';
15
15
  import ConfirmModal from './LoginComp/Modal/ConfirmModal';
16
+ import * as gtag from '../../../lib/gtag';
16
17
  const Box = ({ code, code_name, selected, selectedList, setSelectedList, activeTooltipId, setActiveTooltipId, tooltipTimeoutRef }) => {
17
18
  const [tooltipStyle, setTooltipStyle] = useState({});
18
19
  const buttonRef = useRef(null);
@@ -172,6 +173,28 @@ const StepOne = () => {
172
173
  { code: 'CT0029', code_name: '디지털포렌식' },
173
174
  { code: 'CT0030', code_name: '경호' }
174
175
  ];
176
+ const signUpGAEvent = (userId) => {
177
+ gtag.event({
178
+ action: 'sign_up_ga_event',
179
+ category: 'sign_up',
180
+ label: `회원가입 완료 - ${userId}`,
181
+ value: '1'
182
+ });
183
+ };
184
+ const appendUuidToRedirect = (redirect, uuid) => {
185
+ if (!uuid)
186
+ return redirect;
187
+ try {
188
+ const url = new URL(redirect, window.location.origin);
189
+ if (url.origin !== window.location.origin)
190
+ return redirect; // 외부 도메인 차단
191
+ url.searchParams.set('uuid', uuid);
192
+ return url.pathname + url.search;
193
+ }
194
+ catch (_a) {
195
+ return redirect;
196
+ }
197
+ };
175
198
  const modalHandleClose = () => {
176
199
  setIsModal(false);
177
200
  setModalObj({ title: '', subTitle: '' });
@@ -210,10 +233,17 @@ const StepOne = () => {
210
233
  user: yield userResponse.json()
211
234
  };
212
235
  }),
213
- onSuccess: () => {
236
+ onSuccess: (data) => {
237
+ var _a, _b;
238
+ console.log('data: ', data);
239
+ const redirect = decodeURIComponent(getCookie('redirect')) || '/';
240
+ const newRedirect = appendUuidToRedirect(redirect, (_a = data === null || data === void 0 ? void 0 : data.user) === null || _a === void 0 ? void 0 : _a.uuid);
241
+ setCookie({ key: 'redirect', value: newRedirect });
214
242
  setModalObj({ title: '회원가입이 완료되었습니다.', subTitle: '' });
215
243
  setIsModal(true);
216
244
  sessionStorage.removeItem('login');
245
+ // ga trigger
246
+ signUpGAEvent((_b = data === null || data === void 0 ? void 0 : data.user) === null || _b === void 0 ? void 0 : _b.uuid);
217
247
  },
218
248
  onError: error => {
219
249
  console.error('Skip API 호출 실패:', error);
@@ -3,8 +3,9 @@
3
3
  import React, { useEffect, useRef, useState } from 'react';
4
4
  import Image from 'next/image';
5
5
  import { useMutation } from '@tanstack/react-query';
6
- import { getCookie } from '../../../lib';
6
+ import { getCookie, setCookie } from '../../../lib';
7
7
  import ConfirmModal from './LoginComp/Modal/ConfirmModal';
8
+ import * as gtag from '../../../lib/gtag';
8
9
 
9
10
  const Box = ({
10
11
  code,
@@ -234,6 +235,27 @@ const StepOne = () => {
234
235
  { code: 'CT0030', code_name: '경호' }
235
236
  ];
236
237
 
238
+ const signUpGAEvent = (userId: string) => {
239
+ gtag.event({
240
+ action: 'sign_up_ga_event',
241
+ category: 'sign_up',
242
+ label: `회원가입 완료 - ${userId}`,
243
+ value: '1'
244
+ });
245
+ };
246
+
247
+ const appendUuidToRedirect = (redirect: string, uuid?: string) => {
248
+ if (!uuid) return redirect;
249
+ try {
250
+ const url = new URL(redirect, window.location.origin);
251
+ if (url.origin !== window.location.origin) return redirect; // 외부 도메인 차단
252
+ url.searchParams.set('uuid', uuid);
253
+ return url.pathname + url.search;
254
+ } catch {
255
+ return redirect;
256
+ }
257
+ };
258
+
237
259
  const modalHandleClose = () => {
238
260
  setIsModal(false);
239
261
  setModalObj({ title: '', subTitle: '' });
@@ -278,11 +300,18 @@ const StepOne = () => {
278
300
  user: await userResponse.json()
279
301
  };
280
302
  },
281
- onSuccess: () => {
303
+ onSuccess: (data) => {
304
+ console.log('data: ', data);
305
+ const redirect = decodeURIComponent(getCookie('redirect')) || '/';
306
+ const newRedirect = appendUuidToRedirect(redirect, data?.user?.uuid);
307
+ setCookie({ key: 'redirect', value: newRedirect });
282
308
  setModalObj({ title: '회원가입이 완료되었습니다.', subTitle: '' });
283
309
  setIsModal(true);
284
310
 
285
311
  sessionStorage.removeItem('login');
312
+
313
+ // ga trigger
314
+ signUpGAEvent(data?.user?.uuid);
286
315
  },
287
316
  onError: error => {
288
317
  console.error('Skip API 호출 실패:', error);
@@ -229,7 +229,7 @@ const StepTwo = () => {
229
229
  if (url.origin !== window.location.origin)
230
230
  return redirect; // 외부 도메인 차단
231
231
  url.searchParams.set('uuid', uuid);
232
- return url.pathname + url.search; // 해시 등 필요하면 추가
232
+ return url.pathname + url.search;
233
233
  }
234
234
  catch (_a) {
235
235
  return redirect;
@@ -286,7 +286,7 @@ const StepTwo = () => {
286
286
  const url = new URL(redirect, window.location.origin);
287
287
  if (url.origin !== window.location.origin) return redirect; // 외부 도메인 차단
288
288
  url.searchParams.set('uuid', uuid);
289
- return url.pathname + url.search; // 해시 등 필요하면 추가
289
+ return url.pathname + url.search;
290
290
  } catch {
291
291
  return redirect;
292
292
  }