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
31 changes: 31 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier'
],
rules: {
'object-curly-spacing': ['error', 'always'],
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }]
},
env: {
node: true,
es6: true
},
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module'
},
ignorePatterns: [
'lib/',
'sample/',
'android/',
'ios/',
'*.min.js',
'node_modules/'
]
};
5 changes: 4 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ jobs:
- name: "Checkout"
uses: actions/checkout@v4
- uses: actions/setup-node@master
- uses: c-hive/gha-yarn-cache@v2
with:
node-version: 18
cache: yarn
cache-dependency-path: yarn.lock

- name: "Install node modules"
run: |
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
## Build generated
build/
DerivedData/
.yarn/
*.DS_Store

## Various settings
Expand Down Expand Up @@ -78,3 +79,9 @@ build
.gradle
local.properties
package-lock.json

# TypeScript build output
lib/

# Development package
*.tgz
66 changes: 65 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
sample
# Sample app
sample/

# Android build artifacts and libs
android/libs/
android/build/
android/.gradle/
android/local.properties

# iOS build artifacts
ios/build/
ios/Pods/
ios/Podfile.lock

# Build directories
build/
dist/

# Dependencies
node_modules/

# IDE files
.idea/
.vscode/
*.iml
*.iws

# OS files
.DS_Store
Thumbs.db

# Git
.git/
.github/

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Other
.gradle/
.trunk/
*.tgz
*.tar.gz

# Heavy binary files
*.jar
*.aar
*.so
*.dylib
*.dll

# Development files
package-lock.json
yarn.lock
tsconfig.json
release.sh

# Development and test files
**/*.test.ts
**/*.test.tsx
**/*.spec.ts
**/*.spec.tsx
11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
bracketSpacing: true,
singleQuote: true,
trailingComma: 'es5',
tabWidth: 2,
useTabs: false,
semi: true,
bracketSameLine: false,
arrowParens: 'avoid',
printWidth: 80
};
213 changes: 213 additions & 0 deletions ONBOARDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
# Developer Onboarding Guide

This guide will help you set up your development environment for working on the react-native-mparticle SDK.

## Prerequisites

- Node.js and npm
- React Native development environment set up ([React Native Environment Setup Guide](https://reactnative.dev/docs/environment-setup))
- For iOS:
- macOS
- Xcode (latest version recommended)
- CocoaPods
- Ruby (for CocoaPods)
- For Android:
- Android Studio
- Java Development Kit (JDK)
- Android SDK

## Project Structure

```
react-native-mparticle/
├── android/ # Native Android SDK implementation
├── ios/ # Native iOS SDK implementation
├── js/ # JavaScript/TypeScript SDK implementation
├── sample/ # Sample app for testing
└── ...
```

## Initial Setup

Install dependencies:
```bash
yarn install
```

## Running the Sample App

The sample app is a great way to test your changes and see the SDK in action.

### iOS Sample App

1. Navigate to the sample directory:
```bash
cd sample
```

2. Install JavaScript dependencies:
```bash
yarn install
```

3. Install iOS dependencies:
```bash
cd ios
pod install
cd ..
```

4. Start the Metro bundler:
```bash
yarn start
```

5. Open the iOS workspace:
```bash
open ios/MParticleSample.xcworkspace
```

6. In Xcode:
- Select your target device/simulator
- Update signing configuration if needed
- Build and run (⌘R)

### Android Sample App

1. Navigate to the sample directory:
```bash
cd sample
```

2. Install JavaScript dependencies:
```bash
npm install
# or
yarn install
```

3. Start the Metro bundler:
```bash
npm start
# or
yarn start
```

4. Open Android Studio:
- Open the `android` folder in Android Studio
- Let Gradle sync complete
- Update any required SDK packages if prompted

5. Run the app:
- Select your target device/emulator
- Click Run (or press ⇧F10)

## Development Workflow

### Building the SDK

#### Android
```bash
cd android
./gradlew build
```

#### iOS
```bash
cd ios
pod install
```

### Running Tests

```bash
# Run JavaScript tests
npm test

# Run Android tests
cd android
./gradlew test

# Run iOS tests
cd ios/RNMParticle.xcodeproj
xcodebuild test
```

## Troubleshooting

### Common iOS Issues

1. "Missing config.h" error:
This error occurs because the mParticle SDK contains Swift code which requires special handling. To fix this:

a. Open your `sample/ios/Podfile` and add this block before the target definition:
```ruby
pre_install do |installer|
installer.pod_targets.each do |pod|
if pod.name == 'mParticle-Apple-SDK'
def pod.build_type;
Pod::BuildType.new(:linkage => :dynamic, :packaging => :framework)
end
end
end
end
```

b. Clean and reinstall pods:
```bash
cd sample/ios
pod cache clean --all
rm -rf Pods Podfile.lock
pod install
```

c. If using Xcode 12 or later, ensure your project's Build Settings has "Allow Non-modular Includes In Framework Modules" set to Yes

2. Pod install fails:
- Try cleaning the pod cache: `pod cache clean --all`
- Delete Podfile.lock and try again
- Ensure CocoaPods is up to date: `bundle update`

3. Build errors:
- Clean build folder in Xcode (⇧⌘K)
- Delete derived data: `rm -rf ~/Library/Developer/Xcode/DerivedData`
- Ensure all dependencies are properly installed

### Common Android Issues

1. Gradle sync fails:
- Check Android Studio SDK Manager for missing packages
- Update Gradle version if needed
- Clean project and rebuild

2. Build errors:
- Run `./gradlew clean`
- Invalidate caches in Android Studio
- Ensure all dependencies are properly installed

## Contributing

1. Create a feature branch
2. Make your changes
3. Test thoroughly
4. Create a pull request
5. Ensure CI passes
6. Request review

## Release Process

1. Update version numbers:
- package.json
- android/build.gradle
- ios/RNMParticle.podspec

2. Update CHANGELOG.md

3. Create release PR

4. After merge, create a new release on GitHub

5. Publish to npm:
```bash
npm publish
```
Loading
Loading