@decocms/blocks 7.62.3 → 7.62.4
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/package.json +1 -1
- package/src/sdk/urlUtils.test.ts +34 -0
- package/src/sdk/urlUtils.ts +21 -0
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { cleanPathForCacheKey, isTrackingParam } from "./urlUtils";
|
|
3
|
+
|
|
4
|
+
describe("tracking params that used to fragment the cache key", () => {
|
|
5
|
+
// Each of these was measured missing the edge cache on every route probed on a
|
|
6
|
+
// production storefront, because it was absent from UTM_PARAMS.
|
|
7
|
+
const cases = [
|
|
8
|
+
["GA4 campaign id", "utm_id"],
|
|
9
|
+
["GA4 source platform", "utm_source_platform"],
|
|
10
|
+
["Google Ads source", "gad_source"],
|
|
11
|
+
["Google Ads iOS click id", "gbraid"],
|
|
12
|
+
["Google Ads web-to-app click id", "wbraid"],
|
|
13
|
+
["GA cross-domain linker", "_gl"],
|
|
14
|
+
["Instagram", "igshid"],
|
|
15
|
+
["Pinterest", "epik"],
|
|
16
|
+
["Marketo", "mkt_tok"],
|
|
17
|
+
["Yandex", "yclid"],
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
for (const [label, param] of cases) {
|
|
21
|
+
it(`strips ${label} (${param})`, () => {
|
|
22
|
+
expect(isTrackingParam(param)).toBe(true);
|
|
23
|
+
expect(cleanPathForCacheKey(`https://x.com/aneis?color=ouro&${param}=abc`)).toBe(
|
|
24
|
+
"/aneis?color=ouro",
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
it("still keeps functional params", () => {
|
|
30
|
+
for (const p of ["page", "order", "map", "PS", "filter.color", "skuId", "q"]) {
|
|
31
|
+
expect(isTrackingParam(p)).toBe(false);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
package/src/sdk/urlUtils.ts
CHANGED
|
@@ -25,6 +25,27 @@ const UTM_PARAMS = new Set([
|
|
|
25
25
|
"mc_eid",
|
|
26
26
|
"ttclid",
|
|
27
27
|
"srsltid",
|
|
28
|
+
// GA4's newer campaign params. The five classic `utm_*` above predate them,
|
|
29
|
+
// so a GA4-tagged campaign was still fragmenting the cache key.
|
|
30
|
+
"utm_id",
|
|
31
|
+
"utm_source_platform",
|
|
32
|
+
"utm_creative_format",
|
|
33
|
+
"utm_marketing_tactic",
|
|
34
|
+
// Google Ads click ids that replaced bare `gclid` for privacy-restricted
|
|
35
|
+
// traffic (iOS/Safari), plus the source tag now appended to essentially every
|
|
36
|
+
// Google Ads click. Measured on a production storefront: each of these missed
|
|
37
|
+
// the edge cache on 3/3 routes probed, deterministically.
|
|
38
|
+
"gad_source",
|
|
39
|
+
"gad_campaignid",
|
|
40
|
+
"gbraid",
|
|
41
|
+
"wbraid",
|
|
42
|
+
// Google Analytics cross-domain linker. Sites already strip this by hand in
|
|
43
|
+
// client code, which is the tell that it shows up in real URLs.
|
|
44
|
+
"_gl",
|
|
45
|
+
"igshid",
|
|
46
|
+
"epik",
|
|
47
|
+
"mkt_tok",
|
|
48
|
+
"yclid",
|
|
28
49
|
]);
|
|
29
50
|
|
|
30
51
|
/**
|