Skip to content

Commit

Permalink
👌 add endpoint type
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Aug 31, 2022
1 parent 50c4c1f commit eafac47
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/domain/configuration/endpointBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const INTAKE_TRACKS = {
sessionReplay: 'replay',
}

type EndpointType = keyof typeof ENDPOINTS
export type EndpointType = keyof typeof ENDPOINTS

export type EndpointBuilder = ReturnType<typeof createEndpointBuilder>

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/domain/configuration/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export {
DefaultPrivacyLevel,
validateAndBuildConfiguration,
} from './configuration'
export { createEndpointBuilder, EndpointBuilder } from './endpointBuilder'
export { createEndpointBuilder, EndpointBuilder, EndpointType } from './endpointBuilder'
export {
isExperimentalFeatureEnabled,
updateExperimentalFeatures,
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/transport/httpRequest.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { EndpointBuilder } from '../domain/configuration'
import type { EndpointBuilder, EndpointType } from '../domain/configuration'
import { addTelemetryError } from '../domain/telemetry'
import { monitor } from '../tools/monitor'
import { isExperimentalFeatureEnabled } from '../domain/configuration'
Expand All @@ -21,6 +21,7 @@ export interface HttpResponse {
export interface Payload {
data: string | FormData
bytesCount: number
type?: EndpointType
}

export function createHttpRequest(endpointBuilder: EndpointBuilder, bytesLimit: number) {
Expand All @@ -30,6 +31,7 @@ export function createHttpRequest(endpointBuilder: EndpointBuilder, bytesLimit:

return {
send: (payload: Payload) => {
payload.type = endpointBuilder.endpointType
if (!isExperimentalFeatureEnabled('retry')) {
fetchKeepAliveStrategy(endpointBuilder, bytesLimit, payload)
} else {
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/transport/sendWithRetryStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ function send(
function retryQueuedPayloads(state: RetryState, sendStrategy: SendStrategy, reason: string) {
const previousQueue = state.queuedPayloads
if (previousQueue.isFull()) {
addTelemetryDebug(`retry queue full after ${reason}`)
addTelemetryDebug('retry queue full', {
reason,
endpointType: previousQueue.first().type,
})
}
state.queuedPayloads = newPayloadQueue()
while (previousQueue.size() > 0) {
Expand Down

0 comments on commit eafac47

Please sign in to comment.