DestinationMiddlewareFunction type is missing from export

Open
#929 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
api

Research direction

Start at packages/browser/src/plugins/middleware/index.ts, where DestinationMiddlewareFunction is defined, and compare its export path with MiddlewareFunction. Verify that a type-only import from @segment/analytics-next resolves successfully; done means consumers can import DestinationMiddlewareFunction from the package without using an internal path.

Written by the indexing model from the issue text.

Description

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

Dominant language
TypeScript
Stars
477
Forks
160
Avg merge
6h 19m
Merged PRs (30d)
4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from segmentio/analytics-next

All issues in segmentio/analytics-next

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.