mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
updates documentation and adds typings for axiosConfig (#4405)
This commit is contained in:
parent
4940348dd9
commit
7d3526940e
@ -1,4 +1,5 @@
|
|||||||
import Analytics from 'analytics-node';
|
import Analytics from 'analytics-node';
|
||||||
|
import { AxiosRequestConfig } from 'axios';
|
||||||
import * as uuid from 'uuid';
|
import * as uuid from 'uuid';
|
||||||
|
|
||||||
import { getAccountId } from '../account/session';
|
import { getAccountId } from '../account/session';
|
||||||
@ -12,14 +13,18 @@ import {
|
|||||||
getSegmentWriteKey,
|
getSegmentWriteKey,
|
||||||
} from './constants';
|
} from './constants';
|
||||||
|
|
||||||
|
const axiosConfig: AxiosRequestConfig = {
|
||||||
|
// This is needed to ensure that we use the NodeJS adapter in the render process
|
||||||
|
...(global?.require ? {
|
||||||
|
adapter: global.require('axios/lib/adapters/http'),
|
||||||
|
} : {}),
|
||||||
|
};
|
||||||
|
|
||||||
const segmentClient = new Analytics(getSegmentWriteKey(), {
|
const segmentClient = new Analytics(getSegmentWriteKey(), {
|
||||||
// @ts-expect-error -- TSCONVERSION
|
// @ts-expect-error this is missing from the analytics-node types (and docs) but is present in the source code
|
||||||
axiosConfig: {
|
// https://github.com/segmentio/analytics-node/blob/0a6aa0d9d865b56f799f9d014b4d7b98ae5d2f2e/index.js#L28
|
||||||
// This is needed to ensure that we use the NodeJS adapter in the render process
|
// as for the types: since (as of @types/analytics-node v3.1.7) this is hardcoded into a class constructor, it makes it hard to fix with module augmentation
|
||||||
...(global?.require && {
|
axiosConfig,
|
||||||
adapter: global.require('axios/lib/adapters/http'),
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const getDeviceId = async () => {
|
const getDeviceId = async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user