Skip to content

Commit

Permalink
feat: adding the use of topsort sdk for reporting events
Browse files Browse the repository at this point in the history
  • Loading branch information
barbmarcio committed Jul 25, 2024
1 parent 4be87ec commit 5b8278b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 169 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
"vite": "^5.2.11",
"vite-plugin-dts": "^3.9.1",
"vitest": "^1.6.0"
},
"dependencies": {
"@topsort/sdk": "^0.1.0"
}
}
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

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

16 changes: 11 additions & 5 deletions src/detector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Entity, TopsortEvent } from "./events";
import { type Config, Entity, TopsortEvent, reportEvent } from "@topsort/sdk";
import { ProcessorResult, Queue } from "./queue";
import { reportEvent } from "./reporter";
import { BidStore } from "./store";

const MAX_EVENTS_SIZE = 2500;
Expand Down Expand Up @@ -132,12 +131,19 @@ async function processor(data: ProductEvent[]): Promise<ProcessorResult> {
retry: new Set(),
};
const promises = [];
const config: Config = {
apiKey: window.TS.token,
host: window.TS.url,
};
for (const entry of data) {
promises.push(
reportEvent(getApiPayload(entry), window.TS)
reportEvent(config, getApiPayload(entry))
.then((result) => {
const q = result.retry ? r.retry : r.done;
q.add(entry.id);
if (result.ok) {
r.done.add(entry.id);
} else {
r.retry.add(entry.id);
}
})
.catch(() => {
r.done.add(entry.id);
Expand Down
47 changes: 0 additions & 47 deletions src/events.ts

This file was deleted.

88 changes: 0 additions & 88 deletions src/reporter.test.ts

This file was deleted.

29 changes: 0 additions & 29 deletions src/reporter.ts

This file was deleted.

0 comments on commit 5b8278b

Please sign in to comment.