Skip to content
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
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:

- run: bun install --frozen-lockfile

- run: bun run check
- run: bun run build

lint:
Expand All @@ -41,4 +42,5 @@ jobs:

- run: bun install --frozen-lockfile

- run: bunx eslint .
- run: bun run lint
- run: bun run format
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ Live at **[docs.grlx.dev](https://docs.grlx.dev)**

All commands are run from the root of the project:

| Command | Action |
| :--------------- | :------------------------------------------ |
| `bun install` | Install dependencies |
| `bun run dev` | Start local dev server at `localhost:4321` |
| `bun run build` | Build production site to `./dist/` |
| `bun run preview`| Preview the build locally before deploying |
| Command | Action |
| :---------------- | :----------------------------------------- |
| `bun install` | Install dependencies |
| `bun run dev` | Start local dev server at `localhost:4321` |
| `bun run check` | Run Astro content/type checks |
| `bun run lint` | Run ESLint across the docs site |
| `bun run format` | Check Prettier formatting |
| `bun run build` | Build production site to `./dist/` |
| `bun run preview` | Preview the build locally before deploying |

## Stack

Expand Down
147 changes: 145 additions & 2 deletions bun.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"NATS",
"FARMERBUSPORT",
"FARMERAPIPORT",
"PUBKEYS",
],
"PUBKEYS"
]
}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
"astro": "astro",
"lint": "eslint .",
"format": "prettier --check .",
"format:write": "prettier --write .",
"check": "astro check"
},
"dependencies": {
"@astrojs/starlight": "^0.38.3",
Expand All @@ -22,6 +26,7 @@
"tailwindcss": "^4.2.2"
},
"devDependencies": {
"@astrojs/check": "^0.9.8",
"@typescript-eslint/parser": "^8.58.1",
"astro-eslint-parser": "^1.4.0",
"eslint": "^10.2.0",
Expand Down
34 changes: 17 additions & 17 deletions public/site.webmanifest
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "grlx Docs",
"short_name": "grlx Docs",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#bee1ff",
"background_color": "#bee1ff",
"display": "standalone"
"name": "grlx Docs",
"short_name": "grlx Docs",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#bee1ff",
"background_color": "#bee1ff",
"display": "standalone"
}
1 change: 0 additions & 1 deletion src/components/AdatomicFooter.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import type { Props } from '@astrojs/starlight/props'
import Default from '@astrojs/starlight/components/Footer.astro'
import { Image } from 'astro:assets'
import adatomicLogoBlack from '../assets/adatomic-logotype-color-black-h-1200x302.webp'
Expand Down
187 changes: 136 additions & 51 deletions src/components/Posthog.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,143 @@
---

