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
5 changes: 5 additions & 0 deletions .changeset/loud-pears-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@segment/analytics-signals': patch
---

Fix max buffer size
16 changes: 7 additions & 9 deletions packages/signals/signals/src/core/buffer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
'readonly' | 'readwrite' | 'versionchange'
> {}

const MAX_BUFFER_SIZE_DEFAULT = 50

interface StoreSettings {
maxBufferSize: number
maxBufferSize?: number
}
export class SignalStoreIndexDB implements SignalPersistentStorage {
static readonly DB_NAME = 'Segment Signals Buffer'
Expand All @@ -50,7 +52,7 @@
}

constructor(settings: StoreSettings) {
this.maxBufferSize = settings.maxBufferSize
this.maxBufferSize = settings.maxBufferSize ?? MAX_BUFFER_SIZE_DEFAULT
this.db = this.initSignalDB()
}

Expand Down Expand Up @@ -137,7 +139,7 @@
private maxBufferSize: number

constructor(settings: StoreSettings) {
this.maxBufferSize = settings.maxBufferSize
this.maxBufferSize = settings.maxBufferSize ?? MAX_BUFFER_SIZE_DEFAULT

Check warning on line 142 in packages/signals/signals/src/core/buffer/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/signals/signals/src/core/buffer/index.ts#L142

Added line #L142 was not covered by tests
}

add(signal: Signal): void {
Expand Down Expand Up @@ -216,13 +218,9 @@
>(
settings: SignalBufferSettingsConfig<T>
) => {
const settingsWithDefaults: StoreSettings = {
maxBufferSize: 50,
...settings,
}
const store =
settings.signalStorage ?? settings.storageType === 'session'
? new SignalStoreSessionStorage(settingsWithDefaults)
: new SignalStoreIndexDB(settingsWithDefaults)
? new SignalStoreSessionStorage(settings)

Check warning on line 223 in packages/signals/signals/src/core/buffer/index.ts

View check run for this annotation

Codecov / codecov/patch

packages/signals/signals/src/core/buffer/index.ts#L223

Added line #L223 was not covered by tests
: new SignalStoreIndexDB(settings)
return new SignalBuffer(store)
}