@speedkit/cli 2.47.1 → 2.49.0
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/CHANGELOG.md +16 -0
- package/README.md +1 -1
- package/dist/services/customer-config/customer-config-service-model.d.ts +2 -0
- package/dist/services/customer-config/customer-config-service.d.ts +1 -0
- package/dist/services/customer-config/customer-config-service.js +20 -3
- package/dist/services/customer-config/templates/config_SpeedKit.js.hbs +12 -0
- package/dist/services/customer-config/templates/config_documentHandler.js.hbs +7 -0
- package/dist/services/customer-config/templates/config_loadHandler.js.hbs +146 -49
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
# [2.49.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.48.0...v2.49.0) (2024-07-26)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **customer-config:** add soft navigation tracking ([e473277](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/e4732778c3a33046b2d602743b22b8e3e4e8ec73))
|
|
7
|
+
|
|
8
|
+
# [2.48.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.47.1...v2.48.0) (2024-07-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **config-wizard:** add support for scrapingbee ([c8fe5a1](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/c8fe5a1b45c06fc373cbf868ef6fb6204cadc0fc))
|
|
14
|
+
* **config-wizard:** add support for scrapingbee ([1286550](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/1286550a41fd48a0effee9c4c8f5b424dc8cb864))
|
|
15
|
+
* **config-wizard:** add support for scrapingbee ([f1a6ba3](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/f1a6ba3dcf42ee5715943e5c7a923464c81b77db))
|
|
16
|
+
|
|
1
17
|
## [2.47.1](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.47.0...v2.47.1) (2024-07-24)
|
|
2
18
|
|
|
3
19
|
|
package/README.md
CHANGED
|
@@ -32,8 +32,10 @@ export interface CustomerConfigSettings {
|
|
|
32
32
|
shadowDomCustomElementPrefix?: string;
|
|
33
33
|
activateRumTracking?: boolean;
|
|
34
34
|
useGATracking?: boolean;
|
|
35
|
+
useScrapingBee?: boolean;
|
|
35
36
|
withGoogleOptimize?: boolean;
|
|
36
37
|
activateCfRocketLoaderWorkaround?: boolean;
|
|
38
|
+
hasSoftNavigations?: boolean;
|
|
37
39
|
isShopify?: boolean;
|
|
38
40
|
isShopware?: boolean;
|
|
39
41
|
isSalesforce?: boolean;
|
|
@@ -24,5 +24,6 @@ export declare class CustomerConfigService {
|
|
|
24
24
|
private downloadAndSaveFile;
|
|
25
25
|
private getConfigSettings;
|
|
26
26
|
handleDocumentHandler({ addPreRendering }: CustomerConfigSettings): Promise<void>;
|
|
27
|
+
logWarnings(configSettings: CustomerConfigSettings): Promise<void>;
|
|
27
28
|
generateConfig(): Promise<void>;
|
|
28
29
|
}
|
|
@@ -161,7 +161,7 @@ class CustomerConfigService {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
async getConfigSettings() {
|
|
164
|
-
let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, withGoogleOptimize, activateCfRocketLoaderWorkaround, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
|
|
164
|
+
let { production, staging, subRouteScope, includeServiceWorker, activateImageOptimisation, removeLazyLoading, addPreRendering, supportShadowDomInPreRendering, shadowDomCustomElementPrefix, activateRumTracking, useGATracking, useScrapingBee, withGoogleOptimize, activateCfRocketLoaderWorkaround, hasSoftNavigations, isShopify, isShopware, isSalesforce, isPlentymarkets, shopifyId, } = {};
|
|
165
165
|
this.appName = await this.cli.prompt(`Enter SK App Name:`, {
|
|
166
166
|
validator: (input) => /^[\da-z]+(?:-[\da-z]+)*$/.test(input) ? "" : "No valid kebab-case",
|
|
167
167
|
defaultAnswer: this.appName,
|
|
@@ -214,9 +214,13 @@ class CustomerConfigService {
|
|
|
214
214
|
shadowDomCustomElementPrefix = await this.cli.prompt("Please specify the prefix of the custom elements used (e.g. o2 uses tef-): ", { defaultAnswer: "custom-" });
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
+
useScrapingBee = await this.cli.confirm("Do customer responses differ geo-location-based (ScrapingBee will be needed to fetch documents)?", false);
|
|
217
218
|
activateRumTracking = await this.cli.confirm("Activate RUM Tracking?");
|
|
218
|
-
if (activateRumTracking
|
|
219
|
-
|
|
219
|
+
if (activateRumTracking) {
|
|
220
|
+
if (!isShopify) {
|
|
221
|
+
useGATracking = await this.cli.confirm("Add Tracking based on Google Analytics' DataLayer?");
|
|
222
|
+
}
|
|
223
|
+
hasSoftNavigations = await this.cli.confirm("Add Tracking for Soft Navigations?", false);
|
|
220
224
|
}
|
|
221
225
|
withGoogleOptimize = await this.cli.confirm("Is Google Optimize being used?", false);
|
|
222
226
|
activateCfRocketLoaderWorkaround = isShopify
|
|
@@ -235,8 +239,10 @@ class CustomerConfigService {
|
|
|
235
239
|
shadowDomCustomElementPrefix,
|
|
236
240
|
activateRumTracking,
|
|
237
241
|
useGATracking,
|
|
242
|
+
useScrapingBee,
|
|
238
243
|
withGoogleOptimize,
|
|
239
244
|
activateCfRocketLoaderWorkaround,
|
|
245
|
+
hasSoftNavigations,
|
|
240
246
|
isShopify,
|
|
241
247
|
isShopware,
|
|
242
248
|
isSalesforce,
|
|
@@ -269,6 +275,16 @@ class CustomerConfigService {
|
|
|
269
275
|
`);
|
|
270
276
|
}
|
|
271
277
|
}
|
|
278
|
+
async logWarnings(configSettings) {
|
|
279
|
+
if (configSettings.useScrapingBee) {
|
|
280
|
+
this.cli.writeWarning(`
|
|
281
|
+
⚠️ MANUAL ACTION NEEDED ⚠️
|
|
282
|
+
|
|
283
|
+
Remember to set it up the variation in the orestes config.
|
|
284
|
+
See more info here: https://www.notion.so/baqend/How-to-use-Scraping-Bee-in-the-orestes-config-b94d8571e1a04c9e8310810df55a9a62
|
|
285
|
+
`);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
272
288
|
async generateConfig() {
|
|
273
289
|
this.cli.write("\nLet's generate a config...\n");
|
|
274
290
|
const configSettings = await this.getConfigSettings();
|
|
@@ -278,6 +294,7 @@ class CustomerConfigService {
|
|
|
278
294
|
}
|
|
279
295
|
await this.compileHandlebarsFiles(configSettings);
|
|
280
296
|
await this.handleDocumentHandler(configSettings);
|
|
297
|
+
await this.logWarnings(configSettings);
|
|
281
298
|
this.cli.writeSuccess("\nConfig generation completed 👏\n");
|
|
282
299
|
}
|
|
283
300
|
}
|
|
@@ -74,6 +74,18 @@
|
|
|
74
74
|
split: CURRENT_HOST_CONFIG.split,
|
|
75
75
|
splitTestId: CURRENT_HOST_CONFIG.splitTestId,
|
|
76
76
|
disabled: !CURRENT_HOST_CONFIG.enabled{{#if addPreRendering}} || isTablet(){{/if}},
|
|
77
|
+
{{#if useScrapingBee}}
|
|
78
|
+
customVariation: [
|
|
79
|
+
{
|
|
80
|
+
variationFunction: function (request, device, cookies) {
|
|
81
|
+
if (device === "desktop") {
|
|
82
|
+
return "proxycrawl";
|
|
83
|
+
}
|
|
84
|
+
return "proxycrawlmobile";
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
{{/if}}
|
|
77
89
|
enabledSites: [
|
|
78
90
|
{
|
|
79
91
|
pathname: [
|
|
@@ -56,6 +56,13 @@ const config = {
|
|
|
56
56
|
return `Tablet viewport is unsupported: ${url}`;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
{{/if}}
|
|
60
|
+
{{#if useScrapingBee}}
|
|
61
|
+
// dynamically blacklist not 200 status codes from ScrapingBee
|
|
62
|
+
const spbStatusCode = headers["Spb-initial-status-code"];
|
|
63
|
+
if (spbStatusCode && spbStatusCode !== "200") {
|
|
64
|
+
return `initial status code unequal to 200 received from scrapingbee: ${url} ${spbStatusCode}`;
|
|
65
|
+
}
|
|
59
66
|
{{/if}}
|
|
60
67
|
return false;
|
|
61
68
|
},
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { BaseBundle } from 'rum/BaseBundle';
|
|
2
|
+
{{#if hasSoftNavigations}}
|
|
3
|
+
import { HistoryApiPlugin } from 'rum/HistoryApiPlugin';
|
|
4
|
+
{{/if}}
|
|
2
5
|
{{#if useGATracking}}
|
|
3
6
|
import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
|
|
4
7
|
{{/if}}
|
|
@@ -7,69 +10,76 @@ import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
|
|
|
7
10
|
if (window !== window.top) {
|
|
8
11
|
return;
|
|
9
12
|
}
|
|
13
|
+
{{#if hasSoftNavigations}}
|
|
14
|
+
|
|
15
|
+
var softLcpPending = false;
|
|
16
|
+
var latestUrl = location.href;
|
|
17
|
+
{{/if}}
|
|
10
18
|
|
|
11
19
|
window.SpeedKit = window.SpeedKit || {};
|
|
12
20
|
SpeedKit.rumPlugins = SpeedKit.rumPlugins || [];
|
|
13
21
|
SpeedKit.rumPlugins.push(
|
|
14
22
|
new BaseBundle(),
|
|
23
|
+
{{#if hasSoftNavigations}}
|
|
24
|
+
new HistoryApiPlugin(), // Soft Navigation Tracking using History API
|
|
25
|
+
{{/if}}
|
|
15
26
|
{{#if useGATracking}}
|
|
16
27
|
new GAEcommerceTrackingPlugin(),
|
|
17
28
|
{{/if}}
|
|
18
29
|
|
|
19
30
|
{{#if addPreRendering}}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
{
|
|
32
|
+
key: "isPreRendered",
|
|
33
|
+
type: "PiDimension",
|
|
34
|
+
on: "load",
|
|
35
|
+
set: function () {
|
|
36
|
+
return !!document.querySelector(".speed-kit-pre-rendered");
|
|
37
|
+
},
|
|
26
38
|
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
{
|
|
40
|
+
on: onPrerenderReady,
|
|
41
|
+
track: function (controller, custom, event) {
|
|
42
|
+
var measure = performance.measure("sk-prerender-observe-runtime", {
|
|
43
|
+
start: "sk-prerender-observe-start",
|
|
44
|
+
end: "sk-prerender-observe-end",
|
|
45
|
+
});
|
|
46
|
+
var timing = {
|
|
47
|
+
start: measure.startTime,
|
|
48
|
+
duration: measure.duration,
|
|
49
|
+
url: window.location.href,
|
|
50
|
+
element: event?.detail?.element,
|
|
51
|
+
};
|
|
52
|
+
controller.trackCustomEvent(
|
|
53
|
+
"skPrerenderReady",
|
|
54
|
+
JSON.stringify(timing),
|
|
55
|
+
timing.duration,
|
|
56
|
+
);
|
|
57
|
+
},
|
|
46
58
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
{
|
|
60
|
+
on: onPrerenderReady,
|
|
61
|
+
track: function (controller) {
|
|
62
|
+
var measure = performance.measure(
|
|
63
|
+
"sk-prerender-observe-change-detection",
|
|
64
|
+
{
|
|
65
|
+
start: "sk-prerender-change-detection-start",
|
|
66
|
+
end: "sk-prerender-change-detection-end",
|
|
67
|
+
},
|
|
68
|
+
);
|
|
69
|
+
var timing = {
|
|
70
|
+
start: measure.startTime,
|
|
71
|
+
duration: measure.duration,
|
|
72
|
+
url: window.location.href,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
controller.trackCustomEvent(
|
|
76
|
+
"skPrerenderChangeDetection",
|
|
77
|
+
JSON.stringify(timing),
|
|
78
|
+
timing.duration,
|
|
79
|
+
);
|
|
80
|
+
},
|
|
69
81
|
},
|
|
70
|
-
},
|
|
71
82
|
{{/if}}
|
|
72
|
-
|
|
73
83
|
{
|
|
74
84
|
key: 'language',
|
|
75
85
|
type: 'SessionDimension',
|
|
@@ -312,6 +322,93 @@ import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
|
|
|
312
322
|
},
|
|
313
323
|
},
|
|
314
324
|
{{/if}}
|
|
325
|
+
{{/if}}
|
|
326
|
+
{{#if hasSoftNavigations}}
|
|
327
|
+
{
|
|
328
|
+
on: "softNavigation",
|
|
329
|
+
track: (controller) => {
|
|
330
|
+
var onlyHashChanged =
|
|
331
|
+
latestUrl.split("#")[0] === location.href.split("#")[0];
|
|
332
|
+
latestUrl = location.href;
|
|
333
|
+
|
|
334
|
+
if (onlyHashChanged) {
|
|
335
|
+
controller.trackCustomEvent("hashChanged", location.href, Date.now());
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
controller.trackCustomEvent("softNav", location.href, Date.now());
|
|
340
|
+
var navStartMark = "soft-nav_" + location.pathname;
|
|
341
|
+
performance.mark(navStartMark);
|
|
342
|
+
|
|
343
|
+
// Only capture soft LCP on following pages/page types:
|
|
344
|
+
// * <add>
|
|
345
|
+
// TODO: update list
|
|
346
|
+
|
|
347
|
+
// TODO: update exemplary url pattern to match pages/page types to capture
|
|
348
|
+
if (location.href.indexOf("/p/")) {
|
|
349
|
+
softLcpPending = true;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
var softNavigationPerformanceObserver = new PerformanceObserver(
|
|
353
|
+
(entries, observer) => {
|
|
354
|
+
// TODO: update exemplary selectors within this block
|
|
355
|
+
|
|
356
|
+
if (!document.querySelector(".productBasicInfo")) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
var imageEntries = Array.from(entries.getEntries()).filter(
|
|
361
|
+
(item) =>
|
|
362
|
+
item.name.indexOf("/img/produkte/") > -1 &&
|
|
363
|
+
item.name.indexOf("/img/produkte/15_") === -1,
|
|
364
|
+
);
|
|
365
|
+
if (!imageEntries || imageEntries.length < 1) {
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
var element = document.querySelector(
|
|
370
|
+
".productBasicInfo .carousel__img-wrapper img",
|
|
371
|
+
);
|
|
372
|
+
if (!element) {
|
|
373
|
+
return;
|
|
374
|
+
}
|
|
375
|
+
var imageUrl = element.currentSrc || element.srcset || "";
|
|
376
|
+
|
|
377
|
+
var image = imageEntries.filter((entry) => {
|
|
378
|
+
var urlObj = new URL(entry.name);
|
|
379
|
+
return imageUrl.indexOf(urlObj.pathname) > -1;
|
|
380
|
+
})[0];
|
|
381
|
+
if (!softLcpPending || !image) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
var measure = performance.measure("lcp_" + location.pathname, {
|
|
386
|
+
start: navStartMark,
|
|
387
|
+
end: image.responseEnd,
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
var timing = {
|
|
391
|
+
start: measure.startTime,
|
|
392
|
+
duration: measure.duration,
|
|
393
|
+
image: image.name,
|
|
394
|
+
url: window.location.href,
|
|
395
|
+
};
|
|
396
|
+
controller.trackCustomEvent(
|
|
397
|
+
"softNavLcp",
|
|
398
|
+
JSON.stringify(timing),
|
|
399
|
+
Date.now(),
|
|
400
|
+
);
|
|
401
|
+
softLcpPending = false;
|
|
402
|
+
softNavigationPerformanceObserver.disconnect();
|
|
403
|
+
},
|
|
404
|
+
);
|
|
405
|
+
|
|
406
|
+
softNavigationPerformanceObserver.observe({
|
|
407
|
+
buffered: true,
|
|
408
|
+
type: "resource",
|
|
409
|
+
});
|
|
410
|
+
},
|
|
411
|
+
},
|
|
315
412
|
{{/if}}
|
|
316
413
|
);
|
|
317
414
|
{{#if isShopify}}
|
package/oclif.manifest.json
CHANGED