-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The wirings have been moved to segment-inspector/packages/webext/src/broker/index.ts
- Loading branch information
Showing
6 changed files
with
50 additions
and
666 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@segment/analytics-next': patch | ||
--- | ||
|
||
Remove direct wirings for Segment Inspector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
packages/browser/src/core/inspector/__tests__/index.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
import type { InspectBroker } from '@segment/inspector-webext' | ||
import { getGlobal } from '../../lib/get-global' | ||
import type { Analytics } from '../analytics' | ||
|
||
declare global { | ||
interface Window { | ||
__SEGMENT_INSPECTOR__: Partial<InspectBroker> | ||
} | ||
} | ||
|
||
const env = getGlobal() | ||
|
||
// The code below assumes the inspector extension will use Object.assign | ||
// to add the inspect interface on to this object reference (unless the | ||
// extension code ran first and has already set up the variable) | ||
const inspectorHost: Partial<InspectBroker> = ((env as any)[ | ||
'__SEGMENT_INSPECTOR__' | ||
] ??= {}) | ||
const inspectorHost: { | ||
attach: (analytics: Analytics) => void | ||
} = ((env as any)['__SEGMENT_INSPECTOR__'] ??= {}) | ||
|
||
export const attachInspector = (analytics: Analytics) => { | ||
export const attachInspector = (analytics: Analytics) => | ||
inspectorHost.attach?.(analytics as any) | ||
|
||
analytics.on('dispatch_start', (ctx) => inspectorHost.triggered?.(ctx as any)) | ||
|
||
analytics.queue.on('message_enriched', (ctx) => | ||
inspectorHost.enriched?.(ctx as any) | ||
) | ||
|
||
analytics.queue.on('message_delivered', (ctx) => | ||
// FIXME: Resolve browsers destinations that the event was sent to | ||
inspectorHost.delivered?.(ctx as any, ['segment.io']) | ||
) | ||
} |
Oops, something went wrong.