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