Comments (6)
heartbeat
ticks every 3 sec and flushes any queued events
abort
should be a function there. I've tested this locally with another identifyStart
plugin. Are you calling abort
from anywhere else? Maybe verify it exists before calling it with typeof abort === 'function'
check
Also, It looks like you are missing required name key from your plugin. It should be:
const validationPlugin = {
name: 'my-plugin-name',
identifyStart: ({ payload, abort }) => {
const prev = identifyTraits[payload.userId];
const traits = { ...identifyTraits[payload.userId], ...payload.traits };
if (isEqual(prev, traits)) {
return abort('Identify traits is the same as previous identify');
}
identifyTraits[payload.userId] = traits;
return { ...payload, traits };
}
}
from analytics.
I misread the setInterval as setTimeout, so that explains my confusion about that, but doesn't explain the problem.
The code was just a truncated example so it has a name and other methods, but that is one of the places where the abort function sometimes is missing.
I still don't get how the abort-function i added to the arguments when called from the heartbeat here, because method
here is my identifyStart
as defined above, right?
I could add a guard against the missing abort, but that seem like a recipe for dropping data so I would rather avoid it.
from analytics.
Aha I see.
We probably need a noOp
function in heartbeat. Need to test this out
method({
payload: enrichedPayload,
config: plugins[currentPlugin].config,
instance,
// NoOp on queue drain
abort: () => {}
})
......
When are you calling analytics.identify
in your application? It sounds like you might be running it before all the providers are loaded. This is causing calls to get queued for the heartbeat to flush when it's back. Alternatively, it's from navigator.onLine
toggling and the users internet connection going in and out...
You can try to use .ready
to avoid the first case
analytics.ready(() => {
analytics.identify('abc', { name: 'bob' })
})
from analytics.
Why shouldn't the plugins called from heartbeat be abortable?
We use a queue so it is not so easy to tell when the actual analytics.identify
is being called.
If it's a problem with providers loading that would explain why the problem is so hard to reproduce, it could be the users network connection or firewall that is the problem. But shouldn't the identify
(and others such as track
) be queued when called before ready
?
from analytics.
Why shouldn't the plugins called from heartbeat be abortable?
Yeah probably. The heartbeat was initially setup for simple edge cases though ("Just queue events to fire when network resumes").
The queued items get processed in order here
but the return values aren't checked like the main flow.abort
calls just return an object with abort
key and this signals downstream actions to halt. You can see queue via Analytics.getState().queue
Need to think about how we can get this working for the items shifted off into the queue.
I've reproduced the issue
from analytics.
Fixed in [email protected]
Thanks for reporting this edge case
from analytics.
Related Issues (20)
- Request an analytics integration HOT 1
- Plugin Request: AWS Personalize HOT 1
- @analytics/snowplow not working HOT 1
- Remove user_id as a custom dimension in google-analytics event payload
- Angular warns about using "dlv" – can cause optimization bailouts HOT 2
- Allow URL params for simpleanalytics HOT 2
- Request to upgrade analytics-node to resolve security issue in Axios HOT 2
- Update intercom-client in analytics-plugin-intercom
- Add support for Rudderstack HOT 1
- ga4 support for other protocols HOT 1
- Plugin Request - Server-side Implementation - Google Analytics HOT 3
- Dependency Security: Axios Cross-Site Request Forgery Vulnerability HOT 1
- new Chrome cookie policy warning HOT 1
- OneTrust integration HOT 2
- Google Consent Mode v2 HOT 3
- Google Tag Manager - Consent Mode V2 implementation (Next.js 14)
- Customerio Plugin uses customerio-node v0.5.0
- How to contribute a plugin? HOT 1
- Unloading Plugins based on Path HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from analytics.