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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eppo/js-client-sdk-common",
"version": "4.5.0",
"version": "4.5.1",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)",
"main": "dist/index.js",
"files": [
Expand Down
16 changes: 8 additions & 8 deletions src/events/default-event-dispatcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
} from './default-event-dispatcher';
import { Event } from './event-dispatcher';
import NetworkStatusListener from './network-status-listener';
import NoOpEventDispatcher from './no-op-event-dispatcher';

global.fetch = jest.fn();

const mockNetworkStatusListener = {
isOffline: () => false,
onNetworkStatusChange: (_: (_: boolean) => void) => null as unknown as void,

Check warning on line 15 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (18)

'_' is defined but never used

Check warning on line 15 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (20)

'_' is defined but never used

Check warning on line 15 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (22)

'_' is defined but never used

Check warning on line 15 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (23)

'_' is defined but never used
};

const createDispatcher = (
Expand Down Expand Up @@ -141,7 +142,7 @@
describe('offline handling', () => {
it('skips delivery when offline', async () => {
let isOffline = false;
let cb = (_: boolean) => null as unknown as void;

Check warning on line 145 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (18)

'_' is defined but never used

Check warning on line 145 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (20)

'_' is defined but never used

Check warning on line 145 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (22)

'_' is defined but never used

Check warning on line 145 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (23)

'_' is defined but never used
const networkStatusListener = {
isOffline: () => isOffline,
onNetworkStatusChange: (callback: (isOffline: boolean) => void) => {
Expand All @@ -165,7 +166,7 @@

it('resumes delivery when back online', async () => {
let isOffline = true;
let cb = (_: boolean) => null as unknown as void;

Check warning on line 169 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (18)

'_' is defined but never used

Check warning on line 169 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (20)

'_' is defined but never used

Check warning on line 169 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (22)

'_' is defined but never used

Check warning on line 169 in src/events/default-event-dispatcher.spec.ts

View workflow job for this annotation

GitHub Actions / lint-test-sdk (23)

'_' is defined but never used
const networkStatusListener = {
isOffline: () => isOffline,
onNetworkStatusChange: (callback: (isOffline: boolean) => void) => {
Expand Down Expand Up @@ -201,14 +202,13 @@
});

describe('newDefaultEventDispatcher', () => {
it('should throw if SDK key is invalid', () => {
expect(() => {
newDefaultEventDispatcher(
new ArrayBackedNamedEventQueue('test-queue'),
mockNetworkStatusListener,
'invalid-sdk-key',
);
}).toThrow('Unable to parse Event ingestion URL from SDK key');
it('should fallback to no-op dispatcher if SDK key is invalid', () => {
const eventDispatcher = newDefaultEventDispatcher(
new ArrayBackedNamedEventQueue('test-queue'),
mockNetworkStatusListener,
'invalid-sdk-key',
);
expect(eventDispatcher).toBeInstanceOf(NoOpEventDispatcher);
});

it('should create a new DefaultEventDispatcher with the provided configuration', () => {
Expand Down
6 changes: 5 additions & 1 deletion src/events/default-event-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import EventDelivery from './event-delivery';
import EventDispatcher, { Event } from './event-dispatcher';
import NamedEventQueue from './named-event-queue';
import NetworkStatusListener from './network-status-listener';
import NoOpEventDispatcher from './no-op-event-dispatcher';
import SdkKeyDecoder from './sdk-key-decoder';

export type EventDispatcherConfig = {
Expand Down Expand Up @@ -135,7 +136,10 @@ export function newDefaultEventDispatcher(
const sdkKeyDecoder = new SdkKeyDecoder();
const ingestionUrl = sdkKeyDecoder.decodeEventIngestionHostName(sdkKey);
if (!ingestionUrl) {
throw new Error('Unable to parse Event ingestion URL from SDK key');
logger.debug(
'Unable to parse Event ingestion URL from SDK key, falling back to no-op event dispatcher',
);
return new NoOpEventDispatcher();
}
return new DefaultEventDispatcher(
new BatchEventProcessor(eventQueue, batchSize),
Expand Down
Loading