1 | ;
|
2 | /**
|
3 | * -------------------------------------------------------------------------------------------
|
4 | * Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
|
5 | * See License in the project root for license information.
|
6 | * -------------------------------------------------------------------------------------------
|
7 | */
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | exports.TelemetryHandlerOptions = exports.FeatureUsageFlag = void 0;
|
10 | var MiddlewareControl_1 = require("../MiddlewareControl");
|
11 | /**
|
12 | * @enum
|
13 | * @property {number} NONE - The hexadecimal flag value for nothing enabled
|
14 | * @property {number} REDIRECT_HANDLER_ENABLED - The hexadecimal flag value for redirect handler enabled
|
15 | * @property {number} RETRY_HANDLER_ENABLED - The hexadecimal flag value for retry handler enabled
|
16 | * @property {number} AUTHENTICATION_HANDLER_ENABLED - The hexadecimal flag value for the authentication handler enabled
|
17 | */
|
18 | var FeatureUsageFlag;
|
19 | (function (FeatureUsageFlag) {
|
20 | /* eslint-disable @typescript-eslint/naming-convention */
|
21 | FeatureUsageFlag[FeatureUsageFlag["NONE"] = 0] = "NONE";
|
22 | FeatureUsageFlag[FeatureUsageFlag["REDIRECT_HANDLER_ENABLED"] = 1] = "REDIRECT_HANDLER_ENABLED";
|
23 | FeatureUsageFlag[FeatureUsageFlag["RETRY_HANDLER_ENABLED"] = 2] = "RETRY_HANDLER_ENABLED";
|
24 | FeatureUsageFlag[FeatureUsageFlag["AUTHENTICATION_HANDLER_ENABLED"] = 4] = "AUTHENTICATION_HANDLER_ENABLED";
|
25 | /* eslint-enable @typescript-eslint/naming-convention */
|
26 | })(FeatureUsageFlag = exports.FeatureUsageFlag || (exports.FeatureUsageFlag = {}));
|
27 | /**
|
28 | * @class
|
29 | * @implements MiddlewareOptions
|
30 | * Class for TelemetryHandlerOptions
|
31 | */
|
32 | var TelemetryHandlerOptions = /** @class */ (function () {
|
33 | function TelemetryHandlerOptions() {
|
34 | /**
|
35 | * @private
|
36 | * A member to hold the OR of feature usage flags
|
37 | */
|
38 | this.featureUsage = FeatureUsageFlag.NONE;
|
39 | }
|
40 | /**
|
41 | * @public
|
42 | * @static
|
43 | * To update the feature usage in the context object
|
44 | * @param {Context} context - The request context object containing middleware options
|
45 | * @param {FeatureUsageFlag} flag - The flag value
|
46 | * @returns nothing
|
47 | */
|
48 | TelemetryHandlerOptions.updateFeatureUsageFlag = function (context, flag) {
|
49 | var options;
|
50 | if (context.middlewareControl instanceof MiddlewareControl_1.MiddlewareControl) {
|
51 | options = context.middlewareControl.getMiddlewareOptions(TelemetryHandlerOptions);
|
52 | }
|
53 | else {
|
54 | context.middlewareControl = new MiddlewareControl_1.MiddlewareControl();
|
55 | }
|
56 | if (typeof options === "undefined") {
|
57 | options = new TelemetryHandlerOptions();
|
58 | context.middlewareControl.setMiddlewareOptions(TelemetryHandlerOptions, options);
|
59 | }
|
60 | options.setFeatureUsage(flag);
|
61 | };
|
62 | /**
|
63 | * @private
|
64 | * To set the feature usage flag
|
65 | * @param {FeatureUsageFlag} flag - The flag value
|
66 | * @returns nothing
|
67 | */
|
68 | TelemetryHandlerOptions.prototype.setFeatureUsage = function (flag) {
|
69 | this.featureUsage = this.featureUsage | flag;
|
70 | };
|
71 | /**
|
72 | * @public
|
73 | * To get the feature usage
|
74 | * @returns A feature usage flag as hexadecimal string
|
75 | */
|
76 | TelemetryHandlerOptions.prototype.getFeatureUsage = function () {
|
77 | return this.featureUsage.toString(16);
|
78 | };
|
79 | return TelemetryHandlerOptions;
|
80 | }());
|
81 | exports.TelemetryHandlerOptions = TelemetryHandlerOptions;
|
82 | //# sourceMappingURL=TelemetryHandlerOptions.js.map |
\ | No newline at end of file |