替换telemetry遥测的网址:xxx.data.microsoft.com为0.0.0.0,注意node_modules的包里面也可能会含有,所以yarn步骤之后需要用脚本替换.

This commit is contained in:
chriswang521 2024-05-10 14:03:20 +08:00 committed by wangpenglong
parent bfcae9e5a5
commit e2de66fd31
3 changed files with 69 additions and 2 deletions

View File

@ -27,6 +27,8 @@ export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
# CHILD_CONCURRENCY=1 yarn --frozen-lockfile --check-files --network-timeout 180000
yarn --frozen-lockfile --check-files --network-timeout 180000
#关闭telemetrynode_modules也会有地址
./close_telemetry.sh
#检查
yarn monaco-compile-check
yarn valid-layers-check

65
close_telemetry.sh Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091,SC2016
set -ex
# list of urls to match:
# - mobile.events.data.microsoft.com
# - vortex.data.microsoft.com
SEARCH="\.data\.microsoft\.com"
REPLACEMENT="s|//[^/]+\.data\.microsoft\.com|//0\.0\.0\.0|g"
exists() { type -t "$1" &> /dev/null; }
is_gnu_sed () {
sed --version &> /dev/null
}
replace () {
echo "${1}"
if is_gnu_sed; then
sed -i -E "${1}" "${2}"
else
sed -i '' -E "${1}" "${2}"
fi
}
if ! exists gsed; then
if is_gnu_sed; then
function gsed() {
sed -i -E "$@"
}
else
function gsed() {
sed -i '' -E "$@"
}
fi
fi
if is_gnu_sed; then
replace_with_debug () {
echo "found: ${2}"
sed -i -E "${1}" "${2}"
}
else
replace_with_debug () {
echo "found: ${2}"
sed -i '' -E "${1}" "${2}"
}
fi
export -f replace_with_debug
d1=$( date +%s )
arch=$(uname -m)
if [[ ${arch} == "x86_64" ]]; then
./node_modules/@vscode/ripgrep/bin/rg --no-ignore -l "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
else
grep -rl --exclude-dir=.git -E "${SEARCH}" . | xargs -I {} bash -c 'replace_with_debug "${1}" "{}"' _ "${REPLACEMENT}"
fi
d2=$( date +%s )
echo "undo_telemetry: $((d2 - d1))s"

View File

@ -18,8 +18,8 @@ export interface IAppInsightsCore {
unload(isAsync: boolean, unloadComplete: (unloadState: ITelemetryUnloadState) => void): void;
}
const endpointUrl = 'https://mobile.events.data.microsoft.com/OneCollector/1.0';
const endpointHealthUrl = 'https://mobile.events.data.microsoft.com/ping';
const endpointUrl = 'https://0.0.0.0/OneCollector/1.0';
const endpointHealthUrl = 'https://0.0.0.0/ping';
async function getClient(instrumentationKey: string, addInternalFlag?: boolean, xhrOverride?: IXHROverride): Promise<IAppInsightsCore> {
const oneDs = await importAMDNodeModule<typeof import('@microsoft/1ds-core-js')>('@microsoft/1ds-core-js', 'dist/ms.core.js');