@microsoft/power-apps-cli 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/lib/Verbs/AddDataSource.js +19 -13
  2. package/lib/Verbs/AddDataSource.js.map +1 -1
  3. package/lib/Verbs/DeleteDataSource.js +3 -3
  4. package/lib/Verbs/DeleteDataSource.js.map +1 -1
  5. package/lib/Verbs/Init.d.ts.map +1 -1
  6. package/lib/Verbs/Init.js +20 -0
  7. package/lib/Verbs/Init.js.map +1 -1
  8. package/lib-cjs/Verbs/AddDataSource.js +38 -43
  9. package/lib-cjs/Verbs/AddDataSource.js.map +1 -1
  10. package/lib-cjs/Verbs/DeleteDataSource.js +11 -19
  11. package/lib-cjs/Verbs/DeleteDataSource.js.map +1 -1
  12. package/lib-cjs/Verbs/Init.d.ts.map +1 -1
  13. package/lib-cjs/Verbs/Init.js +39 -8
  14. package/lib-cjs/Verbs/Init.js.map +1 -1
  15. package/node_modules/@microsoft/1ds-properties-js/README.md +193 -0
  16. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.gbl.js +4844 -0
  17. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.gbl.js.map +1 -0
  18. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.gbl.min.js +7 -0
  19. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.gbl.min.js.map +1 -0
  20. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.integrity.json +46 -0
  21. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.js +4848 -0
  22. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.js.map +1 -0
  23. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.min.js +7 -0
  24. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties-4.3.9.min.js.map +1 -0
  25. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.gbl.js +4844 -0
  26. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.gbl.js.map +1 -0
  27. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.gbl.min.js +7 -0
  28. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.gbl.min.js.map +1 -0
  29. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.integrity.json +46 -0
  30. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.js +4848 -0
  31. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.js.map +1 -0
  32. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.min.js +7 -0
  33. package/node_modules/@microsoft/1ds-properties-js/bundle/es5/ms.properties.min.js.map +1 -0
  34. package/node_modules/@microsoft/1ds-properties-js/dist/es5/ms.properties.js +4827 -0
  35. package/node_modules/@microsoft/1ds-properties-js/dist/es5/ms.properties.js.map +1 -0
  36. package/node_modules/@microsoft/1ds-properties-js/dist/es5/ms.properties.min.js +7 -0
  37. package/node_modules/@microsoft/1ds-properties-js/dist/es5/ms.properties.min.js.map +1 -0
  38. package/node_modules/@microsoft/1ds-properties-js/dist-es5/DataModels.js +13 -0
  39. package/node_modules/@microsoft/1ds-properties-js/dist-es5/DataModels.js.map +1 -0
  40. package/node_modules/@microsoft/1ds-properties-js/dist-es5/ExtensionKeys.js +95 -0
  41. package/node_modules/@microsoft/1ds-properties-js/dist-es5/ExtensionKeys.js.map +1 -0
  42. package/node_modules/@microsoft/1ds-properties-js/dist-es5/Index.js +16 -0
  43. package/node_modules/@microsoft/1ds-properties-js/dist-es5/Index.js.map +1 -0
  44. package/node_modules/@microsoft/1ds-properties-js/dist-es5/InternalConstants.js +30 -0
  45. package/node_modules/@microsoft/1ds-properties-js/dist-es5/InternalConstants.js.map +1 -0
  46. package/node_modules/@microsoft/1ds-properties-js/dist-es5/PropertiesPlugin.js +200 -0
  47. package/node_modules/@microsoft/1ds-properties-js/dist-es5/PropertiesPlugin.js.map +1 -0
  48. package/node_modules/@microsoft/1ds-properties-js/dist-es5/SessionManager.js +168 -0
  49. package/node_modules/@microsoft/1ds-properties-js/dist-es5/SessionManager.js.map +1 -0
  50. package/node_modules/@microsoft/1ds-properties-js/dist-es5/TelemetryContext.js +286 -0
  51. package/node_modules/@microsoft/1ds-properties-js/dist-es5/TelemetryContext.js.map +1 -0
  52. package/node_modules/@microsoft/1ds-properties-js/dist-es5/Utils.js +106 -0
  53. package/node_modules/@microsoft/1ds-properties-js/dist-es5/Utils.js.map +1 -0
  54. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Application.js +178 -0
  55. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Application.js.map +1 -0
  56. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Cloud.js +17 -0
  57. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Cloud.js.map +1 -0
  58. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Device.js +17 -0
  59. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Device.js.map +1 -0
  60. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/IntWeb.js +58 -0
  61. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/IntWeb.js.map +1 -0
  62. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Loc.js +29 -0
  63. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Loc.js.map +1 -0
  64. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/OperatingSystem.js +176 -0
  65. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/OperatingSystem.js.map +1 -0
  66. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Sdk.js +71 -0
  67. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Sdk.js.map +1 -0
  68. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Session.js +47 -0
  69. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Session.js.map +1 -0
  70. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Trace.js +36 -0
  71. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Trace.js.map +1 -0
  72. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/User.js +102 -0
  73. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/User.js.map +1 -0
  74. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Utc.js +64 -0
  75. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Utc.js.map +1 -0
  76. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Web.js +274 -0
  77. package/node_modules/@microsoft/1ds-properties-js/dist-es5/context/Web.js.map +1 -0
  78. package/node_modules/@microsoft/1ds-properties-js/package.json +65 -0
  79. package/node_modules/@microsoft/1ds-properties-js/tsconfig.json +27 -0
  80. package/node_modules/@microsoft/1ds-properties-js/types/1ds-properties-js.d.ts +706 -0
  81. package/node_modules/@microsoft/1ds-properties-js/types/1ds-properties-js.namespaced.d.ts +2908 -0
  82. package/node_modules/@microsoft/powerapps-data/package.json +1 -1
  83. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/AddDataSource.js +31 -25
  84. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/AddDataSource.js.map +1 -1
  85. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/DataUtils.d.ts +6 -4
  86. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/DataUtils.d.ts.map +1 -1
  87. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/DataUtils.js +11 -5
  88. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/DataUtils.js.map +1 -1
  89. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/DeleteDataSource.js +3 -3
  90. package/node_modules/@microsoft/powerapps-player-actions/lib/Actions/DeleteDataSource.js.map +1 -1
  91. package/node_modules/@microsoft/powerapps-player-actions/lib/Types/ActionTypes.d.ts +16 -11
  92. package/node_modules/@microsoft/powerapps-player-actions/lib/Types/ActionTypes.d.ts.map +1 -1
  93. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/AddDataSource.spec.js +1 -1
  94. package/node_modules/@microsoft/powerapps-player-actions/lib/__tests__/AddDataSource.spec.js.map +1 -1
  95. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/AddDataSource.js +104 -86
  96. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/AddDataSource.js.map +1 -1
  97. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/DataUtils.d.ts +6 -4
  98. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/DataUtils.d.ts.map +1 -1
  99. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/DataUtils.js +26 -4
  100. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/DataUtils.js.map +1 -1
  101. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/DeleteDataSource.js +52 -46
  102. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Actions/DeleteDataSource.js.map +1 -1
  103. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Types/ActionTypes.d.ts +16 -11
  104. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/Types/ActionTypes.d.ts.map +1 -1
  105. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/AddDataSource.spec.js +1 -1
  106. package/node_modules/@microsoft/powerapps-player-actions/lib-cjs/__tests__/AddDataSource.spec.js.map +1 -1
  107. package/node_modules/@microsoft/powerapps-player-actions/package.json +1 -1
  108. package/node_modules/@pa-client/powerapps-player-services/package.json +69 -69
  109. package/package.json +5 -3
