@adstage/web-sdk 1.3.2 β 1.3.3
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.js +66 -7
- package/dist/index.esm.js +66 -7
- package/dist/index.standalone.js +66 -7
- package/package.json +1 -1
- package/src/index.ts +82 -15
package/dist/index.cjs.js
CHANGED
|
@@ -1852,29 +1852,53 @@ class AdStageSDK {
|
|
|
1852
1852
|
...(options?.deviceType && { deviceType: options.deviceType }),
|
|
1853
1853
|
...(options?.country && { country: options.country }),
|
|
1854
1854
|
});
|
|
1855
|
-
const
|
|
1855
|
+
const requestUrl = `${this.baseUrl}/advertisements/list?${queryParams}`;
|
|
1856
|
+
if (this.config.debug) {
|
|
1857
|
+
console.log(`π κ΄κ³ API μμ² μμ:`, {
|
|
1858
|
+
url: requestUrl,
|
|
1859
|
+
apiKey: this.config.apiKey.substring(0, 10) + '...',
|
|
1860
|
+
slot: slot.id
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
const response = await fetch(requestUrl, {
|
|
1856
1864
|
headers: {
|
|
1857
1865
|
'x-api-key': this.config.apiKey,
|
|
1858
1866
|
'Content-Type': 'application/json',
|
|
1859
1867
|
},
|
|
1860
1868
|
});
|
|
1869
|
+
if (this.config.debug) {
|
|
1870
|
+
console.log(`π‘ API μλ΅ μν:`, {
|
|
1871
|
+
status: response.status,
|
|
1872
|
+
statusText: response.statusText,
|
|
1873
|
+
ok: response.ok
|
|
1874
|
+
});
|
|
1875
|
+
}
|
|
1861
1876
|
if (!response.ok) {
|
|
1862
1877
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1863
1878
|
}
|
|
1864
1879
|
const data = await response.json();
|
|
1880
|
+
if (this.config.debug) {
|
|
1881
|
+
console.log(`π API μλ΅ λ°μ΄ν°:`, {
|
|
1882
|
+
data,
|
|
1883
|
+
advertisementsCount: data.advertisements ? data.advertisements.length : 0
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1865
1886
|
const advertisements = data.advertisements || [];
|
|
1866
1887
|
if (advertisements.length > 0) {
|
|
1888
|
+
if (this.config.debug) {
|
|
1889
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ°κ²¬:`, advertisements);
|
|
1890
|
+
}
|
|
1867
1891
|
// μ¬λ¬ κ΄κ³ κ° μμ κ²½μ° μ¬λΌμ΄λλ‘ λ λλ§
|
|
1868
1892
|
this.renderSlotWithSlider(slot, advertisements, options);
|
|
1869
1893
|
// 첫 λ²μ§Έ κ΄κ³ μ λν΄μλ§ λ
ΈμΆ μ΄λ²€νΈ μΆμ
|
|
1870
1894
|
await this.eventTracker.trackEvent(advertisements[0]._id, slot.id, exports.AdEventType.IMPRESSION);
|
|
1871
1895
|
}
|
|
1872
1896
|
else {
|
|
1873
|
-
console.warn(
|
|
1897
|
+
console.warn(`β οΈ μ¬λ‘― ${slot.id}μ μ¬μ© κ°λ₯ν κ΄κ³ κ° μμ΅λλ€. API μλ΅:`, data);
|
|
1874
1898
|
}
|
|
1875
1899
|
}
|
|
1876
1900
|
catch (error) {
|
|
1877
|
-
console.error(
|
|
1901
|
+
console.error(`β μ¬λ‘― ${slot.id} λ‘λ μ€ν¨:`, error);
|
|
1878
1902
|
}
|
|
1879
1903
|
}
|
|
1880
1904
|
/**
|
|
@@ -1882,8 +1906,18 @@ class AdStageSDK {
|
|
|
1882
1906
|
*/
|
|
1883
1907
|
renderSlotWithSlider(slot, advertisements, options) {
|
|
1884
1908
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
1885
|
-
if (!container)
|
|
1909
|
+
if (!container) {
|
|
1910
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
1886
1911
|
return;
|
|
1912
|
+
}
|
|
1913
|
+
if (this.config.debug) {
|
|
1914
|
+
console.log(`π¨ κ΄κ³ λ λλ§ μμ:`, {
|
|
1915
|
+
slotId: slot.id,
|
|
1916
|
+
containerId: slot.containerId,
|
|
1917
|
+
advertisementCount: advertisements.length,
|
|
1918
|
+
container: container
|
|
1919
|
+
});
|
|
1920
|
+
}
|
|
1887
1921
|
if (advertisements.length === 1) {
|
|
1888
1922
|
// κ΄κ³ κ° νλλΏμ΄λ©΄ κΈ°λ³Έ λ λλ§
|
|
1889
1923
|
this.renderSlot(slot, advertisements[0]);
|
|
@@ -1907,7 +1941,11 @@ class AdStageSDK {
|
|
|
1907
1941
|
slot.isLoaded = true;
|
|
1908
1942
|
if (this.config.debug) {
|
|
1909
1943
|
const sliderType = useFadeEffect ? 'fade slider' : 'slider';
|
|
1910
|
-
console.log(
|
|
1944
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ₯Ό ${sliderType}λ‘ λ λλ§ μλ£:`, {
|
|
1945
|
+
slotId: slot.id,
|
|
1946
|
+
container: container,
|
|
1947
|
+
sliderContainer: sliderContainer
|
|
1948
|
+
});
|
|
1911
1949
|
}
|
|
1912
1950
|
}
|
|
1913
1951
|
/**
|
|
@@ -1915,15 +1953,36 @@ class AdStageSDK {
|
|
|
1915
1953
|
*/
|
|
1916
1954
|
renderSlot(slot, ad) {
|
|
1917
1955
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
1918
|
-
if (!container)
|
|
1956
|
+
if (!container) {
|
|
1957
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
1919
1958
|
return;
|
|
1959
|
+
}
|
|
1960
|
+
if (this.config.debug) {
|
|
1961
|
+
console.log(`π¨ λ¨μΌ κ΄κ³ λ λλ§ μμ:`, {
|
|
1962
|
+
slotId: slot.id,
|
|
1963
|
+
containerId: slot.containerId,
|
|
1964
|
+
ad: ad,
|
|
1965
|
+
container: container
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1920
1968
|
// ν©ν 리λ₯Ό μ¬μ©ν΄μ μ μ ν λ λλ¬λ‘ κ΄κ³ μμ±
|
|
1921
1969
|
const adElement = AdRendererFactory.render(ad, slot, (adId, slotId, eventType) => this.eventTracker.trackEvent(adId, slotId, eventType));
|
|
1970
|
+
if (this.config.debug) {
|
|
1971
|
+
console.log(`π§ κ΄κ³ μμ μμ±λ¨:`, {
|
|
1972
|
+
adElement: adElement,
|
|
1973
|
+
tagName: adElement.tagName,
|
|
1974
|
+
innerHTML: adElement.innerHTML.substring(0, 200) + '...'
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1922
1977
|
container.innerHTML = '';
|
|
1923
1978
|
container.appendChild(adElement);
|
|
1924
1979
|
slot.isLoaded = true;
|
|
1925
1980
|
if (this.config.debug) {
|
|
1926
|
-
console.log(
|
|
1981
|
+
console.log(`β
λ¨μΌ κ΄κ³ λ λλ§ μλ£:`, {
|
|
1982
|
+
slotId: slot.id,
|
|
1983
|
+
ad: ad,
|
|
1984
|
+
containerContent: container.innerHTML.substring(0, 200) + '...'
|
|
1985
|
+
});
|
|
1927
1986
|
}
|
|
1928
1987
|
}
|
|
1929
1988
|
/**
|
package/dist/index.esm.js
CHANGED
|
@@ -1848,29 +1848,53 @@ class AdStageSDK {
|
|
|
1848
1848
|
...(options?.deviceType && { deviceType: options.deviceType }),
|
|
1849
1849
|
...(options?.country && { country: options.country }),
|
|
1850
1850
|
});
|
|
1851
|
-
const
|
|
1851
|
+
const requestUrl = `${this.baseUrl}/advertisements/list?${queryParams}`;
|
|
1852
|
+
if (this.config.debug) {
|
|
1853
|
+
console.log(`π κ΄κ³ API μμ² μμ:`, {
|
|
1854
|
+
url: requestUrl,
|
|
1855
|
+
apiKey: this.config.apiKey.substring(0, 10) + '...',
|
|
1856
|
+
slot: slot.id
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
const response = await fetch(requestUrl, {
|
|
1852
1860
|
headers: {
|
|
1853
1861
|
'x-api-key': this.config.apiKey,
|
|
1854
1862
|
'Content-Type': 'application/json',
|
|
1855
1863
|
},
|
|
1856
1864
|
});
|
|
1865
|
+
if (this.config.debug) {
|
|
1866
|
+
console.log(`π‘ API μλ΅ μν:`, {
|
|
1867
|
+
status: response.status,
|
|
1868
|
+
statusText: response.statusText,
|
|
1869
|
+
ok: response.ok
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1857
1872
|
if (!response.ok) {
|
|
1858
1873
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1859
1874
|
}
|
|
1860
1875
|
const data = await response.json();
|
|
1876
|
+
if (this.config.debug) {
|
|
1877
|
+
console.log(`π API μλ΅ λ°μ΄ν°:`, {
|
|
1878
|
+
data,
|
|
1879
|
+
advertisementsCount: data.advertisements ? data.advertisements.length : 0
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1861
1882
|
const advertisements = data.advertisements || [];
|
|
1862
1883
|
if (advertisements.length > 0) {
|
|
1884
|
+
if (this.config.debug) {
|
|
1885
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ°κ²¬:`, advertisements);
|
|
1886
|
+
}
|
|
1863
1887
|
// μ¬λ¬ κ΄κ³ κ° μμ κ²½μ° μ¬λΌμ΄λλ‘ λ λλ§
|
|
1864
1888
|
this.renderSlotWithSlider(slot, advertisements, options);
|
|
1865
1889
|
// 첫 λ²μ§Έ κ΄κ³ μ λν΄μλ§ λ
ΈμΆ μ΄λ²€νΈ μΆμ
|
|
1866
1890
|
await this.eventTracker.trackEvent(advertisements[0]._id, slot.id, AdEventType.IMPRESSION);
|
|
1867
1891
|
}
|
|
1868
1892
|
else {
|
|
1869
|
-
console.warn(
|
|
1893
|
+
console.warn(`β οΈ μ¬λ‘― ${slot.id}μ μ¬μ© κ°λ₯ν κ΄κ³ κ° μμ΅λλ€. API μλ΅:`, data);
|
|
1870
1894
|
}
|
|
1871
1895
|
}
|
|
1872
1896
|
catch (error) {
|
|
1873
|
-
console.error(
|
|
1897
|
+
console.error(`β μ¬λ‘― ${slot.id} λ‘λ μ€ν¨:`, error);
|
|
1874
1898
|
}
|
|
1875
1899
|
}
|
|
1876
1900
|
/**
|
|
@@ -1878,8 +1902,18 @@ class AdStageSDK {
|
|
|
1878
1902
|
*/
|
|
1879
1903
|
renderSlotWithSlider(slot, advertisements, options) {
|
|
1880
1904
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
1881
|
-
if (!container)
|
|
1905
|
+
if (!container) {
|
|
1906
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
1882
1907
|
return;
|
|
1908
|
+
}
|
|
1909
|
+
if (this.config.debug) {
|
|
1910
|
+
console.log(`π¨ κ΄κ³ λ λλ§ μμ:`, {
|
|
1911
|
+
slotId: slot.id,
|
|
1912
|
+
containerId: slot.containerId,
|
|
1913
|
+
advertisementCount: advertisements.length,
|
|
1914
|
+
container: container
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1883
1917
|
if (advertisements.length === 1) {
|
|
1884
1918
|
// κ΄κ³ κ° νλλΏμ΄λ©΄ κΈ°λ³Έ λ λλ§
|
|
1885
1919
|
this.renderSlot(slot, advertisements[0]);
|
|
@@ -1903,7 +1937,11 @@ class AdStageSDK {
|
|
|
1903
1937
|
slot.isLoaded = true;
|
|
1904
1938
|
if (this.config.debug) {
|
|
1905
1939
|
const sliderType = useFadeEffect ? 'fade slider' : 'slider';
|
|
1906
|
-
console.log(
|
|
1940
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ₯Ό ${sliderType}λ‘ λ λλ§ μλ£:`, {
|
|
1941
|
+
slotId: slot.id,
|
|
1942
|
+
container: container,
|
|
1943
|
+
sliderContainer: sliderContainer
|
|
1944
|
+
});
|
|
1907
1945
|
}
|
|
1908
1946
|
}
|
|
1909
1947
|
/**
|
|
@@ -1911,15 +1949,36 @@ class AdStageSDK {
|
|
|
1911
1949
|
*/
|
|
1912
1950
|
renderSlot(slot, ad) {
|
|
1913
1951
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
1914
|
-
if (!container)
|
|
1952
|
+
if (!container) {
|
|
1953
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
1915
1954
|
return;
|
|
1955
|
+
}
|
|
1956
|
+
if (this.config.debug) {
|
|
1957
|
+
console.log(`π¨ λ¨μΌ κ΄κ³ λ λλ§ μμ:`, {
|
|
1958
|
+
slotId: slot.id,
|
|
1959
|
+
containerId: slot.containerId,
|
|
1960
|
+
ad: ad,
|
|
1961
|
+
container: container
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1916
1964
|
// ν©ν 리λ₯Ό μ¬μ©ν΄μ μ μ ν λ λλ¬λ‘ κ΄κ³ μμ±
|
|
1917
1965
|
const adElement = AdRendererFactory.render(ad, slot, (adId, slotId, eventType) => this.eventTracker.trackEvent(adId, slotId, eventType));
|
|
1966
|
+
if (this.config.debug) {
|
|
1967
|
+
console.log(`π§ κ΄κ³ μμ μμ±λ¨:`, {
|
|
1968
|
+
adElement: adElement,
|
|
1969
|
+
tagName: adElement.tagName,
|
|
1970
|
+
innerHTML: adElement.innerHTML.substring(0, 200) + '...'
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1918
1973
|
container.innerHTML = '';
|
|
1919
1974
|
container.appendChild(adElement);
|
|
1920
1975
|
slot.isLoaded = true;
|
|
1921
1976
|
if (this.config.debug) {
|
|
1922
|
-
console.log(
|
|
1977
|
+
console.log(`β
λ¨μΌ κ΄κ³ λ λλ§ μλ£:`, {
|
|
1978
|
+
slotId: slot.id,
|
|
1979
|
+
ad: ad,
|
|
1980
|
+
containerContent: container.innerHTML.substring(0, 200) + '...'
|
|
1981
|
+
});
|
|
1923
1982
|
}
|
|
1924
1983
|
}
|
|
1925
1984
|
/**
|
package/dist/index.standalone.js
CHANGED
|
@@ -1848,29 +1848,53 @@ class AdStageSDK {
|
|
|
1848
1848
|
...(options?.deviceType && { deviceType: options.deviceType }),
|
|
1849
1849
|
...(options?.country && { country: options.country }),
|
|
1850
1850
|
});
|
|
1851
|
-
const
|
|
1851
|
+
const requestUrl = `${this.baseUrl}/advertisements/list?${queryParams}`;
|
|
1852
|
+
if (this.config.debug) {
|
|
1853
|
+
console.log(`π κ΄κ³ API μμ² μμ:`, {
|
|
1854
|
+
url: requestUrl,
|
|
1855
|
+
apiKey: this.config.apiKey.substring(0, 10) + '...',
|
|
1856
|
+
slot: slot.id
|
|
1857
|
+
});
|
|
1858
|
+
}
|
|
1859
|
+
const response = await fetch(requestUrl, {
|
|
1852
1860
|
headers: {
|
|
1853
1861
|
'x-api-key': this.config.apiKey,
|
|
1854
1862
|
'Content-Type': 'application/json',
|
|
1855
1863
|
},
|
|
1856
1864
|
});
|
|
1865
|
+
if (this.config.debug) {
|
|
1866
|
+
console.log(`π‘ API μλ΅ μν:`, {
|
|
1867
|
+
status: response.status,
|
|
1868
|
+
statusText: response.statusText,
|
|
1869
|
+
ok: response.ok
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1857
1872
|
if (!response.ok) {
|
|
1858
1873
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
1859
1874
|
}
|
|
1860
1875
|
const data = await response.json();
|
|
1876
|
+
if (this.config.debug) {
|
|
1877
|
+
console.log(`π API μλ΅ λ°μ΄ν°:`, {
|
|
1878
|
+
data,
|
|
1879
|
+
advertisementsCount: data.advertisements ? data.advertisements.length : 0
|
|
1880
|
+
});
|
|
1881
|
+
}
|
|
1861
1882
|
const advertisements = data.advertisements || [];
|
|
1862
1883
|
if (advertisements.length > 0) {
|
|
1884
|
+
if (this.config.debug) {
|
|
1885
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ°κ²¬:`, advertisements);
|
|
1886
|
+
}
|
|
1863
1887
|
// μ¬λ¬ κ΄κ³ κ° μμ κ²½μ° μ¬λΌμ΄λλ‘ λ λλ§
|
|
1864
1888
|
this.renderSlotWithSlider(slot, advertisements, options);
|
|
1865
1889
|
// 첫 λ²μ§Έ κ΄κ³ μ λν΄μλ§ λ
ΈμΆ μ΄λ²€νΈ μΆμ
|
|
1866
1890
|
await this.eventTracker.trackEvent(advertisements[0]._id, slot.id, AdEventType.IMPRESSION);
|
|
1867
1891
|
}
|
|
1868
1892
|
else {
|
|
1869
|
-
console.warn(
|
|
1893
|
+
console.warn(`β οΈ μ¬λ‘― ${slot.id}μ μ¬μ© κ°λ₯ν κ΄κ³ κ° μμ΅λλ€. API μλ΅:`, data);
|
|
1870
1894
|
}
|
|
1871
1895
|
}
|
|
1872
1896
|
catch (error) {
|
|
1873
|
-
console.error(
|
|
1897
|
+
console.error(`β μ¬λ‘― ${slot.id} λ‘λ μ€ν¨:`, error);
|
|
1874
1898
|
}
|
|
1875
1899
|
}
|
|
1876
1900
|
/**
|
|
@@ -1878,8 +1902,18 @@ class AdStageSDK {
|
|
|
1878
1902
|
*/
|
|
1879
1903
|
renderSlotWithSlider(slot, advertisements, options) {
|
|
1880
1904
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
1881
|
-
if (!container)
|
|
1905
|
+
if (!container) {
|
|
1906
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
1882
1907
|
return;
|
|
1908
|
+
}
|
|
1909
|
+
if (this.config.debug) {
|
|
1910
|
+
console.log(`π¨ κ΄κ³ λ λλ§ μμ:`, {
|
|
1911
|
+
slotId: slot.id,
|
|
1912
|
+
containerId: slot.containerId,
|
|
1913
|
+
advertisementCount: advertisements.length,
|
|
1914
|
+
container: container
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1883
1917
|
if (advertisements.length === 1) {
|
|
1884
1918
|
// κ΄κ³ κ° νλλΏμ΄λ©΄ κΈ°λ³Έ λ λλ§
|
|
1885
1919
|
this.renderSlot(slot, advertisements[0]);
|
|
@@ -1903,7 +1937,11 @@ class AdStageSDK {
|
|
|
1903
1937
|
slot.isLoaded = true;
|
|
1904
1938
|
if (this.config.debug) {
|
|
1905
1939
|
const sliderType = useFadeEffect ? 'fade slider' : 'slider';
|
|
1906
|
-
console.log(
|
|
1940
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ₯Ό ${sliderType}λ‘ λ λλ§ μλ£:`, {
|
|
1941
|
+
slotId: slot.id,
|
|
1942
|
+
container: container,
|
|
1943
|
+
sliderContainer: sliderContainer
|
|
1944
|
+
});
|
|
1907
1945
|
}
|
|
1908
1946
|
}
|
|
1909
1947
|
/**
|
|
@@ -1911,15 +1949,36 @@ class AdStageSDK {
|
|
|
1911
1949
|
*/
|
|
1912
1950
|
renderSlot(slot, ad) {
|
|
1913
1951
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
1914
|
-
if (!container)
|
|
1952
|
+
if (!container) {
|
|
1953
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
1915
1954
|
return;
|
|
1955
|
+
}
|
|
1956
|
+
if (this.config.debug) {
|
|
1957
|
+
console.log(`π¨ λ¨μΌ κ΄κ³ λ λλ§ μμ:`, {
|
|
1958
|
+
slotId: slot.id,
|
|
1959
|
+
containerId: slot.containerId,
|
|
1960
|
+
ad: ad,
|
|
1961
|
+
container: container
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1916
1964
|
// ν©ν 리λ₯Ό μ¬μ©ν΄μ μ μ ν λ λλ¬λ‘ κ΄κ³ μμ±
|
|
1917
1965
|
const adElement = AdRendererFactory.render(ad, slot, (adId, slotId, eventType) => this.eventTracker.trackEvent(adId, slotId, eventType));
|
|
1966
|
+
if (this.config.debug) {
|
|
1967
|
+
console.log(`π§ κ΄κ³ μμ μμ±λ¨:`, {
|
|
1968
|
+
adElement: adElement,
|
|
1969
|
+
tagName: adElement.tagName,
|
|
1970
|
+
innerHTML: adElement.innerHTML.substring(0, 200) + '...'
|
|
1971
|
+
});
|
|
1972
|
+
}
|
|
1918
1973
|
container.innerHTML = '';
|
|
1919
1974
|
container.appendChild(adElement);
|
|
1920
1975
|
slot.isLoaded = true;
|
|
1921
1976
|
if (this.config.debug) {
|
|
1922
|
-
console.log(
|
|
1977
|
+
console.log(`β
λ¨μΌ κ΄κ³ λ λλ§ μλ£:`, {
|
|
1978
|
+
slotId: slot.id,
|
|
1979
|
+
ad: ad,
|
|
1980
|
+
containerContent: container.innerHTML.substring(0, 200) + '...'
|
|
1981
|
+
});
|
|
1923
1982
|
}
|
|
1924
1983
|
}
|
|
1925
1984
|
/**
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -127,34 +127,61 @@ export class AdStageSDK {
|
|
|
127
127
|
...(options?.country && { country: options.country }),
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
130
|
+
const requestUrl = `${this.baseUrl}/advertisements/list?${queryParams}`;
|
|
131
|
+
|
|
132
|
+
if (this.config.debug) {
|
|
133
|
+
console.log(`π κ΄κ³ API μμ² μμ:`, {
|
|
134
|
+
url: requestUrl,
|
|
135
|
+
apiKey: this.config.apiKey.substring(0, 10) + '...',
|
|
136
|
+
slot: slot.id
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const response = await fetch(requestUrl, {
|
|
141
|
+
headers: {
|
|
142
|
+
'x-api-key': this.config.apiKey,
|
|
143
|
+
'Content-Type': 'application/json',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
if (this.config.debug) {
|
|
148
|
+
console.log(`π‘ API μλ΅ μν:`, {
|
|
149
|
+
status: response.status,
|
|
150
|
+
statusText: response.statusText,
|
|
151
|
+
ok: response.ok
|
|
152
|
+
});
|
|
153
|
+
}
|
|
139
154
|
|
|
140
155
|
if (!response.ok) {
|
|
141
156
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
142
157
|
}
|
|
143
158
|
|
|
144
159
|
const data = await response.json();
|
|
160
|
+
|
|
161
|
+
if (this.config.debug) {
|
|
162
|
+
console.log(`π API μλ΅ λ°μ΄ν°:`, {
|
|
163
|
+
data,
|
|
164
|
+
advertisementsCount: data.advertisements ? data.advertisements.length : 0
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
145
168
|
const advertisements = data.advertisements || [];
|
|
146
169
|
|
|
147
170
|
if (advertisements.length > 0) {
|
|
171
|
+
if (this.config.debug) {
|
|
172
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ°κ²¬:`, advertisements);
|
|
173
|
+
}
|
|
174
|
+
|
|
148
175
|
// μ¬λ¬ κ΄κ³ κ° μμ κ²½μ° μ¬λΌμ΄λλ‘ λ λλ§
|
|
149
176
|
this.renderSlotWithSlider(slot, advertisements, options);
|
|
150
177
|
|
|
151
178
|
// 첫 λ²μ§Έ κ΄κ³ μ λν΄μλ§ λ
ΈμΆ μ΄λ²€νΈ μΆμ
|
|
152
179
|
await this.eventTracker.trackEvent(advertisements[0]._id, slot.id, AdEventType.IMPRESSION);
|
|
153
180
|
} else {
|
|
154
|
-
console.warn(
|
|
181
|
+
console.warn(`β οΈ μ¬λ‘― ${slot.id}μ μ¬μ© κ°λ₯ν κ΄κ³ κ° μμ΅λλ€. API μλ΅:`, data);
|
|
155
182
|
}
|
|
156
183
|
} catch (error) {
|
|
157
|
-
console.error(
|
|
184
|
+
console.error(`β μ¬λ‘― ${slot.id} λ‘λ μ€ν¨:`, error);
|
|
158
185
|
}
|
|
159
186
|
}
|
|
160
187
|
|
|
@@ -163,7 +190,19 @@ export class AdStageSDK {
|
|
|
163
190
|
*/
|
|
164
191
|
private renderSlotWithSlider(slot: AdSlot, advertisements: Advertisement[], options?: any): void {
|
|
165
192
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
166
|
-
if (!container)
|
|
193
|
+
if (!container) {
|
|
194
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (this.config.debug) {
|
|
199
|
+
console.log(`π¨ κ΄κ³ λ λλ§ μμ:`, {
|
|
200
|
+
slotId: slot.id,
|
|
201
|
+
containerId: slot.containerId,
|
|
202
|
+
advertisementCount: advertisements.length,
|
|
203
|
+
container: container
|
|
204
|
+
});
|
|
205
|
+
}
|
|
167
206
|
|
|
168
207
|
if (advertisements.length === 1) {
|
|
169
208
|
// κ΄κ³ κ° νλλΏμ΄λ©΄ κΈ°λ³Έ λ λλ§
|
|
@@ -202,7 +241,11 @@ export class AdStageSDK {
|
|
|
202
241
|
|
|
203
242
|
if (this.config.debug) {
|
|
204
243
|
const sliderType = useFadeEffect ? 'fade slider' : 'slider';
|
|
205
|
-
console.log(
|
|
244
|
+
console.log(`β
${advertisements.length}κ° κ΄κ³ λ₯Ό ${sliderType}λ‘ λ λλ§ μλ£:`, {
|
|
245
|
+
slotId: slot.id,
|
|
246
|
+
container: container,
|
|
247
|
+
sliderContainer: sliderContainer
|
|
248
|
+
});
|
|
206
249
|
}
|
|
207
250
|
}
|
|
208
251
|
|
|
@@ -211,7 +254,19 @@ export class AdStageSDK {
|
|
|
211
254
|
*/
|
|
212
255
|
private renderSlot(slot: AdSlot, ad: Advertisement): void {
|
|
213
256
|
const container = DOMUtils.safeGetElementById(slot.containerId);
|
|
214
|
-
if (!container)
|
|
257
|
+
if (!container) {
|
|
258
|
+
console.error(`β 컨ν
μ΄λλ₯Ό μ°Ύμ μ μμ΅λλ€: ${slot.containerId}`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (this.config.debug) {
|
|
263
|
+
console.log(`π¨ λ¨μΌ κ΄κ³ λ λλ§ μμ:`, {
|
|
264
|
+
slotId: slot.id,
|
|
265
|
+
containerId: slot.containerId,
|
|
266
|
+
ad: ad,
|
|
267
|
+
container: container
|
|
268
|
+
});
|
|
269
|
+
}
|
|
215
270
|
|
|
216
271
|
// ν©ν 리λ₯Ό μ¬μ©ν΄μ μ μ ν λ λλ¬λ‘ κ΄κ³ μμ±
|
|
217
272
|
const adElement = AdRendererFactory.render(
|
|
@@ -220,12 +275,24 @@ export class AdStageSDK {
|
|
|
220
275
|
(adId, slotId, eventType) => this.eventTracker.trackEvent(adId, slotId, eventType)
|
|
221
276
|
);
|
|
222
277
|
|
|
278
|
+
if (this.config.debug) {
|
|
279
|
+
console.log(`π§ κ΄κ³ μμ μμ±λ¨:`, {
|
|
280
|
+
adElement: adElement,
|
|
281
|
+
tagName: adElement.tagName,
|
|
282
|
+
innerHTML: adElement.innerHTML.substring(0, 200) + '...'
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
223
286
|
container.innerHTML = '';
|
|
224
287
|
container.appendChild(adElement);
|
|
225
288
|
slot.isLoaded = true;
|
|
226
289
|
|
|
227
290
|
if (this.config.debug) {
|
|
228
|
-
console.log(
|
|
291
|
+
console.log(`β
λ¨μΌ κ΄κ³ λ λλ§ μλ£:`, {
|
|
292
|
+
slotId: slot.id,
|
|
293
|
+
ad: ad,
|
|
294
|
+
containerContent: container.innerHTML.substring(0, 200) + '...'
|
|
295
|
+
});
|
|
229
296
|
}
|
|
230
297
|
}
|
|
231
298
|
|