fix(storage-resize-images): add missing recordStartEvent call
Fixes issue https://github.com/firebase/extensions/issues/2545
Hi @tad3j, thank you for working on this Pull Request 👏
Can you please make the changed below;
- Please update CHANGELOG.md to reflect what has changed.
- Please bump the extension version in extension.yaml
- Can you please move the event trigger to generateResizedImage function
Cheers!
Hey @HassanBahati .
Updated md and yml files as requested and moved event call to parent function. Notice that I also changed the argument (only passing object without sending name twice) and added await.
Btw, with change above onStart event fires even if shouldResize returns false. Shouldn't we skip onStart event in this case? (that's why I initially added event triggering inside generateResizedImageHandler , after shouldResize checck)
Hey @tad3j that's a good point. The description of this particular event in the extension.yaml implies it is fired every time the function executes, but this is probably less useful here.
We will double check with the Firebase Extensions team to get their opinion on this.
I can think of three options:
- We filter firing the events by shouldResize (like in the original PR)
- We don't filter the events by shouldResize (but we still need the event adding, as in the current PR)
- We don't filter this event but we add a new event, something like "onStartResize"
Hey @tad3j that's a good point. The description of this particular event in the extension.yaml implies it is fired every time the function executes, but this is probably less useful here.
We will double check with the Firebase Extensions team to get their opinion on this.
I can think of three options:
- We filter firing the events by shouldResize (like in the original PR)
- We don't filter the events by shouldResize (but we still need the event adding, as in the current PR)
- We don't filter this event but we add a new event, something like "onStartResize"
My use-case is cleanup before resize:
I want to delete users profile images (resized) before resizing uploaded one (on staging env I saw error that images weren't resized if they already exist hence why I started looking into this event). If event is fired before shouldResize this means I would delete profile images but resize wouldn't even be attempted...leaving user without profile pic (I know exception can occur and the same would happen but this is also the case if images don't exist yet).