Skip to content

Commit f4c9b0e

Browse files
authored
Merge pull request #1755 from rosahbruno/1849862-url-set-fix
2 parents 0a6e781 + 9c0c0b6 commit f4c9b0e

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[Full changelog](https://github.com/mozilla/glean.js/compare/v2.0.1...main)
44

5+
* [#1755](https://github.com/mozilla/glean.js/pull/1755): Add sync check to `set` function for the URL metric.
6+
57
# v2.0.1 (2023-08-11)
68

79
[Full changelog](https://github.com/mozilla/glean.js/compare/v2.0.0...v2.0.1)

glean/src/core/metrics/types/url.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ class InternalUrlMetricType extends MetricType {
9090
}
9191

9292
/// SHARED ///
93+
set(url: string): void {
94+
if (Context.isPlatformSync()) {
95+
this.setSync(url);
96+
} else {
97+
this.setAsync(url);
98+
}
99+
}
100+
93101
setUrl(url: URL): void {
94102
if (Context.isPlatformSync()) {
95103
this.setSync(url.toString());
@@ -100,10 +108,6 @@ class InternalUrlMetricType extends MetricType {
100108

101109
/// ASYNC ///
102110
setAsync(url: string) {
103-
this.set(url);
104-
}
105-
106-
set(url: string): void {
107111
Context.dispatcher.launch(async () => {
108112
if (!this.shouldRecord(Context.uploadEnabled)) {
109113
return;

0 commit comments

Comments
 (0)