8.0.0 • Published 20 days ago

anys-web-plugin-monitor-ajax v8.0.0

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
20 days ago

AnysMonitorAjaxPlugin

Monitor ajax.

Install

npm i anys-web-plugin-monitor-ajax
<script src="https://unpkg.com/anys-web-plugin-monitor-ajax"></script>

Usage

import { AnysMonitorAjaxPlugin } from 'anys-web-plugin-monitor-ajax';
<script>
    const { AnysMonitorAjaxPlugin } = window.anys;
    const anys = new Anys({
        plugins: [AnysMonitorAjaxPlugin],
    });
</script>

Options

  • xhr: boolean, wheather to monitor XMLHttpRequest
  • fetch: boolean, wheather to monitor fetch function
  • ajaxResponse: boolean, wheather to record ajax response, when set to false, response data will be removed from log
  • patchRequestId: boolean, wheather to patch anys.traceId + anys.requestId to each ajax request's url search query with a key _request_id
const anys = new Anys({
    ajaxResponse: false,
    patchRequestId: false,
});

Log

xhr

{
    type: 'xhr.req',
    time: Date.now(),
    name: `xhr_${name}`,
    url,
    detail: {
        method,
        async,
        body,
    },
}
{
    type: 'xhr.ok' | 'xhr.fail' | 'xhr.err',
    time: Date.now(),
    name: `xhr_${name}`,
    url,
    detail: {
        status: xhr.status,
        method,
        responseType,
        response: response || undefined,
    },
}

fetch

{
    type: 'fetch.init',
    time: Date.now(),
    name: `fetch_${name}`,
    url,
    detail: { body, method },
}
{
    type: 'fetch.ok',
    time: Date.now(),
    name: `fetch_${name}`,
    url,
    detail: {
        status,
        data,
        method,
    },
}
{
    type: 'fetch.fail',
    time: Date.now(),
    name: `fetch_${name}`,
    url,
    detail: {
        status,
        method,
    },
}
{
    type: 'fetch.err',
    time: Date.now(),
    name: `fetch_${name}`,
    url,
    detail: {
        method,
        err: message,
    },
}
8.0.0

20 days ago

7.0.0

2 months ago

6.4.0

5 months ago

6.3.0

5 months ago

6.2.0

6 months ago

6.1.1

6 months ago

6.0.0

6 months ago

5.0.3

6 months ago

5.0.2

7 months ago

5.0.0

7 months ago

4.0.0

7 months ago

3.1.0

8 months ago

3.0.2

8 months ago

3.0.1

8 months ago

3.0.0

8 months ago

2.0.2

8 months ago

2.0.0

8 months ago

1.4.0

8 months ago

1.2.0

9 months ago

1.1.3

9 months ago

1.1.0

9 months ago

1.0.1

9 months ago