Skip to content

Commit

Permalink
chore(deps): @topsort/sdk v0.3.1
Browse files Browse the repository at this point in the history
This PR bumps the version of `@topsort/sdk` from 0.2.0 to 0.3.1

| File | Before (gzip) | After (gzip) |
|:-------|:-------|:-------|
| dist/ts.mjs | 10.77 kB (3.76 kB) | 11.15 kB (3.91 kB) |
| dist/ts.js | 7.93 kB (3.33 kB) |  8.17 kB (3.46 kB) |

The difference comes from:
- Now the
[TopsortClient](https://github.com/Topsort/topsort.js/blob/main/src/functions/topsort-client.ts#L8)
class handles the function calls after receiving the config;
- The APIClient now handles the [URL
sanitization](https://github.com/Topsort/topsort.js/blob/main/src/lib/api-client.ts#L57);
- We have improved the [error handling and
response](https://github.com/Topsort/topsort.js/blob/main/src/lib/api-client.ts#L10),
as most of our calls return status code 204 (No Content). Therefore, we
wouldn't need to parse any response.

Please feel free to check the diff
[here](https://gist.github.com/barbmarcio/0af1f85b634522f0168cea6ad7f472bd)
as well
  • Loading branch information
barbmarcio authored Sep 5, 2024
1 parent d06968e commit c42d79b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"vitest": "^2.0.5"
},
"dependencies": {
"@topsort/sdk": "^0.2.0"
"@topsort/sdk": "^0.3.1"
}
}
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/detector.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Config, Entity, TopsortEvent, reportEvent } from "@topsort/sdk";
import { type Config, Entity, TopsortClient, Event as TopsortEvent } from "@topsort/sdk";
import { version } from "../package.json";
import { ProcessorResult, Queue } from "./queue";
import { truncateSet } from "./set";
Expand Down Expand Up @@ -138,9 +138,11 @@ async function processor(data: ProductEvent[]): Promise<ProcessorResult> {
host: window.TS.url,
userAgent: `ts.js/${version}`,
};
const topsortClient = new TopsortClient(config);
for (const entry of data) {
promises.push(
reportEvent(config, getApiPayload(entry))
topsortClient
.reportEvent(getApiPayload(entry))
.then((result) => {
const q = result.retry ? r.retry : r.done;
q.add(entry.id);
Expand Down

0 comments on commit c42d79b

Please sign in to comment.