mobileui-os 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/AGENTS.md +47 -0
  2. package/CHANGELOG.md +25 -0
  3. package/README.md +78 -0
  4. package/bin/cli.mjs +375 -0
  5. package/knowledge/android/00-apple-to-android-adaption.md +1499 -0
  6. package/knowledge/android/accessibility.md +333 -0
  7. package/knowledge/android/components-controls.md +270 -0
  8. package/knowledge/android/material-design-3.md +174 -0
  9. package/knowledge/android/navigation-patterns.md +212 -0
  10. package/knowledge/apple/00-skill-reading-protocol.md +1296 -0
  11. package/knowledge/apple/Accessibility, Inclusive Design & Human Factors Intelligence.md +735 -0
  12. package/knowledge/apple/Advanced Interaction Patterns, Gestures, Feedback & State Transitions.md +1140 -0
  13. package/knowledge/apple/Advanced Navigation, Information Architecture & Wayfinding.md +551 -0
  14. package/knowledge/apple/Autonomus Ui-UX Improvement Loop.md +611 -0
  15. package/knowledge/apple/Color, Materials, Contrast, Themes & Visual Depth.md +1351 -0
  16. package/knowledge/apple/Content, Copy, Microinteractions & UX Communication.md +642 -0
  17. package/knowledge/apple/Data-Heavy Interfaces, Tables, Lists, Search, Filtering & Large-Scale Content.md +721 -0
  18. package/knowledge/apple/Design Systems & Component Architecture.md +412 -0
  19. package/knowledge/apple/Forms, Input, Data Entry & Validation Intelligence.md +705 -0
  20. package/knowledge/apple/Interaction, State & Edge-Case Engineering.md +491 -0
  21. package/knowledge/apple/Interaction-behaviour.md +1378 -0
  22. package/knowledge/apple/Layout Architecture, Responsive Design & Spatial Systems.md +1365 -0
  23. package/knowledge/apple/MASTER UI-UX ORCHESTRATOR.md +1210 -0
  24. package/knowledge/apple/Navigation Architecture, Routing, Deep Linking & State Restoration.md +1392 -0
  25. package/knowledge/apple/Navigation, Information Architecture & Spatial Hierarchy.md +1613 -0
  26. package/knowledge/apple/Notifications, Permissions, Privacy and Trust.md +1540 -0
  27. package/knowledge/apple/Patterns-templates-composition.md +647 -0
  28. package/knowledge/apple/Performance, Perceived Speed, Motion & Rendering Intelligence.md +855 -0
  29. package/knowledge/apple/Responsive, Adaptive & Cross-Platform UI Intelligence.md +669 -0
  30. package/knowledge/apple/Responsive, Adaptive, Accessible & Performant UI.md +545 -0
  31. package/knowledge/apple/Tablet Adaptation & Multi-Device UX.md +1447 -0
  32. package/knowledge/apple/UI Implementation & Refactoring.md +498 -0
  33. package/knowledge/apple/UI-UX Decision-Making, Prioritization & Trade-offs.md +533 -0
  34. package/knowledge/apple/UI-UX Project Lifecycle & Delivery.md +544 -0
  35. package/knowledge/apple/User Flows & Experience Architecture.md +335 -0
  36. package/knowledge/apple/Visual Design Systems, Theming, Tokens & Brand Intelligence.md +764 -0
  37. package/knowledge/apple/Visual QA, Testing & Validation.md +557 -0
  38. package/knowledge/apple/accessibility-inclusive-interaction.md +1361 -0
  39. package/knowledge/apple/accessibility.md +2162 -0
  40. package/knowledge/apple/color.md +1933 -0
  41. package/knowledge/apple/component-architecture.md +2208 -0
  42. package/knowledge/apple/components.md +2172 -0
  43. package/knowledge/apple/design-decision-framework.md +1883 -0
  44. package/knowledge/apple/design-review-engine.md +2108 -0
  45. package/knowledge/apple/design-tokens.md +1943 -0
  46. package/knowledge/apple/designing-for-ios.md +1680 -0
  47. package/knowledge/apple/gestures, touch behavior, feedback, motion, and micro-interactions.md +1538 -0
  48. package/knowledge/apple/hig-foundation.md +1806 -0
  49. package/knowledge/apple/iconography.md +1903 -0
  50. package/knowledge/apple/interaction-patterns.md +2513 -0
  51. package/knowledge/apple/interaction.md +2141 -0
  52. package/knowledge/apple/ios-alerts-confirmations-destructive-actions.md +1342 -0
  53. package/knowledge/apple/ios-components-and-controls.md +1634 -0
  54. package/knowledge/apple/ios-components-patterns.md +1343 -0
  55. package/knowledge/apple/ios-design-system-architecture.md +1520 -0
  56. package/knowledge/apple/ios-empty-error-offline-states.md +1370 -0
  57. package/knowledge/apple/ios-empty-loading-error-recovery.md +1674 -0
  58. package/knowledge/apple/ios-forms-and-input.md +1458 -0
  59. package/knowledge/apple/ios-forms-input-data-entry.md +1308 -0
  60. package/knowledge/apple/ios-gestures-and-touch.md +1272 -0
  61. package/knowledge/apple/ios-lists-collections-and-data-display.md +1735 -0
  62. package/knowledge/apple/ios-loading-progress-async-states.md +1378 -0
  63. package/knowledge/apple/ios-materials-and-surfaces.md +1543 -0
  64. package/knowledge/apple/ios-motion-animation-transitions.md +1178 -0
  65. package/knowledge/apple/ios-navigation-and-information-architecture.md +1674 -0
  66. package/knowledge/apple/ios-navigation-user-flows-design-architecture.md +1195 -0
  67. package/knowledge/apple/ios-search-and-discovery.md +1456 -0
  68. package/knowledge/apple/ios-search-filtering-discovery.md +1402 -0
  69. package/knowledge/apple/ios-sheets-modals-popovers.md +1205 -0
  70. package/knowledge/apple/ios-typography-icons-visual-hierarchy.md +1431 -0
  71. package/knowledge/apple/layout.md +2331 -0
  72. package/knowledge/apple/media-centric-content-ui-patterns.md +1470 -0
  73. package/knowledge/apple/motion, transitions, physics, and animation language.md +1535 -0
  74. package/knowledge/apple/motion-and-animation.md +1698 -0
  75. package/knowledge/apple/motion.md +2087 -0
  76. package/knowledge/apple/navigation.md +2281 -0
  77. package/knowledge/apple/responsive-adaptive.md +2159 -0
  78. package/knowledge/apple/screen-architecture.md +2067 -0
  79. package/knowledge/apple/typography, Content Hierarchy & Readability.md +1411 -0
  80. package/knowledge/apple/typography.md +1802 -0
  81. package/knowledge/apple/ui-ux inteligence audit.md +106 -0
  82. package/knowledge/apple/visual-design-and-premium-ui.md +1555 -0
  83. package/knowledge/apple/visual-hierarchy-engine.md +1647 -0
  84. package/knowledge/apple/visual-materials.md +2189 -0
  85. package/package.json +53 -0
  86. package/principles/design-principles.md +37 -0
  87. package/principles/platform-principles.md +25 -0
  88. package/principles/ux-principles.md +16 -0
  89. package/references/official-links.md +11 -0
  90. package/skills/accessibility-engineer/SKILL.md +125 -0
  91. package/skills/analytics-engineer/SKILL.md +283 -0
  92. package/skills/animation-engineer/SKILL.md +316 -0
  93. package/skills/component-designer/SKILL.md +75 -0
  94. package/skills/component-library-engineer/SKILL.md +140 -0
  95. package/skills/component-library-ops/SKILL.md +155 -0
  96. package/skills/design-system/SKILL.md +77 -0
  97. package/skills/design-token-engineer/SKILL.md +203 -0
  98. package/skills/design-token-pipeline/SKILL.md +277 -0
  99. package/skills/device-lab-engineer/SKILL.md +387 -0
  100. package/skills/forms-engineer/SKILL.md +79 -0
  101. package/skills/internationalization-engineer/SKILL.md +256 -0
  102. package/skills/motion-designer/SKILL.md +77 -0
  103. package/skills/native-data-fetching/SKILL.md +50 -0
  104. package/skills/navigation-architect/SKILL.md +65 -0
  105. package/skills/performance-engineer/SKILL.md +250 -0
  106. package/skills/platform-specialist/SKILL.md +95 -0
  107. package/skills/pre-release-gate/SKILL.md +75 -0
  108. package/skills/screen-designer/SKILL.md +117 -0
  109. package/skills/security-engineer/SKILL.md +375 -0
  110. package/skills/skills.json +134 -0
  111. package/skills/testing-auditor/SKILL.md +62 -0
  112. package/skills/ui-architect/SKILL.md +86 -0
  113. package/skills/ui-implementer/SKILL.md +188 -0
  114. package/skills/ux-architect/SKILL.md +49 -0
  115. package/skills/ux-auditor/SKILL.md +52 -0
  116. package/skills/visual-auditor/SKILL.md +71 -0
  117. package/templates/audit-report.md +29 -0
  118. package/templates/design-tokens.ts +33 -0
  119. package/templates/screen-spec.md +61 -0
  120. package/workflows/new-screen.md +17 -0
  121. package/workflows/pre-release.md +21 -0
  122. package/workflows/redesign.md +14 -0
  123. package/workflows/ui-audit.md +22 -0
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "mobileui-os",
3
+ "version": "1.0.0",
4
+ "description": "Portable agentic UI/UX quality system for premium mobile apps — 26 skills for React Native + Expo + TypeScript",
5
+ "keywords": [
6
+ "mobile",
7
+ "ui",
8
+ "ux",
9
+ "react-native",
10
+ "expo",
11
+ "skills",
12
+ "agent-skills",
13
+ "claude-code",
14
+ "opencode",
15
+ "cursor",
16
+ "design-system",
17
+ "accessibility"
18
+ ],
19
+ "license": "MIT",
20
+ "author": "MobileUI-OS",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/anomalyco/mobileui-os"
24
+ },
25
+ "homepage": "https://github.com/anomalyco/mobileui-os#readme",
26
+ "type": "module",
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "bin": {
34
+ "mobileui-os": "./bin/cli.mjs",
35
+ "mobileui": "./bin/cli.mjs"
36
+ },
37
+ "files": [
38
+ "skills/**/*",
39
+ "templates/**/*",
40
+ "knowledge/**/*",
41
+ "principles/**/*",
42
+ "references/**/*",
43
+ "workflows/**/*",
44
+ "bin/**/*",
45
+ "AGENTS.md",
46
+ "README.md",
47
+ "CHANGELOG.md"
48
+ ],
49
+ "scripts": {
50
+ "sync": "pwsh scripts/sync-platform-adapters.ps1",
51
+ "test:cli": "node bin/cli.mjs --help && node bin/cli.mjs list"
52
+ }
53
+ }
@@ -0,0 +1,37 @@
1
+ # Design Principles
2
+
3
+ ## 1. Purpose
4
+ Design around the product's actual job. Prioritize what creates value.
5
+
6
+ ## 2. Agency
7
+ Users should understand what is happening, control meaningful actions, and recover from mistakes.
8
+
9
+ ## 3. Familiarity
10
+ Build on established digital and platform patterns. Novelty should solve a problem, not create learning cost.
11
+
12
+ ## 4. Flexibility
13
+ Support different devices, inputs, accessibility needs, and usage contexts.
14
+
15
+ ## 5. Simplicity
16
+ Remove unnecessary complexity. Simplicity is not emptiness; it is focused usefulness.
17
+
18
+ ## 6. Craft
19
+ Precision matters: alignment, typography, wording, motion, feedback, performance, and edge states.
20
+
21
+ ## 7. Delight
22
+ Personality should emerge from thoughtful interaction and product identity, not decoration for decoration's sake.
23
+
24
+ ## 8. Hierarchy
25
+ Every screen needs a readable visual and functional priority.
26
+
27
+ ## 9. Feedback
28
+ Every consequential action should communicate its result or current state.
29
+
30
+ ## 10. Continuity
31
+ Transitions should preserve the user's mental model of where content came from and where it went.
32
+
33
+ ## 11. Consistency
34
+ Once a component or interaction has a meaning, preserve that meaning throughout the product.
35
+
36
+ ## 12. Restraint
37
+ Do not add borders, shadows, gradients, badges, icons, animation, or cards unless they improve comprehension or interaction.
@@ -0,0 +1,25 @@
1
+ # Platform Principles
2
+
3
+ ## iOS
4
+ Use Apple conventions as the primary reference for navigation, hierarchy, system controls, sheets, typography, accessibility, and interaction behavior.
5
+
6
+ ## Android
7
+ Use Material conventions where appropriate, while respecting Android-native navigation and interaction expectations.
8
+
9
+ ## Cross-platform
10
+ Share:
11
+ - product architecture
12
+ - semantic design tokens
13
+ - content hierarchy
14
+ - component intent
15
+ - UX principles
16
+
17
+ Adapt:
18
+ - navigation
19
+ - system controls
20
+ - gestures
21
+ - dialogs/sheets
22
+ - accessibility behavior
23
+ - platform-specific affordances
24
+
25
+ Do not equate cross-platform consistency with pixel-identical UI.
@@ -0,0 +1,16 @@
1
+ # UX Principles
2
+
3
+ - Minimize unnecessary steps.
4
+ - Keep the user's current context visible.
5
+ - Make primary actions discoverable.
6
+ - Make destructive actions deliberate.
7
+ - Provide undo/recovery where practical.
8
+ - Never rely on color alone to communicate meaning.
9
+ - Empty states should explain what happened and what to do next.
10
+ - Error states should explain the problem, impact, and recovery path.
11
+ - Loading states should communicate progress or preserve layout stability.
12
+ - Preserve user input during recoverable failures.
13
+ - Avoid dead ends.
14
+ - Prefer progressive disclosure over overwhelming first views.
15
+ - Use terminology users understand.
16
+ - Do not make users remember information that the interface can show.
@@ -0,0 +1,11 @@
1
+ # Official References
2
+
3
+ - Apple Human Interface Guidelines: https://developer.apple.com/design/human-interface-guidelines/
4
+ - Apple Design Resources: https://developer.apple.com/design/resources/
5
+ - Apple Design Principles: https://developer.apple.com/design/human-interface-guidelines/design-principles
6
+ - SF Symbols: https://developer.apple.com/sf-symbols/
7
+ - Material Design: https://m3.material.io/
8
+ - React Native Accessibility: https://reactnative.dev/docs/accessibility
9
+ - React Native Docs: https://reactnative.dev/docs/getting-started
10
+ - Expo Docs: https://docs.expo.dev/
11
+ - Expo UI: https://docs.expo.dev/versions/latest/sdk/ui/
@@ -0,0 +1,125 @@
1
+ # Accessibility Engineer
2
+
3
+ Audit and implement accessibility as architecture, not afterthought.
4
+
5
+ ## Audit Checklist (Every Screen)
6
+
7
+ ### Semantics & Labels
8
+ - [ ] Every interactive element: role + accessible name
9
+ - [ ] Images: `accessibilityLabel` (informative) or `accessibilityHidden` (decorative)
10
+ - [ ] Icon-only buttons: label describes action, not icon
11
+ - [ ] Form fields: label + hint (format, required) + error announcement
12
+ - [ ] Dynamic content: `accessibilityLiveRegion="polite"` (status) / `"assertive"` (errors)
13
+
14
+ ### State Announcements
15
+ - [ ] Loading → "Loading, please wait"
16
+ - [ ] Success → "Saved" / "Completed"
17
+ - [ ] Error → "Error: [message], [recovery action]"
18
+ - [ ] Empty → "No items. [Action to add]"
19
+ - [ ] Selection → "Selected, [item name]" / "Deselected"
20
+
21
+ ### Focus & Navigation
22
+ - [ ] Focus order matches visual order (LTR/RTL)
23
+ - [ ] Focus visible (3px ring, primary color, 3:1 contrast)
24
+ - [ ] No focus traps (except modal)
25
+ - [ ] Skip links for repeated nav
26
+ - [ ] Custom actions exposed (swipe actions → rotor/long press)
27
+
28
+ ### Touch Targets
29
+ - [ ] Minimum 44×44pt (iOS) / 48×48dp (Android)
30
+ - [ ] Visual size ≠ touch target (padding OK)
31
+ - [ ] Adjacent targets: 8dp gap minimum
32
+
33
+ ### Text Scaling
34
+ - [ ] All text uses `sp` / dynamic type
35
+ - [ ] No clipping at 200% (AX3/AX5)
36
+ - [ ] Line height scales proportionally
37
+ - [ ] Containers grow; no fixed heights on text
38
+
39
+ ### Contrast & Color
40
+ - [ ] Text: ≥4.5:1 (AA) / ≥7:1 (AAA)
41
+ - [ ] UI elements (borders, icons): ≥3:1
42
+ - [ ] Color not sole meaning (icon + label + pattern)
43
+ - [ ] Dark mode: surfaces elevated, not inverted
44
+
45
+ ### Reduced Motion
46
+ - [ ] Non-essential animation disabled
47
+ - [ ] Spring → instant; transitions → fade only
48
+ - [ ] Parallax, auto-advance carousel paused
49
+
50
+ ### Platform Testing
51
+ - [ ] **iOS VoiceOver**: Full critical path + rotor navigation
52
+ - [ ] **Android TalkBack**: Full critical path + gesture navigation
53
+ - [ ] **Switch Control** (iOS) / **Switch Access** (Android)
54
+ - [ ] **Voice Control** (iOS) / **Voice Access** (Android)
55
+
56
+ ## Implementation Patterns
57
+
58
+ ### React Native
59
+ ```tsx
60
+ // Semantic button
61
+ <Pressable
62
+ accessibilityRole="button"
63
+ accessibilityLabel="Save changes"
64
+ accessibilityHint="Saves your profile updates"
65
+ accessibilityState={{ disabled: isSaving, busy: isSaving }}
66
+ onPress={handleSave}
67
+ >
68
+ <Text>{isSaving ? 'Saving…' : 'Save'}</Text>
69
+ </Pressable>
70
+
71
+ // Live region for errors
72
+ <Text
73
+ accessibilityLiveRegion="assertive"
74
+ accessibilityRole="alert"
75
+ >
76
+ {errorMessage}
77
+ </Text>
78
+
79
+ // Dynamic type
80
+ <Text style={{ fontSize: 16, lineHeight: 24 }} adjustsFontSizeToFit={false} />
81
+ ```
82
+
83
+ ### Compose
84
+ ```kotlin
85
+ Button(
86
+ onClick = { },
87
+ modifier = Modifier
88
+ .semantics {
89
+ role = Role.Button
90
+ stateDescription = "Saves changes"
91
+ }
92
+ .minimumTouchTargetSize(48.dp)
93
+ ) {
94
+ Text("Save")
95
+ }
96
+
97
+ // Live region
98
+ Text(
99
+ text = errorMessage,
100
+ modifier = Modifier.semantics { liveRegion = LiveRegionMode.Assertive }
101
+ )
102
+ ```
103
+
104
+ ### SwiftUI
105
+ ```swift
106
+ Button("Save") { }
107
+ .accessibilityLabel("Save changes")
108
+ .accessibilityHint("Saves your profile updates")
109
+ .accessibilityAddTraits(.isButton)
110
+
111
+ Text(errorMessage)
112
+ .accessibilityAddTraits(.isStatusElement)
113
+ .accessibilityLiveRegion(.assertive)
114
+ ```
115
+
116
+ ## Compliance Targets
117
+
118
+ - **WCAG 2.1 AA** minimum (AAA for critical paths)
119
+ - **Section 508** (US federal)
120
+ - **EN 301 549** (EU)
121
+ - **App Store / Play Store** accessibility requirements
122
+
123
+ ## Output
124
+
125
+ Accessibility audit report + fix priority + re-test checklist per platform.
@@ -0,0 +1,283 @@
1
+ # Analytics & Telemetry Engineer
2
+
3
+ Implement privacy-compliant, actionable event tracking with clear taxonomy and funnel analysis.
4
+
5
+ ## Event Taxonomy
6
+
7
+ ### Naming Convention
8
+ ```
9
+ object_action_context
10
+ screen_view_home
11
+ button_press_primary_checkout
12
+ form_submit_login_success
13
+ api_request_payment_failure
14
+ ```
15
+
16
+ ### Required Properties (Every Event)
17
+ ```typescript
18
+ interface BaseEvent {
19
+ event_name: string; // snake_case
20
+ timestamp: number; // Unix ms
21
+ session_id: string; // UUID v4
22
+ user_id?: string; // Hashed, if authenticated
23
+ anonymous_id: string; // Persistent device ID
24
+ platform: 'ios' | 'android' | 'web';
25
+ app_version: string; // Semver
26
+ build_number: string;
27
+ os_version: string;
28
+ device_model: string;
29
+ locale: string; // BCP-47
30
+ timezone: string; // IANA
31
+ }
32
+ ```
33
+
34
+ ### Event Categories
35
+ | Category | Prefix | Examples |
36
+ |----------|--------|----------|
37
+ | Screen | `screen_view_` | `screen_view_onboarding_step1` |
38
+ | Interaction | `tap_`, `press_`, `swipe_` | `tap_button_primary`, `swipe_carousel_next` |
39
+ | Form | `form_`, `field_` | `form_start_checkout`, `field_blur_email` |
40
+ | Navigation | `nav_` | `nav_push_detail`, `nav_back_home` |
41
+ | Network | `api_` | `api_request_payment`, `api_response_error` |
42
+ | Error | `error_` | `error_crash_js`, `error_network_timeout` |
43
+ | Lifecycle | `app_` | `app_launch_cold`, `app_background` |
44
+ | Business | `purchase_`, `subscription_` | `purchase_completed`, `subscription_renewed` |
45
+
46
+ ## Implementation (React Native)
47
+
48
+ ### Core Tracker
49
+ ```typescript
50
+ // analytics/tracker.ts
51
+ import { v4 as uuidv4 } from 'uuid';
52
+ import * as Device from 'expo-device';
53
+ import * as Application from 'expo-application';
54
+ import * as Localization from 'expo-localization';
55
+
56
+ class Analytics {
57
+ private sessionId = uuidv4();
58
+ private anonymousId = this.getOrCreateAnonymousId();
59
+ private queue: BaseEvent[] = [];
60
+ private flushInterval = 30_000; // 30s
61
+
62
+ constructor() {
63
+ this.startFlushTimer();
64
+ this.track('app_launch', { cold: true });
65
+ AppState.addEventListener('change', this.handleAppState);
66
+ }
67
+
68
+ track(name: string, properties: Record<string, any> = {}) {
69
+ const event: BaseEvent = {
70
+ event_name: name,
71
+ timestamp: Date.now(),
72
+ session_id: this.sessionId,
73
+ anonymous_id: this.anonymousId,
74
+ platform: Platform.OS as 'ios' | 'android',
75
+ app_version: Application.nativeApplicationVersion ?? 'unknown',
76
+ build_number: Application.nativeBuildVersion ?? 'unknown',
77
+ os_version: Device.osVersion ?? 'unknown',
78
+ device_model: Device.modelName ?? 'unknown',
79
+ locale: Localization.getLocales()[0]?.languageTag ?? 'en-US',
80
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
81
+ ...properties,
82
+ };
83
+ this.queue.push(event);
84
+ }
85
+
86
+ identify(userId: string, traits?: Record<string, any>) {
87
+ this.track('user_identify', { user_id: hashUserId(userId), ...traits });
88
+ }
89
+
90
+ private async flush() {
91
+ if (this.queue.length === 0) return;
92
+ const events = this.queue.splice(0, this.queue.length);
93
+ try {
94
+ await fetch('/api/analytics/batch', {
95
+ method: 'POST',
96
+ headers: { 'Content-Type': 'application/json' },
97
+ body: JSON.stringify({ events }),
98
+ });
99
+ } catch {
100
+ // Re-queue on failure (with max retry)
101
+ this.queue.unshift(...events);
102
+ }
103
+ }
104
+ }
105
+
106
+ export const analytics = new Analytics();
107
+ ```
108
+
109
+ ### React Hooks
110
+ ```typescript
111
+ // hooks/useAnalytics.ts
112
+ export function useAnalytics() {
113
+ return {
114
+ track: (name: string, props?: Record<string, any>) => analytics.track(name, props),
115
+ screen: (name: string, props?: Record<string, any>) => analytics.track(`screen_view_${name}`, props),
116
+ error: (error: Error, context?: string) => analytics.track('error_js', { message: error.message, stack: error.stack, context }),
117
+ };
118
+ }
119
+
120
+ // Screen tracking (Expo Router)
121
+ export function useScreenTracking() {
122
+ const { track } = useAnalytics();
123
+ const route = useLocalSearchParams();
124
+ const segments = useSegments();
125
+
126
+ useEffect(() => {
127
+ const screenName = segments.join('_') || 'home';
128
+ track(`screen_view_${screenName}`, { params: route });
129
+ }, [segments, route]);
130
+ }
131
+ ```
132
+
133
+ ### Automatic Tracking
134
+ ```typescript
135
+ // Navigation (Expo Router)
136
+ import { usePathname } from 'expo-router';
137
+
138
+ export function AnalyticsProvider({ children }) {
139
+ const pathname = usePathname();
140
+ const { track } = useAnalytics();
141
+
142
+ useEffect(() => {
143
+ track(`screen_view_${pathname.replace('/', '')}`);
144
+ }, [pathname]);
145
+
146
+ return <>{children}</>;
147
+ }
148
+ ```
149
+
150
+ ## Privacy & Compliance
151
+
152
+ ### Consent Management
153
+ ```typescript
154
+ // Consent states (GDPR, CCPA, LGPD)
155
+ type Consent = 'granted' | 'denied' | 'pending';
156
+
157
+ interface ConsentState {
158
+ analytics: Consent;
159
+ marketing: Consent;
160
+ functional: Consent;
161
+ preferences: Consent;
162
+ }
163
+
164
+ // Before tracking
165
+ if (consent.analytics === 'granted') {
166
+ analytics.track('event_name', props);
167
+ }
168
+ ```
169
+
170
+ ### Data Minimization
171
+ - **No PII**: Hash user IDs, no emails/names in events
172
+ - **No sensitive data**: No passwords, tokens, payment info
173
+ - **IP anonymization**: Server-side only
174
+ - **Retention**: 13 months max (GDPR), configurable per region
175
+
176
+ ### Opt-Out
177
+ ```typescript
178
+ // Settings screen
179
+ export function PrivacySettings() {
180
+ const [consent, setConsent] = useConsent();
181
+
182
+ return (
183
+ <Switch
184
+ value={consent.analytics === 'granted'}
185
+ onValueChange={v => setConsent({ ...consent, analytics: v ? 'granted' : 'denied' })}
186
+ accessibilityLabel="Analytics tracking"
187
+ />
188
+ );
189
+ }
190
+ ```
191
+
192
+ ## Funnel Analysis
193
+
194
+ ### Define Funnels (Code as Source of Truth)
195
+ ```typescript
196
+ // analytics/funnels.ts
197
+ export const funnels = {
198
+ onboarding: [
199
+ 'screen_view_onboarding_welcome',
200
+ 'screen_view_onboarding_permissions',
201
+ 'screen_view_onboarding_profile',
202
+ 'screen_view_onboarding_complete',
203
+ ],
204
+ checkout: [
205
+ 'screen_view_cart',
206
+ 'tap_button_checkout',
207
+ 'screen_view_shipping',
208
+ 'screen_view_payment',
209
+ 'form_submit_payment',
210
+ 'screen_view_confirmation',
211
+ ],
212
+ subscription: [
213
+ 'screen_view_paywall',
214
+ 'tap_button_subscribe',
215
+ 'api_request_purchase',
216
+ 'purchase_completed',
217
+ ],
218
+ };
219
+ ```
220
+
221
+ ### Funnel Query (SQL/BigQuery)
222
+ ```sql
223
+ WITH funnel_steps AS (
224
+ SELECT
225
+ anonymous_id,
226
+ event_name,
227
+ timestamp,
228
+ ROW_NUMBER() OVER (PARTITION BY anonymous_id ORDER BY timestamp) as step_order
229
+ FROM events
230
+ WHERE event_name IN ('screen_view_cart', 'tap_button_checkout', ...)
231
+ AND timestamp > DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY)
232
+ )
233
+ SELECT
234
+ event_name as step,
235
+ COUNT(DISTINCT anonymous_id) as users,
236
+ LAG(COUNT(DISTINCT anonymous_id)) OVER (ORDER BY MIN(timestamp)) as previous_step_users,
237
+ COUNT(DISTINCT anonymous_id) * 1.0 / LAG(COUNT(DISTINCT anonymous_id)) OVER (ORDER BY MIN(timestamp)) as conversion_rate
238
+ FROM funnel_steps
239
+ GROUP BY event_name, step_order
240
+ ORDER BY step_order;
241
+ ```
242
+
243
+ ## Debugging & Validation
244
+
245
+ ### Dev Tools
246
+ ```typescript
247
+ // analytics/devtools.ts
248
+ if (__DEV__) {
249
+ // Log to console
250
+ const originalTrack = analytics.track;
251
+ analytics.track = (name, props) => {
252
+ console.log('📊 [Analytics]', name, props);
253
+ originalTrack(name, props);
254
+ };
255
+
256
+ // React Native Debugger panel
257
+ import('react-native-debugger').then(({ default: debugger }) => {
258
+ debugger.send('analytics:event', { name, props });
259
+ });
260
+ }
261
+ ```
262
+
263
+ ### QA Checklist
264
+ - [ ] All events follow naming convention
265
+ - [ ] Required properties present
266
+ - [ ] Consent respected (no events before grant)
267
+ - [ ] No PII in events
268
+ - [ ] Funnel steps match user journey
269
+ - [ ] Batch flush works offline → online
270
+ - [ ] Retry logic with exponential backoff
271
+ - [ ] Session ID rotates on app background > 30min
272
+ - [ ] Anonymous ID persists across reinstalls (Keychain/Keystore)
273
+
274
+ ## Vendors (Server-Side)
275
+ | Vendor | Use Case |
276
+ |--------|----------|
277
+ | Segment / RudderStack | Event routing, transformations |
278
+ | Amplitude / Mixpanel | Product analytics, funnels |
279
+ | Firebase Analytics | Free, Google ecosystem |
280
+ | PostHog | Open-source, self-hostable |
281
+ | Snowplow | High-volume, custom pipelines |
282
+
283
+ **Recommendation**: Own the event schema, use vendor as transport only.