Projections: streamMetadata undefined

I want to run a projection based on stream metadata, so I have something like the following:

fromAll()

.when({

$any: function (s, e) {

if (e.streamMetadata) {

linkTo(‘event-’ + e.streamMetadata.MyMetaDataProperty, e);

}

}

});

When I debug though, eventEnvelop.streamMetadata is empty and streamMetadataRaw is undefined - even though the stream from which the Event originates has metadata.

Am I doing something wrong?

I thought it was more on the lines of

fromAll()

.when({

$any: function (s, e) {

if (e.body
!== null && e.body.MyMetadataproperty===123) {

linkTo(‘event-’ + e);

}

}

});