Skip to content

Commit 5b04476

Browse files
committed
cleanup
1 parent 6032ba0 commit 5b04476

28 files changed

+46
-1120
lines changed

lib/core/event_builder/build_event_v1.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
EventTags,
1818
ConversionEvent,
1919
ImpressionEvent,
20-
} from '../../event_processor';
20+
} from '../../event_processor/events';
2121

2222
import { Event } from '../../shared_types';
2323

lib/core/event_builder/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import { LoggerFacade } from '../../modules/logging';
17-
import { EventV1 as CommonEventParams } from '../../event_processor';
17+
import { EventV1 as CommonEventParams } from '../../event_processor/v1/buildEventV1';
1818

1919
import fns from '../../utils/fns';
2020
import { CONTROL_ATTRIBUTES, RESERVED_EVENT_KEYWORDS } from '../../utils/enums';

lib/event_processor/batch_event_processor.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ describe('QueueingEventProcessor', async () => {
726726
expect(mockDispatch).toHaveBeenCalledTimes(1);
727727
expect(mockDispatch.mock.calls[0][0]).toEqual(formatEvents(failedEvents));
728728

729-
let eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
729+
const eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
730730
expect(eventsInStore).toEqual(expect.arrayContaining([
731731
expect.objectContaining(eventA),
732732
expect.objectContaining(eventB),
@@ -782,7 +782,7 @@ describe('QueueingEventProcessor', async () => {
782782
mockResult2.resolve({});
783783
await exhaustMicrotasks();
784784

785-
let eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
785+
const eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
786786
expect(eventsInStore).toEqual(expect.arrayContaining([
787787
expect.objectContaining(eventA),
788788
expect.objectContaining(eventB),
@@ -876,7 +876,7 @@ describe('QueueingEventProcessor', async () => {
876876
expect(mockDispatch).toHaveBeenCalledTimes(1);
877877
expect(mockDispatch.mock.calls[0][0]).toEqual(formatEvents(failedEvents));
878878

879-
let eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
879+
const eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
880880
expect(eventsInStore).toEqual(expect.arrayContaining([
881881
expect.objectContaining(eventA),
882882
expect.objectContaining(eventB),
@@ -934,7 +934,7 @@ describe('QueueingEventProcessor', async () => {
934934
mockResult2.resolve({});
935935
await exhaustMicrotasks();
936936

937-
let eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
937+
const eventsInStore = [...cache.getAll().values()].sort((a, b) => a.id < b.id ? -1 : 1).map(e => e.event);
938938
expect(eventsInStore).toEqual(expect.arrayContaining([
939939
expect.objectContaining(eventA),
940940
expect.objectContaining(eventB),

lib/event_processor/default_dispatcher.browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { BrowserRequestHandler } from "../utils/http_request_handler/browser_request_handler";
18-
import { EventDispatcher } from '../event_processor';
18+
import { EventDispatcher } from '../event_processor/eventDispatcher';
1919
import { DefaultEventDispatcher } from './default_dispatcher';
2020

2121
const eventDispatcher: EventDispatcher = new DefaultEventDispatcher(new BrowserRequestHandler());

lib/event_processor/default_dispatcher.node.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import { EventDispatcher } from '../event_processor';
16+
import { EventDispatcher } from '../event_processor/eventDispatcher';
1717
import { NodeRequestHandler } from '../utils/http_request_handler/node_request_handler';
1818
import { DefaultEventDispatcher } from './default_dispatcher';
1919

lib/event_processor/default_dispatcher.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616
import { RequestHandler } from '../utils/http_request_handler/http';
17-
import { EventDispatcher, EventDispatcherResponse, EventV1Request } from '../event_processor';
17+
import { EventDispatcher, EventDispatcherResponse, EventV1Request } from '../event_processor/eventDispatcher';
1818

1919
export class DefaultEventDispatcher implements EventDispatcher {
2020
private requestHandler: RequestHandler;

lib/event_processor/eventProcessor.ts

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
import { ConversionEvent, ImpressionEvent } from './events'
1717
import { EventV1Request } from './eventDispatcher'
18-
import { EventQueue, DefaultEventQueue, SingleEventQueue, EventQueueSink } from './eventQueue'
1918
import { getLogger } from '../modules/logging'
2019
import { NOTIFICATION_TYPES } from '../utils/enums'
2120
import { NotificationSender } from '../core/notification_center'
@@ -33,56 +32,3 @@ export interface EventProcessor extends Service {
3332
process(event: ProcessableEvent): Promise<unknown>;
3433
onDispatch(handler: Consumer<EventV1Request>): Fn;
3534
}
36-
37-
export function validateAndGetFlushInterval(flushInterval: number): number {
38-
if (flushInterval <= 0) {
39-
logger.warn(
40-
`Invalid flushInterval ${flushInterval}, defaulting to ${DEFAULT_FLUSH_INTERVAL}`,
41-
)
42-
flushInterval = DEFAULT_FLUSH_INTERVAL
43-
}
44-
return flushInterval
45-
}
46-
47-
export function validateAndGetBatchSize(batchSize: number): number {
48-
batchSize = Math.floor(batchSize)
49-
if (batchSize < 1) {
50-
logger.warn(
51-
`Invalid batchSize ${batchSize}, defaulting to ${DEFAULT_BATCH_SIZE}`,
52-
)
53-
batchSize = DEFAULT_BATCH_SIZE
54-
}
55-
batchSize = Math.max(1, batchSize)
56-
return batchSize
57-
}
58-
59-
export function getQueue(
60-
batchSize: number,
61-
flushInterval: number,
62-
batchComparator: (eventA: ProcessableEvent, eventB: ProcessableEvent) => boolean,
63-
sink: EventQueueSink<ProcessableEvent>,
64-
closingSink?: EventQueueSink<ProcessableEvent>
65-
): EventQueue<ProcessableEvent> {
66-
let queue: EventQueue<ProcessableEvent>
67-
if (batchSize > 1) {
68-
queue = new DefaultEventQueue<ProcessableEvent>({
69-
flushInterval,
70-
maxQueueSize: batchSize,
71-
sink,
72-
closingSink,
73-
batchComparator,
74-
})
75-
} else {
76-
queue = new SingleEventQueue({ sink })
77-
}
78-
return queue
79-
}
80-
81-
export function sendEventNotification(notificationSender: NotificationSender | undefined, event: EventV1Request): void {
82-
if (notificationSender) {
83-
notificationSender.sendNotifications(
84-
NOTIFICATION_TYPES.LOG_EVENT,
85-
event,
86-
)
87-
}
88-
}

lib/event_processor/eventQueue.ts

Lines changed: 0 additions & 162 deletions
This file was deleted.

0 commit comments

Comments
 (0)