From 6f71ca3a3056f22e3c2adeb9b9d74a032f28e713 Mon Sep 17 00:00:00 2001 From: BidishaMS <97606074+BidishaMS@users.noreply.github.com> Date: Tue, 6 Feb 2024 20:58:16 +0530 Subject: [PATCH] added region using build time (#825) --- gulpfile.mjs | 12 ++++++++++++ src/common/OneDSLoggerTelemetry/oneDSLogger.ts | 9 +++++---- src/common/telemetry/collectorEndpointProd.ts | 6 ++++++ src/common/telemetry/collectorEndpointTip.ts | 6 ++++++ 4 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 src/common/telemetry/collectorEndpointProd.ts create mode 100644 src/common/telemetry/collectorEndpointTip.ts diff --git a/gulpfile.mjs b/gulpfile.mjs index 87af89eb..d46c5fe0 100644 --- a/gulpfile.mjs +++ b/gulpfile.mjs @@ -64,6 +64,17 @@ function setTelemetryTarget() { .pipe(gulp.dest(path.join('src', 'common', 'telemetry-generated'))); } +function setCollectorEndpoint() { + const collectorEndpointSource = isOfficialBuild + ? 'src/common/telemetry/collectorEndpointProd.ts' + : 'src/common/telemetry/collectorEndpointTip.ts'; + + return gulp + .src(collectorEndpointSource) + .pipe(rename('collectorEndpointConfiguration.ts')) + .pipe(gulp.dest(path.join('src', 'common', 'telemetry-generated'))); +} + function compile() { return gulp @@ -345,6 +356,7 @@ const recompile = gulp.series( translationsExport, translationsImport, setTelemetryTarget, + setCollectorEndpoint, compile, compileWeb, compileWorker, diff --git a/src/common/OneDSLoggerTelemetry/oneDSLogger.ts b/src/common/OneDSLoggerTelemetry/oneDSLogger.ts index a7cb8d30..a6477ab8 100644 --- a/src/common/OneDSLoggerTelemetry/oneDSLogger.ts +++ b/src/common/OneDSLoggerTelemetry/oneDSLogger.ts @@ -15,6 +15,7 @@ import {getExtensionType, getExtensionVersion} from "../../common/Utils"; import { EXTENSION_ID } from "../../client/constants"; import {OneDSCollectorEventName} from "./EventContants"; import { telemetryEventNames } from "../../web/client/telemetry/constants"; +import { collectorEndpointUrl } from "../telemetry-generated/collectorEndpointConfiguration"; interface IInstrumentationSettings { endpointURL: string; @@ -133,7 +134,7 @@ export class OneDSLogger implements ITelemetryLogger{ private static getInstrumentationSettings(geo?:string): IInstrumentationSettings { const region:string = "test"; // TODO: Remove it from here and replace it with value getting from build. Check gulp.mjs (setTelemetryTarget) const instrumentationSettings:IInstrumentationSettings = { - endpointURL: 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/', + endpointURL: collectorEndpointUrl, instrumentationKey: 'bd47fc8d971f4283a6686ec46fd48782-bdef6c1c-75ab-417c-a1f7-8bbe21e12da6-7708' }; switch (region) { @@ -145,11 +146,11 @@ export class OneDSLogger implements ITelemetryLogger{ case 'preview': switch (geo) { case 'eu': - instrumentationSettings.endpointURL = '' //prod endpoint; + instrumentationSettings.endpointURL =collectorEndpointUrl, instrumentationSettings.instrumentationKey = '' //prod key; break; default: - instrumentationSettings.endpointURL = '' //prod endpoint; + instrumentationSettings.endpointURL = collectorEndpointUrl, instrumentationSettings.instrumentationKey = '' //prod key; } break; @@ -157,7 +158,7 @@ export class OneDSLogger implements ITelemetryLogger{ case 'high': case 'dod': case 'mooncake': - instrumentationSettings.endpointURL = '' //prod endpoint; + instrumentationSettings.endpointURL = collectorEndpointUrl, instrumentationSettings.instrumentationKey = '' //prod key; break; case 'ex': diff --git a/src/common/telemetry/collectorEndpointProd.ts b/src/common/telemetry/collectorEndpointProd.ts new file mode 100644 index 00000000..b2a4eaae --- /dev/null +++ b/src/common/telemetry/collectorEndpointProd.ts @@ -0,0 +1,6 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +export const collectorEndpointUrl = 'https://mobile.events.data.microsoft.com/OneCollector/1.0/'; \ No newline at end of file diff --git a/src/common/telemetry/collectorEndpointTip.ts b/src/common/telemetry/collectorEndpointTip.ts new file mode 100644 index 00000000..d77ff351 --- /dev/null +++ b/src/common/telemetry/collectorEndpointTip.ts @@ -0,0 +1,6 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + */ + +export const collectorEndpointUrl = 'https://self.pipe.aria.int.microsoft.com/OneCollector/1.0/'; \ No newline at end of file