Skip to content

Commit aef619c

Browse files
Sync public snapshot from freebuff-private
Source: CodebuffAI/freebuff-private@3f383d858fd87cdf193bf51117ae23c9622ac097
1 parent 79e1b75 commit aef619c

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎common/src/constants/analytics-events.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export enum AnalyticsEvent {
99
// per-surface DAU (filter on the `surface` property) and a combined DAU (no
1010
// filter). The `surface` property is one of: cli, web, chat, desktop, cloud
1111
// (web = the freebuff.com builder, cloud = connected-repo builder projects).
12+
// Native sends additionally carry `client_platform: 'ios' | 'android'`;
13+
// surface still describes the mode, and missing platform means unknown.
1214
// Emission points: cli client analytics; chat's stream route (server-side);
1315
// desktop's analytics module; web/cloud via the Convex send mutation
1416
// (PostHog + Axiom, both direct from Convex — see convex/analytics.ts).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { expect, test } from 'bun:test'
2+
import { clientPlatformProperties } from '../client-platform'
3+
4+
test('mobile attribution is per request and missing/invalid origins stay unknown', () => {
5+
expect(clientPlatformProperties('ios')).toEqual({ client_platform: 'ios' })
6+
expect(clientPlatformProperties('android')).toEqual({ client_platform: 'android' })
7+
for (const value of [undefined, null, '', 'browser', 'ios, android', {}, 1]) {
8+
expect(clientPlatformProperties(value)).toEqual({})
9+
}
10+
expect(clientPlatformProperties('ios')).toEqual({ client_platform: 'ios' })
11+
})

‎common/src/util/client-platform.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/** Request origin, independent of the product surface (chat/cloud/desktop).
2+
* Optional for older clients; never infer a browser from missing metadata.
3+
* Analytics only: client-supplied attribution is not an authorization signal.
4+
*/
5+
export type MobileClientPlatform = 'ios' | 'android'
6+
7+
export function clientPlatformProperties(
8+
value: unknown,
9+
): { client_platform?: MobileClientPlatform } {
10+
return value === 'ios' || value === 'android' ? { client_platform: value } : {}
11+
}

0 commit comments

Comments
 (0)