diff --git a/src/main/ts/index.ts b/src/main/ts/index.ts index 32e7bc6..eabd9a8 100644 --- a/src/main/ts/index.ts +++ b/src/main/ts/index.ts @@ -1,7 +1,7 @@ import { IClientEventDto, LogLevel } from '@qiwi/substrate' import { nanoid } from 'nanoid' -import { IPipeOutput } from './interfaces' +import { IPipeOutput, TPipeline } from './interfaces' import { createFlpPipeline, eventifyPipe } from './pipes/flp' import { createTransmittable, createTransmitter } from './transmitter' import { getCookie, setCookie } from './utils/cookie' @@ -33,9 +33,11 @@ type IClientEventDtoFlp = Omit< const createFrontLogProxyTransmitter = ({ appName, url, + pipeline, }: { appName: string url?: string + pipeline?: TPipeline }) => { const appContextId = nanoid() const clientId = getClientId(appName) @@ -44,10 +46,12 @@ const createFrontLogProxyTransmitter = ({ } const transmitter = createTransmitter({ - pipeline: createFlpPipeline({ - url, - method: 'POST' as any, - }), + pipeline: + pipeline || + createFlpPipeline({ + url, + method: 'POST' as any, + }), }) return [ @@ -66,12 +70,12 @@ const createFrontLogProxyTransmitter = ({ data === undefined || data instanceof Error ) { - return transmitter.push(({ + return transmitter.push({ message: data, details: { appContextId, clientId }, meta: { appName }, level, - })) + }) } return transmitter.push({ diff --git a/src/main/ts/pipes/index.ts b/src/main/ts/pipes/index.ts index 5e7087f..df966a3 100644 --- a/src/main/ts/pipes/index.ts +++ b/src/main/ts/pipes/index.ts @@ -3,14 +3,13 @@ import once from 'lodash.once' import { IPipeOutput, ITransmittable, TPipeline } from '../interfaces' export const getPipelineId = (pipeline: TPipeline): string => - pipeline.reduce((acc, pipe, index) => - ( + pipeline.reduce( + (acc, pipe, index) => acc + (Array.isArray(pipe) ? `{${index}-[${getPipelineId(pipe)}]}` - : `{${index}-${pipe.type}}`) - ), - '' + : `{${index}-${pipe.type}}`), + '', ) export const execute = async ( diff --git a/src/test/ts/pipes/browserLocationHref.ts b/src/test/ts/pipes/browserLocationHref.ts index 6d9a7b6..fa2cd50 100644 --- a/src/test/ts/pipes/browserLocationHref.ts +++ b/src/test/ts/pipes/browserLocationHref.ts @@ -7,7 +7,9 @@ test('browserLocationHref is returned by factory', async () => { const browserLocationHrefPipe = createBrowserLocationHrefPipe() const res = await browserLocationHrefPipe.execute( { data: {}, err: null, meta: { history: [] } }, - () => { /* noop */ }, + () => { + /* noop */ + }, ) assert.equal(res, [ null,