UNPKG

6.41 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright (c) Microsoft Corporation. All rights reserved.
4 * Licensed under the MIT License.
5 */
6var _a;
7Object.defineProperty(exports, "__esModule", { value: true });
8exports.API_EVENT_IDENTIFIER = exports.API_CODE = exports.EVENT_KEYS = void 0;
9var tslib_1 = require("tslib");
10var TelemetryEvent_1 = tslib_1.__importDefault(require("./TelemetryEvent"));
11var TelemetryConstants_1 = require("./TelemetryConstants");
12var TelemetryUtils_1 = require("./TelemetryUtils");
13exports.EVENT_KEYS = {
14 AUTHORITY: TelemetryUtils_1.prependEventNamePrefix("authority"),
15 AUTHORITY_TYPE: TelemetryUtils_1.prependEventNamePrefix("authority_type"),
16 PROMPT: TelemetryUtils_1.prependEventNamePrefix("ui_behavior"),
17 TENANT_ID: TelemetryUtils_1.prependEventNamePrefix("tenant_id"),
18 USER_ID: TelemetryUtils_1.prependEventNamePrefix("user_id"),
19 WAS_SUCESSFUL: TelemetryUtils_1.prependEventNamePrefix("was_successful"),
20 API_ERROR_CODE: TelemetryUtils_1.prependEventNamePrefix("api_error_code"),
21 LOGIN_HINT: TelemetryUtils_1.prependEventNamePrefix("login_hint")
22};
23var API_CODE;
24(function (API_CODE) {
25 API_CODE[API_CODE["AcquireTokenRedirect"] = 2001] = "AcquireTokenRedirect";
26 API_CODE[API_CODE["AcquireTokenSilent"] = 2002] = "AcquireTokenSilent";
27 API_CODE[API_CODE["AcquireTokenPopup"] = 2003] = "AcquireTokenPopup";
28 API_CODE[API_CODE["LoginRedirect"] = 2004] = "LoginRedirect";
29 API_CODE[API_CODE["LoginPopup"] = 2005] = "LoginPopup";
30 API_CODE[API_CODE["Logout"] = 2006] = "Logout";
31})(API_CODE = exports.API_CODE || (exports.API_CODE = {}));
32var API_EVENT_IDENTIFIER;
33(function (API_EVENT_IDENTIFIER) {
34 API_EVENT_IDENTIFIER["AcquireTokenRedirect"] = "AcquireTokenRedirect";
35 API_EVENT_IDENTIFIER["AcquireTokenSilent"] = "AcquireTokenSilent";
36 API_EVENT_IDENTIFIER["AcquireTokenPopup"] = "AcquireTokenPopup";
37 API_EVENT_IDENTIFIER["LoginRedirect"] = "LoginRedirect";
38 API_EVENT_IDENTIFIER["LoginPopup"] = "LoginPopup";
39 API_EVENT_IDENTIFIER["Logout"] = "Logout";
40})(API_EVENT_IDENTIFIER = exports.API_EVENT_IDENTIFIER || (exports.API_EVENT_IDENTIFIER = {}));
41var mapEventIdentiferToCode = (_a = {},
42 _a[API_EVENT_IDENTIFIER.AcquireTokenSilent] = API_CODE.AcquireTokenSilent,
43 _a[API_EVENT_IDENTIFIER.AcquireTokenPopup] = API_CODE.AcquireTokenPopup,
44 _a[API_EVENT_IDENTIFIER.AcquireTokenRedirect] = API_CODE.AcquireTokenRedirect,
45 _a[API_EVENT_IDENTIFIER.LoginPopup] = API_CODE.LoginPopup,
46 _a[API_EVENT_IDENTIFIER.LoginRedirect] = API_CODE.LoginRedirect,
47 _a[API_EVENT_IDENTIFIER.Logout] = API_CODE.Logout,
48 _a);
49var ApiEvent = /** @class */ (function (_super) {
50 tslib_1.__extends(ApiEvent, _super);
51 function ApiEvent(correlationId, piiEnabled, apiEventIdentifier) {
52 var _this = _super.call(this, TelemetryUtils_1.prependEventNamePrefix("api_event"), correlationId, apiEventIdentifier) || this;
53 if (apiEventIdentifier) {
54 _this.apiCode = mapEventIdentiferToCode[apiEventIdentifier];
55 _this.apiEventIdentifier = apiEventIdentifier;
56 }
57 _this.piiEnabled = piiEnabled;
58 return _this;
59 }
60 Object.defineProperty(ApiEvent.prototype, "apiEventIdentifier", {
61 set: function (apiEventIdentifier) {
62 this.event[TelemetryConstants_1.TELEMETRY_BLOB_EVENT_NAMES.ApiTelemIdConstStrKey] = apiEventIdentifier;
63 },
64 enumerable: false,
65 configurable: true
66 });
67 Object.defineProperty(ApiEvent.prototype, "apiCode", {
68 set: function (apiCode) {
69 this.event[TelemetryConstants_1.TELEMETRY_BLOB_EVENT_NAMES.ApiIdConstStrKey] = apiCode;
70 },
71 enumerable: false,
72 configurable: true
73 });
74 Object.defineProperty(ApiEvent.prototype, "authority", {
75 set: function (uri) {
76 this.event[exports.EVENT_KEYS.AUTHORITY] = TelemetryUtils_1.scrubTenantFromUri(uri).toLowerCase();
77 },
78 enumerable: false,
79 configurable: true
80 });
81 Object.defineProperty(ApiEvent.prototype, "apiErrorCode", {
82 set: function (errorCode) {
83 this.event[exports.EVENT_KEYS.API_ERROR_CODE] = errorCode;
84 },
85 enumerable: false,
86 configurable: true
87 });
88 Object.defineProperty(ApiEvent.prototype, "tenantId", {
89 set: function (tenantId) {
90 this.event[exports.EVENT_KEYS.TENANT_ID] = this.piiEnabled && tenantId ?
91 TelemetryUtils_1.hashPersonalIdentifier(tenantId)
92 : null;
93 },
94 enumerable: false,
95 configurable: true
96 });
97 Object.defineProperty(ApiEvent.prototype, "accountId", {
98 set: function (accountId) {
99 this.event[exports.EVENT_KEYS.USER_ID] = this.piiEnabled && accountId ?
100 TelemetryUtils_1.hashPersonalIdentifier(accountId)
101 : null;
102 },
103 enumerable: false,
104 configurable: true
105 });
106 Object.defineProperty(ApiEvent.prototype, "wasSuccessful", {
107 get: function () {
108 return this.event[exports.EVENT_KEYS.WAS_SUCESSFUL] === true;
109 },
110 set: function (wasSuccessful) {
111 this.event[exports.EVENT_KEYS.WAS_SUCESSFUL] = wasSuccessful;
112 },
113 enumerable: false,
114 configurable: true
115 });
116 Object.defineProperty(ApiEvent.prototype, "loginHint", {
117 set: function (loginHint) {
118 this.event[exports.EVENT_KEYS.LOGIN_HINT] = this.piiEnabled && loginHint ?
119 TelemetryUtils_1.hashPersonalIdentifier(loginHint)
120 : null;
121 },
122 enumerable: false,
123 configurable: true
124 });
125 Object.defineProperty(ApiEvent.prototype, "authorityType", {
126 set: function (authorityType) {
127 this.event[exports.EVENT_KEYS.AUTHORITY_TYPE] = authorityType.toLowerCase();
128 },
129 enumerable: false,
130 configurable: true
131 });
132 Object.defineProperty(ApiEvent.prototype, "promptType", {
133 set: function (promptType) {
134 this.event[exports.EVENT_KEYS.PROMPT] = promptType.toLowerCase();
135 },
136 enumerable: false,
137 configurable: true
138 });
139 return ApiEvent;
140}(TelemetryEvent_1.default));
141exports.default = ApiEvent;
142//# sourceMappingURL=ApiEvent.js.map
\No newline at end of file