segmentio / analytics-node

The hassle-free way to integrate analytics into any node application.
https://segment.com/libraries/node
MIT License
591 stars 151 forks source link

Support middleware functions #348

Open Mihailoff opened 2 years ago

Mihailoff commented 2 years ago

Browser library has a handy feature that allows using middleware functions.

https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/middleware/

edsonjab commented 2 years ago

Could you explain what is your issue, please?

Mihailoff commented 2 years ago

Filter events (or prevent tracking) dynamically based on the business rules.

edsonjab commented 2 years ago

Would using a source middleware read this documentation, please

Mihailoff commented 2 years ago

Server-side (analytics-node) is different from the source middleware that we use already. Not sure what you mean.

nd4p90x commented 2 years ago

@Mihailoff I believe there is some confusion as to exactly what the issue is you are having. Are you unable to filter events using your/our middleware solution? Are you describing a solution for another issue you may have had? I believe we just need some clarity on what the issue is exactly so we can better assist you in resolving it. Thank you.

Mihailoff commented 2 years ago

The client (browser) library has middleware functionality, I thought it would be logical to port the same approach to the server side. My issue is that I need to filter events based on dynamic rules -- custom middleware is a perfect solution for it. Client and server are different data sources.

pooyaj commented 2 years ago

@Mihailoff We are working on Node runtime support with https://github.com/segmentio/analytics-next (AJS 2.0) ... so you can use analytics-next to instrument a node-js applications. AJS comes with a plugin architecture, so you can register plugins to modify the payload before they are sent to Segment. Will keep this issue updated as we release the Node support for AJS 2.0

silesky commented 1 year ago

Middleware support is in the new analytics node: https://github.com/segmentio/analytics-next/tree/master/packages/node