export function getEnvironmentDataFromEnvironment()

in src/environment-data-provider.ts [16:35]


export function getEnvironmentDataFromEnvironment(): EnvironmentData {
    // We use the global "axe" object to detect this rather than saying
    // "import { version } from 'axe-core'"" because we want to pick up the
    // version of axe that is invoking us, which will usually be a *peer*
    // dependency, rather than using the version that axe-sarif-converter built
    // against as a child dependency.
    const globalAxeVersion = (global as any).axe && (global as any).axe.version;
    if (!globalAxeVersion) {
        throw Error(
            'Could not infer axe version from global axe object. Are you running from the context of an axe reporter?',
        );
    }

    return {
        timestamp: new Date().toISOString(),
        targetPageUrl: window.location.href,
        targetPageTitle: document.title,
        axeVersion: globalAxeVersion,
    };
}