diff --git a/lib/entrypoint.test-d.ts b/lib/entrypoint.test-d.ts index a9a782522..ee6408344 100644 --- a/lib/entrypoint.test-d.ts +++ b/lib/entrypoint.test-d.ts @@ -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; diff --git a/lib/event_processor/event_processor_factory.browser.ts b/lib/event_processor/event_processor_factory.browser.ts index 0ce034dc7..7270d9b86 100644 --- a/lib/event_processor/event_processor_factory.browser.ts +++ b/lib/event_processor/event_processor_factory.browser.ts @@ -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 = (v: T): T => v; export const createBatchEventProcessor = ( - options: BatchEventProcessorOptions + options: BatchEventProcessorOptions = {} ): OpaqueEventProcessor => { const localStorageCache = new LocalStorageCache(); const eventStore = new SyncPrefixCache( diff --git a/lib/event_processor/event_processor_factory.node.ts b/lib/event_processor/event_processor_factory.node.ts index 4671ce3a3..29ccebade 100644 --- a/lib/event_processor/event_processor_factory.node.ts +++ b/lib/event_processor/event_processor_factory.node.ts @@ -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; diff --git a/lib/event_processor/event_processor_factory.react_native.ts b/lib/event_processor/event_processor_factory.react_native.ts index fefb3f816..0fc5ed8ed 100644 --- a/lib/event_processor/event_processor_factory.react_native.ts +++ b/lib/event_processor/event_processor_factory.react_native.ts @@ -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(); diff --git a/lib/event_processor/event_processor_factory.ts b/lib/event_processor/event_processor_factory.ts index fe7f838f7..4e8b40c64 100644 --- a/lib/event_processor/event_processor_factory.ts +++ b/lib/event_processor/event_processor_factory.ts @@ -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:'; diff --git a/lib/odp/odp_manager_factory.browser.ts b/lib/odp/odp_manager_factory.browser.ts index 2090dcb87..bf56d82cd 100644 --- a/lib/odp/odp_manager_factory.browser.ts +++ b/lib/odp/odp_manager_factory.browser.ts @@ -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, }); diff --git a/lib/odp/odp_manager_factory.node.ts b/lib/odp/odp_manager_factory.node.ts index 35d223462..e59c657bd 100644 --- a/lib/odp/odp_manager_factory.node.ts +++ b/lib/odp/odp_manager_factory.node.ts @@ -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, }); diff --git a/lib/odp/odp_manager_factory.react_native.ts b/lib/odp/odp_manager_factory.react_native.ts index 854ba32bc..c76312d6d 100644 --- a/lib/odp/odp_manager_factory.react_native.ts +++ b/lib/odp/odp_manager_factory.react_native.ts @@ -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, }); diff --git a/lib/vuid/vuid_manager_factory.browser.ts b/lib/vuid/vuid_manager_factory.browser.ts index 97e94dc2e..8aee22f97 100644 --- a/lib/vuid/vuid_manager_factory.browser.ts +++ b/lib/vuid/vuid_manager_factory.browser.ts @@ -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(), enableVuid: options.enableVuid })); -} +}; + diff --git a/lib/vuid/vuid_manager_factory.node.ts b/lib/vuid/vuid_manager_factory.node.ts index e8de3e564..54dd2dbaa 100644 --- a/lib/vuid/vuid_manager_factory.node.ts +++ b/lib/vuid/vuid_manager_factory.node.ts @@ -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); }; diff --git a/lib/vuid/vuid_manager_factory.react_native.ts b/lib/vuid/vuid_manager_factory.react_native.ts index 51b3f754b..0aeb1c537 100644 --- a/lib/vuid/vuid_manager_factory.react_native.ts +++ b/lib/vuid/vuid_manager_factory.react_native.ts @@ -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(), enableVuid: options.enableVuid })); -} +};