faro-web-sdk icon indicating copy to clipboard operation
faro-web-sdk copied to clipboard

Web tracing doesn't work with URI()/urijs: t.match is not a function

Open badalex opened this issue 7 months ago • 0 comments

Description

Hi,

We are trying out faro, so far really great product. We have some uses of https://www.npmjs.com/package/urijs for constructing urls. (Yes I know, urijs recommends using builtin URL these days... but here we are) faro-web-tracing doesn't seem to like that much and throws:

faro-web-tracing.iife.js:1:36572 TypeError: t.match is not a function

Breaking the (previously working) xhr request.

This looks fairly similar to #691

URI() returns an object with .toString() overloaded. Could/should web-tracing/src/faroXhrInstrumentation.ts's patchOpen stringify/ toString() non string/non URL objects it's passed?

Thanks!

Steps to reproduce

<!DOCTYPE html>
<html>
    <head>
        <script src="https://unpkg.com/@grafana/faro-web-sdk@^1.0.0/dist/bundle/faro-web-sdk.iife.js"></script>
        <script src="https://unpkg.com/@grafana/faro-web-tracing@^1.0.0/dist/bundle/faro-web-tracing.iife.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.19.11/URI.min.js"></script>
        <script>
            window.GrafanaFaroWebSdk.initializeFaro({
                app: { 'name': 'test' },
                transports: [
                  new window.GrafanaFaroWebSdk.FetchTransport({
                    url: '/',
                    apiKey: '1234',
                  }),
                ],
                instrumentations: [new window.GrafanaFaroWebTracing.TracingInstrumentation()]
            });

            var req = new XMLHttpRequest();
            req.open("GET", URI("https://github.com"), true);
            req.send();
        </script>
    </head>
</html>

badalex avatar Mar 25 '25 17:03 badalex