redux-beacon
redux-beacon copied to clipboard
Cannot use both ensure() and debounceEvent()?
This is a...
- [x] :beetle: Bug Report
- [ ] :rocket: Feature Request
- [ ] :scroll: Documentation Request
Note: for support questions, please use stackoverflow with the redux-beacon
tag. This repository's issues are reserved for feature requests and bug reports.
Which version of Redux Beacon are you using?
- v2.0.3
Which target(s) are you using?
- [ ] Google Analytics
- [ ] Google Analytics (gtag)
- [ ] React Native Google Analytics
- [ ] Google Tag Manager
- [ ] React Native Google Tag Manager
- [x] Amplitude
- [ ] Segment
- [ ] Other/Third Party: ...(please specify here)
(If this is a bug report, feel free to delete the :scroll: and :rocket: sections. Likewise, if this is a documentation or feature request, feel free to delete the :beetle: sections)
:beetle: What are the steps to reproduce your issue?
const validator = event => {
// validate event...
return true;
}
const emitEvent1 = ensure(validator, emitEvent1Debounced);
const emitEvent1Debounced = debounceEvent(60*1000,
logEvent((action) => ({
type: 'My Event'
}))
);
export default (action) => {
switch (action.type) {
case MY_ACTION:
return [emitEvent1, emitEvent2];
default:
return [];
}
}
Please note that when using only ensure()
or debounceEvent()
, it works as expected. This only happens when trying to use both on the same event.
:beetle: What did you expect to happen?
Event would be debounced, then validated before being sent to target. Or the other way around: validated first, then debounced.
:beetle: What happened instead?
Error:
Uncaught TypeError: eventDef is not a function
at ensure.js:4
at debounce-event.js:11
at wrapped (raven.js:351)
Can you help out?
- [ ] :star2: I am a legend and can get started on a pull request right away given the go-ahead.
- [x] :star: I am a superstar and would like to help out given some guidance.
- [ ] :disappointed: I won't be able to help out on this one.
Hey @julienma.
I would peg this as both a bug and a feature request. The ensure
event was never updated to handle asynchronous events when that was introduced to redux-beacon.
If you like I could write up some test cases that we'd need to pass in order for us to add support for them.
Also if you think it's worth adding a note in the docs that we don't currently support async events that would be very helpful.
Hey @ttmarek, thanks for the answer. I made some changes to my code logic, and don't need this anymore.
However yes, that'd probably be a good idea to add a note in the docs. I've opened https://github.com/rangle/redux-beacon/pull/288 for this.