-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(): migrate to Turborepo monorepo structure #82
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
Open
aidankmcalister
wants to merge
6
commits into
main
Choose a base branch
from
refactor/change-structure-to-turborepo
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
67e245a
refactor(): moved to turborepo
aidankmcalister 52d63e1
chore(): coderabbit comments applied
aidankmcalister 5ab5758
feat(create-db-worker): added create-db-worker tests
aidankmcalister b5dc495
chore(coderabbit): disable coderabbit approvals via `request_changes_…
aidankmcalister fbe5910
chore(): resolve comments
aidankmcalister ef5092a
fix(tests): accidental double version removed
aidankmcalister File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| # Turborepo | ||
| .turbo | ||
|
|
||
| # Node.js | ||
| node_modules/ | ||
| dist/ | ||
|
|
||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,62 @@ | ||
| import { describe, it, expect, vi, beforeEach } from 'vitest'; | ||
| import { PosthogEventCapture, EventCaptureError } from '../src/analytics'; | ||
|
|
||
| describe('PosthogEventCapture', () => { | ||
| beforeEach(() => { | ||
| vi.restoreAllMocks(); | ||
| }); | ||
|
|
||
| it('does nothing when POSTHOG_API_HOST is missing', async () => { | ||
| const fetchSpy = vi.spyOn(global, 'fetch'); | ||
| const capture = new PosthogEventCapture({ POSTHOG_API_KEY: 'key' }); | ||
| await capture.capture('test_event'); | ||
| expect(fetchSpy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('does nothing when POSTHOG_API_KEY is missing', async () => { | ||
| const fetchSpy = vi.spyOn(global, 'fetch'); | ||
| const capture = new PosthogEventCapture({ POSTHOG_API_HOST: 'https://posthog.example.com' }); | ||
| await capture.capture('test_event'); | ||
| expect(fetchSpy).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('sends a POST request to the capture endpoint', async () => { | ||
| const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(null, { status: 200 })); | ||
| const capture = new PosthogEventCapture({ | ||
| POSTHOG_API_HOST: 'https://posthog.example.com', | ||
| POSTHOG_API_KEY: 'phc_testkey', | ||
| }); | ||
|
|
||
| await capture.capture('db_created', { region: 'us-east-1' }); | ||
|
|
||
| expect(fetchSpy).toHaveBeenCalledOnce(); | ||
| const [url, init] = fetchSpy.mock.calls[0]; | ||
| expect(url).toBe('https://posthog.example.com/capture'); | ||
| expect(init?.method).toBe('POST'); | ||
|
|
||
| const body = JSON.parse(init?.body as string); | ||
| expect(body.event).toBe('db_created'); | ||
| expect(body.properties.region).toBe('us-east-1'); | ||
| expect(body.properties.$process_person_profile).toBe(false); | ||
| }); | ||
|
|
||
| it('strips trailing slash from host', async () => { | ||
| const fetchSpy = vi.spyOn(global, 'fetch').mockResolvedValue(new Response(null, { status: 200 })); | ||
| const capture = new PosthogEventCapture({ | ||
| POSTHOG_API_HOST: 'https://posthog.example.com///', | ||
| POSTHOG_API_KEY: 'key', | ||
| }); | ||
| await capture.capture('event'); | ||
| const [url] = fetchSpy.mock.calls[0]; | ||
| expect(url).toBe('https://posthog.example.com/capture'); | ||
| }); | ||
|
|
||
| it('throws EventCaptureError on non-ok response', async () => { | ||
| vi.spyOn(global, 'fetch').mockResolvedValue(new Response(null, { status: 500, statusText: 'Internal Server Error' })); | ||
| const capture = new PosthogEventCapture({ | ||
| POSTHOG_API_HOST: 'https://posthog.example.com', | ||
| POSTHOG_API_KEY: 'key', | ||
| }); | ||
| await expect(capture.capture('event')).rejects.toBeInstanceOf(EventCaptureError); | ||
| }); | ||
| }); |
File renamed without changes.
File renamed without changes.
This file contains hidden or 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,76 @@ | ||
| import { describe, it, expect } from 'vitest'; | ||
| import { parseTtlMsInput, isTtlMsInRange, clampTtlMs, MIN_TTL_MS, MAX_TTL_MS } from '../src/ttl'; | ||
|
|
||
| describe('parseTtlMsInput', () => { | ||
| it('returns the value for a valid finite number', () => { | ||
| expect(parseTtlMsInput(3600000)).toBe(3600000); | ||
| }); | ||
|
|
||
| it('floors float values', () => { | ||
| expect(parseTtlMsInput(3600000.9)).toBe(3600000); | ||
| }); | ||
|
|
||
| it('returns undefined for a string', () => { | ||
| expect(parseTtlMsInput('3600000')).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined for null', () => { | ||
| expect(parseTtlMsInput(null)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined for undefined', () => { | ||
| expect(parseTtlMsInput(undefined)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined for Infinity', () => { | ||
| expect(parseTtlMsInput(Infinity)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('returns undefined for NaN', () => { | ||
| expect(parseTtlMsInput(NaN)).toBeUndefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('isTtlMsInRange', () => { | ||
| it('returns true for the minimum value', () => { | ||
| expect(isTtlMsInRange(MIN_TTL_MS)).toBe(true); | ||
| }); | ||
|
|
||
| it('returns true for the maximum value', () => { | ||
| expect(isTtlMsInRange(MAX_TTL_MS)).toBe(true); | ||
| }); | ||
|
|
||
| it('returns true for a value within range', () => { | ||
| expect(isTtlMsInRange(3600000)).toBe(true); | ||
| }); | ||
|
|
||
| it('returns false for a value below minimum', () => { | ||
| expect(isTtlMsInRange(MIN_TTL_MS - 1)).toBe(false); | ||
| }); | ||
|
|
||
| it('returns false for a value above maximum', () => { | ||
| expect(isTtlMsInRange(MAX_TTL_MS + 1)).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe('clampTtlMs', () => { | ||
| it('returns MAX_TTL_MS for undefined', () => { | ||
| expect(clampTtlMs(undefined)).toBe(MAX_TTL_MS); | ||
| }); | ||
|
|
||
| it('returns MAX_TTL_MS for NaN', () => { | ||
| expect(clampTtlMs(NaN)).toBe(MAX_TTL_MS); | ||
| }); | ||
|
|
||
| it('clamps to MIN_TTL_MS when below range', () => { | ||
| expect(clampTtlMs(1000)).toBe(MIN_TTL_MS); | ||
| }); | ||
|
|
||
| it('clamps to MAX_TTL_MS when above range', () => { | ||
| expect(clampTtlMs(MAX_TTL_MS + 99999)).toBe(MAX_TTL_MS); | ||
| }); | ||
|
|
||
| it('returns the value unchanged when within range', () => { | ||
| expect(clampTtlMs(3600000)).toBe(3600000); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.