@adstage/web-sdk 1.1.0 → 1.3.1
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/README.md +39 -47
- package/dist/index.cjs.js +181 -352
- package/dist/index.d.ts +38 -153
- package/dist/index.esm.js +174 -342
- package/dist/index.standalone.js +174 -385
- package/package.json +6 -2
- package/src/index.ts +22 -2
- package/src/managers/event-tracker.ts +48 -0
- package/src/utils/sdk-standalone.ts +175 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import require$$0, { createContext, useState, useEffect, useContext, useRef, useMemo, Component, useCallback } from 'react';
|
|
2
|
-
|
|
3
1
|
// 광고 타입 정의
|
|
4
2
|
var AdType;
|
|
5
3
|
(function (AdType) {
|
|
@@ -1544,6 +1542,46 @@ class EventTracker {
|
|
|
1544
1542
|
}
|
|
1545
1543
|
return 0; // 기본값
|
|
1546
1544
|
}
|
|
1545
|
+
/**
|
|
1546
|
+
* 커스텀 이벤트 추적
|
|
1547
|
+
*/
|
|
1548
|
+
async trackCustomEvent(eventName, params) {
|
|
1549
|
+
try {
|
|
1550
|
+
// 디바이스 정보 수집
|
|
1551
|
+
const deviceInfo = DeviceInfoCollector.collectDeviceInfo();
|
|
1552
|
+
// 커스텀 이벤트 데이터 구성
|
|
1553
|
+
const eventData = {
|
|
1554
|
+
eventName,
|
|
1555
|
+
params: params || {},
|
|
1556
|
+
// 기본 메타데이터
|
|
1557
|
+
userAgent: deviceInfo.userAgent,
|
|
1558
|
+
platform: deviceInfo.platform,
|
|
1559
|
+
screenWidth: deviceInfo.screenWidth,
|
|
1560
|
+
screenHeight: deviceInfo.screenHeight,
|
|
1561
|
+
deviceId: deviceInfo.deviceId,
|
|
1562
|
+
sessionId: deviceInfo.sessionId,
|
|
1563
|
+
timestamp: new Date().toISOString(),
|
|
1564
|
+
// SDK 정보
|
|
1565
|
+
sdkVersion: '1.3.1',
|
|
1566
|
+
eventTimestamp: Date.now(),
|
|
1567
|
+
};
|
|
1568
|
+
// 커스텀 이벤트 API 엔드포인트로 전송
|
|
1569
|
+
await fetch(`${this.baseUrl}/events/custom`, {
|
|
1570
|
+
method: 'POST',
|
|
1571
|
+
headers: {
|
|
1572
|
+
'x-api-key': this.apiKey,
|
|
1573
|
+
'Content-Type': 'application/json',
|
|
1574
|
+
},
|
|
1575
|
+
body: JSON.stringify(eventData),
|
|
1576
|
+
});
|
|
1577
|
+
if (this.debug) {
|
|
1578
|
+
console.log(`📊 커스텀 이벤트 추적: ${eventName}`, eventData);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
catch (error) {
|
|
1582
|
+
console.error('커스텀 이벤트 추적 실패:', error);
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1547
1585
|
}
|
|
1548
1586
|
|
|
1549
1587
|
/**
|
|
@@ -1662,357 +1700,135 @@ class SDKUtils {
|
|
|
1662
1700
|
}
|
|
1663
1701
|
}
|
|
1664
1702
|
|
|
1665
|
-
var jsxRuntime = {exports: {}};
|
|
1666
|
-
|
|
1667
|
-
var reactJsxRuntime_production_min = {};
|
|
1668
|
-
|
|
1669
1703
|
/**
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1672
|
-
*
|
|
1673
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
1674
|
-
*
|
|
1675
|
-
* This source code is licensed under the MIT license found in the
|
|
1676
|
-
* LICENSE file in the root directory of this source tree.
|
|
1704
|
+
* AdStage SDK Standalone API
|
|
1705
|
+
* 간단하고 직관적인 사용을 위한 통합 API
|
|
1677
1706
|
*/
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
function requireReactJsxRuntime_production_min () {
|
|
1682
|
-
if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
|
|
1683
|
-
hasRequiredReactJsxRuntime_production_min = 1;
|
|
1684
|
-
var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:!0,ref:!0,__self:!0,__source:!0};
|
|
1685
|
-
function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a)void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
|
|
1686
|
-
return reactJsxRuntime_production_min;
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
{
|
|
1690
|
-
jsxRuntime.exports = requireReactJsxRuntime_production_min();
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
1694
|
-
|
|
1695
|
-
const AdStageContext = createContext({
|
|
1696
|
-
sdk: null,
|
|
1697
|
-
isLoading: true,
|
|
1698
|
-
error: null,
|
|
1699
|
-
isInitialized: false,
|
|
1700
|
-
});
|
|
1701
|
-
const AdStageProvider = ({ config, children, autoInit = true, }) => {
|
|
1702
|
-
const [sdk, setSdk] = useState(null);
|
|
1703
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
1704
|
-
const [error, setError] = useState(null);
|
|
1705
|
-
const [isInitialized, setIsInitialized] = useState(false);
|
|
1706
|
-
useEffect(() => {
|
|
1707
|
-
const initializeSDK = async () => {
|
|
1708
|
-
try {
|
|
1709
|
-
setIsLoading(true);
|
|
1710
|
-
setError(null);
|
|
1711
|
-
// Dynamic import를 사용해서 circular dependency 방지
|
|
1712
|
-
const { AdStageSDK } = await Promise.resolve().then(function () { return index; });
|
|
1713
|
-
// SDK 인스턴스 생성
|
|
1714
|
-
const sdkInstance = AdStageSDK.init(config);
|
|
1715
|
-
setSdk(sdkInstance);
|
|
1716
|
-
setIsInitialized(true);
|
|
1717
|
-
setIsLoading(false);
|
|
1718
|
-
}
|
|
1719
|
-
catch (err) {
|
|
1720
|
-
const errorMessage = err instanceof Error ? err.message : 'SDK 초기화 중 오류가 발생했습니다.';
|
|
1721
|
-
setError(errorMessage);
|
|
1722
|
-
setIsLoading(false);
|
|
1723
|
-
console.error('AdStage SDK initialization failed:', err);
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
initializeSDK();
|
|
1727
|
-
}, [config.apiKey, config.debug, autoInit]);
|
|
1728
|
-
const value = {
|
|
1729
|
-
sdk,
|
|
1730
|
-
isLoading,
|
|
1731
|
-
error,
|
|
1732
|
-
isInitialized,
|
|
1733
|
-
};
|
|
1734
|
-
return (jsxRuntimeExports.jsx(AdStageContext.Provider, { value: value, children: children }));
|
|
1735
|
-
};
|
|
1736
|
-
|
|
1707
|
+
let globalSDKInstance = null;
|
|
1708
|
+
let isInitializing = false;
|
|
1737
1709
|
/**
|
|
1738
|
-
*
|
|
1739
|
-
* AdStageProvider 내부에서만 사용 가능
|
|
1710
|
+
* SDK 초기화 (한 번만 호출)
|
|
1740
1711
|
*/
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1712
|
+
async function initAdStage(config) {
|
|
1713
|
+
if (globalSDKInstance) {
|
|
1714
|
+
console.warn('AdStage SDK가 이미 초기화되었습니다.');
|
|
1715
|
+
return;
|
|
1716
|
+
}
|
|
1717
|
+
if (isInitializing) {
|
|
1718
|
+
console.warn('AdStage SDK 초기화가 진행 중입니다.');
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
isInitializing = true;
|
|
1722
|
+
try {
|
|
1723
|
+
// 동적 import로 circular dependency 방지
|
|
1724
|
+
const { AdStageSDK } = await Promise.resolve().then(function () { return index; });
|
|
1725
|
+
globalSDKInstance = AdStageSDK.init({
|
|
1726
|
+
apiKey: config.apiKey,
|
|
1727
|
+
debug: config.debug || false
|
|
1728
|
+
});
|
|
1729
|
+
console.log('✅ AdStage SDK 초기화 완료');
|
|
1745
1730
|
}
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
const containerRef = useRef(null);
|
|
1755
|
-
const { sdk, isLoading, error } = useAdStage();
|
|
1756
|
-
const containerId = useMemo(() => `adstage-${slotId}`, [slotId]);
|
|
1757
|
-
useEffect(() => {
|
|
1758
|
-
if (!sdk || !containerRef.current || isLoading || error) {
|
|
1759
|
-
return;
|
|
1760
|
-
}
|
|
1761
|
-
// 컨테이너에 ID 설정
|
|
1762
|
-
containerRef.current.id = containerId;
|
|
1763
|
-
// 광고 슬롯 생성
|
|
1764
|
-
const createSlot = async () => {
|
|
1765
|
-
try {
|
|
1766
|
-
await sdk.createSlot(slotId, containerId, adType, {
|
|
1767
|
-
width,
|
|
1768
|
-
height,
|
|
1769
|
-
language,
|
|
1770
|
-
deviceType,
|
|
1771
|
-
country,
|
|
1772
|
-
autoSlideInterval,
|
|
1773
|
-
sliderEffect,
|
|
1774
|
-
});
|
|
1775
|
-
}
|
|
1776
|
-
catch (err) {
|
|
1777
|
-
console.error(`Failed to create ad slot ${slotId}:`, err);
|
|
1778
|
-
}
|
|
1779
|
-
};
|
|
1780
|
-
createSlot();
|
|
1781
|
-
// 클린업 함수
|
|
1782
|
-
return () => {
|
|
1783
|
-
// SDK에 removeSlot 메서드가 없으므로 DOM 정리만 수행
|
|
1784
|
-
if (containerRef.current) {
|
|
1785
|
-
containerRef.current.innerHTML = '';
|
|
1786
|
-
}
|
|
1787
|
-
};
|
|
1788
|
-
}, [
|
|
1789
|
-
sdk,
|
|
1790
|
-
slotId,
|
|
1791
|
-
containerId,
|
|
1792
|
-
adType,
|
|
1793
|
-
width,
|
|
1794
|
-
height,
|
|
1795
|
-
language,
|
|
1796
|
-
deviceType,
|
|
1797
|
-
country,
|
|
1798
|
-
autoSlideInterval,
|
|
1799
|
-
sliderEffect,
|
|
1800
|
-
isLoading,
|
|
1801
|
-
error,
|
|
1802
|
-
]);
|
|
1803
|
-
const containerStyle = {
|
|
1804
|
-
width: typeof width === 'number' ? `${width}px` : width,
|
|
1805
|
-
height: typeof height === 'number' ? `${height}px` : height,
|
|
1806
|
-
...style,
|
|
1807
|
-
};
|
|
1808
|
-
// 로딩 상태 표시
|
|
1809
|
-
if (isLoading) {
|
|
1810
|
-
return (jsxRuntimeExports.jsx("div", { className: className, style: {
|
|
1811
|
-
...containerStyle,
|
|
1812
|
-
display: 'flex',
|
|
1813
|
-
alignItems: 'center',
|
|
1814
|
-
justifyContent: 'center',
|
|
1815
|
-
backgroundColor: '#f5f5f5',
|
|
1816
|
-
border: '1px dashed #ccc',
|
|
1817
|
-
color: '#999',
|
|
1818
|
-
}, children: "Loading Ad..." }));
|
|
1819
|
-
}
|
|
1820
|
-
// 에러 상태 표시
|
|
1821
|
-
if (error) {
|
|
1822
|
-
return (jsxRuntimeExports.jsx("div", { className: className, style: {
|
|
1823
|
-
...containerStyle,
|
|
1824
|
-
display: 'flex',
|
|
1825
|
-
alignItems: 'center',
|
|
1826
|
-
justifyContent: 'center',
|
|
1827
|
-
backgroundColor: '#fee',
|
|
1828
|
-
border: '1px solid #fcc',
|
|
1829
|
-
color: '#c00',
|
|
1830
|
-
}, children: "Ad Load Error" }));
|
|
1831
|
-
}
|
|
1832
|
-
return (jsxRuntimeExports.jsx("div", { ref: containerRef, className: className, style: containerStyle }));
|
|
1833
|
-
};
|
|
1834
|
-
|
|
1731
|
+
catch (error) {
|
|
1732
|
+
console.error('❌ AdStage SDK 초기화 실패:', error);
|
|
1733
|
+
throw error;
|
|
1734
|
+
}
|
|
1735
|
+
finally {
|
|
1736
|
+
isInitializing = false;
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1835
1739
|
/**
|
|
1836
|
-
* 배너 광고
|
|
1837
|
-
* AdSlot의 래퍼로 adType이 BANNER로 고정됨
|
|
1740
|
+
* 배너 광고 생성 (가장 간단한 API)
|
|
1838
1741
|
*/
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1742
|
+
async function createBanner(containerId, options) {
|
|
1743
|
+
if (!globalSDKInstance) {
|
|
1744
|
+
throw new Error('AdStage SDK가 초기화되지 않았습니다. initAdStage()를 먼저 호출하세요.');
|
|
1745
|
+
}
|
|
1746
|
+
const slotId = `banner-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1747
|
+
return globalSDKInstance.createSlot(slotId, containerId, 'BANNER', {
|
|
1748
|
+
width: options?.width || '100%',
|
|
1749
|
+
height: options?.height || 120,
|
|
1750
|
+
autoSlideInterval: options?.autoSlide ? (options.slideInterval || 5) : 0,
|
|
1751
|
+
sliderEffect: 'fade'
|
|
1752
|
+
});
|
|
1753
|
+
}
|
|
1843
1754
|
/**
|
|
1844
|
-
* 텍스트 광고
|
|
1845
|
-
* AdSlot의 래퍼로 adType이 TEXT로 고정됨
|
|
1755
|
+
* 텍스트 광고 생성
|
|
1846
1756
|
*/
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1757
|
+
async function createTextAd(containerId, options) {
|
|
1758
|
+
if (!globalSDKInstance) {
|
|
1759
|
+
throw new Error('AdStage SDK가 초기화되지 않았습니다.');
|
|
1760
|
+
}
|
|
1761
|
+
const slotId = `text-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1762
|
+
return globalSDKInstance.createSlot(slotId, containerId, 'TEXT', {
|
|
1763
|
+
maxLines: options?.maxLines || 3,
|
|
1764
|
+
style: options?.style || 'card'
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1851
1767
|
/**
|
|
1852
|
-
*
|
|
1853
|
-
* AdSlot의 래퍼로 adType이 NATIVE로 고정됨
|
|
1768
|
+
* 비디오 광고 생성
|
|
1854
1769
|
*/
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1770
|
+
async function createVideoAd(containerId, options) {
|
|
1771
|
+
if (!globalSDKInstance) {
|
|
1772
|
+
throw new Error('AdStage SDK가 초기화되지 않았습니다.');
|
|
1773
|
+
}
|
|
1774
|
+
const slotId = `video-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
1775
|
+
return globalSDKInstance.createSlot(slotId, containerId, 'VIDEO', {
|
|
1776
|
+
width: options?.width || '100%',
|
|
1777
|
+
height: options?.height || 300,
|
|
1778
|
+
autoplay: options?.autoplay || false,
|
|
1779
|
+
muted: options?.muted || true
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1859
1782
|
/**
|
|
1860
|
-
*
|
|
1861
|
-
* AdSlot의 래퍼로 adType이 VIDEO로 고정됨
|
|
1783
|
+
* 커스텀 이벤트 추적
|
|
1862
1784
|
*/
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1785
|
+
function trackEvent(eventName, params) {
|
|
1786
|
+
if (!globalSDKInstance) {
|
|
1787
|
+
console.warn('AdStage SDK가 초기화되지 않았습니다. 이벤트 추적을 건너뜁니다.');
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
try {
|
|
1791
|
+
globalSDKInstance.trackCustomEvent(eventName, {
|
|
1792
|
+
timestamp: new Date().toISOString(),
|
|
1793
|
+
...params
|
|
1794
|
+
});
|
|
1795
|
+
console.log(`📊 이벤트 추적: ${eventName}`, params);
|
|
1796
|
+
}
|
|
1797
|
+
catch (error) {
|
|
1798
|
+
console.error('이벤트 추적 실패:', error);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1867
1801
|
/**
|
|
1868
|
-
*
|
|
1869
|
-
* AdSlot의 래퍼로 adType이 INTERSTITIAL로 고정됨
|
|
1802
|
+
* SDK 상태 확인
|
|
1870
1803
|
*/
|
|
1871
|
-
|
|
1872
|
-
return
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1804
|
+
function isAdStageReady() {
|
|
1805
|
+
return globalSDKInstance !== null && !isInitializing;
|
|
1806
|
+
}
|
|
1875
1807
|
/**
|
|
1876
|
-
*
|
|
1877
|
-
* 광고 로딩 실패 시 fallback UI를 표시하고 앱 전체가 크래시되는 것을 방지
|
|
1808
|
+
* SDK 인스턴스 가져오기 (고급 사용자용)
|
|
1878
1809
|
*/
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
}
|
|
1884
|
-
static getDerivedStateFromError(error) {
|
|
1885
|
-
return { hasError: true, error };
|
|
1886
|
-
}
|
|
1887
|
-
componentDidCatch(error, errorInfo) {
|
|
1888
|
-
console.error('AdStage Error Boundary caught an error:', error, errorInfo);
|
|
1889
|
-
// 사용자 정의 에러 핸들러 호출
|
|
1890
|
-
if (this.props.onError) {
|
|
1891
|
-
this.props.onError(error, errorInfo);
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
render() {
|
|
1895
|
-
if (this.state.hasError) {
|
|
1896
|
-
// 사용자 정의 fallback이 있으면 사용, 없으면 기본 fallback 표시
|
|
1897
|
-
if (this.props.fallback) {
|
|
1898
|
-
return this.props.fallback;
|
|
1899
|
-
}
|
|
1900
|
-
return (jsxRuntimeExports.jsxs("div", { style: {
|
|
1901
|
-
padding: '20px',
|
|
1902
|
-
textAlign: 'center',
|
|
1903
|
-
backgroundColor: '#fee',
|
|
1904
|
-
border: '1px solid #fcc',
|
|
1905
|
-
borderRadius: '4px',
|
|
1906
|
-
color: '#c00',
|
|
1907
|
-
}, children: [jsxRuntimeExports.jsx("h3", { children: "\uAD11\uACE0 \uB85C\uB529 \uC624\uB958" }), jsxRuntimeExports.jsx("p", { children: "\uAD11\uACE0\uB97C \uBD88\uB7EC\uC624\uB294 \uC911 \uBB38\uC81C\uAC00 \uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4." }), jsxRuntimeExports.jsx("button", { onClick: () => this.setState({ hasError: false, error: null }), style: {
|
|
1908
|
-
padding: '8px 16px',
|
|
1909
|
-
backgroundColor: '#fff',
|
|
1910
|
-
border: '1px solid #ccc',
|
|
1911
|
-
borderRadius: '4px',
|
|
1912
|
-
cursor: 'pointer',
|
|
1913
|
-
}, children: "\uB2E4\uC2DC \uC2DC\uB3C4" })] }));
|
|
1914
|
-
}
|
|
1915
|
-
return this.props.children;
|
|
1810
|
+
function getAdStageInstance() {
|
|
1811
|
+
if (!globalSDKInstance) {
|
|
1812
|
+
console.warn('AdStage SDK가 초기화되지 않았습니다.');
|
|
1813
|
+
return null;
|
|
1916
1814
|
}
|
|
1815
|
+
return globalSDKInstance;
|
|
1917
1816
|
}
|
|
1918
|
-
|
|
1919
1817
|
/**
|
|
1920
|
-
*
|
|
1921
|
-
* 컴포넌트에서 직접 슬롯을 제어하고 싶을 때 사용
|
|
1818
|
+
* SDK 초기화 해제 (필요시)
|
|
1922
1819
|
*/
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
1926
|
-
const [error, setError] = useState(null);
|
|
1927
|
-
const [isCreated, setIsCreated] = useState(false);
|
|
1928
|
-
const createSlot = async () => {
|
|
1929
|
-
if (!sdk) {
|
|
1930
|
-
setError('SDK not initialized');
|
|
1931
|
-
return;
|
|
1932
|
-
}
|
|
1933
|
-
setIsLoading(true);
|
|
1934
|
-
setError(null);
|
|
1820
|
+
function destroyAdStage() {
|
|
1821
|
+
if (globalSDKInstance) {
|
|
1935
1822
|
try {
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
language: options.language,
|
|
1940
|
-
deviceType: options.deviceType,
|
|
1941
|
-
country: options.country,
|
|
1942
|
-
autoSlideInterval: options.autoSlideInterval,
|
|
1943
|
-
sliderEffect: options.sliderEffect,
|
|
1944
|
-
});
|
|
1945
|
-
setIsCreated(true);
|
|
1946
|
-
}
|
|
1947
|
-
catch (err) {
|
|
1948
|
-
const errorMessage = err instanceof Error ? err.message : '슬롯 생성 중 오류가 발생했습니다.';
|
|
1949
|
-
setError(errorMessage);
|
|
1950
|
-
setIsCreated(false);
|
|
1951
|
-
}
|
|
1952
|
-
finally {
|
|
1953
|
-
setIsLoading(false);
|
|
1954
|
-
}
|
|
1955
|
-
};
|
|
1956
|
-
const resetSlot = () => {
|
|
1957
|
-
setIsLoading(false);
|
|
1958
|
-
setError(null);
|
|
1959
|
-
setIsCreated(false);
|
|
1960
|
-
};
|
|
1961
|
-
// SDK가 변경되면 상태 초기화
|
|
1962
|
-
useEffect(() => {
|
|
1963
|
-
resetSlot();
|
|
1964
|
-
}, [sdk]);
|
|
1965
|
-
return {
|
|
1966
|
-
isLoading,
|
|
1967
|
-
error,
|
|
1968
|
-
isCreated,
|
|
1969
|
-
createSlot,
|
|
1970
|
-
resetSlot,
|
|
1971
|
-
};
|
|
1972
|
-
};
|
|
1973
|
-
|
|
1974
|
-
/**
|
|
1975
|
-
* 광고 이벤트 추적을 위한 Hook
|
|
1976
|
-
* 커스텀 이벤트 추적이 필요할 때 사용
|
|
1977
|
-
*/
|
|
1978
|
-
const useAdTracking = () => {
|
|
1979
|
-
const { sdk } = useAdStage();
|
|
1980
|
-
const trackEvent = useCallback((adId, slotId, eventType) => {
|
|
1981
|
-
if (!sdk) {
|
|
1982
|
-
console.warn('SDK not initialized - cannot track event');
|
|
1983
|
-
return;
|
|
1823
|
+
// SDK cleanup logic here
|
|
1824
|
+
globalSDKInstance = null;
|
|
1825
|
+
console.log('🧹 AdStage SDK 정리 완료');
|
|
1984
1826
|
}
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
// sdk.trackEvent(adId, slotId, eventType);
|
|
1991
|
-
}
|
|
1992
|
-
catch (err) {
|
|
1993
|
-
console.error('Failed to track event:', err);
|
|
1994
|
-
}
|
|
1995
|
-
}, [sdk]);
|
|
1996
|
-
const trackClick = useCallback((adId, slotId) => {
|
|
1997
|
-
trackEvent(adId, slotId, AdEventType.CLICK);
|
|
1998
|
-
}, [trackEvent]);
|
|
1999
|
-
const trackImpression = useCallback((adId, slotId) => {
|
|
2000
|
-
trackEvent(adId, slotId, AdEventType.IMPRESSION);
|
|
2001
|
-
}, [trackEvent]);
|
|
2002
|
-
const trackView = useCallback((adId, slotId) => {
|
|
2003
|
-
trackEvent(adId, slotId, AdEventType.VIEWABLE);
|
|
2004
|
-
}, [trackEvent]);
|
|
2005
|
-
const trackClose = useCallback((adId, slotId) => {
|
|
2006
|
-
trackEvent(adId, slotId, AdEventType.COMPLETED);
|
|
2007
|
-
}, [trackEvent]);
|
|
2008
|
-
return {
|
|
2009
|
-
trackEvent,
|
|
2010
|
-
trackClick,
|
|
2011
|
-
trackImpression,
|
|
2012
|
-
trackView,
|
|
2013
|
-
trackClose,
|
|
2014
|
-
};
|
|
2015
|
-
};
|
|
1827
|
+
catch (error) {
|
|
1828
|
+
console.error('SDK 정리 중 오류:', error);
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
2016
1832
|
|
|
2017
1833
|
/**
|
|
2018
1834
|
* AdStage SDK 메인 클래스
|
|
@@ -2240,6 +2056,23 @@ class AdStageSDK {
|
|
|
2240
2056
|
getAllSlots() {
|
|
2241
2057
|
return new Map(this.slots);
|
|
2242
2058
|
}
|
|
2059
|
+
/**
|
|
2060
|
+
* 커스텀 이벤트 추적
|
|
2061
|
+
*/
|
|
2062
|
+
trackCustomEvent(eventName, params) {
|
|
2063
|
+
try {
|
|
2064
|
+
this.eventTracker.trackCustomEvent(eventName, {
|
|
2065
|
+
timestamp: new Date().toISOString(),
|
|
2066
|
+
...params
|
|
2067
|
+
});
|
|
2068
|
+
if (this.config.debug) {
|
|
2069
|
+
console.log(`📊 커스텀 이벤트 추적: ${eventName}`, params);
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2072
|
+
catch (error) {
|
|
2073
|
+
console.error('커스텀 이벤트 추적 실패:', error);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2243
2076
|
}
|
|
2244
2077
|
AdStageSDK.instance = null;
|
|
2245
2078
|
async function autoInit() {
|
|
@@ -2265,24 +2098,23 @@ if (DOMUtils.isBrowser()) {
|
|
|
2265
2098
|
DOMUtils.waitForDOM().then(autoInit);
|
|
2266
2099
|
}
|
|
2267
2100
|
}
|
|
2101
|
+
// React exports (React가 있을 때만 사용 - 레거시)
|
|
2102
|
+
// export * from './react';
|
|
2268
2103
|
|
|
2269
2104
|
var index = /*#__PURE__*/Object.freeze({
|
|
2270
2105
|
__proto__: null,
|
|
2271
|
-
AdErrorBoundary: AdErrorBoundary,
|
|
2272
2106
|
get AdEventType () { return AdEventType; },
|
|
2273
|
-
AdSlot: AdSlot,
|
|
2274
|
-
AdStageProvider: AdStageProvider,
|
|
2275
2107
|
AdStageSDK: AdStageSDK,
|
|
2276
2108
|
get AdType () { return AdType; },
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
TextAd: TextAd,
|
|
2281
|
-
VideoAd: VideoAd,
|
|
2109
|
+
createBanner: createBanner,
|
|
2110
|
+
createTextAd: createTextAd,
|
|
2111
|
+
createVideoAd: createVideoAd,
|
|
2282
2112
|
default: AdStageSDK,
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2113
|
+
destroyAdStage: destroyAdStage,
|
|
2114
|
+
getAdStageInstance: getAdStageInstance,
|
|
2115
|
+
initAdStage: initAdStage,
|
|
2116
|
+
isAdStageReady: isAdStageReady,
|
|
2117
|
+
trackEvent: trackEvent
|
|
2286
2118
|
});
|
|
2287
2119
|
|
|
2288
|
-
export {
|
|
2120
|
+
export { AdEventType, AdStageSDK, AdType, createBanner, createTextAd, createVideoAd, AdStageSDK as default, destroyAdStage, getAdStageInstance, initAdStage, isAdStageReady, trackEvent };
|