@tracelog/capture-web 2.3.0 → 2.3.1
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 +7 -0
- package/README.md +2 -2
- package/dist/tracelog.esm.js +35 -5
- package/dist/tracelog.iife.js +35 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -18,6 +18,13 @@ patch, and neither requires reading your code.
|
|
|
18
18
|
Entries after 1.0.0 are drafted from the commits that touched this package and
|
|
19
19
|
edited before release.
|
|
20
20
|
|
|
21
|
+
## [2.3.1](https://github.com/nacorga/tracelog-sdk/compare/capture-web@2.3.0...capture-web@2.3.1) (2026-10-26)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
* **capture-web:** a deferred runtime rules out the Meta form it could not have missed ([aa0eb2b](https://github.com/nacorga/tracelog-sdk/commit/aa0eb2b3506d0ba7bfb9549e9a5f851af89b4577))
|
|
27
|
+
|
|
21
28
|
## [2.3.0](https://github.com/nacorga/tracelog-sdk/compare/capture-web@2.2.0...capture-web@2.3.0) (2026-10-17)
|
|
22
29
|
|
|
23
30
|
|
package/README.md
CHANGED
|
@@ -22,13 +22,13 @@ as they are served.
|
|
|
22
22
|
<!-- x-release-please-start-version -->
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
npm install --save-exact @tracelog/capture-web@2.3.
|
|
25
|
+
npm install --save-exact @tracelog/capture-web@2.3.1
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
Without a build step, the same runtime as a script tag:
|
|
29
29
|
|
|
30
30
|
```html
|
|
31
|
-
<script src="https://cdn.tracelog.io/v/2.3.
|
|
31
|
+
<script src="https://cdn.tracelog.io/v/2.3.1/tracelog.js"></script>
|
|
32
32
|
```
|
|
33
33
|
|
|
34
34
|
<!-- x-release-please-end -->
|
package/dist/tracelog.esm.js
CHANGED
|
@@ -644,6 +644,7 @@ function instantOfEntry(startTime) {
|
|
|
644
644
|
return new Date(systemClock.now().getTime() - (performance.now() - startTime));
|
|
645
645
|
}
|
|
646
646
|
const TAG_SIGHTING_MEMORY = 100;
|
|
647
|
+
const RESOURCE_TIMING_BUFFER = 250;
|
|
647
648
|
const ga4IdPattern = new RegExp(TAG_ID_PATTERNS.ga4);
|
|
648
649
|
const metaIdPattern = new RegExp(TAG_ID_PATTERNS.meta);
|
|
649
650
|
const adsIdPattern = new RegExp(TAG_ID_PATTERNS.google_ads);
|
|
@@ -654,6 +655,16 @@ function onMetaEndpoint(url) {
|
|
|
654
655
|
return ((host === "facebook.com" || host.endsWith(".facebook.com")) &&
|
|
655
656
|
(url.pathname === "/tr" || url.pathname === "/tr/"));
|
|
656
657
|
}
|
|
658
|
+
function isMetaConfiguration(url) {
|
|
659
|
+
try {
|
|
660
|
+
const parsed = new URL(url);
|
|
661
|
+
return (parsed.hostname === "connect.facebook.net" &&
|
|
662
|
+
parsed.pathname.startsWith("/signals/config/"));
|
|
663
|
+
}
|
|
664
|
+
catch {
|
|
665
|
+
return false;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
657
668
|
function metaMatch(id, event) {
|
|
658
669
|
return id !== null && metaIdPattern.test(id)
|
|
659
670
|
? {
|
|
@@ -716,6 +727,9 @@ function createTagSightingPort() {
|
|
|
716
727
|
let observer;
|
|
717
728
|
let bodyObserver;
|
|
718
729
|
let watchedFrom;
|
|
730
|
+
let metaFrom = Number.POSITIVE_INFINITY;
|
|
731
|
+
let startedAt = 0;
|
|
732
|
+
let buffered = 0;
|
|
719
733
|
let matches = [];
|
|
720
734
|
function remember(match, at) {
|
|
721
735
|
if (match === null)
|
|
@@ -729,7 +743,19 @@ function createTagSightingPort() {
|
|
|
729
743
|
}
|
|
730
744
|
function record(entries) {
|
|
731
745
|
for (const entry of entries) {
|
|
732
|
-
|
|
746
|
+
if (entry.startTime < startedAt)
|
|
747
|
+
buffered += 1;
|
|
748
|
+
const at = instantOfEntry(entry.startTime).getTime();
|
|
749
|
+
const match = matchTagRequest(entry.name);
|
|
750
|
+
remember(match, at);
|
|
751
|
+
const meta = match !== null &&
|
|
752
|
+
("unread" in match ? match.unread : match.sighting.kind) === "meta";
|
|
753
|
+
if (meta) {
|
|
754
|
+
metaFrom = Math.min(metaFrom, at);
|
|
755
|
+
}
|
|
756
|
+
else if (isMetaConfiguration(entry.name)) {
|
|
757
|
+
metaFrom = Math.min(metaFrom, instantOfEntry(entry.startTime + entry.duration).getTime());
|
|
758
|
+
}
|
|
733
759
|
}
|
|
734
760
|
}
|
|
735
761
|
function watchBody() {
|
|
@@ -796,6 +822,7 @@ function createTagSightingPort() {
|
|
|
796
822
|
return;
|
|
797
823
|
}
|
|
798
824
|
const created = new Observer((list) => record(list.getEntries()));
|
|
825
|
+
startedAt = performance.now();
|
|
799
826
|
created.observe({ type: "resource", buffered: true });
|
|
800
827
|
observer = created;
|
|
801
828
|
}
|
|
@@ -811,6 +838,8 @@ function createTagSightingPort() {
|
|
|
811
838
|
bodyObserver?.disconnect();
|
|
812
839
|
bodyObserver = undefined;
|
|
813
840
|
watchedFrom = undefined;
|
|
841
|
+
metaFrom = Number.POSITIVE_INFINITY;
|
|
842
|
+
buffered = 0;
|
|
814
843
|
matches = [];
|
|
815
844
|
},
|
|
816
845
|
observing() {
|
|
@@ -836,11 +865,12 @@ function createTagSightingPort() {
|
|
|
836
865
|
},
|
|
837
866
|
unreadAround(at) {
|
|
838
867
|
const found = within(at);
|
|
839
|
-
if (found === null ||
|
|
840
|
-
|
|
841
|
-
|
|
868
|
+
if (found === null || watchedFrom === undefined)
|
|
869
|
+
return null;
|
|
870
|
+
const missedNone = watchedFrom <= at.getTime() - TAG_SIGHTING_BEFORE_MS ||
|
|
871
|
+
(watchedFrom <= metaFrom && buffered < RESOURCE_TIMING_BUFFER);
|
|
872
|
+
if (!missedNone)
|
|
842
873
|
return null;
|
|
843
|
-
}
|
|
844
874
|
return tagSightingKinds.filter((kind) => found.some((match) => "unread" in match && match.unread === kind));
|
|
845
875
|
},
|
|
846
876
|
};
|
package/dist/tracelog.iife.js
CHANGED
|
@@ -645,6 +645,7 @@ function instantOfEntry(startTime) {
|
|
|
645
645
|
return new Date(systemClock.now().getTime() - (performance.now() - startTime));
|
|
646
646
|
}
|
|
647
647
|
const TAG_SIGHTING_MEMORY = 100;
|
|
648
|
+
const RESOURCE_TIMING_BUFFER = 250;
|
|
648
649
|
const ga4IdPattern = new RegExp(TAG_ID_PATTERNS.ga4);
|
|
649
650
|
const metaIdPattern = new RegExp(TAG_ID_PATTERNS.meta);
|
|
650
651
|
const adsIdPattern = new RegExp(TAG_ID_PATTERNS.google_ads);
|
|
@@ -655,6 +656,16 @@ function onMetaEndpoint(url) {
|
|
|
655
656
|
return ((host === "facebook.com" || host.endsWith(".facebook.com")) &&
|
|
656
657
|
(url.pathname === "/tr" || url.pathname === "/tr/"));
|
|
657
658
|
}
|
|
659
|
+
function isMetaConfiguration(url) {
|
|
660
|
+
try {
|
|
661
|
+
const parsed = new URL(url);
|
|
662
|
+
return (parsed.hostname === "connect.facebook.net" &&
|
|
663
|
+
parsed.pathname.startsWith("/signals/config/"));
|
|
664
|
+
}
|
|
665
|
+
catch {
|
|
666
|
+
return false;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
658
669
|
function metaMatch(id, event) {
|
|
659
670
|
return id !== null && metaIdPattern.test(id)
|
|
660
671
|
? {
|
|
@@ -717,6 +728,9 @@ function createTagSightingPort() {
|
|
|
717
728
|
let observer;
|
|
718
729
|
let bodyObserver;
|
|
719
730
|
let watchedFrom;
|
|
731
|
+
let metaFrom = Number.POSITIVE_INFINITY;
|
|
732
|
+
let startedAt = 0;
|
|
733
|
+
let buffered = 0;
|
|
720
734
|
let matches = [];
|
|
721
735
|
function remember(match, at) {
|
|
722
736
|
if (match === null)
|
|
@@ -730,7 +744,19 @@ function createTagSightingPort() {
|
|
|
730
744
|
}
|
|
731
745
|
function record(entries) {
|
|
732
746
|
for (const entry of entries) {
|
|
733
|
-
|
|
747
|
+
if (entry.startTime < startedAt)
|
|
748
|
+
buffered += 1;
|
|
749
|
+
const at = instantOfEntry(entry.startTime).getTime();
|
|
750
|
+
const match = matchTagRequest(entry.name);
|
|
751
|
+
remember(match, at);
|
|
752
|
+
const meta = match !== null &&
|
|
753
|
+
("unread" in match ? match.unread : match.sighting.kind) === "meta";
|
|
754
|
+
if (meta) {
|
|
755
|
+
metaFrom = Math.min(metaFrom, at);
|
|
756
|
+
}
|
|
757
|
+
else if (isMetaConfiguration(entry.name)) {
|
|
758
|
+
metaFrom = Math.min(metaFrom, instantOfEntry(entry.startTime + entry.duration).getTime());
|
|
759
|
+
}
|
|
734
760
|
}
|
|
735
761
|
}
|
|
736
762
|
function watchBody() {
|
|
@@ -797,6 +823,7 @@ function createTagSightingPort() {
|
|
|
797
823
|
return;
|
|
798
824
|
}
|
|
799
825
|
const created = new Observer((list) => record(list.getEntries()));
|
|
826
|
+
startedAt = performance.now();
|
|
800
827
|
created.observe({ type: "resource", buffered: true });
|
|
801
828
|
observer = created;
|
|
802
829
|
}
|
|
@@ -812,6 +839,8 @@ function createTagSightingPort() {
|
|
|
812
839
|
bodyObserver?.disconnect();
|
|
813
840
|
bodyObserver = undefined;
|
|
814
841
|
watchedFrom = undefined;
|
|
842
|
+
metaFrom = Number.POSITIVE_INFINITY;
|
|
843
|
+
buffered = 0;
|
|
815
844
|
matches = [];
|
|
816
845
|
},
|
|
817
846
|
observing() {
|
|
@@ -837,11 +866,12 @@ function createTagSightingPort() {
|
|
|
837
866
|
},
|
|
838
867
|
unreadAround(at) {
|
|
839
868
|
const found = within(at);
|
|
840
|
-
if (found === null ||
|
|
841
|
-
|
|
842
|
-
|
|
869
|
+
if (found === null || watchedFrom === undefined)
|
|
870
|
+
return null;
|
|
871
|
+
const missedNone = watchedFrom <= at.getTime() - TAG_SIGHTING_BEFORE_MS ||
|
|
872
|
+
(watchedFrom <= metaFrom && buffered < RESOURCE_TIMING_BUFFER);
|
|
873
|
+
if (!missedNone)
|
|
843
874
|
return null;
|
|
844
|
-
}
|
|
845
875
|
return tagSightingKinds.filter((kind) => found.some((match) => "unread" in match && match.unread === kind));
|
|
846
876
|
},
|
|
847
877
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tracelog/capture-web",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "The TraceLog browser capture runtime: consent-first, pinned per version.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"conversion",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"typescript": "5.9.3",
|
|
49
|
-
"@tracelog/capture-core": "2.3.
|
|
50
|
-
"@tracelog/event-contract": "2.3.
|
|
49
|
+
"@tracelog/capture-core": "2.3.1",
|
|
50
|
+
"@tracelog/event-contract": "2.3.1"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsc -p tsconfig.build.json && node build.mjs",
|