Skip to content

Commit 8c5aaf6

Browse files
Patch fathom analytics (#3292)
* try to patch fathom's script el to support SPAs * Update code samples [skip ci] * add timeout, ensure multiple attempts at adding, limit var scope
1 parent 3143cf5 commit 8c5aaf6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

fathom-data-attr.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(function(){
2+
let attempts = 0;
3+
4+
function addDataAttr() {
5+
const spaValue = "auto";
6+
const el = document.getElementById("fathom-script");
7+
attempts += 1;
8+
9+
if (!el && attempts < 10) {
10+
window.setTimeout(addDataAttr, 100);
11+
return;
12+
}
13+
14+
const dataSpaValue = el.dataset.spa;
15+
16+
if (dataSpaValue === undefined) {
17+
el.dataset.spa = spaValue;
18+
}
19+
}
20+
21+
addDataAttr();
22+
})();

snippets/samples/code_samples_update_filterable_attributes_1.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ curl \
1111
"attributePatterns": ["*_ratings"],
1212
"features": {
1313
"facetSearch": false,
14-
"filters": {
14+
"filter": {
1515
"equality": true,
1616
"comparison": false
1717
}

0 commit comments

Comments
 (0)