Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

[Full changelog](https://github.com/mozilla/glean.js/compare/v5.0.2...main)

* [#1970](https://github.com/mozilla/glean.js/pull/1970): Add `window.Glean.debugSession` API for automatically opening a link to the Debug Ping Viewer with your current session selected.

# v5.0.2 (2024-05-23)

[Full changelog](https://github.com/mozilla/glean.js/compare/v5.0.1...v5.0.2)
Expand Down
3 changes: 2 additions & 1 deletion automation/compat/tests/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export async function runWebTest(driver) {
window.Glean &&
window.Glean.setDebugViewTag &&
window.Glean.setLogPings &&
window.Glean.setSourceTags
window.Glean.setSourceTags &&
window.Glean.debugSession
) {
return true;
}
Expand Down
3 changes: 3 additions & 0 deletions documentation/src/content/docs/debugging/browser.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ window.Glean.setDebugViewTag("example-tag");

// Tag pings with source tags.
window.Glean.setSourceTags(["my-tag", "your-tag", "our-tag"]);

// Open a new tab in the browser showing the Debug Ping Viewer with the active session in focus.
window.Glean.debugSession();
```

## Try it out
Expand Down
16 changes: 16 additions & 0 deletions glean/src/core/glean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ declare global {
setLogPings: (flag: boolean) => void;
setDebugViewTag: (value: string) => void;
setSourceTags: (value: string[]) => void;
debugSession: () => void;
};
}
}
Expand Down Expand Up @@ -558,6 +559,21 @@ if (
"Pings will be given the specified tags until the tab is closed."
);
},
debugSession: () => {
const sessionId = Context.metricsDatabase.getMetric(
CLIENT_INFO_STORAGE,
Context.coreMetrics.sessionId
);

if (!!sessionId && typeof sessionId === "string" && !!Context.config.debugViewTag) {
window.open(
`https://debug-ping-preview.firebaseapp.com/stream/${Context.config.debugViewTag}#${sessionId}`,
"_blank"
);
} else {
console.info("You must set a debug tag via `window.Glean.setDebugViewTag` before debugging your session.");
}
}
};
}

Expand Down