Skip to content
Draft
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
10 changes: 4 additions & 6 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,13 @@ npm test

### Native SDK Dependencies
- iOS: `Mixpanel-swift@5.1.0`
- Android: `mixpanel-android@8.2.0`
- Android: `mixpanel-android@8.7.0`

## Sample Apps
Located in `Samples/` directory:
- `SimpleMixpanel` - Minimal integration example (used in CI)
- `MixpanelDemo` - Full API demonstration
- `ContextAPIMixpanel` - React Context integration
- `MixpanelExpo` - Expo project example
- `MixpanelExample`, `MixpanelStarter` - Additional examples
- `MixpanelExample` - Core integration patterns (used in CI)
- `MixpanelExpo` - Expo project example with full API reference
- `MixpanelStarter` - Production-ready architecture with TypeScript

## Generating Documentation
```bash
Expand Down
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ updates:
directory: "/" # Tells Dependabot to scan root directory only
schedule:
interval: "daily"
cooldown:
default-days: 30
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
cooldown:
default-days: 30
9 changes: 9 additions & 0 deletions .github/modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"analytics": {
"tag_prefix": "v",
"package_json": "package.json",
"changelog": "CHANGELOG.md",
"readme": "README.md",
"package_name": "mixpanel-react-native"
}
}
87 changes: 87 additions & 0 deletions .github/scripts/generate-changelog.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -euo pipefail

MODULE="$1"
VERSION_LABEL="$2"
REPO_URL="$3"
END_REF="${4:-HEAD}"

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
MODULES_JSON="$SCRIPT_DIR/../modules.json"

TAG_PREFIX=$(jq -e -r --arg m "$MODULE" '.[$m].tag_prefix' "$MODULES_JSON") || {
echo "Unknown module: $MODULE. Valid modules: $(jq -r 'keys | join(", ")' "$MODULES_JSON")" >&2
exit 1
}
TAG_GLOB="${TAG_PREFIX}*"

PREVIOUS_TAG=$(git tag --sort=-creatordate --list "$TAG_GLOB" | head -1 || true)

if [ -z "$PREVIOUS_TAG" ]; then
RANGE="$END_REF"
else
RANGE="${PREVIOUS_TAG}..${END_REF}"
fi

DATE=$(date +%Y-%m-%d)
SAFE_URL=$(printf '%s' "$REPO_URL" | sed 's|[&/\]|\\&|g')

declare -a FEATURES=()
declare -a FIXES=()
declare -a CHORES=()

while IFS= read -r line; do
[ -z "$line" ] && continue
MSG=$(echo "$line" | cut -d' ' -f2-)

# feat / fix: include whether bare, scoped to our module, or scoped to
# `all` (cross-cutting changes that appear in every module's changelog).
# chore: include only when explicitly scoped to our module or `all` —
# bare `chore:` is the convention for changes intentionally hidden from
# the changelog (release prep PRs, CI tweaks, lockfile bumps, internal
# docs).
if [[ "$MSG" =~ ^(feat|fix)(\((${MODULE}|all)\))?:\ (.+) ]]; then
TYPE="${BASH_REMATCH[1]}"
DESC="${BASH_REMATCH[4]}"
DESC=$(echo "$DESC" | sed -E "s|\(#([0-9]+)\)|([#\1](${SAFE_URL}/pull/\1))|g")
case "$TYPE" in
feat) FEATURES+=("$DESC") ;;
fix) FIXES+=("$DESC") ;;
esac
elif [[ "$MSG" =~ ^chore\((${MODULE}|all)\):\ (.+) ]]; then
DESC="${BASH_REMATCH[2]}"
DESC=$(echo "$DESC" | sed -E "s|\(#([0-9]+)\)|([#\1](${SAFE_URL}/pull/\1))|g")
CHORES+=("$DESC")
fi
done < <(git log --oneline "$RANGE")

echo "## [${VERSION_LABEL}](${REPO_URL}/tree/${VERSION_LABEL}) (${DATE})"
echo ""

if [ ${#FEATURES[@]} -gt 0 ]; then
echo "### Features"
for entry in "${FEATURES[@]}"; do
echo "- ${entry}"
done
echo ""
fi

if [ ${#FIXES[@]} -gt 0 ]; then
echo "### Fixes"
for entry in "${FIXES[@]}"; do
echo "- ${entry}"
done
echo ""
fi

if [ ${#CHORES[@]} -gt 0 ]; then
echo "### Chores"
for entry in "${CHORES[@]}"; do
echo "- ${entry}"
done
echo ""
fi

if [ -n "$PREVIOUS_TAG" ]; then
echo "[Full Changelog](${REPO_URL}/compare/${PREVIOUS_TAG}...${VERSION_LABEL})"
fi
38 changes: 20 additions & 18 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
Expand All @@ -34,21 +34,21 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup Java
uses: actions/setup-java@v4
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4
with:
distribution: "temurin"
java-version: "17"

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
uses: gradle/actions/setup-gradle@48b5f213c81028ace310571dc5ec0fbbca0b2947 # v4

- name: Install dependencies
run: |
Expand All @@ -57,7 +57,7 @@ jobs:
npm i react-native-gradle-plugin

- name: Test Integration - Install dependencies
working-directory: ./Samples/SimpleMixpanel
working-directory: ./Samples/MixpanelExample
run: yarn install

- name: Enable KVM
Expand All @@ -67,7 +67,7 @@ jobs:
sudo udevadm trigger --name-match=kvm

- name: AVD cache
uses: actions/cache@v4
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
id: avd-cache
with:
path: |
Expand All @@ -77,7 +77,7 @@ jobs:

- name: Create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2
env:
GRADLE_OPTS: -Xmx4096m -Dorg.gradle.daemon=false
JAVA_OPTS: -Xmx4096m
Expand All @@ -89,11 +89,11 @@ jobs:
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
working-directory: ./Samples/SimpleMixpanel
working-directory: ./Samples/MixpanelExample
script: echo "Generated AVD snapshot for caching."

- name: Run Android Tests
uses: reactivecircus/android-emulator-runner@v2
uses: reactivecircus/android-emulator-runner@e89f39f1abbbd05b1113a29cf4db69e7540cae5a # v2
env:
GRADLE_OPTS: -Xmx4096m -Dorg.gradle.daemon=false
JAVA_OPTS: -Xmx4096m
Expand All @@ -106,7 +106,7 @@ jobs:
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
emulator-boot-timeout: 900
working-directory: ./Samples/SimpleMixpanel
working-directory: ./Samples/MixpanelExample
script: |
echo "org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError" >> android/gradle.properties
echo "org.gradle.daemon=false" >> android/gradle.properties
Expand All @@ -119,19 +119,21 @@ jobs:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm install -g react-native-cli
- name: Test Integration - Install dependencies
working-directory: ./Samples/SimpleMixpanel
working-directory: ./Samples/MixpanelExample
run: npm install
- name: Setup iOS
working-directory: ./Samples/SimpleMixpanel/ios
run: pod install --repo-update
working-directory: ./Samples/MixpanelExample/ios
run: |
rm -f Podfile.lock
pod install --repo-update
- name: Test iOS
working-directory: ./Samples/SimpleMixpanel
working-directory: ./Samples/MixpanelExample
run: react-native run-ios
51 changes: 51 additions & 0 deletions .github/workflows/pr-title-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: PR Title Check

on:
pull_request:
types: [opened, edited, synchronize, reopened]

permissions:
contents: read

jobs:
check-title:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
sparse-checkout: .github/modules.json
sparse-checkout-cone-mode: false

- name: Check PR title format
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
MODULE_LIST=$(jq -r 'keys | join("|")' .github/modules.json)
# Scope is optional. Bare, scoped to a known module, or scoped to
# `all` (cross-cutting changes that appear in every module's
# changelog) all pass.
MAIN_PATTERN="^(feat|fix|chore)(\((${MODULE_LIST}|all)\))?: .+"
RELEASE_PATTERN="^release: .+"

if [[ "$PR_TITLE" =~ $MAIN_PATTERN ]] || [[ "$PR_TITLE" =~ $RELEASE_PATTERN ]]; then
echo "PR title is valid: $PR_TITLE"
exit 0
fi

echo "PR title does not match the required format."
echo ""
echo " Got: $PR_TITLE"
echo ""
echo "Expected one of:"
echo " feat: description"
echo " fix: description"
echo " chore: description"
echo " feat(<module>|all): description"
echo " fix(<module>|all): description"
echo " chore(<module>|all): description"
echo " release: description"
echo ""
echo "Valid scopes: ${MODULE_LIST//|/, }, all"
exit 1
Loading
Loading