@speedkit/cli 2.54.0 → 2.56.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 CHANGED
@@ -1,3 +1,17 @@
1
+ # [2.56.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.55.0...v2.56.0) (2024-09-10)
2
+
3
+
4
+ ### Features
5
+
6
+ * **customer-config:** provide default currency for ga ecommerce tracking plugin ([1e26367](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/1e263670d19fa8d4f9b18e2ed0bdc6bb4c06ebb2))
7
+
8
+ # [2.55.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.54.0...v2.55.0) (2024-08-28)
9
+
10
+
11
+ ### Features
12
+
13
+ * **customer-config:** update soft navigation tracking ([d43bf1b](https://gitlab.orestes.info/baqend/speed-kit-cli/commit/d43bf1b64893e7b5910be9534d3e7f244dcf8165))
14
+
1
15
  # [2.54.0](https://gitlab.orestes.info/baqend/speed-kit-cli/compare/v2.53.2...v2.54.0) (2024-08-23)
2
16
 
3
17
 
package/README.md CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @speedkit/cli
21
21
  $ sk COMMAND
22
22
  running command...
23
23
  $ sk (--version)
24
- @speedkit/cli/2.54.0 linux-x64 node-v20.17.0
24
+ @speedkit/cli/2.56.0 linux-x64 node-v20.17.0
25
25
  $ sk --help [COMMAND]
26
26
  USAGE
27
27
  $ sk COMMAND
@@ -24,7 +24,7 @@ import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
24
24
  new HistoryApiPlugin(), // Soft Navigation Tracking using History API
25
25
  {{/if}}
26
26
  {{#if useGATracking}}
27
- new GAEcommerceTrackingPlugin(),
27
+ new GAEcommerceTrackingPlugin({ defaultCurrency: "EUR" }),
28
28
  {{/if}}
29
29
 
30
30
  {{#if addPreRendering}}
@@ -337,60 +337,72 @@ import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
337
337
  }
338
338
 
339
339
  controller.trackCustomEvent("softNav", location.href, Date.now());
340
- var navStartMark = "soft-nav_" + location.pathname;
341
- performance.mark(navStartMark);
342
340
 
343
341
  // Only capture soft LCP on following pages/page types:
344
- // * <add>
345
- // TODO: update list
342
+ // TODO: update to match the resp. page types to capture
343
+ var isProduct = location.href.indexOf("/p/") !== -1;
344
+ var isCategory = location.href.indexOf("/c/") !== -1;
346
345
 
347
- // TODO: update exemplary url pattern to match pages/page types to capture
348
- if (location.href.indexOf("/p/")) {
349
- softLcpPending = true;
350
- }
346
+ if (!isCategory && !isProduct) return;
347
+
348
+ var navStartMark = "soft-nav_" + location.pathname;
349
+ performance.mark(navStartMark);
350
+
351
+ softLcpPending = true;
351
352
 
352
353
  var softNavigationPerformanceObserver = new PerformanceObserver(
353
354
  (entries, observer) => {
354
355
  // TODO: update exemplary selectors within this block
355
356
 
356
- if (!document.querySelector(".productBasicInfo")) {
357
- return;
358
- }
359
-
357
+ // Wait for product image resources to be loaded:
360
358
  var imageEntries = Array.from(entries.getEntries()).filter(
361
- (item) =>
362
- item.name.indexOf("/img/produkte/") > -1 &&
363
- item.name.indexOf("/img/produkte/15_") === -1,
359
+ (item) => item.name.indexOf("/product/image/") !== -1,
364
360
  );
361
+
362
+ // Ensure product images can be found in requested resources list:
365
363
  if (!imageEntries || imageEntries.length < 1) {
366
364
  return;
367
365
  }
368
366
 
369
- var element = document.querySelector(
370
- ".productBasicInfo .carousel__img-wrapper img",
371
- );
372
- if (!element) {
367
+ // Wait for product hero image / first product image in list to be referenced in DOM:
368
+ var imageElementSelector = isProduct
369
+ ? ".product-details .slick-slide.slick-active img" // PDP hero image
370
+ : ".product-list .product-image img"; // PLP list image(s)
371
+
372
+ var imageElement = document.querySelector(imageElementSelector);
373
+
374
+ // Ensure image element can be found in document:
375
+ if (!imageElement) {
376
+ return;
377
+ }
378
+ var imageUrl = imageElement.currentSrc || imageElement.srcset || "";
379
+
380
+ var imageMatchingRequestedResource = imageEntries.filter(
381
+ (entry) => {
382
+ var urlObj = new URL(entry.name);
383
+ return imageUrl.indexOf(urlObj.pathname) > -1;
384
+ },
385
+ )[0];
386
+
387
+ // Ensure the resp. image source referenced in the document can be found in requested resources list:
388
+ if (!imageMatchingRequestedResource) {
373
389
  return;
374
390
  }
375
- var imageUrl = element.currentSrc || element.srcset || "";
376
391
 
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) {
392
+ // Ensure Soft LCP is still pending:
393
+ if (!softLcpPending) {
382
394
  return;
383
395
  }
384
396
 
385
397
  var measure = performance.measure("lcp_" + location.pathname, {
386
398
  start: navStartMark,
387
- end: image.responseEnd,
399
+ end: imageMatchingRequestedResource.responseEnd,
388
400
  });
389
401
 
390
402
  var timing = {
391
403
  start: measure.startTime,
392
404
  duration: measure.duration,
393
- image: image.name,
405
+ image: imageMatchingRequestedResource.name,
394
406
  url: window.location.href,
395
407
  };
396
408
  controller.trackCustomEvent(
@@ -398,8 +410,9 @@ import { GAEcommerceTrackingPlugin } from 'rum/GAEcommerceTrackingPlugin';
398
410
  JSON.stringify(timing),
399
411
  Date.now(),
400
412
  );
401
- softLcpPending = false;
413
+
402
414
  softNavigationPerformanceObserver.disconnect();
415
+ softLcpPending = false;
403
416
  },
404
417
  );
405
418
 
@@ -712,5 +712,5 @@
712
712
  ]
713
713
  }
714
714
  },
715
- "version": "2.54.0"
715
+ "version": "2.56.0"
716
716
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@speedkit/cli",
3
3
  "description": "Speed Kit CLI",
4
- "version": "2.54.0",
4
+ "version": "2.56.0",
5
5
  "author": {
6
6
  "name": "Baqend.com",
7
7
  "email": "info@baqend.com"