1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | Object.defineProperty(exports, "__esModule", { value: true });
|
7 | exports.startBrowserPerformanceMeasurement = exports.endBrowserPerformanceMeasurement = exports.supportsBrowserPerformance = exports.prependEventNamePrefix = exports.hashPersonalIdentifier = exports.scrubTenantFromUri = void 0;
|
8 | var TelemetryConstants_1 = require("./TelemetryConstants");
|
9 | var CryptoUtils_1 = require("../utils/CryptoUtils");
|
10 | var UrlUtils_1 = require("../utils/UrlUtils");
|
11 | var Authority_1 = require("../authority/Authority");
|
12 | exports.scrubTenantFromUri = function (uri) {
|
13 | var url = UrlUtils_1.UrlUtils.GetUrlComponents(uri);
|
14 |
|
15 | if (Authority_1.Authority.isAdfs(uri)) {
|
16 | |
17 |
|
18 |
|
19 |
|
20 |
|
21 | return uri;
|
22 | }
|
23 | var pathParams = url.PathSegments;
|
24 | if (pathParams && pathParams.length >= 2) {
|
25 | var tenantPosition = pathParams[1] === "tfp" ? 2 : 1;
|
26 | if (tenantPosition < pathParams.length) {
|
27 | pathParams[tenantPosition] = TelemetryConstants_1.TENANT_PLACEHOLDER;
|
28 | }
|
29 | }
|
30 | return url.Protocol + "//" + url.HostNameAndPort + "/" + pathParams.join("/");
|
31 | };
|
32 | exports.hashPersonalIdentifier = function (valueToHash) {
|
33 | |
34 |
|
35 |
|
36 |
|
37 |
|
38 | return CryptoUtils_1.CryptoUtils.base64Encode(valueToHash);
|
39 | };
|
40 | exports.prependEventNamePrefix = function (suffix) { return "" + TelemetryConstants_1.EVENT_NAME_PREFIX + (suffix || ""); };
|
41 | exports.supportsBrowserPerformance = function () { return !!(typeof window !== "undefined" &&
|
42 | "performance" in window &&
|
43 | window.performance.mark &&
|
44 | window.performance.measure); };
|
45 | exports.endBrowserPerformanceMeasurement = function (measureName, startMark, endMark) {
|
46 | if (exports.supportsBrowserPerformance()) {
|
47 | window.performance.mark(endMark);
|
48 | window.performance.measure(measureName, startMark, endMark);
|
49 | window.performance.clearMeasures(measureName);
|
50 | window.performance.clearMarks(startMark);
|
51 | window.performance.clearMarks(endMark);
|
52 | }
|
53 | };
|
54 | exports.startBrowserPerformanceMeasurement = function (startMark) {
|
55 | if (exports.supportsBrowserPerformance()) {
|
56 | window.performance.mark(startMark);
|
57 | }
|
58 | };
|
59 |
|
\ | No newline at end of file |