@embrace-io/web-sdk
Version:
32 lines (31 loc) • 1.08 kB
JavaScript
import { KEY_APP_SURFACE_LABEL, KEY_EMB_PAGE_ID, KEY_EMB_PAGE_PATH } from "../../constants/attributes.js";
//#region src/processors/PageSpanProcessor/PageSpanProcessor.ts
var PageSpanProcessor = class {
_pageManager;
constructor({ pageManager }) {
this._pageManager = pageManager;
}
forceFlush() {
return Promise.resolve(void 0);
}
onEnding(span) {
if (!span.attributes["app.surface.name"] || !span.attributes["app.surface.id"]) {
const currentRoute = this._pageManager.getCurrentRoute();
const currentPageId = this._pageManager.getCurrentPageId();
if (currentRoute && currentPageId) {
span.attributes[KEY_EMB_PAGE_PATH] = currentRoute.path;
span.attributes[KEY_EMB_PAGE_ID] = currentPageId;
}
}
const appSurfaceLabel = this._pageManager.getPageLabel();
if (appSurfaceLabel && !span.attributes["app.surface.label"]) span.attributes[KEY_APP_SURFACE_LABEL] = appSurfaceLabel;
}
onStart() {}
onEnd() {}
shutdown() {
return Promise.resolve(void 0);
}
};
//#endregion
export { PageSpanProcessor };
//# sourceMappingURL=PageSpanProcessor.js.map