UNPKG

5.34 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright (c) Microsoft Corporation. All rights reserved.
4 * Licensed under the MIT License.
5 */
6Object.defineProperty(exports, "__esModule", { value: true });
7exports.EVENT_KEYS = void 0;
8var tslib_1 = require("tslib");
9var TelemetryEvent_1 = tslib_1.__importDefault(require("./TelemetryEvent"));
10var TelemetryUtils_1 = require("./TelemetryUtils");
11var ServerRequestParameters_1 = require("../ServerRequestParameters");
12exports.EVENT_KEYS = {
13 HTTP_PATH: TelemetryUtils_1.prependEventNamePrefix("http_path"),
14 USER_AGENT: TelemetryUtils_1.prependEventNamePrefix("user_agent"),
15 QUERY_PARAMETERS: TelemetryUtils_1.prependEventNamePrefix("query_parameters"),
16 API_VERSION: TelemetryUtils_1.prependEventNamePrefix("api_version"),
17 RESPONSE_CODE: TelemetryUtils_1.prependEventNamePrefix("response_code"),
18 O_AUTH_ERROR_CODE: TelemetryUtils_1.prependEventNamePrefix("oauth_error_code"),
19 HTTP_METHOD: TelemetryUtils_1.prependEventNamePrefix("http_method"),
20 REQUEST_ID_HEADER: TelemetryUtils_1.prependEventNamePrefix("request_id_header"),
21 SPE_INFO: TelemetryUtils_1.prependEventNamePrefix("spe_info"),
22 SERVER_ERROR_CODE: TelemetryUtils_1.prependEventNamePrefix("server_error_code"),
23 SERVER_SUB_ERROR_CODE: TelemetryUtils_1.prependEventNamePrefix("server_sub_error_code"),
24 URL: TelemetryUtils_1.prependEventNamePrefix("url")
25};
26var HttpEvent = /** @class */ (function (_super) {
27 tslib_1.__extends(HttpEvent, _super);
28 function HttpEvent(correlationId, eventLabel) {
29 return _super.call(this, TelemetryUtils_1.prependEventNamePrefix("http_event"), correlationId, eventLabel) || this;
30 }
31 Object.defineProperty(HttpEvent.prototype, "url", {
32 set: function (url) {
33 var scrubbedUri = TelemetryUtils_1.scrubTenantFromUri(url);
34 this.event[exports.EVENT_KEYS.URL] = scrubbedUri && scrubbedUri.toLowerCase();
35 },
36 enumerable: false,
37 configurable: true
38 });
39 Object.defineProperty(HttpEvent.prototype, "httpPath", {
40 set: function (httpPath) {
41 this.event[exports.EVENT_KEYS.HTTP_PATH] = TelemetryUtils_1.scrubTenantFromUri(httpPath).toLowerCase();
42 },
43 enumerable: false,
44 configurable: true
45 });
46 Object.defineProperty(HttpEvent.prototype, "userAgent", {
47 set: function (userAgent) {
48 this.event[exports.EVENT_KEYS.USER_AGENT] = userAgent;
49 },
50 enumerable: false,
51 configurable: true
52 });
53 Object.defineProperty(HttpEvent.prototype, "queryParams", {
54 set: function (queryParams) {
55 this.event[exports.EVENT_KEYS.QUERY_PARAMETERS] = ServerRequestParameters_1.ServerRequestParameters.generateQueryParametersString(queryParams);
56 },
57 enumerable: false,
58 configurable: true
59 });
60 Object.defineProperty(HttpEvent.prototype, "apiVersion", {
61 set: function (apiVersion) {
62 this.event[exports.EVENT_KEYS.API_VERSION] = apiVersion.toLowerCase();
63 },
64 enumerable: false,
65 configurable: true
66 });
67 Object.defineProperty(HttpEvent.prototype, "httpResponseStatus", {
68 set: function (statusCode) {
69 this.event[exports.EVENT_KEYS.RESPONSE_CODE] = statusCode;
70 },
71 enumerable: false,
72 configurable: true
73 });
74 Object.defineProperty(HttpEvent.prototype, "oAuthErrorCode", {
75 set: function (errorCode) {
76 this.event[exports.EVENT_KEYS.O_AUTH_ERROR_CODE] = errorCode;
77 },
78 enumerable: false,
79 configurable: true
80 });
81 Object.defineProperty(HttpEvent.prototype, "httpMethod", {
82 set: function (httpMethod) {
83 this.event[exports.EVENT_KEYS.HTTP_METHOD] = httpMethod;
84 },
85 enumerable: false,
86 configurable: true
87 });
88 Object.defineProperty(HttpEvent.prototype, "requestIdHeader", {
89 set: function (requestIdHeader) {
90 this.event[exports.EVENT_KEYS.REQUEST_ID_HEADER] = requestIdHeader;
91 },
92 enumerable: false,
93 configurable: true
94 });
95 Object.defineProperty(HttpEvent.prototype, "speInfo", {
96 /**
97 * Indicates whether the request was executed on a ring serving SPE traffic.
98 * An empty string indicates this occurred on an outer ring, and the string "I"
99 * indicates the request occurred on the inner ring
100 */
101 set: function (speInfo) {
102 this.event[exports.EVENT_KEYS.SPE_INFO] = speInfo;
103 },
104 enumerable: false,
105 configurable: true
106 });
107 Object.defineProperty(HttpEvent.prototype, "serverErrorCode", {
108 set: function (errorCode) {
109 this.event[exports.EVENT_KEYS.SERVER_ERROR_CODE] = errorCode;
110 },
111 enumerable: false,
112 configurable: true
113 });
114 Object.defineProperty(HttpEvent.prototype, "serverSubErrorCode", {
115 set: function (subErrorCode) {
116 this.event[exports.EVENT_KEYS.SERVER_SUB_ERROR_CODE] = subErrorCode;
117 },
118 enumerable: false,
119 configurable: true
120 });
121 return HttpEvent;
122}(TelemetryEvent_1.default));
123exports.default = HttpEvent;
124//# sourceMappingURL=HttpEvent.js.map
\No newline at end of file