sales-frontend-utils 0.0.43 → 0.0.44
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.
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/ga/index.cjs +32 -0
- package/dist/utils/ga/index.cjs.map +1 -0
- package/dist/utils/ga/index.d.cts +3 -0
- package/dist/utils/ga/index.d.ts +3 -0
- package/dist/utils/ga/index.js +30 -0
- package/dist/utils/ga/index.js.map +1 -0
- package/package.json +53 -43
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/utils/environment-utils.ts
|
|
4
|
+
var isClient = () => {
|
|
5
|
+
try {
|
|
6
|
+
return !!window;
|
|
7
|
+
} catch {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/utils/ga/ga.js
|
|
13
|
+
var ga_default = "(function (w, d, s, l, i) {\n w[l] = w[l] || [];\n w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });\n let f = d.getElementsByTagName(s)[0],\n j = d.createElement(s),\n dl = l !== 'dataLayer' ? `&l=${l}` : '';\n j.async = true;\n j.src = `https://www.googletagmanager.com/gtm.js?id=${i}${dl}`;\n f.parentNode.insertBefore(j, f);\n})(window, document, 'script', 'dataLayer', 'GTM-PPT3LJ56');\n";
|
|
14
|
+
|
|
15
|
+
// src/utils/ga/index.ts
|
|
16
|
+
var loadGaScript = () => {
|
|
17
|
+
if (isClient()) {
|
|
18
|
+
if (document.querySelector('script[src*="googletagmanager.com/gtm.js"]')) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
console.log("ga script load dynamic");
|
|
22
|
+
const script = document.createElement("script");
|
|
23
|
+
script.innerHTML = `
|
|
24
|
+
${ga_default}
|
|
25
|
+
`;
|
|
26
|
+
document.head.appendChild(script);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.loadGaScript = loadGaScript;
|
|
31
|
+
//# sourceMappingURL=index.cjs.map
|
|
32
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/environment-utils.ts","../../../src/utils/ga/ga.js","../../../src/utils/ga/index.ts"],"names":[],"mappings":";;;AA0DO,IAAM,WAAW,MAAM;AAC5B,EAAI,IAAA;AACF,IAAA,OAAO,CAAC,CAAC,MAAA;AAAA,GACH,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX,CAAA;;;AChEA,IAAA,UAAA,GAAA,uaAAA;;;ACIO,IAAM,eAAe,MAAM;AAC9B,EAAA,IAAI,UAAY,EAAA;AAEZ,IAAI,IAAA,QAAA,CAAS,aAAc,CAAA,4CAA4C,CAAG,EAAA;AACtE,MAAA;AAAA;AAEJ,IAAA,OAAA,CAAQ,IAAI,wBAAwB,CAAA;AACpC,IAAM,MAAA,MAAA,GAAS,QAAS,CAAA,aAAA,CAAc,QAAQ,CAAA;AAC9C,IAAA,MAAA,CAAO,SAAY,GAAA;AAAA,QAAA,EACjB,UAAQ;AAAA,QAAA,CAAA;AAEV,IAAS,QAAA,CAAA,IAAA,CAAK,YAAY,MAAM,CAAA;AAAA;AAGxC","file":"index.cjs","sourcesContent":["import { getCookie } from './cookie-utils';\n\n/**\n * 호스트명에서 서브도메인을 추출합니다.\n * @param hostname 호스트명\n * @returns 서브도메인 (예: nxl-dsp-dev)\n */\nexport const getSubdomain = (hostname: string): string => {\n if (!hostname || hostname === 'localhost' || hostname === '127.0.0.1') {\n return '';\n }\n\n const parts = hostname.split('.');\n\n // 최소 3개 부분이 있어야 서브도메인 존재 (subdomain.domain.com)\n if (parts.length < 3) {\n return '';\n }\n\n // 첫 번째 부분이 서브도메인\n return parts[0] ?? '';\n};\n\n/**\n * 호스트명을 기반으로 환경을 판단합니다.\n * @param hostname 호스트명\n * @returns 환경 구분 문자열 ('local' | 'dev' | 'stg' | 'prd')\n */\nexport const getEnvironmentFromHostname = (hostname: string): 'local' | 'dev' | 'stg' | 'prd' => {\n const debugModeEnv = getCookie('dsp-debug-mode-env')?.toLowerCase();\n if (debugModeEnv) {\n return debugModeEnv as 'local' | 'dev' | 'stg' | 'prd';\n }\n const subDomain = getSubdomain(hostname);\n\n // localhost 판단\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('localhost')) {\n return 'local';\n }\n\n // dev 환경 판단\n if (subDomain.includes(`dev`)) {\n return 'dev';\n }\n\n // stg 환경 판단\n if (subDomain.includes('stg')) {\n return 'stg';\n }\n\n // 기본 운영\n return 'prd';\n};\n\n/**\n * @see https://github.com/storybookjs/storybook/issues/32028#issuecomment-3298982086\n * @note 스토리북에서 버그로인해 window객체를 정상적으로 탐지하지 못하는 이슈우회\n */\nexport const isClient = () => {\n try {\n return !!window;\n } catch {\n return false;\n }\n};\n\n// window.isStorybookEnv 접근을 위한 타입캐스팅\ndeclare const window: Window & { isStorybookEnv?: boolean };\n/**\n * 현재 실행 환경이 Storybook인지 확인하는 함수\n *\n * 사용 전, `viteFinal` 설정에서 `window.isStorybookEnv`를 `true`로 정의해야 정상 동작합니다.\n *\n * 예시:\n * ```ts\n * const config: StorybookConfig = {\n * viteFinal: (config) => {\n * // window.isStorybookEnv를 true로 설정 (boolean 값으로 처리됨)\n * config.define = {\n * ...config.define,\n * 'window.isStorybookEnv': 'true',\n * };\n *\n * return config;\n * },\n * };\n * ```\n */\nexport const isStorybookEnv = () => {\n try {\n return window.isStorybookEnv === true;\n } catch {\n // window가 존재하지 않는 등 예외 상황에서는 false 반환\n return false;\n }\n};\n\n/**\n * 현재 업무구분 코드 구하기\n * 원칙: pathname의 첫 번째가 업무구분코드를 사용할 경우 해당 값을 반환\n * @returns\n */\nexport const getBusinessWorkDivisionCode = () => {\n return location.pathname.split('/')[1] ?? '';\n};\n\n/**\n * @description storybook에서 동작을 고려하여 수정한 버전\n * @returns\n */\nexport const getServicePath = () => {\n if (typeof window.isStorybookEnv === 'boolean') {\n return '';\n } else {\n return `/${getBusinessWorkDivisionCode()}`;\n }\n};\n\n/**\n * 환경에 맞는 API 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\n\nexport const getApiHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * 환경에 맞는 CDN 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\nexport const getCdnHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (!isClient()) {\n return '';\n }\n\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://dev-dsp-static.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://stg-dsp-static.hanwhalife.com`;\n\n case 'prd':\n return `https://dsp-static.hanwhalife.com'`;\n\n default:\n console.warn('DSP environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 비정형PI 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCode dea,dis,dcm\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDudApiBasePathFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/dud`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://dsp-dud-dev.hanwhalife.com:10101/api`;\n\n case 'stg':\n return `https://dsp-dud-stg.hanwhalife.com:10102/api`;\n\n case 'prd':\n return `https://dsp-dud.hanwhalife.com/api`;\n\n default:\n console.warn('DUD API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 Dsp 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCodeTo dea,dis 같은 api서버명\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDspApiBasePathFromEnvironment = (serviceCodeTo: string, hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/${serviceCodeTo}`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n\n/**\n * @description\n * 환경에 맞는 NLC 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getNlcHostFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n case 'local':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'dev':\n return `https://nxl-nlc-dev.hanwhalife.com`;\n\n case 'stg':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-nlc.hanwhalife.com`;\n\n default:\n console.warn('NLC environment is not defined');\n\n return '';\n }\n};\n\n","(function (w, d, s, l, i) {\n w[l] = w[l] || [];\n w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });\n let f = d.getElementsByTagName(s)[0],\n j = d.createElement(s),\n dl = l !== 'dataLayer' ? `&l=${l}` : '';\n j.async = true;\n j.src = `https://www.googletagmanager.com/gtm.js?id=${i}${dl}`;\n f.parentNode.insertBefore(j, f);\n})(window, document, 'script', 'dataLayer', 'GTM-PPT3LJ56');\n","import { isClient } from '../environment-utils.js';\n\nimport gaScript from './ga.js';\n\nexport const loadGaScript = () => {\n if (isClient()) {\n //이미 로드된 경우 return\n if (document.querySelector('script[src*=\"googletagmanager.com/gtm.js\"]')) {\n return;\n }\n console.log('ga script load dynamic');\n const script = document.createElement('script');\n script.innerHTML = `\n ${gaScript}\n `;\n document.head.appendChild(script);\n\n }\n}"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/utils/environment-utils.ts
|
|
2
|
+
var isClient = () => {
|
|
3
|
+
try {
|
|
4
|
+
return !!window;
|
|
5
|
+
} catch {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/utils/ga/ga.js
|
|
11
|
+
var ga_default = "(function (w, d, s, l, i) {\n w[l] = w[l] || [];\n w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });\n let f = d.getElementsByTagName(s)[0],\n j = d.createElement(s),\n dl = l !== 'dataLayer' ? `&l=${l}` : '';\n j.async = true;\n j.src = `https://www.googletagmanager.com/gtm.js?id=${i}${dl}`;\n f.parentNode.insertBefore(j, f);\n})(window, document, 'script', 'dataLayer', 'GTM-PPT3LJ56');\n";
|
|
12
|
+
|
|
13
|
+
// src/utils/ga/index.ts
|
|
14
|
+
var loadGaScript = () => {
|
|
15
|
+
if (isClient()) {
|
|
16
|
+
if (document.querySelector('script[src*="googletagmanager.com/gtm.js"]')) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
console.log("ga script load dynamic");
|
|
20
|
+
const script = document.createElement("script");
|
|
21
|
+
script.innerHTML = `
|
|
22
|
+
${ga_default}
|
|
23
|
+
`;
|
|
24
|
+
document.head.appendChild(script);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { loadGaScript };
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/utils/environment-utils.ts","../../../src/utils/ga/ga.js","../../../src/utils/ga/index.ts"],"names":[],"mappings":";AA0DO,IAAM,WAAW,MAAM;AAC5B,EAAI,IAAA;AACF,IAAA,OAAO,CAAC,CAAC,MAAA;AAAA,GACH,CAAA,MAAA;AACN,IAAO,OAAA,KAAA;AAAA;AAEX,CAAA;;;AChEA,IAAA,UAAA,GAAA,uaAAA;;;ACIO,IAAM,eAAe,MAAM;AAC9B,EAAA,IAAI,UAAY,EAAA;AAEZ,IAAI,IAAA,QAAA,CAAS,aAAc,CAAA,4CAA4C,CAAG,EAAA;AACtE,MAAA;AAAA;AAEJ,IAAA,OAAA,CAAQ,IAAI,wBAAwB,CAAA;AACpC,IAAM,MAAA,MAAA,GAAS,QAAS,CAAA,aAAA,CAAc,QAAQ,CAAA;AAC9C,IAAA,MAAA,CAAO,SAAY,GAAA;AAAA,QAAA,EACjB,UAAQ;AAAA,QAAA,CAAA;AAEV,IAAS,QAAA,CAAA,IAAA,CAAK,YAAY,MAAM,CAAA;AAAA;AAGxC","file":"index.js","sourcesContent":["import { getCookie } from './cookie-utils';\n\n/**\n * 호스트명에서 서브도메인을 추출합니다.\n * @param hostname 호스트명\n * @returns 서브도메인 (예: nxl-dsp-dev)\n */\nexport const getSubdomain = (hostname: string): string => {\n if (!hostname || hostname === 'localhost' || hostname === '127.0.0.1') {\n return '';\n }\n\n const parts = hostname.split('.');\n\n // 최소 3개 부분이 있어야 서브도메인 존재 (subdomain.domain.com)\n if (parts.length < 3) {\n return '';\n }\n\n // 첫 번째 부분이 서브도메인\n return parts[0] ?? '';\n};\n\n/**\n * 호스트명을 기반으로 환경을 판단합니다.\n * @param hostname 호스트명\n * @returns 환경 구분 문자열 ('local' | 'dev' | 'stg' | 'prd')\n */\nexport const getEnvironmentFromHostname = (hostname: string): 'local' | 'dev' | 'stg' | 'prd' => {\n const debugModeEnv = getCookie('dsp-debug-mode-env')?.toLowerCase();\n if (debugModeEnv) {\n return debugModeEnv as 'local' | 'dev' | 'stg' | 'prd';\n }\n const subDomain = getSubdomain(hostname);\n\n // localhost 판단\n if (hostname === 'localhost' || hostname === '127.0.0.1' || hostname.startsWith('localhost')) {\n return 'local';\n }\n\n // dev 환경 판단\n if (subDomain.includes(`dev`)) {\n return 'dev';\n }\n\n // stg 환경 판단\n if (subDomain.includes('stg')) {\n return 'stg';\n }\n\n // 기본 운영\n return 'prd';\n};\n\n/**\n * @see https://github.com/storybookjs/storybook/issues/32028#issuecomment-3298982086\n * @note 스토리북에서 버그로인해 window객체를 정상적으로 탐지하지 못하는 이슈우회\n */\nexport const isClient = () => {\n try {\n return !!window;\n } catch {\n return false;\n }\n};\n\n// window.isStorybookEnv 접근을 위한 타입캐스팅\ndeclare const window: Window & { isStorybookEnv?: boolean };\n/**\n * 현재 실행 환경이 Storybook인지 확인하는 함수\n *\n * 사용 전, `viteFinal` 설정에서 `window.isStorybookEnv`를 `true`로 정의해야 정상 동작합니다.\n *\n * 예시:\n * ```ts\n * const config: StorybookConfig = {\n * viteFinal: (config) => {\n * // window.isStorybookEnv를 true로 설정 (boolean 값으로 처리됨)\n * config.define = {\n * ...config.define,\n * 'window.isStorybookEnv': 'true',\n * };\n *\n * return config;\n * },\n * };\n * ```\n */\nexport const isStorybookEnv = () => {\n try {\n return window.isStorybookEnv === true;\n } catch {\n // window가 존재하지 않는 등 예외 상황에서는 false 반환\n return false;\n }\n};\n\n/**\n * 현재 업무구분 코드 구하기\n * 원칙: pathname의 첫 번째가 업무구분코드를 사용할 경우 해당 값을 반환\n * @returns\n */\nexport const getBusinessWorkDivisionCode = () => {\n return location.pathname.split('/')[1] ?? '';\n};\n\n/**\n * @description storybook에서 동작을 고려하여 수정한 버전\n * @returns\n */\nexport const getServicePath = () => {\n if (typeof window.isStorybookEnv === 'boolean') {\n return '';\n } else {\n return `/${getBusinessWorkDivisionCode()}`;\n }\n};\n\n/**\n * 환경에 맞는 API 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\n\nexport const getApiHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * 환경에 맞는 CDN 호스트명을 반환합니다.\n * 호스트명을 강제하고 싶으면 두 번째 파라미터로 넘기세요.\n * @param currentHostname\n * @param forceApiHostName\n * @returns\n */\nexport const getCdnHostNameFromEnvironment = (currentHostname: string, forceApiHostName?: string) => {\n if (!isClient()) {\n return '';\n }\n\n if (forceApiHostName) {\n return forceApiHostName;\n }\n\n const environment = getEnvironmentFromHostname(currentHostname);\n\n switch (environment) {\n case 'dev':\n return `https://dev-dsp-static.hanwhalife.com`;\n\n case 'local':\n case 'stg':\n return `https://stg-dsp-static.hanwhalife.com`;\n\n case 'prd':\n return `https://dsp-static.hanwhalife.com'`;\n\n default:\n console.warn('DSP environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 비정형PI 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCode dea,dis,dcm\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDudApiBasePathFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/dud`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://dsp-dud-dev.hanwhalife.com:10101/api`;\n\n case 'stg':\n return `https://dsp-dud-stg.hanwhalife.com:10102/api`;\n\n case 'prd':\n return `https://dsp-dud.hanwhalife.com/api`;\n\n default:\n console.warn('DUD API environment is not defined');\n\n return '';\n }\n};\n\n/**\n * @description\n * 환경에 맞는 Dsp 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param serviceCodeTo dea,dis 같은 api서버명\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getDspApiBasePathFromEnvironment = (serviceCodeTo: string, hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n /**\n * local에서 호출시, rewrite동작을 위해 상대주소를 호출합니다.\n * (cors이슈 해결을 위해 필수)\n */\n case 'local':\n return `${getServicePath()}/api/${serviceCodeTo}`;\n /**\n * local 이 아닌 환경에서는 전체주소를 호출합니다.\n */\n case 'dev':\n return `https://nxl-dsp-dev.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'stg':\n return `https://nxl-dsp-stg.hanwhalife.com/api/${serviceCodeTo}`;\n\n case 'prd':\n return `https://nxl-dsp.hanwhalife.com/api/${serviceCodeTo}`;\n\n default:\n console.warn('DSP API environment is not defined');\n\n return '';\n }\n};\n\n\n/**\n * @description\n * 환경에 맞는 NLC 호스트명을 반환합니다.\n * client side에서 사용하는 함수입니다.\n * @param hostname window.location.hostname\n * @returns\n */\nexport const getNlcHostFromEnvironment = (hostname?: string) => {\n if (!isClient()) {\n return '';\n }\n\n const environment = getEnvironmentFromHostname(hostname || location.hostname);\n\n switch (environment) {\n case 'local':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'dev':\n return `https://nxl-nlc-dev.hanwhalife.com`;\n\n case 'stg':\n return `https://nxl-nlc-stg.hanwhalife.com`;\n\n case 'prd':\n return `https://nxl-nlc.hanwhalife.com`;\n\n default:\n console.warn('NLC environment is not defined');\n\n return '';\n }\n};\n\n","(function (w, d, s, l, i) {\n w[l] = w[l] || [];\n w[l].push({ 'gtm.start': new Date().getTime(), event: 'gtm.js' });\n let f = d.getElementsByTagName(s)[0],\n j = d.createElement(s),\n dl = l !== 'dataLayer' ? `&l=${l}` : '';\n j.async = true;\n j.src = `https://www.googletagmanager.com/gtm.js?id=${i}${dl}`;\n f.parentNode.insertBefore(j, f);\n})(window, document, 'script', 'dataLayer', 'GTM-PPT3LJ56');\n","import { isClient } from '../environment-utils.js';\n\nimport gaScript from './ga.js';\n\nexport const loadGaScript = () => {\n if (isClient()) {\n //이미 로드된 경우 return\n if (document.querySelector('script[src*=\"googletagmanager.com/gtm.js\"]')) {\n return;\n }\n console.log('ga script load dynamic');\n const script = document.createElement('script');\n script.innerHTML = `\n ${gaScript}\n `;\n document.head.appendChild(script);\n\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sales-frontend-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,112 +21,122 @@
|
|
|
21
21
|
},
|
|
22
22
|
"./age": {
|
|
23
23
|
"import": {
|
|
24
|
-
"types": "./dist/utils/age-utils.d.cts",
|
|
25
|
-
"default": "./dist/utils/age-utils.cjs"
|
|
26
|
-
},
|
|
27
|
-
"require": {
|
|
28
24
|
"types": "./dist/utils/age-utils.d.ts",
|
|
29
25
|
"default": "./dist/utils/age-utils.js"
|
|
26
|
+
},
|
|
27
|
+
"require": {
|
|
28
|
+
"types": "./dist/utils/age-utils.d.cts",
|
|
29
|
+
"default": "./dist/utils/age-utils.cjs"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"./astx2": {
|
|
33
33
|
"import": {
|
|
34
|
-
"types": "./dist/utils/astx2-utils.d.cts",
|
|
35
|
-
"default": "./dist/utils/astx2-utils.cjs"
|
|
36
|
-
},
|
|
37
|
-
"require": {
|
|
38
34
|
"types": "./dist/utils/astx2-utils.d.ts",
|
|
39
35
|
"default": "./dist/utils/astx2-utils.js"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/utils/astx2-utils.d.cts",
|
|
39
|
+
"default": "./dist/utils/astx2-utils.cjs"
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"./canvas": {
|
|
43
43
|
"import": {
|
|
44
|
-
"types": "./dist/utils/canvas-utils.d.cts",
|
|
45
|
-
"default": "./dist/utils/canvas-utils.cjs"
|
|
46
|
-
},
|
|
47
|
-
"require": {
|
|
48
44
|
"types": "./dist/utils/canvas-utils.d.ts",
|
|
49
45
|
"default": "./dist/utils/canvas-utils.js"
|
|
46
|
+
},
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./dist/utils/canvas-utils.d.cts",
|
|
49
|
+
"default": "./dist/utils/canvas-utils.cjs"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
52
|
"./cookie": {
|
|
53
53
|
"import": {
|
|
54
|
-
"types": "./dist/utils/cookie-utils.d.cts",
|
|
55
|
-
"default": "./dist/utils/cookie-utils.cjs"
|
|
56
|
-
},
|
|
57
|
-
"require": {
|
|
58
54
|
"types": "./dist/utils/cookie-utils.d.ts",
|
|
59
55
|
"default": "./dist/utils/cookie-utils.js"
|
|
56
|
+
},
|
|
57
|
+
"require": {
|
|
58
|
+
"types": "./dist/utils/cookie-utils.d.cts",
|
|
59
|
+
"default": "./dist/utils/cookie-utils.cjs"
|
|
60
60
|
}
|
|
61
61
|
},
|
|
62
62
|
"./date": {
|
|
63
63
|
"import": {
|
|
64
|
-
"types": "./dist/utils/date-utils.d.cts",
|
|
65
|
-
"default": "./dist/utils/date-utils.cjs"
|
|
66
|
-
},
|
|
67
|
-
"require": {
|
|
68
64
|
"types": "./dist/utils/date-utils.d.ts",
|
|
69
65
|
"default": "./dist/utils/date-utils.js"
|
|
66
|
+
},
|
|
67
|
+
"require": {
|
|
68
|
+
"types": "./dist/utils/date-utils.d.cts",
|
|
69
|
+
"default": "./dist/utils/date-utils.cjs"
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"./environment": {
|
|
73
73
|
"import": {
|
|
74
|
-
"types": "./dist/utils/environment-utils.d.cts",
|
|
75
|
-
"default": "./dist/utils/environment-utils.cjs"
|
|
76
|
-
},
|
|
77
|
-
"require": {
|
|
78
74
|
"types": "./dist/utils/environment-utils.d.ts",
|
|
79
75
|
"default": "./dist/utils/environment-utils.js"
|
|
76
|
+
},
|
|
77
|
+
"require": {
|
|
78
|
+
"types": "./dist/utils/environment-utils.d.cts",
|
|
79
|
+
"default": "./dist/utils/environment-utils.cjs"
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"./event-handler": {
|
|
83
83
|
"import": {
|
|
84
|
-
"types": "./dist/utils/event-handler-utils.d.cts",
|
|
85
|
-
"default": "./dist/utils/event-handler-utils.cjs"
|
|
86
|
-
},
|
|
87
|
-
"require": {
|
|
88
84
|
"types": "./dist/utils/event-handler-utils.d.ts",
|
|
89
85
|
"default": "./dist/utils/event-handler-utils.js"
|
|
86
|
+
},
|
|
87
|
+
"require": {
|
|
88
|
+
"types": "./dist/utils/event-handler-utils.d.cts",
|
|
89
|
+
"default": "./dist/utils/event-handler-utils.cjs"
|
|
90
90
|
}
|
|
91
91
|
},
|
|
92
92
|
"./file": {
|
|
93
93
|
"import": {
|
|
94
|
-
"types": "./dist/utils/file-utils.d.cts",
|
|
95
|
-
"default": "./dist/utils/file-utils.cjs"
|
|
96
|
-
},
|
|
97
|
-
"require": {
|
|
98
94
|
"types": "./dist/utils/file-utils.d.ts",
|
|
99
95
|
"default": "./dist/utils/file-utils.js"
|
|
96
|
+
},
|
|
97
|
+
"require": {
|
|
98
|
+
"types": "./dist/utils/file-utils.d.cts",
|
|
99
|
+
"default": "./dist/utils/file-utils.cjs"
|
|
100
100
|
}
|
|
101
101
|
},
|
|
102
102
|
"./formatting": {
|
|
103
103
|
"import": {
|
|
104
|
-
"types": "./dist/utils/formatting-utils.d.cts",
|
|
105
|
-
"default": "./dist/utils/formatting-utils.cjs"
|
|
106
|
-
},
|
|
107
|
-
"require": {
|
|
108
104
|
"types": "./dist/utils/formatting-utils.d.ts",
|
|
109
105
|
"default": "./dist/utils/formatting-utils.js"
|
|
106
|
+
},
|
|
107
|
+
"require": {
|
|
108
|
+
"types": "./dist/utils/formatting-utils.d.cts",
|
|
109
|
+
"default": "./dist/utils/formatting-utils.cjs"
|
|
110
110
|
}
|
|
111
111
|
},
|
|
112
112
|
"./timing": {
|
|
113
113
|
"import": {
|
|
114
|
-
"types": "./dist/utils/timing-utils.d.cts",
|
|
115
|
-
"default": "./dist/utils/timing-utils.cjs"
|
|
116
|
-
},
|
|
117
|
-
"require": {
|
|
118
114
|
"types": "./dist/utils/timing-utils.d.ts",
|
|
119
115
|
"default": "./dist/utils/timing-utils.js"
|
|
116
|
+
},
|
|
117
|
+
"require": {
|
|
118
|
+
"types": "./dist/utils/timing-utils.d.cts",
|
|
119
|
+
"default": "./dist/utils/timing-utils.cjs"
|
|
120
120
|
}
|
|
121
121
|
},
|
|
122
122
|
"./user-agent": {
|
|
123
123
|
"import": {
|
|
124
|
+
"types": "./dist/utils/user-agent-utils.d.ts",
|
|
125
|
+
"default": "./dist/utils/user-agent-utils.js"
|
|
126
|
+
},
|
|
127
|
+
"require": {
|
|
124
128
|
"types": "./dist/utils/user-agent-utils.d.cts",
|
|
125
129
|
"default": "./dist/utils/user-agent-utils.cjs"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"./ga": {
|
|
133
|
+
"import": {
|
|
134
|
+
"types": "./dist/utils/ga/index.d.ts",
|
|
135
|
+
"default": "./dist/utils/ga/index.js"
|
|
126
136
|
},
|
|
127
137
|
"require": {
|
|
128
|
-
"types": "./dist/utils/
|
|
129
|
-
"default": "./dist/utils/
|
|
138
|
+
"types": "./dist/utils/ga/index.d.cts",
|
|
139
|
+
"default": "./dist/utils/ga/index.cjs"
|
|
130
140
|
}
|
|
131
141
|
}
|
|
132
142
|
},
|