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

feat: Hook up datadog logger #25

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ yarn-error.log*
$ CloudFlare worker
.mf/
tsconfig.tsbuildinfo
.env
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must define the env var in here for miniflare to work. See: https://miniflare.dev/core/variables-secrets


12 changes: 6 additions & 6 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"replicache": "^9.0.0-beta.0",
"replicache-react": "^2.5.0",
"reps-client": "file:reps-client-0.0.1.tgz",
"reps-do": "file:reps-do-0.0.1.tgz",
"reps-do": "file:reps-do-0.1.0.tgz",
"typescript": "^4.5.5",
"zod": "^3.11.6"
}
Expand Down
Binary file removed reps-do-0.0.1.tgz
Binary file not shown.
Binary file added reps-do-0.1.0.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/pages/d/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function Home() {

const workerHost =
process.env.NEXT_PUBLIC_WORKER_HOST ??
"wss://reps.replicache.workers.dev";
"wss://replidraw.replicache.workers.dev";
const workerURL = `${workerHost}/connect`;
console.info(`Connecting to worker at ${workerURL}`);
new Client(r, roomID, workerURL);
Expand Down
15 changes: 12 additions & 3 deletions worker/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import { Server as BaseServer } from "reps-do";
import { DatadogLogger, Server as BaseServer } from "reps-do";
export { worker as default } from "reps-do";
import { mutators, type M } from "../src/datamodel/mutators.js";

export class Server extends BaseServer<M> {
constructor(state: DurableObjectState) {
super(mutators, state);
constructor(state: DurableObjectState, env: Record<string, string>) {
const logger = new DatadogLogger({
apiKey: env.DATADOG_API_KEY,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to come from env :'(

service: "replidraw",
});

super({
mutators,
state,
logger,
});
}
}
5 changes: 4 additions & 1 deletion wrangler.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = "replidraw-do"
name = "replidraw"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm moving to this name.

type = "javascript"

account_id = ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can leave this empty and login via wrangler instead. This makes it a bit easier for customers to reuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that is correct:

👀  You have multiple accounts.
🕵️  You can copy your account_id below
+--------------------------+----------------------------------+
| Account Name             | Account ID                       |
+--------------------------+----------------------------------+
| Arv@roci.dev's Account   | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+--------------------------+----------------------------------+
| Hello@roci.dev's Account | xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx |
+--------------------------+----------------------------------+
Error: field `account_id` is required

...but you can use environment variables instead:

CF_ACCOUNT_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx wrangler dev

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wfm but I only have one account.

Expand Down Expand Up @@ -28,3 +28,6 @@ main = "./index.mjs"

[miniflare]
durable_objects_persist = true

#[secrets]
#DATADOG_API_KEY