Skip to content

Commit a015138

Browse files
authored
Print the dlsource in the logs (#246)
1 parent 4b97c03 commit a015138

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

stubservice/stubhandlers/stubhandler_test.go

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,14 +156,15 @@ func TestRedirectFull(t *testing.T) {
156156
)
157157

158158
for _, params := range []struct {
159-
AttributionCode string
160-
Referer string
161-
ExpectedLocation string
162-
ExpectedCode string
163-
SkipDownloadLogChecks bool
164-
ExpectedClientID string
165-
ExpectedClientIDGA4 string
166-
ExpectedSessionID string
159+
AttributionCode string
160+
Referer string
161+
ExpectedLocation string
162+
ExpectedCode string
163+
SkipDownloadLogChecks bool
164+
ExpectedClientID string
165+
ExpectedClientIDGA4 string
166+
ExpectedSessionID string
167+
ExpectedDownloadSource string
167168
}{
168169
{
169170
AttributionCode: `campaign=%28not+set%29&content=%28not+set%29&medium=organic&source=www.google.com`,
@@ -261,6 +262,14 @@ func TestRedirectFull(t *testing.T) {
261262
ExpectedCode: "",
262263
SkipDownloadLogChecks: true,
263264
},
265+
266+
{
267+
AttributionCode: `campaign=%28not+set%29&content=%28not+set%29&medium=organic&source=www.google.com&dlsource=fxdotcom`,
268+
Referer: "",
269+
ExpectedLocation: `/cdn/builds/firefox-stub/en-US/win/`,
270+
ExpectedCode: `campaign%3D%2528not%2Bset%2529%26content%3D%2528not%2Bset%2529%26dlsource%3Dfxdotcom%26dltoken%3D[\w\d-]+%26medium%3Dorganic%26source%3Dwww.google.com`,
271+
ExpectedDownloadSource: "fxdotcom",
272+
},
264273
} {
265274
testHook.Reset()
266275

@@ -343,6 +352,11 @@ func TestRedirectFull(t *testing.T) {
343352
t.Errorf("Expected session_id: %s, got: %v", params.ExpectedSessionID, sessionID)
344353
}
345354

355+
downloadSource := entry.Data["dlsource"]
356+
if downloadSource != params.ExpectedDownloadSource {
357+
t.Errorf("Expected dlsource: %s, got: %v", params.ExpectedDownloadSource, downloadSource)
358+
}
359+
346360
product := entry.Data["product"]
347361
if entry.Data["product"] != "firefox-stub" {
348362
t.Errorf("Expected product: firefox-stub, got: %v", product)

stubservice/stubhandlers/stubservice.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ func (s *stubService) ServeHTTP(w http.ResponseWriter, req *http.Request) {
5858
"client_id": code.ClientID,
5959
"client_id_ga4": code.ClientIDGA4,
6060
"session_id": code.SessionID,
61+
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1972893
62+
"dlsource": code.DownloadSource,
6163
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1896957
6264
"product": query.Get("product"),
6365
"os": query.Get("os"),
@@ -108,6 +110,8 @@ func (s *stubService) ServeHTTP(w http.ResponseWriter, req *http.Request) {
108110
"client_id": code.ClientID,
109111
"client_id_ga4": code.ClientIDGA4,
110112
"session_id": code.SessionID,
113+
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1972893
114+
"dlsource": code.DownloadSource,
111115
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1896957
112116
"product": query.Get("product"),
113117
"os": query.Get("os"),

0 commit comments

Comments
 (0)