Skip to content

Commit 972f4bf

Browse files
Add .github/copilot-instructions.md for agent onboarding (#343)
Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 1488c6e commit 972f4bf

File tree

3 files changed

+136
-3
lines changed

3 files changed

+136
-3
lines changed

.github/copilot-instructions.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# Mixpanel React Native SDK - Copilot Instructions
2+
3+
## Repository Overview
4+
This is the official Mixpanel React Native SDK, a wrapper around native iOS and Android SDKs for analytics tracking. It supports React Native apps, Expo, and React Native for Web (via JavaScript mode).
5+
6+
**Type:** React Native library (npm package)
7+
**Languages:** JavaScript (main), Swift (iOS native), Java (Android native)
8+
**Version:** 3.1.2
9+
**Minimum React Native:** 0.6+
10+
11+
## Quick Reference - Build & Test Commands
12+
13+
### Primary Commands (Always Run in This Order)
14+
```bash
15+
# 1. Install dependencies (ALWAYS run first after checkout)
16+
npm install
17+
18+
# 2. Run tests
19+
npm test
20+
```
21+
22+
### Validation Results
23+
- All 106 tests should pass across 6 test suites
24+
- Jest is the test framework with react-native preset
25+
26+
## Project Architecture
27+
28+
### Key Entry Points
29+
| File | Purpose |
30+
|------|---------|
31+
| `index.js` | Main SDK entry - exports `Mixpanel`, `People`, `MixpanelGroup` classes |
32+
| `index.d.ts` | TypeScript type definitions |
33+
| `package.json` | NPM package config, dependencies, Jest configuration |
34+
35+
### Native Platform Code
36+
| Directory | Purpose |
37+
|-----------|---------|
38+
| `ios/` | Swift native bridge (`MixpanelReactNative.swift`) |
39+
| `android/` | Java native bridge (`android/src/main/java/com/mixpanel/reactnative/`) |
40+
41+
### JavaScript Mode (Expo/Web Support)
42+
| File | Purpose |
43+
|------|---------|
44+
| `javascript/mixpanel-main.js` | Main JavaScript implementation |
45+
| `javascript/mixpanel-core.js` | Queue processing and event handling |
46+
| `javascript/mixpanel-persistent.js` | Storage and identity persistence |
47+
| `javascript/mixpanel-network.js` | API request handling |
48+
| `javascript/mixpanel-config.js` | Configuration management |
49+
| `javascript/mixpanel-queue.js` | Event queue management |
50+
| `javascript/mixpanel-storage.js` | AsyncStorage adapter |
51+
| `javascript/mixpanel-logger.js` | Logging utilities |
52+
| `javascript/mixpanel-utils.js` | Helper utilities |
53+
| `javascript/mixpanel-constants.js` | Constants (MixpanelType enum) |
54+
55+
### Test Files
56+
| File | Tests |
57+
|------|-------|
58+
| `__tests__/index.test.js` | Native bridge integration tests |
59+
| `__tests__/main.test.js` | JavaScript mode MixpanelMain tests |
60+
| `__tests__/core.test.js` | Queue and core processing tests |
61+
| `__tests__/persistent.test.js` | Persistence layer tests |
62+
| `__tests__/queue.test.js` | Queue management tests |
63+
| `__tests__/network.test.js` | Network request tests |
64+
| `__tests__/jest_setup.js` | Mock setup for react-native and dependencies |
65+
66+
## Configuration Files
67+
68+
| File | Purpose |
69+
|------|---------|
70+
| `MixpanelReactNative.podspec` | iOS CocoaPods spec (Swift 5.0, iOS 11.0+) |
71+
| `android/build.gradle` | Android config (compileSdk 34, minSdk 21, Gradle 8.1.0) |
72+
| `react-native.config.js` | React Native auto-linking configuration |
73+
74+
## CI/CD Workflows
75+
76+
### `.github/workflows/node.js.yml` (Primary CI)
77+
- Runs on: push/PR to master
78+
- Jobs: `test_main_code`, `test_android`, `test_ios`
79+
- Node version: 18.x
80+
- Steps: `npm install``npm test`
81+
82+
### Test Requirements
83+
- Tests use mocked react-native modules (`__tests__/jest_setup.js`)
84+
- AsyncStorage, uuid, and react-native-get-random-values are mocked
85+
86+
## Development Guidelines
87+
88+
### Making Code Changes
89+
1. JavaScript/TypeScript changes: Modify files in root or `javascript/` directory
90+
2. iOS changes: Modify `.swift` files in `ios/` directory
91+
3. Android changes: Modify `.java` files in `android/src/main/java/`
92+
4. After changes: Always run `npm test` to verify
93+
94+
### Adding Tests
95+
- Place tests in `__tests__/` directory with `.test.js` suffix
96+
- Use existing mock setup from `jest_setup.js`
97+
- Follow patterns in existing test files
98+
99+
### Type Definitions
100+
- Update `index.d.ts` when adding/modifying public API methods
101+
- Ensure TypeScript types match runtime behavior
102+
103+
## Dependencies
104+
105+
### Runtime Dependencies
106+
- `@react-native-async-storage/async-storage` - Persistence (JavaScript mode)
107+
- `react-native-get-random-values` - UUID polyfill
108+
- `uuid@3.3.2` - UUID generation
109+
110+
### Native SDK Dependencies
111+
- iOS: `Mixpanel-swift@5.1.0`
112+
- Android: `mixpanel-android@8.2.0`
113+
114+
## Sample Apps
115+
Located in `Samples/` directory:
116+
- `SimpleMixpanel` - Minimal integration example (used in CI)
117+
- `MixpanelDemo` - Full API demonstration
118+
- `ContextAPIMixpanel` - React Context integration
119+
- `MixpanelExpo` - Expo project example
120+
- `MixpanelExample`, `MixpanelStarter` - Additional examples
121+
122+
## Generating Documentation
123+
```bash
124+
./generate_docs.sh # Uses jsdoc, outputs to docs/
125+
```
126+
127+
## Important Notes
128+
129+
1. **Trust these instructions first** - Only perform additional searches if information here is incomplete or incorrect
130+
2. **npm install is required** before running tests
131+
3. **All 106 tests must pass** before submitting changes
132+
4. **Mocks are essential** - Tests rely on mocked react-native modules; do not remove mocks from `jest_setup.js`
133+
5. **Two modes of operation**: Native mode (iOS/Android) and JavaScript mode (Expo/Web)
134+
6. **API surface**: Changes to `index.js` require corresponding updates to `index.d.ts`

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,5 @@ CLAUDE.md
6161
claude/
6262
.claude/
6363
.cursor/
64-
.github/copilot-*
6564
.github/instructions/
6665
.github/prompts/

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)