Git Product home page Git Product logo

Comments (5)

tehhowch avatar tehhowch commented on August 25, 2024

I have been using the intercept service to intercept segmentio messages.
We have now upgraded to their new https://github.com/segmentio/analytics-next library.
Ever since, we are not able to see any of their messages in getRequests().
I know the interceptor is set up right because it is showing all the other network calls.
Only the messages generated by the segmentio library do not show up.
Anything about this library https://github.com/segmentio/analytics-next that needs special handling for the interceptor?

Based on your description, yes. I don't know anything about that library or how it implements its tracking functionality. If you would like this service to support intercepting those requests, you will need to do some research to figure out what that library is doing differently, and why that difference doesn't play with how this library works (which is by wrapping the global window object's fetch and XHR). Whoever in your org upgraded the library version should have determined what the changes were; so asking them would be a good place to start.

A PR to add support for whatever that library is now doing would be welcomed.

from wdio-intercept-service.

ksubramanian2 avatar ksubramanian2 commented on August 25, 2024

Thanks, @tehhowch, for the very quick response.
I can try creating the PR and testing it out.
Below is some code I see in the library
import unfetch from 'unfetch'

let fetch = unfetch
if (typeof window !== 'undefined') {
fetch = window.fetch || unfetch
}

export type Dispatcher = (url: string, body: object) => Promise

export default function (): { dispatch: Dispatcher } {
function dispatch(url: string, body: object): Promise {
return fetch(url, {
headers: { 'Content-Type': 'text/plain' },
method: 'post',
body: JSON.stringify(body),
})
}

return {
dispatch,
}
}
Anything stand out?

I see these additional fetch modules in the library code - unfetch, node-fetch, cross-fetch, minipass-fetch and make-fetch-happen.

from wdio-intercept-service.

ksubramanian2 avatar ksubramanian2 commented on August 25, 2024

@tehhowch I see the problem in the code above.
'fetch' variable is getting set at module initialization and even though the correct window.fetch (with interceptor) is passed to the analytics.page call later, dispatch is not using the current window.fetch, but uses the stored value of 'fetch'. One fix would be to make the assignment to 'fetch' inside the dispatch function. Then it would use the latest value.

from wdio-intercept-service.

tehhowch avatar tehhowch commented on August 25, 2024

There is no change possible in wdio-intercept-service, short of an entire change in its architecture (to support intercepting by some means that is not redefining window.fetch and global XMLHttpRequest), that will allow intercepting that code. You would need to propose the library revert a change it likely made for a specific reason, which is probably unlikely to be accepted.

from wdio-intercept-service.

ksubramanian2 avatar ksubramanian2 commented on August 25, 2024

@tehhowch I have created a PR for the library to enable the intercept.

from wdio-intercept-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.