UNPKG

@embrace-io/web-sdk

Version:
36 lines (35 loc) 1.69 kB
import { KEY_EMB_APP_INSTANCE_ID } from "../constants/attributes.js"; import { EMBRACE_SERVICE_NAME, SDK_VERSION } from "./constants/index.js"; import { getAppInstanceId } from "./appInstanceId.js"; import { ATTR_SERVICE_NAME, ATTR_TELEMETRY_SDK_LANGUAGE, ATTR_TELEMETRY_SDK_NAME, ATTR_TELEMETRY_SDK_VERSION, ATTR_USER_AGENT_ORIGINAL } from "@opentelemetry/semantic-conventions"; import { resourceFromAttributes } from "@opentelemetry/resources"; //#region src/resources/webSdkResource.ts /** * Returns resource attributes that users are allowed to override via the `resource` option in `initSDK`. * These defaults are applied first in the merge chain so user-provided values take precedence. */ const getWebSDKOverridableResource = () => { return resourceFromAttributes({ [ATTR_SERVICE_NAME]: EMBRACE_SERVICE_NAME }); }; /** * Returns SDK resource attributes that must not be overridden by user-provided resources. * These are applied last in the merge chain so they always take precedence. */ const getWebSDKResource = ({ diagLogger, appVersion, tabStorage }) => { return resourceFromAttributes({ [ATTR_TELEMETRY_SDK_NAME]: EMBRACE_SERVICE_NAME, app_version: appVersion, app_framework: 1, sdk_version: SDK_VERSION, [ATTR_TELEMETRY_SDK_VERSION]: SDK_VERSION, sdk_simple_version: 1, sdk_platform: "web", [ATTR_TELEMETRY_SDK_LANGUAGE]: "webjs", [KEY_EMB_APP_INSTANCE_ID]: getAppInstanceId(tabStorage, diagLogger), [ATTR_USER_AGENT_ORIGINAL]: window.navigator.userAgent, screen_resolution: `${window.screen.width}x${window.screen.height}` }); }; //#endregion export { getWebSDKOverridableResource, getWebSDKResource }; //# sourceMappingURL=webSdkResource.js.map