@@ -0,0 +1,286 @@
1
+ /*
2
+ * 1DS JS SDK Properties plugin, 4.3.9
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ * (Microsoft Internal Only)
5
+ */
6
+ /**
7
+ * TelemetryContext.ts
8
+ * @author Hector Hernandez (hectorh)
9
+ * @copyright Microsoft 2019
10
+ */
11
+ import dynamicProto from "@microsoft/dynamicproto-js";
12
+ import { isBoolean, isNullOrUndefined, isNumber, isString, isValidSpanId, isValidTraceId, objForEachKey } from "@microsoft/1ds-core-js";
13
+ import { AppExtensionKeys, CloudExtKeys, DeviceExtKeys, DistributedTraceExtKeys, Extensions, IntWebExtKeys, LocExtKeys, OSExtKeys, SDKExtKeys, SessionExtKeys, TraceExtKeys, UserExtensionKeys, UtcExtKeys, WebExtensionKeys } from "./ExtensionKeys";
14
+ import { SessionManager } from "./SessionManager";
15
+ import { Application } from "./context/Application";
16
+ import { Cloud } from "./context/Cloud";
17
+ import { Device } from "./context/Device";
18
+ import { IntWeb } from "./context/IntWeb";
19
+ import { Loc } from "./context/Loc";
20
+ import { OperatingSystem } from "./context/OperatingSystem";
21
+ import { Sdk } from "./context/Sdk";
22
+ import { Session } from "./context/Session";
23
+ import { Trace } from "./context/Trace";
24
+ import { User } from "./context/User";
25
+ import { Utc } from "./context/Utc";
26
+ import { Web } from "./context/Web";
27
+ function _applyExtValues(extension, event, names, map, overwriteTarget) {
28
+ var target = event.ext[Extensions[extension]];
29
+ if (target) {
30
+ try {
31
+ objForEachKey(map, function (field, value) {
32
+ if (isString(value) || isNumber(value) || isBoolean(value)) {
33
+ var targetValue = target[names[field]];
34
+ if (!overwriteTarget && (targetValue || isString(targetValue) || isNumber(targetValue) || isBoolean(targetValue))) {
35
+ value = targetValue;
36
+ }
37
+ target[names[field]] = value;
38
+ }
39
+ });
40
+ }
41
+ catch (e) {
42
+ // During unload some accesses may cause a TypeError due to accessing a dead object
43
+ }
44
+ }
45
+ return target;
46
+ }
47
+ var TelemetryContext = /** @class */ (function () {
48
+ function TelemetryContext(coreConfig, propertiesConfig, core, unloadHookContainer) {
49
+ dynamicProto(TelemetryContext, this, function (_self) {
50
+ _self.app = new Application(propertiesConfig, core, unloadHookContainer);
51
+ _self.cloud = new Cloud();
52
+ _self.user = new User(coreConfig, propertiesConfig, core, unloadHookContainer);
53
+ _self.os = new OperatingSystem(propertiesConfig, unloadHookContainer);
54
+ _self.web = new Web(propertiesConfig, core, unloadHookContainer);
55
+ var _sdk = new Sdk(coreConfig, core, unloadHookContainer);
56
+ var _intWeb = new IntWeb(propertiesConfig, core, unloadHookContainer);
57
+ var _utc = new Utc(propertiesConfig, unloadHookContainer);
58
+ _self.loc = new Loc();
59
+ _self.device = new Device();
60
+ var _sessionManager = new SessionManager(core, propertiesConfig, unloadHookContainer);
61
+ _self.session = new Session();
62
+ var undefValue = undefined;
63
+ var _distributedTraceCtx = createDistributedTraceContextFromTraceCtx(new Trace(propertiesConfig, undefValue, undefValue, undefValue, unloadHookContainer), _getTraceCtx());
64
+ var _overwriteEventPartA = !(propertiesConfig || {}).eventContainExtFields;
65
+ function _getSessionId() {
66
+ var session = _self.session;
67
+ if (session && isString(session.customId)) {
68
+ return session.customId;
69
+ }
70
+ _sessionManager.update();
71
+ var autoSession = _sessionManager.automaticSession;
72
+ if (autoSession) {
73
+ var autoId = autoSession.getId();
74
+ if (autoId && isString(autoId)) {
75
+ session.automaticId = autoId;
76
+ }
77
+ }
78
+ return session.automaticId;
79
+ }
80
+ _self.getTraceCtx = function () {
81
+ return _distributedTraceCtx;
82
+ };
83
+ _self.getSessionId = _getSessionId;
84
+ _self.applyApplicationContext = function (event) {
85
+ var _a;
86
+ var app = _self.app;
87
+ _applyExtValues(4 /* eExtensions.AppExt */, event, AppExtensionKeys, (_a = {},
88
+ _a[0 /* eAppExtensionKeys.id */] = app.id,
89
+ _a[1 /* eAppExtensionKeys.ver */] = app.ver,
90
+ _a[2 /* eAppExtensionKeys.appName */] = app.name,
91
+ _a[3 /* eAppExtensionKeys.locale */] = app.locale,
92
+ _a[4 /* eAppExtensionKeys.expId */] = app.getExpId(),
93
+ _a[5 /* eAppExtensionKeys.env */] = app.env,
94
+ _a), _overwriteEventPartA);
95
+ };
96
+ _self.applyUserContext = function (event) {
97
+ var _a;
98
+ var user = _self.user;
99
+ _applyExtValues(0 /* eExtensions.UserExt */, event, UserExtensionKeys, (_a = {},
100
+ _a[1 /* eUserExtensionKeys.localId */] = user.getLocalId(),
101
+ _a[0 /* eUserExtensionKeys.locale */] = user.locale,
102
+ _a[2 /* eUserExtensionKeys.id */] = user.id,
103
+ _a), _overwriteEventPartA);
104
+ };
105
+ _self.applyWebContext = function (event) {
106
+ var _a;
107
+ var web = _self.web;
108
+ _applyExtValues(3 /* eExtensions.WebExt */, event, WebExtensionKeys, (_a = {},
109
+ _a[0 /* eWebExtensionKeys.domain */] = web.domain,
110
+ _a[1 /* eWebExtensionKeys.browser */] = web.browser,
111
+ _a[2 /* eWebExtensionKeys.browserVer */] = web.browserVer,
112
+ _a[3 /* eWebExtensionKeys.screenRes */] = web.screenRes,
113
+ _a[5 /* eWebExtensionKeys.consentDetails */] = web.getUserConsentDetails(),
114
+ _a[4 /* eWebExtensionKeys.userConsent */] = false,
115
+ _a), _overwriteEventPartA);
116
+ };
117
+ _self.applyOsContext = function (event) {
118
+ var _a;
119
+ var os = _self.os;
120
+ _applyExtValues(5 /* eExtensions.OSExt */, event, OSExtKeys, (_a = {},
121
+ _a[0 /* eOSExtKeys.osName */] = os.name,
122
+ _a[1 /* eOSExtKeys.ver */] = os.ver,
123
+ _a), _overwriteEventPartA);
124
+ };
125
+ _self.applySdkContext = function (event) {
126
+ var _a;
127
+ _applyExtValues(6 /* eExtensions.SdkExt */, event, SDKExtKeys, (_a = {},
128
+ _a[2 /* eSDKExtKeys.installId */] = _sdk.installId,
129
+ _a[1 /* eSDKExtKeys.seq */] = _sdk.getSequenceId(),
130
+ _a[3 /* eSDKExtKeys.epoch */] = _sdk.epoch,
131
+ _a), _overwriteEventPartA);
132
+ };
133
+ _self.applyIntWebContext = function (event) {
134
+ var _a;
135
+ _applyExtValues(7 /* eExtensions.IntWebExt */, event, IntWebExtKeys, (_a = {},
136
+ _a[0 /* eIntWebExtKeys.msfpc */] = _intWeb.getMsfpc(),
137
+ _a[1 /* eIntWebExtKeys.anid */] = _intWeb.getAnid(),
138
+ _a[2 /* eIntWebExtKeys.serviceName */] = _intWeb.serviceName,
139
+ _a), _overwriteEventPartA);
140
+ };
141
+ _self.applyUtcContext = function (event) {
142
+ var _a;
143
+ var utcFields = (_a = {},
144
+ _a[0 /* eUtcExtKeys.popSample */] = _utc.popSample,
145
+ _a);
146
+ if (_utc.eventFlags > 0) {
147
+ utcFields[1 /* eUtcExtKeys.eventFlags */] = _utc.eventFlags;
148
+ }
149
+ _applyExtValues(8 /* eExtensions.UtcExt */, event, UtcExtKeys, utcFields, _overwriteEventPartA);
150
+ };
151
+ _self.applyLocContext = function (event) {
152
+ var _a;
153
+ _applyExtValues(9 /* eExtensions.LocExt */, event, LocExtKeys, (_a = {},
154
+ _a[0 /* eLocExtKeys.tz */] = _self.loc.tz,
155
+ _a), _overwriteEventPartA);
156
+ };
157
+ _self.applySessionContext = function (event) {
158
+ var _a;
159
+ _applyExtValues(4 /* eExtensions.AppExt */, event, SessionExtKeys, (_a = {},
160
+ _a[0 /* eSessionExtKeys.sessionId */] = _getSessionId(),
161
+ _a), _overwriteEventPartA);
162
+ };
163
+ _self.applyDeviceContext = function (event) {
164
+ var _a;
165
+ var device = _self.device;
166
+ _applyExtValues(1 /* eExtensions.DeviceExt */, event, DeviceExtKeys, (_a = {},
167
+ _a[0 /* eDeviceExtKeys.localId */] = device.localId,
168
+ _a[2 /* eDeviceExtKeys.make */] = device.make,
169
+ _a[3 /* eDeviceExtKeys.model */] = device.model,
170
+ _a[1 /* eDeviceExtKeys.deviceClass */] = device.deviceClass,
171
+ _a), _overwriteEventPartA);
172
+ };
173
+ _self.applyCloudContext = function (event) {
174
+ var _a;
175
+ var cloud = _self.cloud;
176
+ _applyExtValues(10 /* eExtensions.CloudExt */, event, CloudExtKeys, (_a = {},
177
+ _a[0 /* eCloudExtKeys.role */] = cloud.role,
178
+ _a[1 /* eCloudExtKeys.roleInstance */] = cloud.roleInstance,
179
+ _a[2 /* eCloudExtKeys.roleVer */] = cloud.roleVer,
180
+ _a), _overwriteEventPartA);
181
+ };
182
+ _self.applyAITraceContext = function (event) {
183
+ var _a;
184
+ if (propertiesConfig.enableApplicationInsightsTrace) {
185
+ var distributedTrace = _getTraceCtx();
186
+ if (distributedTrace) {
187
+ _applyExtValues(2 /* eExtensions.TraceExt */, event, TraceExtKeys, (_a = {},
188
+ _a[0 /* eTraceExtKeys.traceId */] = distributedTrace.getTraceId(),
189
+ _a[1 /* eTraceExtKeys.traceName */] = distributedTrace.getName(),
190
+ _a[2 /* eTraceExtKeys.parentId */] = distributedTrace.getSpanId(),
191
+ _a), false); // Always allow the event to define these values
192
+ }
193
+ }
194
+ };
195
+ _self.applyDistributedTraceContext = function (event) {
196
+ var _a;
197
+ var distributedTrace = _getTraceCtx();
198
+ if (distributedTrace) {
199
+ var traceFields = (_a = {},
200
+ _a[0 /* eDistributedTraceExtKeys.traceId */] = distributedTrace.getTraceId(),
201
+ _a[1 /* eDistributedTraceExtKeys.spanId */] = distributedTrace.getSpanId(),
202
+ _a);
203
+ var traceFlags = distributedTrace.getTraceFlags();
204
+ if (!isNullOrUndefined(traceFlags)) {
205
+ traceFields[2 /* eDistributedTraceExtKeys.traceFlags */] = traceFlags;
206
+ }
207
+ // Always allow the event to define these values
208
+ _applyExtValues(11 /* eExtensions.DtExt */, event, DistributedTraceExtKeys, traceFields, false);
209
+ }
210
+ };
211
+ function _getTraceCtx() {
212
+ var traceCtx = _distributedTraceCtx;
213
+ if (core && core.getTraceCtx) {
214
+ traceCtx = core.getTraceCtx(false) || _distributedTraceCtx;
215
+ }
216
+ return traceCtx;
217
+ }
218
+ });
219
+ }
220
+ // Removed Stub for TelemetryContext.prototype.getTraceCtx.
221
+ // Removed Stub for TelemetryContext.prototype.getSessionId.
222
+ // Removed Stub for TelemetryContext.prototype.applyApplicationContext.
223
+ // Removed Stub for TelemetryContext.prototype.applyUserContext.
224
+ // Removed Stub for TelemetryContext.prototype.applyWebContext.
225
+ // Removed Stub for TelemetryContext.prototype.applyOsContext.
226
+ // Removed Stub for TelemetryContext.prototype.applySdkContext.
227
+ // Removed Stub for TelemetryContext.prototype.applyIntWebContext.
228
+ // Removed Stub for TelemetryContext.prototype.applyUtcContext.
229
+ // Removed Stub for TelemetryContext.prototype.applyLocContext.
230
+ // Removed Stub for TelemetryContext.prototype.applySessionContext.
231
+ // Removed Stub for TelemetryContext.prototype.applyDeviceContext.
232
+ // Removed Stub for TelemetryContext.prototype.applyCloudContext.
233
+ // Removed Stub for TelemetryContext.prototype.applyAITraceContext.
234
+ // Removed Stub for TelemetryContext.prototype.applyDistributedTraceContext.
235
+ // This is a workaround for an IE8 bug when using dynamicProto() with classes that don't have any
236
+ // non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
237
+ // this will be removed when ES3 support is dropped.
238
+ TelemetryContext.__ieDyn=1;
239
+
240
+ return TelemetryContext;
241
+ }());
242
+ export { TelemetryContext };
243
+ /**
244
+ * Creates a IDistributedTraceContext from an optional telemetryTrace
245
+ * @param traceContext - The ITraceContext instance that is being wrapped
246
+ * @param parentCtx - An optional parent distributed trace instance, almost always undefined as this scenario is only used in the case of multiple property handlers.
247
+ * @returns A new IDistributedTraceContext instance that is backed by the traceContext or temporary object
248
+ */
249
+ function createDistributedTraceContextFromTraceCtx(traceContext, parentCtx) {
250
+ var trace = traceContext || {};
251
+ return {
252
+ getName: function () {
253
+ return trace.name;
254
+ },
255
+ setName: function (newValue) {
256
+ parentCtx && parentCtx.setName(newValue);
257
+ trace.name = newValue;
258
+ },
259
+ getTraceId: function () {
260
+ return trace.traceId;
261
+ },
262
+ setTraceId: function (newValue) {
263
+ parentCtx && parentCtx.setTraceId(newValue);
264
+ if (isValidTraceId(newValue)) {
265
+ trace.traceId = newValue;
266
+ }
267
+ },
268
+ getSpanId: function () {
269
+ return trace.parentId;
270
+ },
271
+ setSpanId: function (newValue) {
272
+ parentCtx && parentCtx.setSpanId(newValue);
273
+ if (isValidSpanId(newValue)) {
274
+ trace.parentId = newValue;
275
+ }
276
+ },
277
+ getTraceFlags: function () {
278
+ return trace.traceFlags;
279
+ },
280
+ setTraceFlags: function (newTraceFlags) {
281
+ parentCtx && parentCtx.setTraceFlags(newTraceFlags);
282
+ trace.traceFlags = newTraceFlags;
283
+ }
284
+ };
285
+ }
286
+ //# sourceMappingURL=TelemetryContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TelemetryContext.js.map","sources":["TelemetryContext.js"],"sourcesContent":["/**\r\n* TelemetryContext.ts\r\n* @author Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2019\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { isBoolean, isNullOrUndefined, isNumber, isString, isValidSpanId, isValidTraceId, objForEachKey } from \"@microsoft/1ds-core-js\";\r\nimport { AppExtensionKeys, CloudExtKeys, DeviceExtKeys, DistributedTraceExtKeys, Extensions, IntWebExtKeys, LocExtKeys, OSExtKeys, SDKExtKeys, SessionExtKeys, TraceExtKeys, UserExtensionKeys, UtcExtKeys, WebExtensionKeys } from \"./ExtensionKeys\";\r\nimport { SessionManager } from \"./SessionManager\";\r\nimport { Application } from \"./context/Application\";\r\nimport { Cloud } from \"./context/Cloud\";\r\nimport { Device } from \"./context/Device\";\r\nimport { IntWeb } from \"./context/IntWeb\";\r\nimport { Loc } from \"./context/Loc\";\r\nimport { OperatingSystem } from \"./context/OperatingSystem\";\r\nimport { Sdk } from \"./context/Sdk\";\r\nimport { Session } from \"./context/Session\";\r\nimport { Trace } from \"./context/Trace\";\r\nimport { User } from \"./context/User\";\r\nimport { Utc } from \"./context/Utc\";\r\nimport { Web } from \"./context/Web\";\r\nfunction _applyExtValues(extension, event, names, map, overwriteTarget) {\r\n var target = event.ext[Extensions[extension]];\r\n if (target) {\r\n try {\r\n objForEachKey(map, function (field, value) {\r\n if (isString(value) || isNumber(value) || isBoolean(value)) {\r\n var targetValue = target[names[field]];\r\n if (!overwriteTarget && (targetValue || isString(targetValue) || isNumber(targetValue) || isBoolean(targetValue))) {\r\n value = targetValue;\r\n }\r\n target[names[field]] = value;\r\n }\r\n });\r\n }\r\n catch (e) {\r\n // During unload some accesses may cause a TypeError due to accessing a dead object\r\n }\r\n }\r\n return target;\r\n}\r\nvar TelemetryContext = /** @class */ (function () {\r\n function TelemetryContext(coreConfig, propertiesConfig, core, unloadHookContainer) {\r\n dynamicProto(TelemetryContext, this, function (_self) {\r\n _self.app = new Application(propertiesConfig, core, unloadHookContainer);\r\n _self.cloud = new Cloud();\r\n _self.user = new User(coreConfig, propertiesConfig, core, unloadHookContainer);\r\n _self.os = new OperatingSystem(propertiesConfig, unloadHookContainer);\r\n _self.web = new Web(propertiesConfig, core, unloadHookContainer);\r\n var _sdk = new Sdk(coreConfig, core, unloadHookContainer);\r\n var _intWeb = new IntWeb(propertiesConfig, core, unloadHookContainer);\r\n var _utc = new Utc(propertiesConfig, unloadHookContainer);\r\n _self.loc = new Loc();\r\n _self.device = new Device();\r\n var _sessionManager = new SessionManager(core, propertiesConfig, unloadHookContainer);\r\n _self.session = new Session();\r\n var undefValue = undefined;\r\n var _distributedTraceCtx = createDistributedTraceContextFromTraceCtx(new Trace(propertiesConfig, undefValue, undefValue, undefValue, unloadHookContainer), _getTraceCtx());\r\n var _overwriteEventPartA = !(propertiesConfig || {}).eventContainExtFields;\r\n function _getSessionId() {\r\n var session = _self.session;\r\n if (session && isString(session.customId)) {\r\n return session.customId;\r\n }\r\n _sessionManager.update();\r\n var autoSession = _sessionManager.automaticSession;\r\n if (autoSession) {\r\n var autoId = autoSession.getId();\r\n if (autoId && isString(autoId)) {\r\n session.automaticId = autoId;\r\n }\r\n }\r\n return session.automaticId;\r\n }\r\n _self.getTraceCtx = function () {\r\n return _distributedTraceCtx;\r\n };\r\n _self.getSessionId = _getSessionId;\r\n _self.applyApplicationContext = function (event) {\r\n var _a;\r\n var app = _self.app;\r\n _applyExtValues(4 /* eExtensions.AppExt */, event, AppExtensionKeys, (_a = {},\r\n _a[0 /* eAppExtensionKeys.id */] = app.id,\r\n _a[1 /* eAppExtensionKeys.ver */] = app.ver,\r\n _a[2 /* eAppExtensionKeys.appName */] = app.name,\r\n _a[3 /* eAppExtensionKeys.locale */] = app.locale,\r\n _a[4 /* eAppExtensionKeys.expId */] = app.getExpId(),\r\n _a[5 /* eAppExtensionKeys.env */] = app.env,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyUserContext = function (event) {\r\n var _a;\r\n var user = _self.user;\r\n _applyExtValues(0 /* eExtensions.UserExt */, event, UserExtensionKeys, (_a = {},\r\n _a[1 /* eUserExtensionKeys.localId */] = user.getLocalId(),\r\n _a[0 /* eUserExtensionKeys.locale */] = user.locale,\r\n _a[2 /* eUserExtensionKeys.id */] = user.id,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyWebContext = function (event) {\r\n var _a;\r\n var web = _self.web;\r\n _applyExtValues(3 /* eExtensions.WebExt */, event, WebExtensionKeys, (_a = {},\r\n _a[0 /* eWebExtensionKeys.domain */] = web.domain,\r\n _a[1 /* eWebExtensionKeys.browser */] = web.browser,\r\n _a[2 /* eWebExtensionKeys.browserVer */] = web.browserVer,\r\n _a[3 /* eWebExtensionKeys.screenRes */] = web.screenRes,\r\n _a[5 /* eWebExtensionKeys.consentDetails */] = web.getUserConsentDetails(),\r\n _a[4 /* eWebExtensionKeys.userConsent */] = false,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyOsContext = function (event) {\r\n var _a;\r\n var os = _self.os;\r\n _applyExtValues(5 /* eExtensions.OSExt */, event, OSExtKeys, (_a = {},\r\n _a[0 /* eOSExtKeys.osName */] = os.name,\r\n _a[1 /* eOSExtKeys.ver */] = os.ver,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applySdkContext = function (event) {\r\n var _a;\r\n _applyExtValues(6 /* eExtensions.SdkExt */, event, SDKExtKeys, (_a = {},\r\n _a[2 /* eSDKExtKeys.installId */] = _sdk.installId,\r\n _a[1 /* eSDKExtKeys.seq */] = _sdk.getSequenceId(),\r\n _a[3 /* eSDKExtKeys.epoch */] = _sdk.epoch,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyIntWebContext = function (event) {\r\n var _a;\r\n _applyExtValues(7 /* eExtensions.IntWebExt */, event, IntWebExtKeys, (_a = {},\r\n _a[0 /* eIntWebExtKeys.msfpc */] = _intWeb.getMsfpc(),\r\n _a[1 /* eIntWebExtKeys.anid */] = _intWeb.getAnid(),\r\n _a[2 /* eIntWebExtKeys.serviceName */] = _intWeb.serviceName,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyUtcContext = function (event) {\r\n var _a;\r\n var utcFields = (_a = {},\r\n _a[0 /* eUtcExtKeys.popSample */] = _utc.popSample,\r\n _a);\r\n if (_utc.eventFlags > 0) {\r\n utcFields[1 /* eUtcExtKeys.eventFlags */] = _utc.eventFlags;\r\n }\r\n _applyExtValues(8 /* eExtensions.UtcExt */, event, UtcExtKeys, utcFields, _overwriteEventPartA);\r\n };\r\n _self.applyLocContext = function (event) {\r\n var _a;\r\n _applyExtValues(9 /* eExtensions.LocExt */, event, LocExtKeys, (_a = {},\r\n _a[0 /* eLocExtKeys.tz */] = _self.loc.tz,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applySessionContext = function (event) {\r\n var _a;\r\n _applyExtValues(4 /* eExtensions.AppExt */, event, SessionExtKeys, (_a = {},\r\n _a[0 /* eSessionExtKeys.sessionId */] = _getSessionId(),\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyDeviceContext = function (event) {\r\n var _a;\r\n var device = _self.device;\r\n _applyExtValues(1 /* eExtensions.DeviceExt */, event, DeviceExtKeys, (_a = {},\r\n _a[0 /* eDeviceExtKeys.localId */] = device.localId,\r\n _a[2 /* eDeviceExtKeys.make */] = device.make,\r\n _a[3 /* eDeviceExtKeys.model */] = device.model,\r\n _a[1 /* eDeviceExtKeys.deviceClass */] = device.deviceClass,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyCloudContext = function (event) {\r\n var _a;\r\n var cloud = _self.cloud;\r\n _applyExtValues(10 /* eExtensions.CloudExt */, event, CloudExtKeys, (_a = {},\r\n _a[0 /* eCloudExtKeys.role */] = cloud.role,\r\n _a[1 /* eCloudExtKeys.roleInstance */] = cloud.roleInstance,\r\n _a[2 /* eCloudExtKeys.roleVer */] = cloud.roleVer,\r\n _a), _overwriteEventPartA);\r\n };\r\n _self.applyAITraceContext = function (event) {\r\n var _a;\r\n if (propertiesConfig.enableApplicationInsightsTrace) {\r\n var distributedTrace = _getTraceCtx();\r\n if (distributedTrace) {\r\n _applyExtValues(2 /* eExtensions.TraceExt */, event, TraceExtKeys, (_a = {},\r\n _a[0 /* eTraceExtKeys.traceId */] = distributedTrace.getTraceId(),\r\n _a[1 /* eTraceExtKeys.traceName */] = distributedTrace.getName(),\r\n _a[2 /* eTraceExtKeys.parentId */] = distributedTrace.getSpanId(),\r\n _a), false); // Always allow the event to define these values\r\n }\r\n }\r\n };\r\n _self.applyDistributedTraceContext = function (event) {\r\n var _a;\r\n var distributedTrace = _getTraceCtx();\r\n if (distributedTrace) {\r\n var traceFields = (_a = {},\r\n _a[0 /* eDistributedTraceExtKeys.traceId */] = distributedTrace.getTraceId(),\r\n _a[1 /* eDistributedTraceExtKeys.spanId */] = distributedTrace.getSpanId(),\r\n _a);\r\n var traceFlags = distributedTrace.getTraceFlags();\r\n if (!isNullOrUndefined(traceFlags)) {\r\n traceFields[2 /* eDistributedTraceExtKeys.traceFlags */] = traceFlags;\r\n }\r\n // Always allow the event to define these values\r\n _applyExtValues(11 /* eExtensions.DtExt */, event, DistributedTraceExtKeys, traceFields, false);\r\n }\r\n };\r\n function _getTraceCtx() {\r\n var traceCtx = _distributedTraceCtx;\r\n if (core && core.getTraceCtx) {\r\n traceCtx = core.getTraceCtx(false) || _distributedTraceCtx;\r\n }\r\n return traceCtx;\r\n }\r\n });\r\n }\r\n /**\r\n * Gets the current distributed trace context for this instance if available\r\n */\r\n TelemetryContext.prototype.getTraceCtx = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /**\r\n * Returns the current session id, if one does not already exist a new one will be attempted to be created.\r\n * If you have set a specific custom id via session.setId(), this function will return that value.\r\n */\r\n TelemetryContext.prototype.getSessionId = function () {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n TelemetryContext.prototype.applyApplicationContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyUserContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyWebContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyOsContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applySdkContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyIntWebContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyUtcContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyLocContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applySessionContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyDeviceContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyCloudContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyAITraceContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n TelemetryContext.prototype.applyDistributedTraceContext = function (event) {\r\n // @DynamicProtoStub -- DO NOT add any code as this will be removed during packaging\r\n };\r\n return TelemetryContext;\r\n}());\r\nexport { TelemetryContext };\r\n/**\r\n * Creates a IDistributedTraceContext from an optional telemetryTrace\r\n * @param traceContext - The ITraceContext instance that is being wrapped\r\n * @param parentCtx - An optional parent distributed trace instance, almost always undefined as this scenario is only used in the case of multiple property handlers.\r\n * @returns A new IDistributedTraceContext instance that is backed by the traceContext or temporary object\r\n */\r\nfunction createDistributedTraceContextFromTraceCtx(traceContext, parentCtx) {\r\n var trace = traceContext || {};\r\n return {\r\n getName: function () {\r\n return trace.name;\r\n },\r\n setName: function (newValue) {\r\n parentCtx && parentCtx.setName(newValue);\r\n trace.name = newValue;\r\n },\r\n getTraceId: function () {\r\n return trace.traceId;\r\n },\r\n setTraceId: function (newValue) {\r\n parentCtx && parentCtx.setTraceId(newValue);\r\n if (isValidTraceId(newValue)) {\r\n trace.traceId = newValue;\r\n }\r\n },\r\n getSpanId: function () {\r\n return trace.parentId;\r\n },\r\n setSpanId: function (newValue) {\r\n parentCtx && parentCtx.setSpanId(newValue);\r\n if (isValidSpanId(newValue)) {\r\n trace.parentId = newValue;\r\n }\r\n },\r\n getTraceFlags: function () {\r\n return trace.traceFlags;\r\n },\r\n setTraceFlags: function (newTraceFlags) {\r\n parentCtx && parentCtx.setTraceFlags(newTraceFlags);\r\n trace.traceFlags = newTraceFlags;\r\n }\r\n };\r\n}\r\n//# sourceMappingURL=TelemetryContext.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;4EAqDM,CAAC;;;;;;4BACqB;AAC5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,106 @@
1
+ /*
2
+ * 1DS JS SDK Properties plugin, 4.3.9
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ * (Microsoft Internal Only)
5
+ */
6
+ /**
7
+ * Utils.ts
8
+ * @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)
9
+ * @copyright Microsoft 2018
10
+ * File containing utility functions.
11
+ */
12
+ import { _throwInternal, getGlobal, isFunction } from "@microsoft/1ds-core-js";
13
+ var _canUseLocalStorage;
14
+ /**
15
+ * Check if the browser supports local storage.
16
+ *
17
+ * @returns {boolean} True if local storage is supported.
18
+ */
19
+ export function canUseLocalStorage() {
20
+ if (_canUseLocalStorage === undefined) {
21
+ _canUseLocalStorage = !!_getVerifiedStorageObject(0 /* StorageType.LocalStorage */);
22
+ }
23
+ return _canUseLocalStorage;
24
+ }
25
+ /**
26
+ * Gets the localStorage object if available
27
+ * @returns Returns the storage object if available else returns null
28
+ */
29
+ function _getLocalStorageObject() {
30
+ if (canUseLocalStorage()) {
31
+ return _getVerifiedStorageObject(0 /* StorageType.LocalStorage */);
32
+ }
33
+ return null;
34
+ }
35
+ /**
36
+ * Tests storage object (localStorage or sessionStorage) to verify that it is usable
37
+ * More details here: https://mathiasbynens.be/notes/localstorage-pattern
38
+ * @param storageType - Type of storage
39
+ * @returns Returns storage object verified that it is usable
40
+ */
41
+ function _getVerifiedStorageObject(storageType) {
42
+ var storage = null;
43
+ var fail;
44
+ var uid;
45
+ try {
46
+ var global_1 = getGlobal();
47
+ if (!global_1) {
48
+ return null;
49
+ }
50
+ uid = new Date();
51
+ storage = storageType === 0 /* StorageType.LocalStorage */ ? global_1.localStorage : global_1.sessionStorage;
52
+ if (storage && isFunction(storage.setItem)) {
53
+ storage.setItem(uid, uid);
54
+ fail = storage.getItem(uid) !== uid;
55
+ storage.removeItem(uid);
56
+ if (fail) {
57
+ storage = null;
58
+ }
59
+ }
60
+ }
61
+ catch (exception) {
62
+ storage = null;
63
+ }
64
+ return storage;
65
+ }
66
+ /**
67
+ * Set the contents of an object in the browser's local storage
68
+ *
69
+ * @param name - the name of the object to set in storage
70
+ * @param data - the contents of the object to set in storage
71
+ * @returns True if the storage object could be written.
72
+ */
73
+ export function setStorage(logger, name, data) {
74
+ var storage = _getLocalStorageObject();
75
+ if (storage !== null) {
76
+ try {
77
+ storage.setItem(name, data);
78
+ return true;
79
+ }
80
+ catch (e) {
81
+ _canUseLocalStorage = false;
82
+ _throwInternal(logger, 1 /* eLoggingSeverity.CRITICAL */, 504 /* _eExtendedInternalMessageId.BrowserCannotWriteLocalStorage */, "Browser failed write to local storage. " + e);
83
+ }
84
+ }
85
+ return false;
86
+ }
87
+ /**
88
+ * Get an object from the browser's local storage
89
+ *
90
+ * @param name - the name of the object to get from storage
91
+ * @returns The contents of the storage object with the given name. Null if storage is not supported.
92
+ */
93
+ export function getStorage(logger, name) {
94
+ var storage = _getLocalStorageObject();
95
+ if (storage !== null) {
96
+ try {
97
+ return storage.getItem(name);
98
+ }
99
+ catch (e) {
100
+ _canUseLocalStorage = false;
101
+ _throwInternal(logger, 1 /* eLoggingSeverity.CRITICAL */, 503 /* _eExtendedInternalMessageId.BrowserCannotReadLocalStorage */, "Browser failed read of local storage. " + e);
102
+ }
103
+ }
104
+ return null;
105
+ }
106
+ //# sourceMappingURL=Utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.js.map","sources":["Utils.js"],"sourcesContent":["/**\r\n* Utils.ts\r\n* @author Abhilash Panwar (abpanwar) Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2018\r\n* File containing utility functions.\r\n*/\r\nimport { _throwInternal, getGlobal, isFunction } from \"@microsoft/1ds-core-js\";\r\nvar _canUseLocalStorage;\r\n/**\r\n * Check if the browser supports local storage.\r\n *\r\n * @returns {boolean} True if local storage is supported.\r\n */\r\nexport function canUseLocalStorage() {\r\n if (_canUseLocalStorage === undefined) {\r\n _canUseLocalStorage = !!_getVerifiedStorageObject(0 /* StorageType.LocalStorage */);\r\n }\r\n return _canUseLocalStorage;\r\n}\r\n/**\r\n* Gets the localStorage object if available\r\n* @returns Returns the storage object if available else returns null\r\n*/\r\nfunction _getLocalStorageObject() {\r\n if (canUseLocalStorage()) {\r\n return _getVerifiedStorageObject(0 /* StorageType.LocalStorage */);\r\n }\r\n return null;\r\n}\r\n/**\r\n * Tests storage object (localStorage or sessionStorage) to verify that it is usable\r\n * More details here: https://mathiasbynens.be/notes/localstorage-pattern\r\n * @param storageType - Type of storage\r\n * @returns Returns storage object verified that it is usable\r\n */\r\nfunction _getVerifiedStorageObject(storageType) {\r\n var storage = null;\r\n var fail;\r\n var uid;\r\n try {\r\n var global_1 = getGlobal();\r\n if (!global_1) {\r\n return null;\r\n }\r\n uid = new Date();\r\n storage = storageType === 0 /* StorageType.LocalStorage */ ? global_1.localStorage : global_1.sessionStorage;\r\n if (storage && isFunction(storage.setItem)) {\r\n storage.setItem(uid, uid);\r\n fail = storage.getItem(uid) !== uid;\r\n storage.removeItem(uid);\r\n if (fail) {\r\n storage = null;\r\n }\r\n }\r\n }\r\n catch (exception) {\r\n storage = null;\r\n }\r\n return storage;\r\n}\r\n/**\r\n * Set the contents of an object in the browser's local storage\r\n *\r\n * @param name - the name of the object to set in storage\r\n * @param data - the contents of the object to set in storage\r\n * @returns True if the storage object could be written.\r\n */\r\nexport function setStorage(logger, name, data) {\r\n var storage = _getLocalStorageObject();\r\n if (storage !== null) {\r\n try {\r\n storage.setItem(name, data);\r\n return true;\r\n }\r\n catch (e) {\r\n _canUseLocalStorage = false;\r\n _throwInternal(logger, 1 /* eLoggingSeverity.CRITICAL */, 504 /* _eExtendedInternalMessageId.BrowserCannotWriteLocalStorage */, \"Browser failed write to local storage. \" + e);\r\n }\r\n }\r\n return false;\r\n}\r\n/**\r\n * Get an object from the browser's local storage\r\n *\r\n * @param name - the name of the object to get from storage\r\n * @returns The contents of the storage object with the given name. Null if storage is not supported.\r\n */\r\nexport function getStorage(logger, name) {\r\n var storage = _getLocalStorageObject();\r\n if (storage !== null) {\r\n try {\r\n return storage.getItem(name);\r\n }\r\n catch (e) {\r\n _canUseLocalStorage = false;\r\n _throwInternal(logger, 1 /* eLoggingSeverity.CRITICAL */, 503 /* _eExtendedInternalMessageId.BrowserCannotReadLocalStorage */, \"Browser failed read of local storage. \" + e);\r\n }\r\n }\r\n return null;\r\n}\r\n//# sourceMappingURL=Utils.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,178 @@
1
+ /*
2
+ * 1DS JS SDK Properties plugin, 4.3.9
3
+ * Copyright (c) Microsoft and contributors. All rights reserved.
4
+ * (Microsoft Internal Only)
5
+ */
6
+ /**
7
+ * Application.ts
8
+ * @author Hector Hernandez (hectorh)
9
+ * @copyright Microsoft 2019
10
+ */
11
+ import dynamicProto from "@microsoft/dynamicproto-js";
12
+ import { getCookieValue, getDocument, hasDocument, onConfigChange } from "@microsoft/1ds-core-js";
13
+ import { objDefine } from "@nevware21/ts-utils";
14
+ export var defaultFlightIdNameSpaces = [
15
+ "AX",
16
+ "EX",
17
+ "SF",
18
+ "CS",
19
+ "CF",
20
+ "CT",
21
+ "CU",
22
+ "DC",
23
+ "DF",
24
+ "H5",
25
+ "HL",
26
+ "WS",
27
+ "WP" // WINDOWSPHONE
28
+ ];
29
+ /// <summary>Validate each flight id in appExpId against the app flight ID
30
+ /// format and create a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs< /summary>
31
+ /// <param type='Object'>A list of comma seperated appExpId</param>
32
+ /// <returns type='void'>none</returns>
33
+ function _validateAppExpId(appExpIdNew, flightIdNameSpaces) {
34
+ if (flightIdNameSpaces === void 0) { flightIdNameSpaces = defaultFlightIdNameSpaces; }
35
+ var appExpId = null;
36
+ if (appExpIdNew) {
37
+ var expIdArray = appExpIdNew.split(",");
38
+ for (var i = 0; i < expIdArray.length; i++) {
39
+ if (_isValidAppFlightId(expIdArray[i], flightIdNameSpaces)) {
40
+ if (!appExpId) {
41
+ appExpId = expIdArray[i];
42
+ }
43
+ else {
44
+ appExpId += "," + expIdArray[i];
45
+ }
46
+ }
47
+ else {
48
+ // this._traceLogger.w('Unsupported flight id format for this app expId: ' + expIdArray[i]);
49
+ }
50
+ }
51
+ }
52
+ return appExpId;
53
+ }
54
+ /// <summary>Verify an expId against the CS2.1 spec</summary>
55
+ /// <param type='Object'>expId to verify in string format</param>
56
+ /// <returns type='true'>true if expId is valid, false otherwise</returns>
57
+ function _isValidAppFlightId(appFlightId, flightIdNameSpaces) {
58
+ if (flightIdNameSpaces === void 0) { flightIdNameSpaces = defaultFlightIdNameSpaces; }
59
+ if (!appFlightId || appFlightId.length < 4) {
60
+ return false;
61
+ }
62
+ var isValid = false;
63
+ var MAXFLIGHTIDLENGTH = 256;
64
+ var curNameSpace = (appFlightId.substring(0, 3)).toString().toUpperCase();
65
+ // The prefix check must include ':', else strings starting with prefixes will slip through
66
+ for (var i = 0; i < flightIdNameSpaces.length; i++) {
67
+ if (flightIdNameSpaces[i] + ":" === curNameSpace && appFlightId.length <= MAXFLIGHTIDLENGTH) {
68
+ isValid = true;
69
+ break;
70
+ }
71
+ }
72
+ return isValid;
73
+ }
74
+ function _getExpId() {
75
+ return this.getExpId();
76
+ }
77
+ var Application = /** @class */ (function () {
78
+ function Application(propertiesConfig, core, unloadHookContainer) {
79
+ var _appExpId = null;
80
+ // Create a copy of the defaultNamespaces
81
+ var flightIdNameSpaces = defaultFlightIdNameSpaces.slice(0);
82
+ var expIdCookieName = "Treatments";
83
+ var _cookieMgr;
84
+ var _propertiesConfig = null;
85
+ dynamicProto(Application, this, function (_self) {
86
+ _populateDefaults(propertiesConfig);
87
+ // Add app language
88
+ if (hasDocument()) {
89
+ var documentElement = getDocument().documentElement;
90
+ if (documentElement) {
91
+ _self.locale = documentElement.lang;
92
+ }
93
+ }
94
+ _self.getExpId = function () {
95
+ return _propertiesConfig.expId ? _readExpIdFromCoreData(_propertiesConfig.expId) : _readExpIdFromCookie();
96
+ };
97
+ /**
98
+ * Retrieve a specified metadata tag value from the DOM.
99
+ * @param prefix - Prefix to search the metatags with.
100
+ * @returns Metadata collection/property bag
101
+ */
102
+ function _getMetaDataFromDOM(prefix) {
103
+ var metaElements;
104
+ var metaData = {};
105
+ var doc = getDocument();
106
+ if (doc) {
107
+ metaElements = doc && doc.querySelectorAll("meta");
108
+ for (var i = 0; i < metaElements.length; i++) {
109
+ var meta = metaElements[i];
110
+ if (meta.name) {
111
+ var mt = meta.name.toLowerCase();
112
+ if (mt.indexOf(prefix) === 0) {
113
+ var name = meta.name.replace(prefix, "");
114
+ metaData[name] = meta.content;
115
+ }
116
+ }
117
+ }
118
+ }
119
+ return metaData;
120
+ }
121
+ /// <summary>Validate each flight id in appExpId against the app flight ID
122
+ /// format and create a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs< /summary>
123
+ /// <param type='Object'>A list of comma seperated appExpId</param>
124
+ /// <returns type='void'>none</returns>
125
+ function _setAppExpId(appExpIdNew) {
126
+ if (appExpIdNew === _appExpId) {
127
+ return; // Nothing to do if seen before
128
+ }
129
+ // Reset to empty first. The new but invalid appExpId should not be logged and we cannot leave the old one hanging around
130
+ // since it means old experiment id cannot represent the new experiment with an invalid appExpId.
131
+ _appExpId = _validateAppExpId(appExpIdNew, flightIdNameSpaces);
132
+ }
133
+ function _readExpIdFromCookie() {
134
+ var cookieValue = getCookieValue(_cookieMgr, expIdCookieName);
135
+ _setAppExpId(cookieValue);
136
+ return _appExpId;
137
+ }
138
+ function _readExpIdFromCoreData(expId) {
139
+ _setAppExpId(expId);
140
+ return _appExpId;
141
+ }
142
+ function _populateDefaults(config) {
143
+ // This function will be re-called whenever any referenced configuration is changed
144
+ var unloadHook = onConfigChange(config, function () {
145
+ _cookieMgr = core && core.getCookieMgr();
146
+ _propertiesConfig = config || {};
147
+ // config.env default is set at properities plugin level with ""
148
+ _self.env = _propertiesConfig.env || _getMetaDataFromDOM("awa-")["env"];
149
+ });
150
+ unloadHookContainer && unloadHookContainer.add(unloadHook);
151
+ }
152
+ });
153
+ }
154
+ // Removed Stub for Application.prototype.getExpId.
155
+ /// <summary>Validate each flight id in appExpId against the app flight ID
156
+ /// format and create a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs< /summary>
157
+ /// <param type='Object'>A list of comma seperated appExpId</param>
158
+ /// <returns type='void'>none</returns>
159
+ /**
160
+ * Validate each flight id in appExpId against the app flight ID format and create
161
+ * a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs
162
+ * @param appExpId - The current experiment id
163
+ * @param appExpIdNew - The new experiment id to set (if valid)
164
+ * @param flightIdNameSpaces - The valid set of flight id names
165
+ * @returns The validated experiment id,
166
+ */
167
+ Application.validateAppExpId = _validateAppExpId;
168
+ /**
169
+ * Static constructor, attempt to create accessors
170
+ */
171
+ Application._staticInit = (function () {
172
+ // Dynamically create get/set property accessors
173
+ objDefine(Application.prototype, "expId", { g: _getExpId });
174
+ })();
175
+ return Application;
176
+ }());
177
+ export { Application };
178
+ //# sourceMappingURL=Application.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Application.js.map","sources":["Application.js"],"sourcesContent":["/**\r\n* Application.ts\r\n* @author Hector Hernandez (hectorh)\r\n* @copyright Microsoft 2019\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { getCookieValue, getDocument, hasDocument, onConfigChange } from \"@microsoft/1ds-core-js\";\r\nimport { objDefine } from \"@nevware21/ts-utils\";\r\nexport var defaultFlightIdNameSpaces = [\r\n \"AX\",\r\n \"EX\",\r\n \"SF\",\r\n \"CS\",\r\n \"CF\",\r\n \"CT\",\r\n \"CU\",\r\n \"DC\",\r\n \"DF\",\r\n \"H5\",\r\n \"HL\",\r\n \"WS\",\r\n \"WP\" // WINDOWSPHONE\r\n];\r\n/// <summary>Validate each flight id in appExpId against the app flight ID\r\n/// format and create a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs< /summary>\r\n/// <param type='Object'>A list of comma seperated appExpId</param>\r\n/// <returns type='void'>none</returns>\r\nfunction _validateAppExpId(appExpIdNew, flightIdNameSpaces) {\r\n if (flightIdNameSpaces === void 0) { flightIdNameSpaces = defaultFlightIdNameSpaces; }\r\n var appExpId = null;\r\n if (appExpIdNew) {\r\n var expIdArray = appExpIdNew.split(\",\");\r\n for (var i = 0; i < expIdArray.length; i++) {\r\n if (_isValidAppFlightId(expIdArray[i], flightIdNameSpaces)) {\r\n if (!appExpId) {\r\n appExpId = expIdArray[i];\r\n }\r\n else {\r\n appExpId += \",\" + expIdArray[i];\r\n }\r\n }\r\n else {\r\n // this._traceLogger.w('Unsupported flight id format for this app expId: ' + expIdArray[i]);\r\n }\r\n }\r\n }\r\n return appExpId;\r\n}\r\n/// <summary>Verify an expId against the CS2.1 spec</summary>\r\n/// <param type='Object'>expId to verify in string format</param>\r\n/// <returns type='true'>true if expId is valid, false otherwise</returns>\r\nfunction _isValidAppFlightId(appFlightId, flightIdNameSpaces) {\r\n if (flightIdNameSpaces === void 0) { flightIdNameSpaces = defaultFlightIdNameSpaces; }\r\n if (!appFlightId || appFlightId.length < 4) {\r\n return false;\r\n }\r\n var isValid = false;\r\n var MAXFLIGHTIDLENGTH = 256;\r\n var curNameSpace = (appFlightId.substring(0, 3)).toString().toUpperCase();\r\n // The prefix check must include ':', else strings starting with prefixes will slip through\r\n for (var i = 0; i < flightIdNameSpaces.length; i++) {\r\n if (flightIdNameSpaces[i] + \":\" === curNameSpace && appFlightId.length <= MAXFLIGHTIDLENGTH) {\r\n isValid = true;\r\n break;\r\n }\r\n }\r\n return isValid;\r\n}\r\nfunction _getExpId() {\r\n return this.getExpId();\r\n}\r\nvar Application = /** @class */ (function () {\r\n function Application(propertiesConfig, core, unloadHookContainer) {\r\n var _appExpId = null;\r\n // Create a copy of the defaultNamespaces\r\n var flightIdNameSpaces = defaultFlightIdNameSpaces.slice(0);\r\n var expIdCookieName = \"Treatments\";\r\n var _cookieMgr;\r\n var _propertiesConfig = null;\r\n dynamicProto(Application, this, function (_self) {\r\n _populateDefaults(propertiesConfig);\r\n // Add app language\r\n if (hasDocument()) {\r\n var documentElement = getDocument().documentElement;\r\n if (documentElement) {\r\n _self.locale = documentElement.lang;\r\n }\r\n }\r\n _self.getExpId = function () {\r\n return _propertiesConfig.expId ? _readExpIdFromCoreData(_propertiesConfig.expId) : _readExpIdFromCookie();\r\n };\r\n /**\r\n * Retrieve a specified metadata tag value from the DOM.\r\n * @param prefix - Prefix to search the metatags with.\r\n * @returns Metadata collection/property bag\r\n */\r\n function _getMetaDataFromDOM(prefix) {\r\n var metaElements;\r\n var metaData = {};\r\n var doc = getDocument();\r\n if (doc) {\r\n metaElements = doc && doc.querySelectorAll(\"meta\");\r\n for (var i = 0; i < metaElements.length; i++) {\r\n var meta = metaElements[i];\r\n if (meta.name) {\r\n var mt = meta.name.toLowerCase();\r\n if (mt.indexOf(prefix) === 0) {\r\n var name = meta.name.replace(prefix, \"\");\r\n metaData[name] = meta.content;\r\n }\r\n }\r\n }\r\n }\r\n return metaData;\r\n }\r\n /// <summary>Validate each flight id in appExpId against the app flight ID\r\n /// format and create a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs< /summary>\r\n /// <param type='Object'>A list of comma seperated appExpId</param>\r\n /// <returns type='void'>none</returns>\r\n function _setAppExpId(appExpIdNew) {\r\n if (appExpIdNew === _appExpId) {\r\n return; // Nothing to do if seen before\r\n }\r\n // Reset to empty first. The new but invalid appExpId should not be logged and we cannot leave the old one hanging around\r\n // since it means old experiment id cannot represent the new experiment with an invalid appExpId.\r\n _appExpId = _validateAppExpId(appExpIdNew, flightIdNameSpaces);\r\n }\r\n function _readExpIdFromCookie() {\r\n var cookieValue = getCookieValue(_cookieMgr, expIdCookieName);\r\n _setAppExpId(cookieValue);\r\n return _appExpId;\r\n }\r\n function _readExpIdFromCoreData(expId) {\r\n _setAppExpId(expId);\r\n return _appExpId;\r\n }\r\n function _populateDefaults(config) {\r\n // This function will be re-called whenever any referenced configuration is changed\r\n var unloadHook = onConfigChange(config, function () {\r\n _cookieMgr = core && core.getCookieMgr();\r\n _propertiesConfig = config || {};\r\n // config.env default is set at properities plugin level with \"\"\r\n _self.env = _propertiesConfig.env || _getMetaDataFromDOM(\"awa-\")[\"env\"];\r\n });\r\n unloadHookContainer && unloadHookContainer.add(unloadHook);\r\n }\r\n });\r\n }\r\n /**\r\n * The application experiment Id.\r\n */\r\n Application.prototype.getExpId = function () {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return null;\r\n };\r\n /// <summary>Validate each flight id in appExpId against the app flight ID\r\n /// format and create a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs< /summary>\r\n /// <param type='Object'>A list of comma seperated appExpId</param>\r\n /// <returns type='void'>none</returns>\r\n /**\r\n * Validate each flight id in appExpId against the app flight ID format and create\r\n * a comma seperated appExpId with valid flight ids.Ignore invalid flight IDs\r\n * @param appExpId - The current experiment id\r\n * @param appExpIdNew - The new experiment id to set (if valid)\r\n * @param flightIdNameSpaces - The valid set of flight id names\r\n * @returns The validated experiment id,\r\n */\r\n Application.validateAppExpId = _validateAppExpId;\r\n /**\r\n * Static constructor, attempt to create accessors\r\n */\r\n Application._staticInit = (function () {\r\n // Dynamically create get/set property accessors\r\n objDefine(Application.prototype, \"expId\", { g: _getExpId });\r\n })();\r\n return Application;\r\n}());\r\nexport { Application };\r\n//# sourceMappingURL=Application.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mDAMM;AACN;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}