-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from cloudflare/quick-quality-metrics
Add quick quality metrics stored in D1
- Loading branch information
Showing
13 changed files
with
1,502 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import type { ActionFunctionArgs } from '@remix-run/cloudflare' | ||
import { AnalyticsRefreshes, getDb } from 'schema' | ||
import { RELEASE } from '~/utils/constants' | ||
import { mode } from '~/utils/mode' | ||
|
||
export const action = async ({ context }: ActionFunctionArgs) => { | ||
const db = getDb(context) | ||
if (db === null || mode === 'development') | ||
return new Response(null, { status: 200 }) | ||
|
||
await db.insert(AnalyticsRefreshes).values({ | ||
version: RELEASE ?? 'dev', | ||
}) | ||
|
||
return new Response(null, { status: 201 }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { type ActionFunctionArgs } from '@remix-run/cloudflare' | ||
import { Form } from '@remix-run/react' | ||
import { AnalyticsSimpleCallFeedback, getDb } from 'schema' | ||
import { Button } from '~/components/Button' | ||
import { RELEASE } from '~/utils/constants' | ||
|
||
const redirectToHome = new Response(null, { | ||
status: 302, | ||
headers: { | ||
Location: '/', | ||
}, | ||
}) | ||
|
||
export const action = async ({ request, context }: ActionFunctionArgs) => { | ||
const db = getDb(context) | ||
if (!db) return redirectToHome | ||
|
||
const formData = await request.formData() | ||
const experiencedIssues = formData.get('experiencedIssues') === 'true' | ||
await db.insert(AnalyticsSimpleCallFeedback).values({ | ||
experiencedIssues: Number(experiencedIssues), | ||
version: RELEASE ?? 'dev', | ||
}) | ||
|
||
return redirectToHome | ||
} | ||
|
||
export default function SetUsername() { | ||
return ( | ||
<div className="grid h-full gap-4 place-content-center"> | ||
<h1 className="text-3xl font-bold">Experience any issues?</h1> | ||
<Form className="flex items-end gap-4" method="post"> | ||
<Button displayType="secondary" value="true" name="experiencedIssues"> | ||
Yes | ||
</Button> | ||
<Button displayType="secondary" value="false" name="experiencedIssues"> | ||
No | ||
</Button> | ||
</Form> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Config } from 'drizzle-kit' | ||
|
||
const { LOCAL_DB_PATH, DB_ID, D1_TOKEN, CF_ACCOUNT_ID } = process.env | ||
|
||
// Use better-sqlite driver for local development | ||
export default LOCAL_DB_PATH | ||
? ({ | ||
schema: './schema.ts', | ||
dialect: 'sqlite', | ||
dbCredentials: { | ||
url: LOCAL_DB_PATH, | ||
}, | ||
} satisfies Config) | ||
: ({ | ||
schema: './schema.ts', | ||
out: './migrations', | ||
dialect: 'sqlite', | ||
driver: 'd1-http', | ||
dbCredentials: { | ||
databaseId: DB_ID!, | ||
token: D1_TOKEN!, | ||
accountId: CF_ACCOUNT_ID!, | ||
}, | ||
} satisfies Config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CREATE TABLE `AnalyticsRefreshes` ( | ||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
`created` text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`modified` text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`deleted` text, | ||
`version` text NOT NULL | ||
); | ||
--> statement-breakpoint | ||
CREATE TABLE `AnalyticsSimpleCallFeedback` ( | ||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
`created` text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`modified` text DEFAULT CURRENT_TIMESTAMP NOT NULL, | ||
`deleted` text, | ||
`version` text NOT NULL, | ||
`experiencedIssues` integer NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
{ | ||
"version": "6", | ||
"dialect": "sqlite", | ||
"id": "fe0342f9-5cae-44a5-86d3-368c43bf7869", | ||
"prevId": "00000000-0000-0000-0000-000000000000", | ||
"tables": { | ||
"AnalyticsRefreshes": { | ||
"name": "AnalyticsRefreshes", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "integer", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": true | ||
}, | ||
"created": { | ||
"name": "created", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"modified": { | ||
"name": "modified", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"deleted": { | ||
"name": "deleted", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
}, | ||
"version": { | ||
"name": "version", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
}, | ||
"AnalyticsSimpleCallFeedback": { | ||
"name": "AnalyticsSimpleCallFeedback", | ||
"columns": { | ||
"id": { | ||
"name": "id", | ||
"type": "integer", | ||
"primaryKey": true, | ||
"notNull": true, | ||
"autoincrement": true | ||
}, | ||
"created": { | ||
"name": "created", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"modified": { | ||
"name": "modified", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false, | ||
"default": "CURRENT_TIMESTAMP" | ||
}, | ||
"deleted": { | ||
"name": "deleted", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": false, | ||
"autoincrement": false | ||
}, | ||
"version": { | ||
"name": "version", | ||
"type": "text", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
}, | ||
"experiencedIssues": { | ||
"name": "experiencedIssues", | ||
"type": "integer", | ||
"primaryKey": false, | ||
"notNull": true, | ||
"autoincrement": false | ||
} | ||
}, | ||
"indexes": {}, | ||
"foreignKeys": {}, | ||
"compositePrimaryKeys": {}, | ||
"uniqueConstraints": {} | ||
} | ||
}, | ||
"enums": {}, | ||
"_meta": { | ||
"schemas": {}, | ||
"tables": {}, | ||
"columns": {} | ||
}, | ||
"internal": { | ||
"indexes": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": "7", | ||
"dialect": "sqlite", | ||
"entries": [ | ||
{ | ||
"idx": 0, | ||
"version": "6", | ||
"when": 1726697068248, | ||
"tag": "0000_warm_siren", | ||
"breakpoints": true | ||
} | ||
] | ||
} |
Oops, something went wrong.