Skip to content

Commit f556cc0

Browse files
committed
wip
1 parent e960708 commit f556cc0

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

packages/browser/src/core/events/index.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import { v4 as uuid } from '@lukeed/uuid'
22
import { ID, User } from '../user'
33
import { Options, EventProperties, Traits, SegmentEvent } from './interfaces'
44
import { addPageContext, PageContext } from '../page'
5-
import { CoreEventFactory } from '@segment/analytics-core'
6-
import type { BrowserIntegrationsOptions } from '../../browser/settings'
5+
import { CoreEventFactory, IntegrationsOptions } from '@segment/analytics-core'
76

87
export * from './interfaces'
98

@@ -48,7 +47,7 @@ export class EventFactory extends CoreEventFactory {
4847
event: string,
4948
properties?: EventProperties,
5049
options?: Options,
51-
globalIntegrations?: BrowserIntegrationsOptions,
50+
globalIntegrations?: IntegrationsOptions,
5251
pageCtx?: PageContext
5352
): SegmentEvent {
5453
const ev = super.track(event, properties, options, globalIntegrations)
@@ -61,7 +60,7 @@ export class EventFactory extends CoreEventFactory {
6160
page: string | null,
6261
properties?: EventProperties,
6362
options?: Options,
64-
globalIntegrations?: BrowserIntegrationsOptions,
63+
globalIntegrations?: IntegrationsOptions,
6564
pageCtx?: PageContext
6665
): SegmentEvent {
6766
const ev = super.page(
@@ -80,7 +79,7 @@ export class EventFactory extends CoreEventFactory {
8079
screen: string | null,
8180
properties?: EventProperties,
8281
options?: Options,
83-
globalIntegrations?: BrowserIntegrationsOptions,
82+
globalIntegrations?: IntegrationsOptions,
8483
pageCtx?: PageContext
8584
): SegmentEvent {
8685
const ev = super.screen(
@@ -98,7 +97,7 @@ export class EventFactory extends CoreEventFactory {
9897
userId: ID,
9998
traits?: Traits,
10099
options?: Options,
101-
globalIntegrations?: BrowserIntegrationsOptions,
100+
globalIntegrations?: IntegrationsOptions,
102101
pageCtx?: PageContext
103102
): SegmentEvent {
104103
const ev = super.identify(userId, traits, options, globalIntegrations)
@@ -110,7 +109,7 @@ export class EventFactory extends CoreEventFactory {
110109
groupId: ID,
111110
traits?: Traits,
112111
options?: Options,
113-
globalIntegrations?: BrowserIntegrationsOptions,
112+
globalIntegrations?: IntegrationsOptions,
114113
pageCtx?: PageContext
115114
): SegmentEvent {
116115
const ev = super.group(groupId, traits, options, globalIntegrations)
@@ -122,7 +121,7 @@ export class EventFactory extends CoreEventFactory {
122121
to: string,
123122
from: string | null,
124123
options?: Options,
125-
globalIntegrations?: BrowserIntegrationsOptions,
124+
globalIntegrations?: IntegrationsOptions,
126125
pageCtx?: PageContext
127126
): SegmentEvent {
128127
const ev = super.alias(to, from, options, globalIntegrations)

packages/browser/src/plugins/segmentio/__tests__/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ describe('Segment.io', () => {
104104
await segmentio(analytics, {
105105
apiKey: '',
106106
deliveryStrategy: {
107+
strategy: 'standard',
107108
config: {
108109
headers: () => ({
109110
'X-My-Header': 'foo',

packages/browser/src/plugins/segmentio/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export function segmentio(
8484

8585
const deliveryStrategy = settings?.deliveryStrategy
8686
const client =
87-
deliveryStrategy?.strategy === 'batching'
87+
deliveryStrategy &&
88+
'strategy' in deliveryStrategy &&
89+
deliveryStrategy.strategy === 'batching'
8890
? batch(apiHost, deliveryStrategy.config)
8991
: standard(deliveryStrategy?.config)
9092

packages/browser/src/plugins/segmentio/shared-dispatcher.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ interface DispatchFetchConfig {
4646
priority?: RequestPriority
4747
}
4848

49-
export interface BatchingDispatchConfig extends DispatchFetchConfig {
49+
export type BatchingDispatchConfig = DispatchFetchConfig & {
5050
/**
5151
* The maximum number of events to send in a single request. If the batch reaches this size, a request will automatically be sent.
5252
*
@@ -73,10 +73,13 @@ export interface StandardDispatcherConfig extends DispatchFetchConfig {}
7373

7474
export type DeliveryStrategy =
7575
| {
76-
strategy?: 'standard'
76+
strategy: 'batching'
77+
config?: BatchingDispatchConfig
78+
}
79+
| {
80+
strategy: 'standard'
7781
config?: StandardDispatcherConfig
7882
}
7983
| {
80-
strategy?: 'batching'
81-
config?: BatchingDispatchConfig
84+
config: StandardDispatcherConfig
8285
}

0 commit comments

Comments
 (0)