Skip to content

Raju/event flush default #1017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/entrypoint.test-d.ts
Original file line number Diff line number Diff line change
@@ -68,13 +68,13 @@ export type Entrypoint = {
eventDispatcher: EventDispatcher;
getSendBeaconEventDispatcher: () => EventDispatcher;
createForwardingEventProcessor: (eventDispatcher?: EventDispatcher) => OpaqueEventProcessor;
createBatchEventProcessor: (options: BatchEventProcessorOptions) => OpaqueEventProcessor;
createBatchEventProcessor: (options?: BatchEventProcessorOptions) => OpaqueEventProcessor;

// odp manager related exports
createOdpManager: (options: OdpManagerOptions) => OpaqueOdpManager;
createOdpManager: (options?: OdpManagerOptions) => OpaqueOdpManager;

// vuid manager related exports
createVuidManager: (options: VuidManagerOptions) => OpaqueVuidManager;
createVuidManager: (options?: VuidManagerOptions) => OpaqueVuidManager;

// logger related exports
LogLevel: typeof LogLevel;
4 changes: 2 additions & 2 deletions lib/event_processor/event_processor_factory.browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -39,7 +39,7 @@ export const createForwardingEventProcessor = (
const identity = <T>(v: T): T => v;

export const createBatchEventProcessor = (
options: BatchEventProcessorOptions
options: BatchEventProcessorOptions = {}
): OpaqueEventProcessor => {
const localStorageCache = new LocalStorageCache<EventWithId>();
const eventStore = new SyncPrefixCache<EventWithId, EventWithId>(
4 changes: 2 additions & 2 deletions lib/event_processor/event_processor_factory.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,7 @@ export const createForwardingEventProcessor = (
};

export const createBatchEventProcessor = (
options: BatchEventProcessorOptions
options: BatchEventProcessorOptions = {}
): OpaqueEventProcessor => {
const eventStore = options.eventStore ? getPrefixEventStore(options.eventStore) : undefined;

4 changes: 2 additions & 2 deletions lib/event_processor/event_processor_factory.react_native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,7 +53,7 @@ const getDefaultEventStore = () => {
}

export const createBatchEventProcessor = (
options: BatchEventProcessorOptions
options: BatchEventProcessorOptions = {}
): OpaqueEventProcessor => {
const eventStore = options.eventStore ? getPrefixEventStore(options.eventStore) : getDefaultEventStore();

3 changes: 2 additions & 1 deletion lib/event_processor/event_processor_factory.ts
Original file line number Diff line number Diff line change
@@ -23,7 +23,8 @@ import { BatchEventProcessor, DEFAULT_MAX_BACKOFF, DEFAULT_MIN_BACKOFF, EventWit
import { AsyncPrefixCache, Cache, SyncPrefixCache } from "../utils/cache/cache";

export const DEFAULT_EVENT_BATCH_SIZE = 10;
export const DEFAULT_EVENT_FLUSH_INTERVAL = 1000;
// export const DEFAULT_EVENT_FLUSH_INTERVAL = 1000;
export const DEFAULT_EVENT_FLUSH_INTERVAL = 30_000;
export const DEFAULT_EVENT_MAX_QUEUE_SIZE = 10000;
export const FAILED_EVENT_RETRY_INTERVAL = 20 * 1000;
export const EVENT_STORE_PREFIX = 'optly_event:';
4 changes: 2 additions & 2 deletions lib/odp/odp_manager_factory.browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,7 @@ import { getOpaqueOdpManager, OdpManagerOptions, OpaqueOdpManager } from './odp_

export const BROWSER_DEFAULT_API_TIMEOUT = 10_000;

export const createOdpManager = (options: OdpManagerOptions): OpaqueOdpManager => {
export const createOdpManager = (options: OdpManagerOptions = {}): OpaqueOdpManager => {
const segmentRequestHandler = new BrowserRequestHandler({
timeout: options.segmentsApiTimeout || BROWSER_DEFAULT_API_TIMEOUT,
});
4 changes: 2 additions & 2 deletions lib/odp/odp_manager_factory.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ export const NODE_DEFAULT_API_TIMEOUT = 10_000;
export const NODE_DEFAULT_BATCH_SIZE = 10;
export const NODE_DEFAULT_FLUSH_INTERVAL = 1000;

export const createOdpManager = (options: OdpManagerOptions): OpaqueOdpManager => {
export const createOdpManager = (options: OdpManagerOptions = {}): OpaqueOdpManager => {
const segmentRequestHandler = new NodeRequestHandler({
timeout: options.segmentsApiTimeout || NODE_DEFAULT_API_TIMEOUT,
});
4 changes: 2 additions & 2 deletions lib/odp/odp_manager_factory.react_native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ export const RN_DEFAULT_API_TIMEOUT = 10_000;
export const RN_DEFAULT_BATCH_SIZE = 10;
export const RN_DEFAULT_FLUSH_INTERVAL = 1000;

export const createOdpManager = (options: OdpManagerOptions): OpaqueOdpManager => {
export const createOdpManager = (options: OdpManagerOptions = {}): OpaqueOdpManager => {
const segmentRequestHandler = new BrowserRequestHandler({
timeout: options.segmentsApiTimeout || RN_DEFAULT_API_TIMEOUT,
});
7 changes: 4 additions & 3 deletions lib/vuid/vuid_manager_factory.browser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,11 @@ import { OpaqueVuidManager, VuidManagerOptions, wrapVuidManager } from './vuid_m

export const vuidCacheManager = new VuidCacheManager();

export const createVuidManager = (options: VuidManagerOptions): OpaqueVuidManager => {
export const createVuidManager = (options: VuidManagerOptions = {}): OpaqueVuidManager => {
return wrapVuidManager(new DefaultVuidManager({
vuidCacheManager,
vuidCache: options.vuidCache || new LocalStorageCache<string>(),
enableVuid: options.enableVuid
}));
}
};

4 changes: 2 additions & 2 deletions lib/vuid/vuid_manager_factory.node.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,6 @@ import { OpaqueVuidManager, VuidManagerOptions } from './vuid_manager_factory';

export const VUID_IS_NOT_SUPPORTED_IN_NODEJS= 'VUID is not supported in Node.js environment';

export const createVuidManager = (options: VuidManagerOptions): OpaqueVuidManager => {
export const createVuidManager = (options: VuidManagerOptions = {}): OpaqueVuidManager => {
throw new Error(VUID_IS_NOT_SUPPORTED_IN_NODEJS);
};
6 changes: 3 additions & 3 deletions lib/vuid/vuid_manager_factory.react_native.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024, Optimizely
* Copyright 2024-2025, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,10 +19,10 @@ import { OpaqueVuidManager, VuidManagerOptions, wrapVuidManager } from './vuid_m

export const vuidCacheManager = new VuidCacheManager();

export const createVuidManager = (options: VuidManagerOptions): OpaqueVuidManager => {
export const createVuidManager = (options: VuidManagerOptions = {}): OpaqueVuidManager => {
return wrapVuidManager(new DefaultVuidManager({
vuidCacheManager,
vuidCache: options.vuidCache || new AsyncStorageCache<string>(),
enableVuid: options.enableVuid
}));
}
};
Loading