@surfside/ads-core-web 0.1.21 → 0.1.23
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 +15 -15
- package/lib/cjs/BuildInfo.js +1 -1
- package/lib/cjs/BuildInfo.js.map +1 -1
- package/lib/cjs/Init.js +92 -0
- package/lib/cjs/Init.js.map +1 -0
- package/lib/cjs/helpers/WebTelemetryCollector.js +56 -0
- package/lib/cjs/helpers/WebTelemetryCollector.js.map +1 -0
- package/lib/cjs/rendering/Banner.js +28 -28
- package/lib/cjs/rendering/Carousel.js +120 -120
- package/lib/cjs/rendering/ProductCard.js +19 -19
- package/lib/cjs/rendering/Video.js +121 -121
- package/lib/cjs/rendering/Watermark.js +32 -32
- package/lib/esm/BuildInfo.js +1 -1
- package/lib/esm/BuildInfo.js.map +1 -1
- package/lib/esm/Init.js +85 -0
- package/lib/esm/Init.js.map +1 -0
- package/lib/esm/helpers/WebTelemetryCollector.js +52 -0
- package/lib/esm/helpers/WebTelemetryCollector.js.map +1 -0
- package/lib/esm/rendering/Banner.js +28 -28
- package/lib/esm/rendering/Carousel.js +120 -120
- package/lib/esm/rendering/ProductCard.js +19 -19
- package/lib/esm/rendering/Video.js +121 -121
- package/lib/esm/rendering/Watermark.js +32 -32
- package/lib/types/Init.d.ts +24 -0
- package/lib/types/helpers/WebTelemetryCollector.d.ts +24 -0
- package/package.json +41 -41
|
@@ -173,127 +173,127 @@ const toggleMute = (logger, videoElement, e) => {
|
|
|
173
173
|
element.classList.remove('muted');
|
|
174
174
|
}
|
|
175
175
|
};
|
|
176
|
-
const template = `<div>
|
|
177
|
-
<video id="surf-video-container" autoplay muted></video>
|
|
178
|
-
|
|
179
|
-
<div class="timer">
|
|
180
|
-
<svg
|
|
181
|
-
width="36"
|
|
182
|
-
height="36"
|
|
183
|
-
viewBox="-2 2 36 36"
|
|
184
|
-
>
|
|
185
|
-
<circle
|
|
186
|
-
cx="16"
|
|
187
|
-
cy="16"
|
|
188
|
-
r="15"
|
|
189
|
-
stroke="#7b4af4"
|
|
190
|
-
stroke-width="4"
|
|
191
|
-
fill="none"
|
|
192
|
-
class="timer-circle"
|
|
193
|
-
/>
|
|
194
|
-
</svg>
|
|
195
|
-
<div class="timer-value"></div>
|
|
196
|
-
</div>
|
|
197
|
-
|
|
198
|
-
<div class="watermark"></div>
|
|
199
|
-
<div class="mute-button muted"></div>
|
|
176
|
+
const template = `<div>
|
|
177
|
+
<video id="surf-video-container" autoplay muted></video>
|
|
178
|
+
|
|
179
|
+
<div class="timer">
|
|
180
|
+
<svg
|
|
181
|
+
width="36"
|
|
182
|
+
height="36"
|
|
183
|
+
viewBox="-2 2 36 36"
|
|
184
|
+
>
|
|
185
|
+
<circle
|
|
186
|
+
cx="16"
|
|
187
|
+
cy="16"
|
|
188
|
+
r="15"
|
|
189
|
+
stroke="#7b4af4"
|
|
190
|
+
stroke-width="4"
|
|
191
|
+
fill="none"
|
|
192
|
+
class="timer-circle"
|
|
193
|
+
/>
|
|
194
|
+
</svg>
|
|
195
|
+
<div class="timer-value"></div>
|
|
196
|
+
</div>
|
|
197
|
+
|
|
198
|
+
<div class="watermark"></div>
|
|
199
|
+
<div class="mute-button muted"></div>
|
|
200
200
|
</div>`;
|
|
201
|
-
const style = `@keyframes grow-arc {
|
|
202
|
-
0% {
|
|
203
|
-
stroke-dasharray: 0 94; /* 0% of the circumference */
|
|
204
|
-
stroke-dashoffset: 0;
|
|
205
|
-
}
|
|
206
|
-
50% {
|
|
207
|
-
stroke-dasharray: 47 94; /* 90 degrees of the circle */
|
|
208
|
-
stroke-dashoffset: 0;
|
|
209
|
-
}
|
|
210
|
-
100% {
|
|
211
|
-
stroke-dasharray: 94 94; /* Full circle */
|
|
212
|
-
stroke-dashoffset: 0;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
.surfside-video {
|
|
218
|
-
--icon-muted: url('//cdn.surfside.io/icons/muted.svg');
|
|
219
|
-
--icon-unmuted: url('//cdn.surfside.io/icons/unmuted.svg');
|
|
220
|
-
|
|
221
|
-
position: relative;
|
|
222
|
-
overflow: hidden;
|
|
223
|
-
|
|
224
|
-
video {
|
|
225
|
-
width: 100%;
|
|
226
|
-
height: auto;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
.timer {
|
|
230
|
-
position: absolute;
|
|
231
|
-
left: 5px;
|
|
232
|
-
top: 5px;
|
|
233
|
-
width: 32px;
|
|
234
|
-
height: 32px;
|
|
235
|
-
|
|
236
|
-
.timer-value {
|
|
237
|
-
position: absolute;
|
|
238
|
-
top: 0px;
|
|
239
|
-
left: 0;
|
|
240
|
-
width: 36px;
|
|
241
|
-
height: 36px;
|
|
242
|
-
|
|
243
|
-
color: white;
|
|
244
|
-
|
|
245
|
-
font-family: Poppins, Arial;
|
|
246
|
-
text-align: center;
|
|
247
|
-
font-size: 12px;
|
|
248
|
-
line-height: 36px;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
.timer-circle {
|
|
252
|
-
fill: none;
|
|
253
|
-
stroke-width: 4;
|
|
254
|
-
animation-name: grow-arc;
|
|
255
|
-
animation-iteration-count: 1;
|
|
256
|
-
animation-timing-function: linear;
|
|
257
|
-
animation-fill-mode: forwards;
|
|
258
|
-
transform: rotate(-90deg);
|
|
259
|
-
transform-origin: 50% 50%;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.mute-button {
|
|
265
|
-
position: absolute;
|
|
266
|
-
width: 24px;
|
|
267
|
-
height: 24px;
|
|
268
|
-
right: 5px;
|
|
269
|
-
bottom: 5px;
|
|
270
|
-
cursor: pointer;
|
|
271
|
-
transition: transform 0.2s;
|
|
272
|
-
filter: drop-shadow(0 0 2px white) drop-shadow(0 0 4px white);
|
|
273
|
-
|
|
274
|
-
&:hover {
|
|
275
|
-
transform: scale(1.3);
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
&:active {
|
|
279
|
-
transform: scale(0.8);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
&.muted {
|
|
283
|
-
background-image: var(--icon-muted);
|
|
284
|
-
|
|
285
|
-
&:hover {
|
|
286
|
-
background-image: var(--icon-unmuted);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
&.unmuted {
|
|
291
|
-
background-image: var(--icon-unmuted);
|
|
292
|
-
|
|
293
|
-
&:hover {
|
|
294
|
-
background-image: var(--icon-muted);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
201
|
+
const style = `@keyframes grow-arc {
|
|
202
|
+
0% {
|
|
203
|
+
stroke-dasharray: 0 94; /* 0% of the circumference */
|
|
204
|
+
stroke-dashoffset: 0;
|
|
205
|
+
}
|
|
206
|
+
50% {
|
|
207
|
+
stroke-dasharray: 47 94; /* 90 degrees of the circle */
|
|
208
|
+
stroke-dashoffset: 0;
|
|
209
|
+
}
|
|
210
|
+
100% {
|
|
211
|
+
stroke-dasharray: 94 94; /* Full circle */
|
|
212
|
+
stroke-dashoffset: 0;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
.surfside-video {
|
|
218
|
+
--icon-muted: url('//cdn.surfside.io/icons/muted.svg');
|
|
219
|
+
--icon-unmuted: url('//cdn.surfside.io/icons/unmuted.svg');
|
|
220
|
+
|
|
221
|
+
position: relative;
|
|
222
|
+
overflow: hidden;
|
|
223
|
+
|
|
224
|
+
video {
|
|
225
|
+
width: 100%;
|
|
226
|
+
height: auto;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.timer {
|
|
230
|
+
position: absolute;
|
|
231
|
+
left: 5px;
|
|
232
|
+
top: 5px;
|
|
233
|
+
width: 32px;
|
|
234
|
+
height: 32px;
|
|
235
|
+
|
|
236
|
+
.timer-value {
|
|
237
|
+
position: absolute;
|
|
238
|
+
top: 0px;
|
|
239
|
+
left: 0;
|
|
240
|
+
width: 36px;
|
|
241
|
+
height: 36px;
|
|
242
|
+
|
|
243
|
+
color: white;
|
|
244
|
+
|
|
245
|
+
font-family: Poppins, Arial;
|
|
246
|
+
text-align: center;
|
|
247
|
+
font-size: 12px;
|
|
248
|
+
line-height: 36px;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.timer-circle {
|
|
252
|
+
fill: none;
|
|
253
|
+
stroke-width: 4;
|
|
254
|
+
animation-name: grow-arc;
|
|
255
|
+
animation-iteration-count: 1;
|
|
256
|
+
animation-timing-function: linear;
|
|
257
|
+
animation-fill-mode: forwards;
|
|
258
|
+
transform: rotate(-90deg);
|
|
259
|
+
transform-origin: 50% 50%;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.mute-button {
|
|
265
|
+
position: absolute;
|
|
266
|
+
width: 24px;
|
|
267
|
+
height: 24px;
|
|
268
|
+
right: 5px;
|
|
269
|
+
bottom: 5px;
|
|
270
|
+
cursor: pointer;
|
|
271
|
+
transition: transform 0.2s;
|
|
272
|
+
filter: drop-shadow(0 0 2px white) drop-shadow(0 0 4px white);
|
|
273
|
+
|
|
274
|
+
&:hover {
|
|
275
|
+
transform: scale(1.3);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
&:active {
|
|
279
|
+
transform: scale(0.8);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
&.muted {
|
|
283
|
+
background-image: var(--icon-muted);
|
|
284
|
+
|
|
285
|
+
&:hover {
|
|
286
|
+
background-image: var(--icon-unmuted);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
&.unmuted {
|
|
291
|
+
background-image: var(--icon-unmuted);
|
|
292
|
+
|
|
293
|
+
&:hover {
|
|
294
|
+
background-image: var(--icon-muted);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
298
|
}`;
|
|
299
299
|
//# sourceMappingURL=Video.js.map
|
|
@@ -22,38 +22,38 @@ const RenderWatermark = (logger) => {
|
|
|
22
22
|
return (0, ads_core_1.Ok)(wrapper);
|
|
23
23
|
};
|
|
24
24
|
exports.RenderWatermark = RenderWatermark;
|
|
25
|
-
const template = `<div class="watermark">
|
|
26
|
-
<a href="https://surfside.io/contact" target="_blank">
|
|
27
|
-
<div class="watermark-svg">
|
|
28
|
-
<img src="https://cdn.surfside.io/assets/surfside-logo.svg" alt="Surfside logo"/>
|
|
29
|
-
</div>
|
|
30
|
-
</a>
|
|
31
|
-
</div>
|
|
25
|
+
const template = `<div class="watermark">
|
|
26
|
+
<a href="https://surfside.io/contact" target="_blank">
|
|
27
|
+
<div class="watermark-svg">
|
|
28
|
+
<img src="https://cdn.surfside.io/assets/surfside-logo.svg" alt="Surfside logo"/>
|
|
29
|
+
</div>
|
|
30
|
+
</a>
|
|
31
|
+
</div>
|
|
32
32
|
`;
|
|
33
|
-
const style = `.watermark {
|
|
34
|
-
background: rgba(255, 255, 255, 0.7);
|
|
35
|
-
|
|
36
|
-
position: absolute;
|
|
37
|
-
right: -67px;
|
|
38
|
-
width: 85px;
|
|
39
|
-
/* transform: scale(0.8); */
|
|
40
|
-
transform-origin: bottom right;
|
|
41
|
-
bottom: 0;
|
|
42
|
-
|
|
43
|
-
padding: 3px 2px 0px 6px;
|
|
44
|
-
border-radius: 5px 0 0 5px !important;
|
|
45
|
-
transition: right 300ms ease-out;
|
|
46
|
-
|
|
47
|
-
&:hover {
|
|
48
|
-
right: 0
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.surfside-video .watermark {
|
|
53
|
-
top: 0;
|
|
54
|
-
height: auto;
|
|
55
|
-
bottom: initial;
|
|
56
|
-
overflow: hidden;
|
|
57
|
-
}
|
|
33
|
+
const style = `.watermark {
|
|
34
|
+
background: rgba(255, 255, 255, 0.7);
|
|
35
|
+
|
|
36
|
+
position: absolute;
|
|
37
|
+
right: -67px;
|
|
38
|
+
width: 85px;
|
|
39
|
+
/* transform: scale(0.8); */
|
|
40
|
+
transform-origin: bottom right;
|
|
41
|
+
bottom: 0;
|
|
42
|
+
|
|
43
|
+
padding: 3px 2px 0px 6px;
|
|
44
|
+
border-radius: 5px 0 0 5px !important;
|
|
45
|
+
transition: right 300ms ease-out;
|
|
46
|
+
|
|
47
|
+
&:hover {
|
|
48
|
+
right: 0
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.surfside-video .watermark {
|
|
53
|
+
top: 0;
|
|
54
|
+
height: auto;
|
|
55
|
+
bottom: initial;
|
|
56
|
+
overflow: hidden;
|
|
57
|
+
}
|
|
58
58
|
`;
|
|
59
59
|
//# sourceMappingURL=Watermark.js.map
|
package/lib/esm/BuildInfo.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const SurfsideAdsCoreWebVersionInfo = { buildBranch: '
|
|
1
|
+
export const SurfsideAdsCoreWebVersionInfo = { buildBranch: 'hotfix-0.1.23', buildHash: 'f4f4536', buildVer: '0.1.23' };
|
|
2
2
|
//# sourceMappingURL=BuildInfo.js.map
|
package/lib/esm/BuildInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildInfo.js","sourceRoot":"src/","sources":["BuildInfo.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"BuildInfo.js","sourceRoot":"src/","sources":["BuildInfo.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAC,CAAC"}
|
package/lib/esm/Init.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { CreateSurfAdsClient, Ok, LoadSurfAdsClientDependencies, GetBrowserInfo, PROD_TELEMETRY_SERVICE, DeviceToTelemetryDevice, } from '@surfside/ads-core-client';
|
|
2
|
+
import { RenderBanner, RenderCarousel, RenderProductCard, RenderVideo } from '.';
|
|
3
|
+
import { WebTelemetryCollector } from './helpers';
|
|
4
|
+
const TLS = (url) => 'https:' + url;
|
|
5
|
+
;
|
|
6
|
+
export const CreateSurfAdsWeb = (config) => {
|
|
7
|
+
const clientApiRes = CreateSurfAdsClient(config);
|
|
8
|
+
if (!clientApiRes.ok) {
|
|
9
|
+
return clientApiRes;
|
|
10
|
+
}
|
|
11
|
+
const clientApi = clientApiRes.value;
|
|
12
|
+
const { logger, mobile } = config;
|
|
13
|
+
const { evaluateProductCardTemplate } = clientApi;
|
|
14
|
+
const { configuration, device, geo, navigator } = config;
|
|
15
|
+
const renderBanner = RenderBanner.bind(undefined, logger, mobile);
|
|
16
|
+
const renderProductCard = RenderProductCard.bind(undefined, logger, configuration.templates.productCardStylesheet, configuration.templates.javascriptCallbacks, evaluateProductCardTemplate);
|
|
17
|
+
const renderCarousel = RenderCarousel.bind(undefined, logger, evaluateProductCardTemplate, configuration.settings.sponsoredByEnabled === true, configuration.templates.productCardStylesheet, configuration.templates.carouselStylesheet, configuration.templates.javascriptCallbacks);
|
|
18
|
+
const renderVideo = RenderVideo.bind(undefined, logger, device, geo, navigator.userAgent);
|
|
19
|
+
return Ok({
|
|
20
|
+
...clientApi,
|
|
21
|
+
renderBanner,
|
|
22
|
+
renderProductCard,
|
|
23
|
+
renderCarousel,
|
|
24
|
+
renderVideo
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const LoadSurfAdsWebDependencies = (config) => {
|
|
28
|
+
const { overrides, accountId, siteId, locationId, telemetry } = config;
|
|
29
|
+
const createTelemetryCollector = overrides?.services?.createTelemetryCollector ?? ((config) => Ok(telemetry === true
|
|
30
|
+
? new WebTelemetryCollector({
|
|
31
|
+
accountId: config.accountId,
|
|
32
|
+
siteId: config.siteId,
|
|
33
|
+
channelId: config.channelId,
|
|
34
|
+
locationId: config.locationId,
|
|
35
|
+
endpoint: TLS(PROD_TELEMETRY_SERVICE),
|
|
36
|
+
tags: { accountId, siteId, locationId },
|
|
37
|
+
device: DeviceToTelemetryDevice(config.device)
|
|
38
|
+
})
|
|
39
|
+
: undefined));
|
|
40
|
+
return LoadSurfAdsClientDependencies({
|
|
41
|
+
...config,
|
|
42
|
+
overrides: {
|
|
43
|
+
...config.overrides,
|
|
44
|
+
services: {
|
|
45
|
+
...config.overrides?.services,
|
|
46
|
+
createTelemetryCollector,
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const LoadSurfAdsWeb = async (config) => {
|
|
52
|
+
const dependenciesRes = await LoadSurfAdsWebDependencies(config);
|
|
53
|
+
if (!dependenciesRes.ok) {
|
|
54
|
+
return dependenciesRes;
|
|
55
|
+
}
|
|
56
|
+
const dependencies = dependenciesRes.value;
|
|
57
|
+
const result = CreateSurfAdsWeb({
|
|
58
|
+
...config,
|
|
59
|
+
...dependencies,
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
};
|
|
63
|
+
export const LoadSurfAdsWebSimple = async (accountId, siteId, channelId, locationId, userId, logger, telemetry, overrides) => {
|
|
64
|
+
const browserInfo = GetBrowserInfo();
|
|
65
|
+
if (!browserInfo.ok) {
|
|
66
|
+
return browserInfo;
|
|
67
|
+
}
|
|
68
|
+
const { windowInfo, navigator, isMobile, screen } = browserInfo.value;
|
|
69
|
+
return await LoadSurfAdsWeb({
|
|
70
|
+
logger,
|
|
71
|
+
accountId,
|
|
72
|
+
channelId,
|
|
73
|
+
siteId,
|
|
74
|
+
locationId,
|
|
75
|
+
userId,
|
|
76
|
+
windowInfo,
|
|
77
|
+
navigator,
|
|
78
|
+
mobile: isMobile,
|
|
79
|
+
screen,
|
|
80
|
+
ip: undefined,
|
|
81
|
+
overrides,
|
|
82
|
+
telemetry
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
//# sourceMappingURL=Init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AG,MAAM,CAAC,SAAS,EAAE,QAAQ;gBAC7B,wBAAwB;aAC3B;SACJ;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAC/B,MAAoC,EACR,EAAE;IAC9B,MAAM,eAAe,GAAG,MAAM,0BAA0B,CAAC,MAAM,CAAC,CAAC;IACjE,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC;QACtB,OAAO,eAAe,CAAC;IAC3B,CAAC;IACD,MAAM,YAAY,GAAG,eAAe,CAAC,KAAK,CAAC;IAE3C,MAAM,MAAM,GAAG,gBAAgB,CAAC;QAC5B,GAAG,MAAM;QACT,GAAG,YAAY;KAClB,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACrC,SAAiB,EACjB,MAAc,EACd,SAAiB,EACjB,UAAkB,EAClB,MAAe,EACf,MAAgB,EAChB,SAAmB,EACnB,SAGC,EAC2B,EAAE;IAC9B,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,CAAC;QAClB,OAAO,WAAW,CAAC;IACvB,CAAC;IACD,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;IAEtE,OAAO,MAAM,cAAc,CACvB;QACI,MAAM;QACN,SAAS;QACT,SAAS;QACT,MAAM;QACN,UAAU;QACV,MAAM;QACN,UAAU;QACV,SAAS;QACT,MAAM,EAAE,QAAQ;QAChB,MAAM;QACN,EAAE,EAAE,SAAS;QACb,SAAS;QACT,SAAS;KACZ,CACJ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ITelemetryCollector } from '@surfside/ads-core-client';
|
|
2
|
+
export class WebTelemetryCollector extends ITelemetryCollector {
|
|
3
|
+
_endpoint;
|
|
4
|
+
_tags;
|
|
5
|
+
_batchIntervalMs;
|
|
6
|
+
_pageUrl;
|
|
7
|
+
_queue = [];
|
|
8
|
+
_flushTimer;
|
|
9
|
+
_device;
|
|
10
|
+
constructor(options) {
|
|
11
|
+
super(options.accountId, options.siteId, options.channelId, options.locationId, options.device);
|
|
12
|
+
this._endpoint = options.endpoint;
|
|
13
|
+
this._tags = { pageSessionId: crypto.randomUUID(), ...(options.tags ?? {}) };
|
|
14
|
+
this._batchIntervalMs = options.batchIntervalMs ?? 1000;
|
|
15
|
+
this._pageUrl = options.url ?? globalThis.location?.href;
|
|
16
|
+
}
|
|
17
|
+
record(entry) {
|
|
18
|
+
this._queue.push({
|
|
19
|
+
device: this.device,
|
|
20
|
+
pageUrl: this._pageUrl ?? globalThis?.window?.location?.href,
|
|
21
|
+
...entry,
|
|
22
|
+
tags: { ...this._tags, ...(entry.tags ?? {}) },
|
|
23
|
+
});
|
|
24
|
+
if (this._batchIntervalMs === 0) {
|
|
25
|
+
this.flush();
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
clearTimeout(this._flushTimer);
|
|
29
|
+
this._flushTimer = setTimeout(() => this.flush(), this._batchIntervalMs);
|
|
30
|
+
if (this._queue.length >= 100) {
|
|
31
|
+
this.flush();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
flush() {
|
|
35
|
+
if (this._queue.length === 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const payload = JSON.stringify(this._queue.splice(0));
|
|
39
|
+
clearTimeout(this._flushTimer);
|
|
40
|
+
this._flushTimer = undefined;
|
|
41
|
+
const sent = globalThis.navigator.sendBeacon(this._endpoint, new Blob([payload], { type: 'application/json' }));
|
|
42
|
+
if (!sent) {
|
|
43
|
+
fetch(this._endpoint, {
|
|
44
|
+
method: 'POST',
|
|
45
|
+
headers: { 'Content-Type': 'application/json' },
|
|
46
|
+
body: payload,
|
|
47
|
+
keepalive: true,
|
|
48
|
+
}).catch(() => { });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=WebTelemetryCollector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebTelemetryCollector.js","sourceRoot":"../@surfside-ads-core-web/","sources":["helpers/WebTelemetryCollector.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,mBAAmB,EAGtB,MAAM,2BAA2B,CAAC;AAcnC,MAAM,OAAO,qBAAsB,SAAQ,mBAAmB;IACzC,SAAS,CAAS;IAClB,KAAK,CAAyB;IAC9B,gBAAgB,CAAS;IACzB,QAAQ,CAAqB;IACtC,MAAM,GAAsB,EAAE,CAAC;IAC/B,WAAW,CAA4C;IACvD,OAAO,CAA+B;IAE9C,YAAY,OAAsC;QAC9C,KAAK,CACD,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,MAAM,EACd,OAAO,CAAC,SAAS,EACjB,OAAO,CAAC,UAAU,EAClB,OAAO,CAAC,MAAM,CACjB,CAAC;QACF,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,EAAE,aAAa,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QAC7E,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,IAAI,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC;IAC7D,CAAC;IAED,MAAM,CAAC,KAAsB;QACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,QAAQ,IAAI,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI;YAC5D,GAAG,KAAK;YACR,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AK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -57,34 +57,34 @@ export class MissingNurlError extends Error {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
;
|
|
60
|
-
const template = `<div>
|
|
61
|
-
<div class="surfside-banner-adm">
|
|
62
|
-
|
|
63
|
-
</div>
|
|
64
|
-
<div class="surfside-banner-watermark">
|
|
65
|
-
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
60
|
+
const template = `<div>
|
|
61
|
+
<div class="surfside-banner-adm">
|
|
62
|
+
|
|
63
|
+
</div>
|
|
64
|
+
<div class="surfside-banner-watermark">
|
|
65
|
+
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
68
|
`;
|
|
69
|
-
const style = `.surfside-banner {
|
|
70
|
-
position: relative;
|
|
71
|
-
display: inline-block;
|
|
72
|
-
overflow: hidden;
|
|
73
|
-
max-width: 100%;
|
|
74
|
-
height: auto;
|
|
75
|
-
width: 100%;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.surfside-banner-adm {
|
|
79
|
-
display: flex;
|
|
80
|
-
|
|
81
|
-
a {
|
|
82
|
-
width: 100%;
|
|
83
|
-
|
|
84
|
-
img {
|
|
85
|
-
width: 100%;
|
|
86
|
-
height: auto;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
69
|
+
const style = `.surfside-banner {
|
|
70
|
+
position: relative;
|
|
71
|
+
display: inline-block;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
max-width: 100%;
|
|
74
|
+
height: auto;
|
|
75
|
+
width: 100%;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.surfside-banner-adm {
|
|
79
|
+
display: flex;
|
|
80
|
+
|
|
81
|
+
a {
|
|
82
|
+
width: 100%;
|
|
83
|
+
|
|
84
|
+
img {
|
|
85
|
+
width: 100%;
|
|
86
|
+
height: auto;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
89
|
}`;
|
|
90
90
|
//# sourceMappingURL=Banner.js.map
|