-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort2: medium (days)freq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fixworkaround1: obvious
Description
Versions
1.5.0 (ejected configuration)
Repro steps
- Include in
module.rules
:
{
test: /(\.ngfactory\.js|\.ngstyle\.js|\.ts)$/,
use: [
{
loader: '@angular-devkit/build-optimizer/webpack-loader',
options: {
sourceMap: true
}
},
'@ngtools/webpack'
]
},
Step 2: Write code in a method for a component like this:
private instrumentCreateMenuImpression() {
const params: InstrumentationParams = {};
params[InstrumentationParam.ItemCount] = this.items ? this.items.length.toString() : '0';
params[InstrumentationParam.RenderSize] = this.createLinks ? this.createLinks.length.toString() : '0';
params[InstrumentationParam.Distribution] = this.createLinks
? this.createLinks.map(link => link.workload.Id).reduce((prevVal, currVal, index) => prevVal + (index === 0 ? '' : ';') + currVal, '')
: '';
const metrics = [
KnownInstrumentationEvents.CreateMenuImpression,
`${KnownInstrumentationEvents.CreateMenuImpression}.${this.createLinks.length}`
];
this.instrumentationService.generateImpressionEvent(KnownInstrumentationEvents.CreateMenuImpression, null, params, metrics).record();
}
Step 3: Observe build optimizer output:
CreateMenuComponent.prototype.instrumentCreateMenuImpression = function () {
var params = /*@__PURE__*/ (function () {
var params = {};
params[instrumentation_service["a" /* InstrumentationParam */].ItemCount] = this.items ? this.items.length.toString() : '0';
params[instrumentation_service["a" /* InstrumentationParam */].RenderSize] = this.createLinks ? this.createLinks.length.toString() : '0';
params[instrumentation_service["a" /* InstrumentationParam */].Distribution] = this.createLinks
? this.createLinks.map(function (link) { return link.workload.Id; }).reduce(function (prevVal, currVal, index) { return prevVal + (index === 0 ? '' : ';') + currVal; }, '')
: '';
return params;
})();
var metrics = [
instrumentation_service["e" /* KnownInstrumentationEvents */].CreateMenuImpression,
instrumentation_service["e" /* KnownInstrumentationEvents */].CreateMenuImpression + "." + this.createLinks.length
];
this.instrumentationService.generateImpressionEvent(instrumentation_service["e" /* KnownInstrumentationEvents */].CreateMenuImpression, null, params, metrics).record();
}
Observed behavior
An exception is thrown: 'Cannot read propery 'items' of undefined'
Desired behavior
Why is params
changing structure? I would expect the params
object to remain an object.
Mention any other details that might be useful (optional)
Angular 5.0.1
Webpack 3.8.1
TypeScript 2.4.2
alexkushnarov
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgenteffort2: medium (days)freq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fixworkaround1: obvious