Skip to content

Commit

Permalink
reorganise
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Nov 15, 2024
1 parent a44429e commit 482cfa8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/customizations/before-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ import { BeforeSendFn, CaptureResult, KnownEventName } from '../types'
import { includes } from '../utils'
import { isArray, isUndefined } from '../utils/type-utils'

function appendArray(currentValue: string[] | undefined, sampleType: string | string[]): string[] {
return [...(currentValue ? currentValue : []), ...(isArray(sampleType) ? sampleType : [sampleType])]
}

function updateThreshold(currentValue: number | undefined, percent: number): number {
return (isUndefined(currentValue) ? 1 : currentValue) * percent
}

function simpleHash(str: string) {
let hash = 0
for (let i = 0; i < str.length; i++) {
Expand Down Expand Up @@ -48,14 +56,6 @@ export function sampleByDistinctId(percent: number): BeforeSendFn {
}
}

function appendArray(currentValue: string[] | undefined, sampleType: string | string[]): string[] {
return [...(currentValue ? currentValue : []), ...(isArray(sampleType) ? sampleType : [sampleType])]
}

function updateThreshold(currentValue: number | undefined, percent: number): number {
return (isUndefined(currentValue) ? 1 : currentValue) * percent
}

/**
* Provides an implementation of sampling that samples based on the session ID.
* Using the provided percentage.
Expand Down

0 comments on commit 482cfa8

Please sign in to comment.