Skip to content

Commit 53987ed

Browse files
committed
fix: request util not awaiting json parsing, import replay package while replaying
1 parent 0212765 commit 53987ed

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

e2e/replay.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, test } from "@playwright/test";
22
import { REPLAY_NEXTJS_PORT, getBaseUrl, waitMs } from "./util";
33

4-
test('should replay front-end bug in nextjs example', async ({ page }) => {
4+
test.only('should replay front-end bug in nextjs example', async ({ page }) => {
55
// const capturesBefore = await fetchCaptures('sk_Y8dYLe5VoNJfDI_CPEqF8AqMTEwWAvTwBi7Ml-pN9bzWsgsP');
66
// Start from the index page (the baseURL is set via the webServer in the playwright.config.ts)
77
await page.goto(getBaseUrl(REPLAY_NEXTJS_PORT));

src/core/requestUtils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ export async function request<DataType = unknown>(
2525
...(options.headers && { headers: options.headers }),
2626
body
2727
})
28-
if (data.status >= 400 && data.status < 600) throw await data.text()
29-
return Ok(data.json() as DataType)
28+
if (data.status >= 400 && data.status < 600) {
29+
throw await data.text()
30+
}
31+
return Ok((await data.json()) as DataType)
3032
} catch (error) {
3133
return Err(
3234
createHumanLog({

src/core/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ export type FlytrapConfig = {
135135
/**
136136
* Use Flytrap in environments with access to only browser APIs, eg. Cloudflare
137137
* Workers & Pages and Deno Deploy.
138+
*
139+
* @deprecated Starting from v0.8 the Flytrap SDK only uses browser & edge-friendly APIs, meaning that the `browser` option is no longer needed.
138140
*/
139141
browser?: true
140142
transformOptions?: {

src/transform/imports.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ export function addMissingFlytrapImports(
6767
s.appendLeft(
6868
startingIndex,
6969
`\n\nconst { ${importsToBeAdded.join(', ')} } = require('${FLYTRAP_PACKAGE_NAME}${
70-
config?.browser === true ? '/browser' : ''
70+
config?.mode === 'replay' ? '/replay' : ''
7171
}');\n\n`
7272
)
7373
} else {
7474
s.appendLeft(
7575
startingIndex,
7676
`\n\nimport { ${importsToBeAdded.join(', ')} } from '${FLYTRAP_PACKAGE_NAME}${
77-
config?.browser === true ? '/browser' : ''
77+
config?.mode === 'replay' ? '/replay' : ''
7878
}';\n\n`
7979
)
8080
}

0 commit comments

Comments
 (0)