@speedkit/cli 4.21.0 → 4.22.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.
@@ -1,548 +0,0 @@
1
- {{#*inline "disabledSites"}}
2
- // TODO: adjust/replace this exemplary list
3
- {{#if isPlentymarkets}}
4
-
5
- // Plentymarkets specific:
6
- /kundenkonto/i,
7
- /warenkorb/i,
8
- {{/if}}
9
-
10
- // Login & Account:
11
- /account/i,
12
- /profile/i,
13
- /password/i,
14
- /registration/i,
15
- /register/i,
16
- /login/i,
17
- /authenticate/i,
18
- /wish(-)?list/i,
19
-
20
- // Checkout & Payment:
21
- /cart/i,
22
- /basket/i,
23
- /checkout/i,
24
- /order/i,
25
- /success/i,
26
- /confirmation/i,
27
- /payment/i,
28
- /success/i,
29
-
30
- // Admin:
31
- /\/admin/i,
32
- /\/backend/i,
33
- {{/inline}}
34
-
35
- {{#if isShopify}}
36
- import { ShopifyPlugin } from "speed-kit-config/ShopifyPlugin";
37
- {{/if}}
38
- {{#if addSSR}}
39
- import { SSRPlugin } from "speed-kit-config/SSRPlugin";
40
- {{/if}}
41
-
42
- (function() {
43
- {{#if isShopify}}
44
- SpeedKit.configPlugins = SpeedKit.configPlugins || [];
45
- SpeedKit.configPlugins.push(new ShopifyPlugin());
46
- {{/if}}
47
- {{#if addSSR}}
48
- {{#unless isShopify}}
49
- SpeedKit.configPlugins = SpeedKit.configPlugins || [];
50
- {{/unless}}
51
- SpeedKit.configPlugins.push(new SSRPlugin());
52
- {{/if}}
53
-
54
- var ENABLED_HOSTS_CONFIGS = [
55
- // Production:
56
- {
57
- hosts: ["{{production.host}}"],
58
- {{#if subRouteScope}}
59
- scopes: ["{{subRouteScope}}"],
60
- {{/if}}
61
- split: 0,
62
- splitTestId: "0vs100_20xx-xx-xx",
63
- },
64
-
65
- {{#if staging.host}}
66
- // Staging:
67
- {
68
- hosts: ["{{staging.host}}"],
69
- {{#if subRouteScope}}
70
- scopes: ["{{subRouteScope}}"],
71
- {{/if}}
72
- },
73
- {{else}}
74
- // No Staging configured
75
- {{/if}}
76
- ];
77
- var ENABLED_HOSTS = getEnabledHosts(ENABLED_HOSTS_CONFIGS);
78
- var CURRENT_HOST_CONFIG = getCurrentHostConfig(ENABLED_HOSTS_CONFIGS);
79
- {{#if useDisabledSitesApproach}}
80
-
81
- var DISABLED_SITES = [
82
- // Used as pathnames in...
83
- // - disabled sites
84
- // - blacklist
85
-
86
- {{> disabledSites}}
87
- ];
88
- {{/if}}
89
-
90
- /**
91
- * @type {SpeedKitConfig}
92
- */
93
- window.speedKit = {
94
- ruleSetConfig: {
95
- version: 2,
96
- },
97
- appName: APP,
98
- {{#if isShopify}}
99
- sw: "/apps/speed-kit/sw.js", // Shopify specific
100
- {{else}}
101
- sw: "/wrapper-sw.js",
102
- {{/if}}
103
- {{#if includeServiceWorker}}
104
- includeServiceWorker: "{{includeServiceWorker}}",
105
- {{/if}}
106
- preloadDynamicBlocks: true,
107
- rumTracking: true,
108
- {{#if addDeviceDetection}}
109
- {{#unless addSSR}}
110
- // Server-side responsive: origin returns different HTML per device (UA-keyed).
111
- userAgentDetection: true,
112
- detectDevice: function(doc) {
113
- // TODO: set a marker present only in the mobile variation. Read it from `doc`.
114
- return doc.querySelector('<mobile-specific-element>') ? "mobile" : "desktop";
115
- },
116
- {{/unless}}
117
- {{#if addSSR}}
118
- // SSR: pick the device by viewport width; SSRPlugin (above) handles resize/zoom/bfcache.
119
- detectDevice: function(doc) {
120
- // TODO: set the real breakpoint — discover it, don't guess (tools/sk-breakpoints.mjs).
121
- var width = document.documentElement.clientWidth;
122
- if (!width) return null;
123
- return width <= 820 ? "mobile" : "desktop";
124
- },
125
- {{/if}}
126
- {{/if}}
127
- {{#if addSSR}}
128
- customVariation: [
129
- {
130
- variationFunction: function (request, device, cookies) {
131
- // SSR specific – don't report a variation for specific page types NOT covered by SSR:
132
- // TODO: adjust and activate if needed
133
- // if (request.url.indexOf("<url-page-type-idenfier>") > -1) return "desktop";
134
- return device;
135
- },
136
- },
137
- ],
138
- {{/if}}
139
- {{#if useScrapingBee}}
140
- customVariation: [
141
- {
142
- variationFunction: function (request, device, cookies) {
143
- if (device === "desktop") {
144
- return "proxycrawl";
145
- }
146
- return "proxycrawlmobile";
147
- },
148
- },
149
- ],
150
- {{/if}}
151
- split: CURRENT_HOST_CONFIG.split,
152
- splitTestId: CURRENT_HOST_CONFIG.splitTestId,
153
- disabled: !CURRENT_HOST_CONFIG.enabled,
154
- // TODO: walk the live checkout + login flows and pin exact prefixes (SSO/PSP returns, separate reg pages). See /disabled-scopes.
155
- disabledScopes: [
156
- "/cart",
157
- "/checkout",
158
- {{#if isShopify}}
159
- "/account", // login/register/recover/orders
160
- "/services/login_with_shop", // Shop Pay auto-login transfer (platform route, all locales)
161
- {{else}}
162
- "/login",
163
- {{/if}}
164
- ],
165
- enabledSites: [
166
- {
167
- pathname: [
168
- // TODO: adjust/replace this exemplary list
169
-
170
- /^\/$/, // Home
171
-
172
- {{#if isShopify}}
173
- /\/collections\//i, // Category & PLP
174
- /\/products\//i, // PDP
175
- {{else}}
176
- /\/c\//, // Category & PLP
177
- /\/p\//, // PDP
178
- {{/if}}
179
- ],
180
- },
181
- ],
182
- // Pages that aren't enabled themselves, but are allowed to trigger soft-to-hard
183
- // navigations and preloading/prerendering for enabled pages.
184
- activeSites: [
185
- {
186
- pathname: [
187
- // TODO: adjust/replace or remove if not needed
188
- /\/search/i, // e.g. search results
189
- ],
190
- },
191
- ],
192
- whitelist: [
193
- {
194
- {{#if isPlentymarkets}}
195
- host: ENABLED_HOSTS.concat([
196
- // Plentymarkets specific:
197
- /cdn\d\d\.plentymarkets\.com/,
198
- "www.gstatic.com",
199
- "static.doubleclick.net",
200
- "static.newsletter2go.com",
201
- "cdn-static.optimonk.com",
202
- ]),
203
- {{else}}
204
- host: ENABLED_HOSTS,
205
- {{/if}}
206
- contentType: [
207
- 'navigate',
208
- {{#if activateImageOptimisation}}
209
- 'image',
210
- {{/if}}
211
- ],
212
- },
213
- {
214
- host: [
215
- "fonts.googleapis.com",
216
- "fonts.gstatic.com",
217
- ],
218
- contentType: ["script", "style", "font"],
219
- },
220
- {{#if isShopify}}
221
- // Shopify specific:
222
- {
223
- url: [
224
- "bat.bing.com/bat.js",
225
- "connect.facebook.net/en_US/fbevents.js",
226
- ],
227
- },
228
- {{/if}}
229
- ],
230
- blacklist: [
231
- {{#if useDisabledSitesApproach}}
232
- {
233
- pathname: DISABLED_SITES,
234
- },
235
- {{/if}}
236
- {
237
- pathname: [
238
- {{#if isPlentymarkets}}
239
-
240
- // Plentymarkets specific:
241
- /\/rest/i, // REST API
242
- {{/if}}
243
- {{#if isSalesforce}}
244
-
245
- // SFCC specific:
246
- /\/demandware\.store/i, // high-level api blacklist
247
- {{/if}}
248
- {{#unless useDisabledSitesApproach}}
249
- {{> disabledSites}}
250
- {{/unless}}
251
-
252
- // Payment Services:
253
- /paypal/i,
254
- /klarna/i,
255
- /amazon/i,
256
- /ratepay/i,
257
- /payone/i,
258
-
259
- // Misc:
260
- /\/akam\//i, // Akamai telemetry data
261
- /\.pdf/,
262
- /\/adyen/i,
263
- /\/cdn-cgi\//i, // dynamic scripts
264
- ],
265
- },
266
- {
267
- url: [
268
- /[?&](_=1\d{12})/, // jQuery code execution callbacks
269
- /[?&]nocache/i,
270
- /[?&]kameleoon=true/i, // = Kameleoon's graphical editor mode is active
271
-
272
- // GTM:
273
- "www.googletagmanager.com/gtm.js",
274
- "www.googletagmanager.com/gtag/js",
275
- ],
276
- },
277
- {
278
- host: ["www.paypal.com", "www.paypalobjects.com"],
279
- },
280
- {{#if isShopify}}
281
-
282
- // Shopify specific:
283
- {
284
- pathname: [
285
- "/api/",
286
- "/apps/",
287
- "/a/",
288
- "/community/",
289
- "/tools/",
290
- "/recommendations/",
291
- /discount/,
292
- /orders/,
293
- /digital_wallets/, // HTML Fragment in Checkout that does not match XHR Rule
294
- "/app/services/", // many checkout resources
295
- ],
296
- },
297
- {{/if}}
298
- {{#if isShopware}}
299
-
300
- // Shopware specific:
301
- {
302
- pathname: [
303
- /\/refreshStatistic/i, // stats request
304
- ],
305
- },
306
- {{/if}}
307
- {{#if isOxid}}
308
-
309
- // OXID eShop specific:
310
- {
311
- url: [
312
- /[?&]cl=/i,
313
- // "cl" parameter specifying the OXID controller class, which can affect the entire page layout and content
314
- // – common values: start, alist, details, basket, order, register, login
315
- // TODO: check in the fine-tuning phase at the latest whether the resulting blacklisted rate is not too high
316
- /[?&]searchparam/i,
317
- ],
318
- },
319
- {{/if}}
320
- {{#if isPlentymarkets}}
321
-
322
- // Plentymarkets specific:
323
- {
324
- url: [
325
- /\/plentymarkets/i, // API, updates of certain pages can be triggered under this path
326
-
327
- // params:
328
- /[?&]time=/i,
329
- /[?&]subscription=/i,
330
- /[?&]hash=/i,
331
- /[?&]AccountShow=/i,
332
- /[?&]OrderID=/i,
333
- /[?&]PaymentMethod=/i,
334
- /[?&]paymentId=/i,
335
- /[?&]token=/i,
336
- /[?&]PayerID=/i,
337
- ],
338
- },
339
- {{/if}}
340
- {{#if isShopify}}
341
-
342
- // Shopify specific:
343
- // exclude preview function from caching
344
- {
345
- url: [
346
- /[?&]view=/i,
347
- /[?&]_ab=/i,
348
- /[?&]_fd=/i,
349
- /[?&]preview_theme/i,
350
- ],
351
- },
352
- { cookie: ["preview_theme"] },
353
- {{/if}}
354
- {{#if isPlentymarkets}}
355
-
356
- // Plentymarkets specific:
357
- // blacklist on experimental features cookie
358
- {
359
- cookie: ['PluginSetPreview'],
360
- contentType: ['document'],
361
- },
362
-
363
- // Plentymarkets specific:
364
- // blacklist based on custom cookie (e.g. on user logging in => see loadHandler)
365
- { cookie: ['baqend-speedkit-blacklist'] },
366
- {{/if}}
367
- ],
368
- stripQueryParams: [{
369
- params: [
370
- // Default:
371
- /.*clid$/, // generic Click ID
372
- "AdSet", // Meta Ads (Facebook)
373
- "_ga", // Google Analytics User ID (Universal Analytics)
374
- "_gl", // Google Analytics User ID (GA 4+)
375
- "_klaviyopid", // Klaviyo
376
- "_kx", // Klaviyo
377
- "a8", // A8.net (affiliate marketing)
378
- "ad_id",
379
- "adid",
380
- "adobe_mc", // Adobe Marketing Cloud
381
- "adword",
382
- "at_gd", // Urchin Tracking Module
383
- "awc", // AWIN (former Zanox Affiliate Network)
384
- "brid",
385
- "cjid",
386
- "clickid",
387
- "clickref",
388
- "cstrackid", // ChannelSight
389
- "cto_pld",
390
- "dicbo",
391
- "ds_rl",
392
- "ef_id", // Adobe Advertising Cloud
393
- "epik",
394
- "fb_audience", // Facebook Ads
395
- "gQT",
396
- "gb_clk", // Click tracking
397
- "gtm_debug", // Google Tag Manager
398
- "irclickid",
399
- "kk", // Kelkoo Shopping Search Engine Key
400
- "ldtag_cl", // LINE Ads
401
- "lt_r", // LINE Ads
402
- "msclkid", // Microsoft Click ID
403
- "msockid", // Microsoft Bing
404
- "nsctrid",
405
- "ps_kw", // Paid Search Keyword Tracking
406
- "rdt_cid", // Reddit Ad Click ID
407
- "rtbhc", // RTB House
408
- "s_kwcid", // AMO ID, Adobe Advertising Cloud
409
- "srclt", // LINE Ads
410
- "srsltid", // google search engine
411
- "tblci", // Taboola Click ID
412
- "tduid", // Tradedoubler UID
413
- "trackingtoken",
414
- "ved",
415
- "yj_r", // Yahoo! JAPAN Ads
416
- "zanpid", // AWIN (former Zanox Affiliate Network)
417
- /^(mb|nb|nx|ny)$/,
418
- /^ScCid$/i, // Snapchat Click ID
419
- /^WT\./, // WebTrends
420
- /^[gw]braid$/, // Google's iOS web-to-app campaign measurement
421
- /^_ly_/, // LY Ads
422
- /^affid$/i, // Affiliate ID
423
- /^bv(state|messageType|notificationId|recipientDomain)$/, // Bazaarvoice
424
- /^campaign(_id)?$/,
425
- /^cq_/,
426
- /^dy(IsPreview|SmartId|IsDraft|ExperienceId|VariationId|pPreviewKey|PersistSession|Temp)$/, // Dynamic Yield
427
- /^ecm(Uid|Id)$/i, // Econda ARP / Mailings
428
- /^em_/, // Econda ARP / Mailings
429
- /^et_/,
430
- /^ext(ProvId|Pu|Li|Pm|Cr|Tg|Si|MT|NT|DV|AP)$/,
431
- /^gad(w|_source|_campaignid)?$/, // Google Ads
432
- /^gcl(id|src)$/, // Google Click ID + Source
433
- /^judgeme_/, // Judge.me (review system)
434
- /^klar_/, // getklar.com
435
- /^neocom_/, // Neocom.ai
436
- /^sa_/,
437
- /^saf_/, // Spider AF
438
- /^sc_/, // e.g. Adobe
439
- /^sfmc_/, // Salesforce Marketing Cloud
440
- /^sv(1|_campaign_id)$/,
441
- /^trc_/, // Tracify
442
- /^uslk_/, // Userlike Chatbot
443
- /^utm[_-]/, // Urchin Tracking Module
444
- /^vm(st|track)_id$/,
445
- /^wg(u|expiry)$/, // Webgains Affiliate Network
446
- /^wt_(mc|az|ref|t)$/, // Webtrekk/Mapp Intelligence
447
- {{#if isShopify}}
448
-
449
- // Shopify specific:
450
- "_fid",
451
- "_pos",
452
- "_psq",
453
- "_sid",
454
- "_ss",
455
- "_v",
456
- /^pr_/i, // Product Recommendation
457
- {{/if}}
458
- {{#if isOxid}}
459
-
460
- // OXID specific:
461
- "cnid",
462
- "force_sid",
463
- {{/if}}
464
-
465
- // Site-specific:
466
- // TODO: extend or remove during query param analysis
467
- ],
468
- }],
469
- };
470
-
471
- //================================================================================
472
- // Utility Functions
473
- //================================================================================
474
-
475
- function getEnabledHosts(enabledHostsConfigs) {
476
- var allHosts = [];
477
- enabledHostsConfigs.forEach(function (enabledHostsConfig) {
478
- allHosts = allHosts.concat(enabledHostsConfig.hosts);
479
- });
480
-
481
- // Return unique array ("set") of all enabled hosts
482
- return allHosts.filter(function (value, index, self) {
483
- return self.indexOf(value) === index;
484
- });
485
- }
486
-
487
- function getCurrentHostConfig(enabledHostsConfigs) {
488
- var currentHost = location.hostname;
489
- var defaultSplit = 0;
490
- var defaultSplitTestId = "0vs100";
491
- var foundHostConfig;
492
-
493
- // Lookup for matching enabled hosts config
494
- for (var i = 0; i < enabledHostsConfigs.length; i++) {
495
- {{#if subRouteScope}}
496
- if (
497
- enabledHostsConfigs[i].hosts.indexOf(currentHost) !== -1 &&
498
- isCurrentScopeEnabled(enabledHostsConfigs[i].scopes)
499
- ) {
500
- {{else}}
501
- if (enabledHostsConfigs[i].hosts.indexOf(currentHost) !== -1) {
502
- {{/if}}
503
- foundHostConfig = enabledHostsConfigs[i];
504
- break; // Break out of the loop once the config related to the host is found
505
- }
506
- }
507
-
508
- if (foundHostConfig) {
509
- // Provide fallback split values if incomplete or incorrect
510
- if (
511
- !(foundHostConfig.split >= 0 && foundHostConfig.split <= 1) ||
512
- !foundHostConfig.splitTestId
513
- ) {
514
- foundHostConfig.split = defaultSplit;
515
- foundHostConfig.splitTestId = defaultSplitTestId;
516
- }
517
- foundHostConfig.enabled = true;
518
- return foundHostConfig;
519
- } else {
520
- return {
521
- enabled: false,
522
- split: defaultSplit,
523
- splitTestId: defaultSplitTestId,
524
- };
525
- }
526
- }
527
- {{#if subRouteScope}}
528
-
529
- function isCurrentScopeEnabled(enabledScopes) {
530
- // Check if enabled scopes are provided
531
- if (!enabledScopes) {
532
- // If not: consider current scope as enabled due to no scoping
533
- return true;
534
- }
535
-
536
- // Check if enabled scopes are provided as array
537
- if (!Array.isArray(enabledScopes)) {
538
- // If not: consider current scope as disabled due to faulty scoping
539
- return false;
540
- }
541
-
542
- // Test if current scope matches enabled scopes
543
- var pattern = "^/(" + enabledScopes.join("|") + ")/";
544
- var regex = new RegExp(pattern);
545
- return regex.test(location.pathname);
546
- }
547
- {{/if}}
548
- })();
@@ -1,38 +0,0 @@
1
- {
2
- "production": {
3
- "_meta": {
4
- "shopSystem":
5
- {{#if shopSystemName}}
6
- "{{shopSystemName}}"
7
- {{else}}
8
- "TODO: enter name of system in use"
9
- {{/if}}
10
- },
11
- "app": "{{appName}}",
12
- "domain": "{{production.host}}",
13
- "origins": [
14
- "https://{{production.host}}"
15
- ],
16
- {{#if isShopify}}
17
- "swPath": "/apps/speed-kit/sw.js",
18
- {{else}}
19
- "swPath": "/wrapper-sw.js",
20
- {{/if}}
21
- {{#if subRouteScope}}
22
- "scope": "/{{subRouteScope}}/",
23
- {{else}}
24
- "scope": "/",
25
- {{/if}}
26
- "forceInstall": {{production.forceInstall}}
27
- }
28
- {{#if staging.host}},
29
- "staging": {
30
- "name": "staging",
31
- "domain": "{{staging.host}}",
32
- "origins": [
33
- "https://{{staging.host}}"
34
- ],
35
- "forceInstall": {{staging.forceInstall}}
36
- }
37
- {{/if}}
38
- }