Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove transport method that doesn't work #1167

Merged
merged 7 commits into from
May 8, 2024
Merged
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
20 changes: 1 addition & 19 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Compression, RequestOptions, RequestResponse } from './types'
import { formDataToQuery } from './utils/request-utils'

import { logger } from './utils/logger'
import { fetch, document, XMLHttpRequest, AbortController, navigator } from './utils/globals'
import { fetch, XMLHttpRequest, AbortController, navigator } from './utils/globals'
import { gzipSync, strToU8 } from 'fflate'

// eslint-disable-next-line compat/compat
Expand Down Expand Up @@ -183,19 +183,6 @@ const _sendBeacon = (options: RequestOptions) => {
}
}

const scriptRequest = (options: RequestOptions) => {
if (!document) {
return
}
const script = document.createElement('script')
script.type = 'text/javascript'
script.async = true
script.defer = true
script.src = options.url
const s = document.getElementsByTagName('script')[0]
s.parentNode?.insertBefore(script, s)
}

const AVAILABLE_TRANSPORTS: { transport: RequestOptions['transport']; method: (options: RequestOptions) => void }[] = []

// We add the transports in order of preference
Expand All @@ -221,11 +208,6 @@ if (navigator?.sendBeacon) {
})
}

AVAILABLE_TRANSPORTS.push({
transport: undefined,
method: scriptRequest,
})

// This is the entrypoint. It takes care of sanitizing the options and then calls the appropriate request method.
export const request = (_options: RequestOptions) => {
// Clone the options so we don't modify the original object
Expand Down
Loading