<script>
!(function (t, e) {
var o, n, p, r
e.__SV ||
((window.posthog = e),
(e._i = []),
(e.init = function (i, s, a) {
function g(t, e) {
var o = e.split('.')
;(2 == o.length && ((t = t[o[0]]), (e = o[1])),
(t[e] = function () {
t.push([e].concat(Array.prototype.slice.call(arguments, 0)))
}))
type PosthogMethod = (...args: unknown[]) => void

type PosthogStub = {
__SV?: number
_i: [string, PosthogConfig, string][]
people?: PosthogStub
init?: (token: string, config: PosthogConfig, name?: string) => void
toString?: (stub?: number) => string
[key: string]: unknown
}

type PosthogConfig = {
api_host: string
person_profiles: 'identified_only' | 'always'
}

declare global {
interface Window {
posthog?: PosthogStub
}
}

const posthogMethods = [
'init',
'capture',
'register',
'register_once',
'register_for_session',
'unregister',
'unregister_for_session',
'getFeatureFlag',
'getFeatureFlagPayload',
'isFeatureEnabled',
'reloadFeatureFlags',
'updateEarlyAccessFeatureEnrollment',
'getEarlyAccessFeatures',
'on',
'onFeatureFlags',
'onSessionId',
'getSurveys',
'getActiveMatchingSurveys',
'renderSurvey',
'canRenderSurvey',
'getNextSurveyStep',
'identify',
'setPersonProperties',
'group',
'resetGroups',
'setPersonPropertiesForFlags',
'resetPersonPropertiesForFlags',
'setGroupPropertiesForFlags',
'resetGroupPropertiesForFlags',
'reset',
'get_distinct_id',
'getGroups',
'get_session_id',
'get_session_replay_url',
'alias',
'set_config',
'startSessionRecording',
'stopSessionRecording',
'sessionRecordingStarted',
'captureException',
'loadToolbar',
'get_property',
'getSessionProperty',
'createPersonProfile',
'opt_in_capturing',
'opt_out_capturing',
'has_opted_in_capturing',
'has_opted_out_capturing',
'clear_opt_in_out_capturing',
'debug',
] as const

const attachMethod = (target: PosthogStub, methodName: string) => {
target[methodName] = ((...args: unknown[]) => {
const queue = target._i ?? []
queue.push([methodName, args as unknown as PosthogConfig, 'posthog'])
target._i = queue as [string, PosthogConfig, string][]
}) as PosthogMethod
}

const bootstrapPosthog = (documentRef: Document, posthogRef: PosthogStub) => {
if (posthogRef.__SV) {
return posthogRef
}

window.posthog = posthogRef
posthogRef._i ??= []
posthogRef.people ??= { _i: [] }

posthogRef.init = (
token: string,
config: PosthogConfig,
name = 'posthog',
) => {
const script = documentRef.createElement('script')
script.type = 'text/javascript'
script.async = true
script.src = `${config.api_host.replace('.i.posthog.com', '-assets.i.posthog.com')}/static/array.js`

const firstScript = documentRef.getElementsByTagName('script')[0]
firstScript?.parentNode?.insertBefore(script, firstScript)

const stub = name === 'posthog' ? posthogRef : { _i: [] }
if (name !== 'posthog') {
posthogRef[name] = stub
}

stub.people ??= { _i: [] }
stub.toString = (stubbed?: number) => {
let displayName = 'posthog'
if (name !== 'posthog') {
displayName += `.${name}`
}
if (!stubbed) {
displayName += ' (stub)'
}
;(((p = t.createElement('script')).type = 'text/javascript'),
(p.async = !0),
(p.src =
s.api_host.replace('.i.posthog.com', '-assets.i.posthog.com') +
'/static/array.js'),
(r = t.getElementsByTagName('script')[0]).parentNode.insertBefore(
p,
r,
))
var u = e
for (
void 0 !== a ? (u = e[a] = []) : (a = 'posthog'),
u.people = u.people || [],
u.toString = function (t) {
var e = 'posthog'
return (
'posthog' !== a && (e += '.' + a),
t || (e += ' (stub)'),
e
)
},
u.people.toString = function () {
return u.toString(1) + '.people (stub)'
},
o =
'init capture register register_once register_for_session unregister unregister_for_session getFeatureFlag getFeatureFlagPayload isFeatureEnabled reloadFeatureFlags updateEarlyAccessFeatureEnrollment getEarlyAccessFeatures on onFeatureFlags onSessionId getSurveys getActiveMatchingSurveys renderSurvey canRenderSurvey getNextSurveyStep identify setPersonProperties group resetGroups setPersonPropertiesForFlags resetPersonPropertiesForFlags setGroupPropertiesForFlags resetGroupPropertiesForFlags reset get_distinct_id getGroups get_session_id get_session_replay_url alias set_config startSessionRecording stopSessionRecording sessionRecordingStarted captureException loadToolbar get_property getSessionProperty createPersonProfile opt_in_capturing opt_out_capturing has_opted_in_capturing has_opted_out_capturing clear_opt_in_out_capturing debug'.split(
' ',
),
n = 0;
n < o.length;
n++
)
g(u, o[n])
e._i.push([i, s, a])
}),
(e.__SV = 1))
})(document, window.posthog || [])
posthog.init('phc_WaZmfSjKT84EymwV3W6BG9yGH9y1kUuhnJfXd3ehepU', {
return displayName
}
stub.people.toString = () => `${stub.toString?.(1)}.people (stub)`

for (const methodName of posthogMethods) {
attachMethod(stub, methodName)
}

posthogRef._i.push([token, config, name])
}

posthogRef.__SV = 1
return posthogRef
}

const posthog = bootstrapPosthog(document, window.posthog ?? { _i: [] })
posthog.init?.('phc_WaZmfSjKT84EymwV3W6BG9yGH9y1kUuhnJfXd3ehepU', {
api_host: 'https://us.i.posthog.com',
person_profiles: 'identified_only', // or 'always' to create profiles for anonymous users as well
person_profiles: 'identified_only',
})
</script>
2 changes: 1 addition & 1 deletion src/content/versions/1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"link": "/glossary"
}
]
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}
}
Loading