analytics-next icon indicating copy to clipboard operation
analytics-next copied to clipboard

DestinationMiddlewareFunction type is missing from export

Open antgonzales opened this issue 1 year ago • 1 comments

I'm currently trying to create a Destination Middleware Function outlined in this guide: https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/middleware/

The current @segment/analytics-next library supports importing the general MiddlewareFunction type but does not support DestinationMiddlewareFunction.

Here's how I want to use the type:

import type { DestinationMiddlewareFunction } from '@segment/analytics-next';

export function destinationMiddlewareFactory(): DestinationMiddlewareFunction {
  return function destinationMiddlware({payload, integration, next}) {
    ...
    next(payload)
  }
}

I'm currently using "@segment/analytics-next": "^1.53.3".

Here is the type in the sourcecode: https://github.com/segmentio/analytics-next/blob/9ba0dc6fc1fb237bbed72da458d0c4ea80d52cd8/packages/browser/src/plugins/middleware/index.ts#L23

antgonzales avatar Aug 16 '23 19:08 antgonzales

Hey @antgonzales

We would accept a PR for this if you want to fast track it.

silesky avatar Aug 16 '23 22:08 silesky