Skip to content
Merged
Show file tree
Hide file tree
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/event_processor/batch_event_processor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,8 +33,8 @@ import { sprintf } from "../utils/fns";
import { SERVICE_STOPPED_BEFORE_RUNNING } from "../service";
import { Platform } from '../platform_support';

export const DEFAULT_MIN_BACKOFF = 1000;
export const DEFAULT_MAX_BACKOFF = 32000;
export const DEFAULT_MIN_BACKOFF = 200;
export const DEFAULT_MAX_BACKOFF = 1000;
export const MAX_EVENTS_IN_STORE = 500;

export type EventWithId = {
Expand Down
6 changes: 3 additions & 3 deletions lib/event_processor/event_processor_factory.browser.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -227,10 +227,10 @@ describe('createBatchEventProcessor', () => {
expect(mockGetOpaqueBatchEventProcessor.mock.calls[1][0].batchSize).toBe(undefined);
});

it('uses maxRetries value of 5 by default', () => {
it('uses maxRetries value of 2 by default', () => {
const processor = createBatchEventProcessor({ });
expect(Object.is(processor, mockGetOpaqueBatchEventProcessor.mock.results[0].value)).toBe(true);
expect(mockGetOpaqueBatchEventProcessor.mock.calls[0][0].retryOptions?.maxRetries).toBe(5);
expect(mockGetOpaqueBatchEventProcessor.mock.calls[0][0].retryOptions?.maxRetries).toBe(2);
});

it('uses the provided maxRetries value', () => {
Expand Down
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-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,7 +32,7 @@ import { DEFAULT_MAX_EVENTS_IN_STORE, EventStore } from './event_store';
import { Platform } from '../platform_support';
export const DEFAULT_EVENT_BATCH_SIZE = 10;
export const DEFAULT_EVENT_FLUSH_INTERVAL = 1_000;
export const EVENT_MAX_RETRIES_BROWSER = 5;
export const EVENT_MAX_RETRIES_BROWSER = 2;

export const createForwardingEventProcessor = (
eventDispatcher: EventDispatcher = defaultEventDispatcher,
Expand Down
6 changes: 3 additions & 3 deletions lib/event_processor/event_processor_factory.node.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -184,10 +184,10 @@ describe('createBatchEventProcessor', () => {
expect(mockGetOpaqueBatchEventProcessor.mock.calls[1][0].batchSize).toBe(undefined);
});

it('uses maxRetries value of 5 by default', () => {
it('uses maxRetries value of 2 by default', () => {
const processor = createBatchEventProcessor({ });
expect(Object.is(processor, mockGetOpaqueBatchEventProcessor.mock.results[0].value)).toBe(true);
expect(mockGetOpaqueBatchEventProcessor.mock.calls[0][0].retryOptions?.maxRetries).toBe(5);
expect(mockGetOpaqueBatchEventProcessor.mock.calls[0][0].retryOptions?.maxRetries).toBe(2);
});

it('uses the provided maxRetries value', () => {
Expand Down
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-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ import {
import { Platform } from '../platform_support';
export const DEFAULT_EVENT_BATCH_SIZE = 10;
export const DEFAULT_EVENT_FLUSH_INTERVAL = 30_000;
export const EVENT_MAX_RETRIES_NODE = 5;
export const EVENT_MAX_RETRIES_NODE = 2;

export const createForwardingEventProcessor = (
eventDispatcher: EventDispatcher = defaultEventDispatcher,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -281,10 +281,10 @@ describe('createBatchEventProcessor', () => {
expect(mockGetOpaqueBatchEventProcessor.mock.calls[1][0].batchSize).toBe(undefined);
});

it('uses maxRetries value of 5 by default', () => {
it('uses maxRetries value of 2 by default', () => {
const processor = createBatchEventProcessor({});
expect(Object.is(processor, mockGetOpaqueBatchEventProcessor.mock.results[0].value)).toBe(true);
expect(mockGetOpaqueBatchEventProcessor.mock.calls[0][0].retryOptions?.maxRetries).toBe(5);
expect(mockGetOpaqueBatchEventProcessor.mock.calls[0][0].retryOptions?.maxRetries).toBe(2);
});

it('uses the provided maxRetries value', () => {
Expand Down
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-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,7 +31,7 @@ import { DEFAULT_MAX_EVENTS_IN_STORE, EventStore } from './event_store';
import { Platform } from '../platform_support';
export const DEFAULT_EVENT_BATCH_SIZE = 10;
export const DEFAULT_EVENT_FLUSH_INTERVAL = 1_000;
export const EVENT_MAX_RETRIES_REACT_NATIVE = 5;
export const EVENT_MAX_RETRIES_REACT_NATIVE = 2;

export const createForwardingEventProcessor = (
eventDispatcher: EventDispatcher = defaultEventDispatcher,
Expand Down
4 changes: 2 additions & 2 deletions lib/event_processor/event_processor_factory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ describe('getBatchEventProcessor', () => {
expect(backoffProvider).not.toBe(undefined);
const backoff = backoffProvider?.();
expect(Object.is(backoff, MockExponentialBackoff.mock.instances[0])).toBe(true);
expect(MockExponentialBackoff).toHaveBeenNthCalledWith(1, DEFAULT_MIN_BACKOFF, DEFAULT_MAX_BACKOFF, 500);
expect(MockExponentialBackoff).toHaveBeenNthCalledWith(1, DEFAULT_MIN_BACKOFF, DEFAULT_MAX_BACKOFF, 50);
});

it('uses exponential backoff with provided backoff values in retryOptions', () => {
Expand All @@ -243,7 +243,7 @@ describe('getBatchEventProcessor', () => {
expect(backoffProvider).not.toBe(undefined);
const backoff = backoffProvider?.();
expect(Object.is(backoff, MockExponentialBackoff.mock.instances[0])).toBe(true);
expect(MockExponentialBackoff).toHaveBeenNthCalledWith(1, 1000, 2000, 500);
expect(MockExponentialBackoff).toHaveBeenNthCalledWith(1, 1000, 2000, 50);
});

it('uses a IntervalRepeater with default flush interval and adds a startup log if flushInterval is not provided', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/event_processor/event_processor_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const getBatchEventProcessor = (
backoffProvider: () => {
const minBackoff = retryOptions?.minBackoff ?? DEFAULT_MIN_BACKOFF;
const maxBackoff = retryOptions?.maxBackoff ?? DEFAULT_MAX_BACKOFF;
return new ExponentialBackoff(minBackoff, maxBackoff, 500);
return new ExponentialBackoff(minBackoff, maxBackoff, 50);
}
} : undefined;

Expand Down
10 changes: 5 additions & 5 deletions lib/odp/odp_manager_factory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,9 +32,9 @@ export const DEFAULT_CACHE_TIMEOUT = 600_000;

export const DEFAULT_EVENT_BATCH_SIZE = 100;
export const DEFAULT_EVENT_FLUSH_INTERVAL = 10_000;
export const DEFAULT_EVENT_MAX_RETRIES = 5;
export const DEFAULT_EVENT_MIN_BACKOFF = 1000;
export const DEFAULT_EVENT_MAX_BACKOFF = 32_000;
export const DEFAULT_EVENT_MAX_RETRIES = 2;
export const DEFAULT_EVENT_MIN_BACKOFF = 200;
export const DEFAULT_EVENT_MAX_BACKOFF = 1_000;

export const INVALID_CACHE = 'Invalid cache';
export const INVALID_CACHE_METHOD = 'Invalid cache method %s';
Expand Down Expand Up @@ -107,7 +107,7 @@ const getDefaultEventManager = (options: OdpManagerFactoryOptions) => {
backoffProvider: () => new ExponentialBackoff(
options.eventMinBackoff || DEFAULT_EVENT_MIN_BACKOFF,
options.eventMaxBackoff || DEFAULT_EVENT_MAX_BACKOFF,
500,
50,
),
},
});
Expand Down
6 changes: 5 additions & 1 deletion lib/utils/repeater/repeater.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2024-2025, Optimizely
* Copyright 2024-2026, Optimizely
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -51,6 +51,10 @@ export class ExponentialBackoff implements BackoffController {
this.base = base;
this.max = max;
this.maxJitter = maxJitter;
if (this.maxJitter > this.base / 2) {
this.maxJitter = this.base / 2;
}
this.maxJitter = maxJitter;
this.current = base;
}

Expand Down
Loading