diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2acd25e..2816eec0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: node-version: ${{ matrix.node }} cache: 'pnpm' - run: pnpm install --frozen-lockfile - - run: pnpm build && pnpm build:esm + - run: pnpm build && pnpm build:cjs - run: pnpm lint - run: pnpm test @@ -58,7 +58,7 @@ jobs: node-version: ${{ matrix.node }} cache: 'pnpm' - run: pnpm install --frozen-lockfile - - run: pnpm build && pnpm build:esm + - run: pnpm build && pnpm build:cjs - run: cd examples/winston && pnpm example test-integration: @@ -83,7 +83,7 @@ jobs: node-version: ${{ matrix.node }} cache: 'pnpm' - run: pnpm install --frozen-lockfile - - run: pnpm build && pnpm build:esm + - run: pnpm build && pnpm build:cjs - env: AXIOM_TOKEN: ${{ secrets.TESTING_STAGING_TOKEN }} AXIOM_URL: ${{ secrets.TESTING_STAGING_API_URL }} @@ -133,7 +133,7 @@ jobs: node-version: ${{ matrix.node }} cache: 'pnpm' - run: pnpm install --frozen-lockfile - - run: pnpm build && pnpm build:esm # cjs build needed to run jest tests + - run: pnpm build && pnpm build:cjs # cjs build needed to run tests - env: TESTING_TARGET_URL: ${{ needs.deploy-e2e-apps.outputs.preview-url }} run: pnpm run e2e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7bbf7b18..e38f8ba3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,8 +21,7 @@ jobs: registry-url: 'https://registry.npmjs.org' cache: 'pnpm' - run: pnpm install --frozen-lockfile - - run: pnpm build && pnpm build:esm - - run: ./scripts/resolveVersion.sh # replace the constant VERSION with correct value + - run: pnpm build && pnpm build:cjs - run: pnpm publish --access public --filter "./packages/**" env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTOMATION_TOKEN }} diff --git a/e2e/nextjs-app/jest.config.ts b/e2e/nextjs-app/jest.config.ts deleted file mode 100644 index b7d42e97..00000000 --- a/e2e/nextjs-app/jest.config.ts +++ /dev/null @@ -1,10 +0,0 @@ -const jestConfig = { - moduleNameMapper: { - '^(\\.{1,2}/.*)\\.js$': '$1', - }, - transform: { - '^.+\\.ts?$': 'ts-jest', - }, - testEnvironment: 'node', -}; -export default jestConfig; diff --git a/e2e/nextjs-app/package.json b/e2e/nextjs-app/package.json index 430a5b21..6e5b2da2 100644 --- a/e2e/nextjs-app/package.json +++ b/e2e/nextjs-app/package.json @@ -8,7 +8,7 @@ "dev": "next dev", "format": "eslint 'src/**/*.{js,ts}' --quiet --fix", "lint": "eslint 'src/**/*.{js,ts}'", - "e2e": "jest test" + "e2e": "vitest run test/*" }, "dependencies": { "@axiomhq/js": "workspace:*", diff --git a/e2e/nextjs-app/src/app/api/edge/route.ts b/e2e/nextjs-app/src/app/api/edge/route.ts index d6f5b2f4..060466f3 100644 --- a/e2e/nextjs-app/src/app/api/edge/route.ts +++ b/e2e/nextjs-app/src/app/api/edge/route.ts @@ -5,17 +5,27 @@ export const runtime = 'edge'; export const dynamic = 'force-dynamic'; // disable prerendering export async function GET() { - const axiom = new AxiomWithoutBatching(); + const axiom = new AxiomWithoutBatching({ + token: process.env.AXIOM_TOKEN || '', + orgId: process.env.AXIOM_ORG_ID, + url: process.env.AXIOM_URL, + }); - const resp = await axiom.ingestRaw( - 'axiom-js-e2e-test', - `[{"foo":"bar", "test": "ingest_on_edge"},{"bar":"baz", "test": "ingest_on_edge"}]`, - ContentType.JSON, - ContentEncoding.Identity, - ); - if (resp.ingested !== 2) { - return NextResponse.json({ test: 'ingest_on_edge', error: 'ingest failed' }, { status: 500 }); + try { + const resp = await axiom.ingestRaw( + 'axiom-js-e2e-test', + `[{"foo":"bar", "test": "ingest_on_edge"},{"bar":"baz", "test": "ingest_on_edge"}]`, + ContentType.JSON, + ContentEncoding.Identity, + ); + if (resp.ingested !== 2) { + return NextResponse.json({ test: 'ingest_on_edge', error: 'ingest failed' }, { status: 500 }); + } + + return NextResponse.json({ test: 'ingest_on_edge', ...resp }); + } catch(err) { + return NextResponse.json({ test: 'ingest_on_edge', error: err.message }, { status: 500 }); } - return NextResponse.json({ test: 'ingest_on_edge', ...resp }); + } diff --git a/e2e/nextjs-app/src/app/api/lambda/route.ts b/e2e/nextjs-app/src/app/api/lambda/route.ts index 254211ca..4c26b20e 100644 --- a/e2e/nextjs-app/src/app/api/lambda/route.ts +++ b/e2e/nextjs-app/src/app/api/lambda/route.ts @@ -4,17 +4,25 @@ import { NextResponse } from 'next/server'; export const dynamic = 'force-dynamic'; // disable prerendering export async function GET() { - const axiom = new AxiomWithoutBatching(); + const axiom = new AxiomWithoutBatching({ + token: process.env.AXIOM_TOKEN || '', + orgId: process.env.AXIOM_ORG_ID, + url: process.env.AXIOM_URL, + }); - const resp = await axiom.ingestRaw( - 'axiom-js-e2e-test', - `[{"foo":"bar", "test": "ingest_on_lambda"},{"bar":"baz", "test": "ingest_on_lambda"}]`, - ContentType.JSON, - ContentEncoding.Identity, - ); - if (resp.ingested !== 2) { - return NextResponse.json({ test: 'ingest_on_lambda', error: 'ingest failed' }, { status: 500 }); - } + try { + const resp = await axiom.ingestRaw( + 'axiom-js-e2e-test', + `[{"foo":"bar", "test": "ingest_on_lambda"},{"bar":"baz", "test": "ingest_on_lambda"}]`, + ContentType.JSON, + ContentEncoding.Identity, + ); + if (resp.ingested !== 2) { + return NextResponse.json({ test: 'ingest_on_lambda', error: 'ingest failed' }, { status: 500 }); + } - return NextResponse.json({ test: 'ingest_on_lambda', ...resp }); + return NextResponse.json({ test: 'ingest_on_lambda', ...resp }); + } catch (err) { + return NextResponse.json({ test: 'ingest_on_lambda', error: err.message }, { status: 500 }); + } } diff --git a/e2e/nextjs-app/src/app/page.jsx b/e2e/nextjs-app/src/app/page.jsx index c00debe7..05c589b7 100644 --- a/e2e/nextjs-app/src/app/page.jsx +++ b/e2e/nextjs-app/src/app/page.jsx @@ -1,5 +1,20 @@ +'use client'; +import { Axiom } from '@axiomhq/js' +import { useEffect } from 'react'; export default function Home() { + const axiom = new Axiom({ token: '' }) + + axiom.ingest({ + name: 'test', + }) + + useEffect(() => { + return async () => { + await axiom.flush(); + } + }) + return (