├── .github ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── daily.yml │ ├── dependabot-automerge.yml │ ├── issue-autorespond-and-close.yml │ ├── pull-request.yml │ ├── release.yml │ └── sonarcloud.yml ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── android ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── libs │ ├── java-json.jar │ └── react-native-android │ │ └── com │ │ └── facebook │ │ └── react │ │ ├── hermes-engine │ │ ├── 0.70.5 │ │ │ ├── hermes-engine-0.70.5-debug-sources.jar │ │ │ ├── hermes-engine-0.70.5-debug-sources.jar.md5 │ │ │ ├── hermes-engine-0.70.5-debug-sources.jar.sha1 │ │ │ ├── hermes-engine-0.70.5-debug-sources.jar.sha256 │ │ │ ├── hermes-engine-0.70.5-debug-sources.jar.sha512 │ │ │ ├── hermes-engine-0.70.5-debug.aar │ │ │ ├── hermes-engine-0.70.5-debug.aar.md5 │ │ │ ├── hermes-engine-0.70.5-debug.aar.sha1 │ │ │ ├── hermes-engine-0.70.5-debug.aar.sha256 │ │ │ ├── hermes-engine-0.70.5-debug.aar.sha512 │ │ │ ├── hermes-engine-0.70.5-release-sources.jar │ │ │ ├── hermes-engine-0.70.5-release-sources.jar.md5 │ │ │ ├── hermes-engine-0.70.5-release-sources.jar.sha1 │ │ │ ├── hermes-engine-0.70.5-release-sources.jar.sha256 │ │ │ ├── hermes-engine-0.70.5-release-sources.jar.sha512 │ │ │ ├── hermes-engine-0.70.5-release.aar │ │ │ ├── hermes-engine-0.70.5-release.aar.md5 │ │ │ ├── hermes-engine-0.70.5-release.aar.sha1 │ │ │ ├── hermes-engine-0.70.5-release.aar.sha256 │ │ │ ├── hermes-engine-0.70.5-release.aar.sha512 │ │ │ ├── hermes-engine-0.70.5.module │ │ │ ├── hermes-engine-0.70.5.module.md5 │ │ │ ├── hermes-engine-0.70.5.module.sha1 │ │ │ ├── hermes-engine-0.70.5.module.sha256 │ │ │ ├── hermes-engine-0.70.5.module.sha512 │ │ │ ├── hermes-engine-0.70.5.pom │ │ │ ├── hermes-engine-0.70.5.pom.md5 │ │ │ ├── hermes-engine-0.70.5.pom.sha1 │ │ │ ├── hermes-engine-0.70.5.pom.sha256 │ │ │ └── hermes-engine-0.70.5.pom.sha512 │ │ ├── maven-metadata.xml │ │ ├── maven-metadata.xml.md5 │ │ ├── maven-metadata.xml.sha1 │ │ ├── maven-metadata.xml.sha256 │ │ └── maven-metadata.xml.sha512 │ │ └── react-native │ │ ├── 0.70.5 │ │ ├── react-native-0.70.5-debug-sources.jar │ │ ├── react-native-0.70.5-debug-sources.jar.md5 │ │ ├── react-native-0.70.5-debug-sources.jar.sha1 │ │ ├── react-native-0.70.5-debug-sources.jar.sha256 │ │ ├── react-native-0.70.5-debug-sources.jar.sha512 │ │ ├── react-native-0.70.5-debug.aar │ │ ├── react-native-0.70.5-debug.aar.md5 │ │ ├── react-native-0.70.5-debug.aar.sha1 │ │ ├── react-native-0.70.5-debug.aar.sha256 │ │ ├── react-native-0.70.5-debug.aar.sha512 │ │ ├── react-native-0.70.5-release-sources.jar │ │ ├── react-native-0.70.5-release-sources.jar.md5 │ │ ├── react-native-0.70.5-release-sources.jar.sha1 │ │ ├── react-native-0.70.5-release-sources.jar.sha256 │ │ ├── react-native-0.70.5-release-sources.jar.sha512 │ │ ├── react-native-0.70.5-release.aar │ │ ├── react-native-0.70.5-release.aar.md5 │ │ ├── react-native-0.70.5-release.aar.sha1 │ │ ├── react-native-0.70.5-release.aar.sha256 │ │ ├── react-native-0.70.5-release.aar.sha512 │ │ ├── react-native-0.70.5.module │ │ ├── react-native-0.70.5.module.md5 │ │ ├── react-native-0.70.5.module.sha1 │ │ ├── react-native-0.70.5.module.sha256 │ │ ├── react-native-0.70.5.module.sha512 │ │ ├── react-native-0.70.5.pom │ │ ├── react-native-0.70.5.pom.md5 │ │ ├── react-native-0.70.5.pom.sha1 │ │ ├── react-native-0.70.5.pom.sha256 │ │ └── react-native-0.70.5.pom.sha512 │ │ ├── maven-metadata.xml │ │ ├── maven-metadata.xml.md5 │ │ ├── maven-metadata.xml.sha1 │ │ ├── maven-metadata.xml.sha256 │ │ └── maven-metadata.xml.sha512 └── src │ ├── main │ ├── AndroidManifest.xml │ └── java │ │ └── com │ │ └── mparticle │ │ └── react │ │ ├── MParticleModule.java │ │ ├── MParticlePackage.java │ │ └── Utils.java │ └── test │ └── java │ └── com │ └── mparticle │ └── react │ ├── IdentityApiTest.java │ ├── MParticleUserTest.java │ └── testutils │ ├── MockMParticleUser.java │ ├── MockMap.java │ ├── MockReadableArray.java │ ├── MockWritableMap.java │ └── Mutable.java ├── ios ├── RNMParticle.xcodeproj │ └── project.pbxproj └── RNMParticle │ ├── RNMParticle.h │ └── RNMParticle.m ├── js └── index.js ├── package.json ├── react-native-mparticle.podspec ├── release.sh ├── sample ├── .babelrc ├── .buckconfig ├── .flowconfig ├── .gitattributes ├── .gitignore ├── .watchmanconfig ├── __tests__ │ ├── index.android.js │ └── index.ios.js ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── mparticlesample │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle ├── build ├── index.android.js ├── index.ios.js ├── index.js ├── ios │ ├── MParticleSample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── MParticleSample.xcscheme │ ├── MParticleSample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ ├── MParticleSampleTests │ │ ├── Info.plist │ │ └── MParticleSampleTests.m │ └── Podfile ├── package.json ├── run-android └── yarn.lock └── yarn.lock /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Summary 2 | {provide a thorough description of the changes} 3 | 4 | ## Testing Plan 5 | {explain how this has been tested, and what additional testing should be done} 6 | 7 | ## Master Issue 8 | Closes https://go.mparticle.com/work/REPLACEME 9 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: gradle 4 | directory: "/android" 5 | schedule: 6 | interval: daily 7 | labels: ["dependabot"] 8 | open-pull-requests-limit: 10 9 | ignore: 10 | - dependency-name: "com.google.firebase:firebase-messaging" 11 | commit-message: 12 | prefix: "chore" 13 | -------------------------------------------------------------------------------- /.github/workflows/daily.yml: -------------------------------------------------------------------------------- 1 | name: "Daily" 2 | 3 | on: 4 | 5 | schedule: 6 | - cron: "0 0 * * *" 7 | 8 | # Allow workflow to be manually run from the GitHub UI 9 | workflow_dispatch: 10 | 11 | jobs: 12 | 13 | # daily-job: 14 | # name: "Daily Common Repo Checks" 15 | # uses: mParticle/mparticle-workflows/.github/workflows/daily-cron.yml@main 16 | 17 | daily-local-job: 18 | name: "Daily Local Repo Checks" 19 | uses: mParticle/react-native-mparticle/.github/workflows/pull-request.yml@main 20 | -------------------------------------------------------------------------------- /.github/workflows/dependabot-automerge.yml: -------------------------------------------------------------------------------- 1 | name: "Dependabot Automerge" 2 | 3 | on: 4 | workflow_run: 5 | workflows: ["Build and Test"] 6 | types: 7 | - completed 8 | 9 | jobs: 10 | automerge-dependabot: 11 | name: "Automerge Dependabot PR" 12 | uses: mParticle/mparticle-workflows/.github/workflows/dependabot-automerge.yml@main 13 | -------------------------------------------------------------------------------- /.github/workflows/issue-autorespond-and-close.yml: -------------------------------------------------------------------------------- 1 | name: Auto respond and close issue 2 | 3 | on: 4 | issues: 5 | types: 6 | - opened 7 | 8 | jobs: 9 | auto-respond-and-close-issue: 10 | uses: mparticle/mparticle-workflows/.github/workflows/auto-respond-close-issue.yml@main 11 | with: 12 | issue_number: ${{ github.event.issue.number }} 13 | repository: ${{ github.repository }} 14 | user_login: ${{ github.event.issue.user.login }} -------------------------------------------------------------------------------- /.github/workflows/pull-request.yml: -------------------------------------------------------------------------------- 1 | name: "Build and Test" 2 | 3 | on: 4 | pull_request: 5 | push: 6 | workflow_call: 7 | workflow_dispatch: 8 | 9 | jobs: 10 | js-tests: 11 | name: "JS Tests" 12 | runs-on: macOS-latest 13 | steps: 14 | - name: "Checkout" 15 | uses: actions/checkout@v4 16 | - uses: actions/setup-node@master 17 | - uses: c-hive/gha-yarn-cache@v2 18 | 19 | - name: "Install node modules" 20 | run: | 21 | yarn install 22 | 23 | - name: "Run test" 24 | run: | 25 | yarn test 26 | 27 | android-unit-tests: 28 | name: "Android Unit Tests" 29 | runs-on: ubuntu-latest 30 | steps: 31 | - name: "Checkout" 32 | uses: actions/checkout@v4 33 | - name: "Run Android Unit Tests" 34 | working-directory: android 35 | run: ./gradlew test 36 | 37 | android-lint: 38 | name: "Android Unit Tests" 39 | runs-on: ubuntu-latest 40 | steps: 41 | - name: "Checkout" 42 | uses: actions/checkout@v4 43 | - name: "Run Android Unit Tests" 44 | working-directory: android 45 | run: ./gradlew lint 46 | 47 | android-kotlin-lint: 48 | name: "Android Unit Tests" 49 | runs-on: ubuntu-latest 50 | steps: 51 | - name: "Checkout" 52 | uses: actions/checkout@v4 53 | - name: "Run Android Unit Tests" 54 | working-directory: android 55 | run: ./gradlew ktlintCheck 56 | 57 | automerge-dependabot: 58 | name: "Save PR Number for Dependabot Automerge" 59 | needs: [ js-tests, android-unit-tests, android-lint, android-kotlin-lint ] 60 | uses: mParticle/mparticle-workflows/.github/workflows/dependabot-save-pr-number.yml@main 61 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release SDK 2 | 3 | on: 4 | workflow_dispatch 5 | 6 | jobs: 7 | # SDK release is done from public/master branch. 8 | confirm-master-branch: 9 | name: Confirm release is run on public/master branch 10 | uses: mParticle/mparticle-workflows/.github/workflows/sdk-release-repo-branch-check.yml@main 11 | 12 | # All new code is stored in internal/development. Release from public/master will merge changes from internal/development into 13 | # public/master, then run semantic-release on public/master to update changelog and release notes. Before semantic-release publishes 14 | # to npm, it builds the dist/ folder. Finally, commits from public/master are synced back to internal/master and internal/development. 15 | 16 | react-tests: 17 | name: Run React Native Unit Tests 18 | runs-on: ubuntu-latest 19 | needs: ['confirm-master-branch'] 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@v3 23 | - uses: actions/setup-node@master 24 | - uses: c-hive/gha-yarn-cache@v2 25 | 26 | - name: Install node modules 27 | run: yarn install 28 | 29 | - name: Run test 30 | run: yarn test 31 | 32 | android-unit-tests: 33 | name: Run Android Unit Tests 34 | runs-on: ubuntu-latest 35 | needs: ['confirm-master-branch'] 36 | steps: 37 | - name: Checkout 38 | uses: actions/checkout@v3 39 | 40 | - name: Run Android Unit Tests 41 | run: echo "pwd"; pwd; echo "ls:"; ls; cd android; ./gradlew test 42 | 43 | release-and-sync-repos: 44 | name: Release and Sync Repos 45 | runs-on: ubuntu-latest 46 | needs: ['android-unit-tests', 'react-tests'] 47 | steps: 48 | - name: Checkout internal/development 49 | uses: actions/checkout@v3 50 | 51 | - name: Setup Node.js 52 | uses: actions/setup-node@v3 53 | with: 54 | node-version: 12.x 55 | 56 | - name: Install node modules 57 | run: yarn install 58 | 59 | - name: Release 60 | run: ./release.sh ${{ secrets.NPM_TOKEN}} -------------------------------------------------------------------------------- /.github/workflows/sonarcloud.yml: -------------------------------------------------------------------------------- 1 | name: "SonarCloud" 2 | 3 | on: 4 | workflow_dispatch: 5 | workflow_run: 6 | workflows: ["Build and Test"] 7 | types: 8 | - completed 9 | 10 | jobs: 11 | sonarcloud-check: 12 | name: "SonarCloud Check" 13 | uses: mParticle/mparticle-workflows/.github/workflows/sonarcloud.yml@main 14 | secrets: inherit 15 | with: 16 | app_relative_path: "android" 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | *.DS_Store 9 | 10 | ## Various settings 11 | *.pbxuser 12 | !default.pbxuser 13 | *.mode1v3 14 | !default.mode1v3 15 | *.mode2v3 16 | !default.mode2v3 17 | *.perspectivev3 18 | !default.perspectivev3 19 | xcuserdata/ 20 | 21 | ## Other 22 | *.moved-aside 23 | *.xcuserstate 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | 29 | ## Playgrounds 30 | timeline.xctimeline 31 | playground.xcworkspace 32 | 33 | # Swift Package Manager 34 | # 35 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 36 | # Packages/ 37 | .build/ 38 | 39 | # CocoaPods 40 | # 41 | # We recommend against adding the Pods directory to your .gitignore. However 42 | # you should judge for yourself, the pros and cons are mentioned at: 43 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 44 | # 45 | Pods/ 46 | 47 | # Carthage 48 | # 49 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 50 | **/Carthage/Checkouts 51 | 52 | **/Carthage/Build 53 | 54 | # fastlane 55 | # 56 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 57 | # screenshots whenever they are needed. 58 | # For more information about the recommended setup visit: 59 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 60 | 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | 66 | **/Podfile.lock 67 | **/*.xcworkspace 68 | Cartfile.resolved 69 | **/node_modules 70 | npm-debug.log 71 | # Intellij 72 | .idea/ 73 | *.iml 74 | *.iws 75 | 76 | # Gradle 77 | build 78 | .gradle 79 | local.properties 80 | package-lock.json 81 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | sample 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2017 mParticle, Inc. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | 15 | 16 | Apache License 17 | Version 2.0, January 2004 18 | http://www.apache.org/licenses/ 19 | 20 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 21 | 22 | 1. Definitions. 23 | 24 | "License" shall mean the terms and conditions for use, reproduction, 25 | and distribution as defined by Sections 1 through 9 of this document. 26 | 27 | "Licensor" shall mean the copyright owner or entity authorized by 28 | the copyright owner that is granting the License. 29 | 30 | "Legal Entity" shall mean the union of the acting entity and all 31 | other entities that control, are controlled by, or are under common 32 | control with that entity. For the purposes of this definition, 33 | "control" means (i) the power, direct or indirect, to cause the 34 | direction or management of such entity, whether by contract or 35 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 36 | outstanding shares, or (iii) beneficial ownership of such entity. 37 | 38 | "You" (or "Your") shall mean an individual or Legal Entity 39 | exercising permissions granted by this License. 40 | 41 | "Source" form shall mean the preferred form for making modifications, 42 | including but not limited to software source code, documentation 43 | source, and configuration files. 44 | 45 | "Object" form shall mean any form resulting from mechanical 46 | transformation or translation of a Source form, including but 47 | not limited to compiled object code, generated documentation, 48 | and conversions to other media types. 49 | 50 | "Work" shall mean the work of authorship, whether in Source or 51 | Object form, made available under the License, as indicated by a 52 | copyright notice that is included in or attached to the work 53 | (an example is provided in the Appendix below). 54 | 55 | "Derivative Works" shall mean any work, whether in Source or Object 56 | form, that is based on (or derived from) the Work and for which the 57 | editorial revisions, annotations, elaborations, or other modifications 58 | represent, as a whole, an original work of authorship. For the purposes 59 | of this License, Derivative Works shall not include works that remain 60 | separable from, or merely link (or bind by name) to the interfaces of, 61 | the Work and Derivative Works thereof. 62 | 63 | "Contribution" shall mean any work of authorship, including 64 | the original version of the Work and any modifications or additions 65 | to that Work or Derivative Works thereof, that is intentionally 66 | submitted to Licensor for inclusion in the Work by the copyright owner 67 | or by an individual or Legal Entity authorized to submit on behalf of 68 | the copyright owner. For the purposes of this definition, "submitted" 69 | means any form of electronic, verbal, or written communication sent 70 | to the Licensor or its representatives, including but not limited to 71 | communication on electronic mailing lists, source code control systems, 72 | and issue tracking systems that are managed by, or on behalf of, the 73 | Licensor for the purpose of discussing and improving the Work, but 74 | excluding communication that is conspicuously marked or otherwise 75 | designated in writing by the copyright owner as "Not a Contribution." 76 | 77 | "Contributor" shall mean Licensor and any individual or Legal Entity 78 | on behalf of whom a Contribution has been received by Licensor and 79 | subsequently incorporated within the Work. 80 | 81 | 2. Grant of Copyright License. Subject to the terms and conditions of 82 | this License, each Contributor hereby grants to You a perpetual, 83 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 84 | copyright license to reproduce, prepare Derivative Works of, 85 | publicly display, publicly perform, sublicense, and distribute the 86 | Work and such Derivative Works in Source or Object form. 87 | 88 | 3. Grant of Patent License. Subject to the terms and conditions of 89 | this License, each Contributor hereby grants to You a perpetual, 90 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 91 | (except as stated in this section) patent license to make, have made, 92 | use, offer to sell, sell, import, and otherwise transfer the Work, 93 | where such license applies only to those patent claims licensable 94 | by such Contributor that are necessarily infringed by their 95 | Contribution(s) alone or by combination of their Contribution(s) 96 | with the Work to which such Contribution(s) was submitted. If You 97 | institute patent litigation against any entity (including a 98 | cross-claim or counterclaim in a lawsuit) alleging that the Work 99 | or a Contribution incorporated within the Work constitutes direct 100 | or contributory patent infringement, then any patent licenses 101 | granted to You under this License for that Work shall terminate 102 | as of the date such litigation is filed. 103 | 104 | 4. Redistribution. You may reproduce and distribute copies of the 105 | Work or Derivative Works thereof in any medium, with or without 106 | modifications, and in Source or Object form, provided that You 107 | meet the following conditions: 108 | 109 | (a) You must give any other recipients of the Work or 110 | Derivative Works a copy of this License; and 111 | 112 | (b) You must cause any modified files to carry prominent notices 113 | stating that You changed the files; and 114 | 115 | (c) You must retain, in the Source form of any Derivative Works 116 | that You distribute, all copyright, patent, trademark, and 117 | attribution notices from the Source form of the Work, 118 | excluding those notices that do not pertain to any part of 119 | the Derivative Works; and 120 | 121 | (d) If the Work includes a "NOTICE" text file as part of its 122 | distribution, then any Derivative Works that You distribute must 123 | include a readable copy of the attribution notices contained 124 | within such NOTICE file, excluding those notices that do not 125 | pertain to any part of the Derivative Works, in at least one 126 | of the following places: within a NOTICE text file distributed 127 | as part of the Derivative Works; within the Source form or 128 | documentation, if provided along with the Derivative Works; or, 129 | within a display generated by the Derivative Works, if and 130 | wherever such third-party notices normally appear. The contents 131 | of the NOTICE file are for informational purposes only and 132 | do not modify the License. You may add Your own attribution 133 | notices within Derivative Works that You distribute, alongside 134 | or as an addendum to the NOTICE text from the Work, provided 135 | that such additional attribution notices cannot be construed 136 | as modifying the License. 137 | 138 | You may add Your own copyright statement to Your modifications and 139 | may provide additional or different license terms and conditions 140 | for use, reproduction, or distribution of Your modifications, or 141 | for any such Derivative Works as a whole, provided Your use, 142 | reproduction, and distribution of the Work otherwise complies with 143 | the conditions stated in this License. 144 | 145 | 5. Submission of Contributions. Unless You explicitly state otherwise, 146 | any Contribution intentionally submitted for inclusion in the Work 147 | by You to the Licensor shall be under the terms and conditions of 148 | this License, without any additional terms or conditions. 149 | Notwithstanding the above, nothing herein shall supersede or modify 150 | the terms of any separate license agreement you may have executed 151 | with Licensor regarding such Contributions. 152 | 153 | 6. Trademarks. This License does not grant permission to use the trade 154 | names, trademarks, service marks, or product names of the Licensor, 155 | except as required for reasonable and customary use in describing the 156 | origin of the Work and reproducing the content of the NOTICE file. 157 | 158 | 7. Disclaimer of Warranty. Unless required by applicable law or 159 | agreed to in writing, Licensor provides the Work (and each 160 | Contributor provides its Contributions) on an "AS IS" BASIS, 161 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 162 | implied, including, without limitation, any warranties or conditions 163 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 164 | PARTICULAR PURPOSE. You are solely responsible for determining the 165 | appropriateness of using or redistributing the Work and assume any 166 | risks associated with Your exercise of permissions under this License. 167 | 168 | 8. Limitation of Liability. In no event and under no legal theory, 169 | whether in tort (including negligence), contract, or otherwise, 170 | unless required by applicable law (such as deliberate and grossly 171 | negligent acts) or agreed to in writing, shall any Contributor be 172 | liable to You for damages, including any direct, indirect, special, 173 | incidental, or consequential damages of any character arising as a 174 | result of this License or out of the use or inability to use the 175 | Work (including but not limited to damages for loss of goodwill, 176 | work stoppage, computer failure or malfunction, or any and all 177 | other commercial damages or losses), even if such Contributor 178 | has been advised of the possibility of such damages. 179 | 180 | 9. Accepting Warranty or Additional Liability. While redistributing 181 | the Work or Derivative Works thereof, You may choose to offer, 182 | and charge a fee for, acceptance of support, warranty, indemnity, 183 | or other liability obligations and/or rights consistent with this 184 | License. However, in accepting such obligations, You may act only 185 | on Your own behalf and on Your sole responsibility, not on behalf 186 | of any other Contributor, and only if You agree to indemnify, 187 | defend, and hold each Contributor harmless for any liability 188 | incurred by, or claims asserted against, such Contributor by reason 189 | of your accepting any such warranty or additional liability. 190 | 191 | END OF TERMS AND CONDITIONS -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-mparticle 2 | 3 | [![npm version](https://badge.fury.io/js/react-native-mparticle.svg)](https://badge.fury.io/js/react-native-mparticle) 4 | [![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/) 5 | 6 | React Native allows developers to use a single code base to deploy features to multiple platforms. With the mParticle React Native library, you can leverage a single API to deploy your data to hundreds of integrations from your iOS and Android apps. 7 | 8 | ### Supported Features 9 | | Method | Android | iOS | 10 | | --- | --- | --- | 11 | | Custom Events |
  • [X]
  • |
  • [X]
  • | 12 | | Page Views |
  • [X]
  • |
  • [X]
  • | 13 | | Identity |
  • [X]
  • |
  • [X]
  • | 14 | | eCommerce |
  • [X]
  • |
  • [X]
  • | 15 | | Consent |
  • [X]
  • |
  • [X]
  • | 16 | 17 | # Installation 18 | 19 | **Download and install the mParticle React Native library** from npm: 20 | 21 | ```bash 22 | $ npm install react-native-mparticle --save 23 | ``` 24 | 25 | ## iOS 26 | 27 | 1. **Copy your mParticle key and secret** from [your app's dashboard][1]. 28 | 29 | [1]: https://app.mparticle.com/setup/inputs/apps 30 | 31 | 2. **Install the SDK** using CocoaPods: 32 | 33 | The npm install step above will automatically include our react framework and the core iOS framework in your project. However depending on your app and its other dependecies you must integrate it in 1 of 3 ways 34 | 35 | A. Static Libraries are the React Native default but since mParticle iOS contains swift code you need to add an exception for it in the from of a pre-install command in the Podfile. 36 | ```bash 37 | pre_install do |installer| 38 | installer.pod_targets.each do |pod| 39 | if pod.name == 'mParticle-Apple-SDK' 40 | def pod.build_type; 41 | Pod::BuildType.new(:linkage => :dynamic, :packaging => :framework) 42 | end 43 | end 44 | end 45 | end 46 | ``` 47 | Then run the following command 48 | ``` 49 | bundle exec pod install 50 | ``` 51 | 52 | B&C. Frameworks are the default for Swift development and while it isn't preferred by React Native it is supported. Additionally you can define whether the frameworks are built staticly or dynamically. 53 | 54 | Update your Podfile to be ready to use dynamically linked frameworks by commenting out the following line 55 | ```bash 56 | # :flipper_configuration => flipper_config, 57 | ``` 58 | Then run either of the following commands 59 | ``` 60 | $ USE_FRAMEWORKS=static bundle exec pod install 61 | ``` 62 | or 63 | ``` 64 | $ USE_FRAMEWORKS=dynamic bundle exec pod install 65 | ``` 66 | 67 | 3. Import and start the mParticle Apple SDK into Swift or Objective-C. 68 | 69 | The mParticle SDK is initialized by calling the `startWithOptions` method within the `application:didFinishLaunchingWithOptions:` delegate call. 70 | 71 | Preferably the location of the initialization method call should be one of the last statements in the `application:didFinishLaunchingWithOptions:`. 72 | 73 | The `startWithOptions` method requires an options argument containing your key and secret and an initial Identity request. 74 | 75 | > Note that you must initialize the SDK in the `application:didFinishLaunchingWithOptions:` method. Other parts of the SDK rely on the `UIApplicationDidBecomeActiveNotification` notification to function properly. Failing to start the SDK as indicated will impair it. Also, please do **not** use _GCD_'s `dispatch_async` to start the SDK. 76 | 77 | For more help, see [the iOS set up docs](https://docs.mparticle.com/developers/sdk/ios/getting-started/#create-an-input). 78 | 79 | #### Swift Example 80 | 81 | ```swift 82 | import mParticle_Apple_SDK 83 | 84 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 85 | 86 | //override point for customization after application launch. 87 | let mParticleOptions = MParticleOptions(key: "<<>>", secret: "<<>>") 88 | 89 | //optional- Please see the Identity page for more information on building this object 90 | let request = MPIdentityApiRequest() 91 | request.email = "email@example.com" 92 | mParticleOptions.identifyRequest = request 93 | //optional 94 | mParticleOptions.onIdentifyComplete = { (apiResult, error) in 95 | NSLog("Identify complete. userId = %@ error = %@", apiResult?.user.userId.stringValue ?? "Null User ID", error?.localizedDescription ?? "No Error Available") 96 | } 97 | //optional 98 | mParticleOptions.onAttributionComplete = { (attributionResult, error) in 99 | NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo) 100 | } 101 | MParticle.sharedInstance().start(with: mParticleOptions) 102 | return true 103 | } 104 | ``` 105 | 106 | #### Objective-C Example 107 | 108 | Your import statement should be this: 109 | 110 | ```objective-c 111 | #if defined(__has_include) && __has_include() 112 | #import 113 | #elif defined(__has_include) && __has_include() 114 | #import 115 | #else 116 | #import "mParticle.h" 117 | #endif 118 | ``` 119 | 120 | Next, you'll need to start the SDK: 121 | 122 | ```objective-c 123 | - (BOOL)application:(UIApplication *)application 124 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 125 | 126 | MParticleOptions *mParticleOptions = [MParticleOptions optionsWithKey:@"REPLACE ME" 127 | secret:@"REPLACE ME"]; 128 | 129 | //optional - Please see the Identity page for more information on building this object 130 | MPIdentityApiRequest *request = [MPIdentityApiRequest requestWithEmptyUser]; 131 | request.email = @"email@example.com"; 132 | mParticleOptions.identifyRequest = request; 133 | //optional 134 | mParticleOptions.onIdentifyComplete = ^(MPIdentityApiResult * _Nullable apiResult, NSError * _Nullable error) { 135 | NSLog(@"Identify complete. userId = %@ error = %@", apiResult.user.userId, error); 136 | }; 137 | //optional 138 | mParticleOptions.onAttributionComplete(MPAttributionResult * _Nullable attributionResult, NSError * _Nullable error) { 139 | NSLog(@"Attribution Complete. attributionResults = %@", attributionResult.linkInfo) 140 | } 141 | 142 | [[MParticle sharedInstance] startWithOptions:mParticleOptions]; 143 | 144 | return YES; 145 | } 146 | ``` 147 | 148 | See [Identity](http://docs.mparticle.com/developers/sdk/ios/identity/) for more information on supplying an `MPIdentityApiRequest` object during SDK initialization. 149 | 150 | 4. Remember to start Metro with: 151 | ```bash 152 | $ npm start 153 | ``` 154 | and build your workspace from xCode. 155 | 156 | 157 | ## Android 158 | 159 | 1. Copy your mParticle key and secret from [your workspace's dashboard](https://app.mparticle.com/setup/inputs/apps) and construct an `MParticleOptions` object. 160 | 161 | 2. Call `start` from the `onCreate` method of your app's `Application` class. It's crucial that the SDK be started here for proper session management. If you don't already have an `Application` class, create it and then specify its fully-qualified name in the `` tag of your app's `AndroidManifest.xml`. 162 | 163 | For more help, see [the Android set up docs](https://docs.mparticle.com/developers/sdk/android/getting-started/#create-an-input). 164 | 165 | ```kotlin 166 | package com.example.myapp; 167 | 168 | import android.app.Application; 169 | import com.mparticle.MParticle; 170 | 171 | class MyApplication : Application() { 172 | fun onCreate() { 173 | super.onCreate() 174 | val options: MParticleOptions = MParticleOptions.builder(this) 175 | .credentials("REPLACE ME WITH KEY", "REPLACE ME WITH SECRET") 176 | //optional 177 | .logLevel(MParticle.LogLevel.VERBOSE) 178 | //optional 179 | .identify(identifyRequest) 180 | //optional 181 | .identifyTask( 182 | BaseIdentityTask() 183 | .addFailureListener { errorResponse -> } 184 | .addSuccessListener{ result -> } 185 | ) 186 | //optional 187 | .attributionListener(this) 188 | .build() 189 | MParticle.start(options) 190 | } 191 | } 192 | ``` 193 | 194 | > **Warning:** Don't log events in your `Application.onCreate()`. Android may instantiate your `Application` class in the background without your knowledge, including when the user isn't using their device, and lead to unexpected results. 195 | 196 | 197 | # Usage 198 | 199 | ## Import the mParticle Module 200 | 201 | ```js 202 | import MParticle from 'react-native-mparticle' 203 | ``` 204 | 205 | ## Logging Events 206 | 207 | To log basic events: 208 | 209 | ```js 210 | MParticle.logEvent('Test event', MParticle.EventType.Other, { 'Test key': 'Test value' }) 211 | ``` 212 | 213 | To log commerce events: 214 | 215 | ```js 216 | const product = new MParticle.Product('Test product for cart', '1234', 19.99) 217 | const transactionAttributes = new MParticle.TransactionAttributes('Test transaction id') 218 | const event = MParticle.CommerceEvent.createProductActionEvent(MParticle.ProductActionType.AddToCart, [product], transactionAttributes) 219 | 220 | MParticle.logCommerceEvent(event) 221 | ``` 222 | 223 | ```js 224 | const promotion = new MParticle.Promotion('Test promotion id', 'Test promotion name', 'Test creative', 'Test position') 225 | const event = MParticle.CommerceEvent.createPromotionEvent(MParticle.PromotionActionType.View, [promotion]) 226 | 227 | MParticle.logCommerceEvent(event) 228 | ``` 229 | 230 | ```js 231 | const product = new MParticle.Product('Test product that was viewed', '5678', 29.99) 232 | const impression = new MParticle.Impression('Test impression list name', [product]) 233 | const event = MParticle.CommerceEvent.createImpressionEvent([impression]) 234 | 235 | MParticle.logCommerceEvent(event) 236 | ``` 237 | 238 | To log screen events: 239 | 240 | ```js 241 | MParticle.logScreenEvent('Test screen', { 'Test key': 'Test value' }) 242 | ``` 243 | 244 | ## User 245 | 246 | To set, remove, and get user details, call the `User` or `Identity` methods as follows: 247 | 248 | ```js 249 | MParticle.User.setUserAttribute('User ID', 'Test key', 'Test value') 250 | ``` 251 | 252 | ```js 253 | MParticle.User.setUserAttribute('User ID', MParticle.UserAttributeType.FirstName, 'Test first name') 254 | ``` 255 | 256 | ```js 257 | MParticle.User.setUserAttributeArray('User ID', 'Test key', ['Test value 1', 'Test value 2']) 258 | ``` 259 | 260 | ```js 261 | MParticle.User.setUserTag('User ID', 'Test value') 262 | ``` 263 | 264 | ```js 265 | MParticle.User.removeUserAttribute('User ID', 'Test key') 266 | ``` 267 | 268 | ```js 269 | MParticle.Identity.getUserIdentities((userIdentities) => { 270 | console.debug(userIdentities); 271 | }); 272 | ``` 273 | 274 | ## IdentityRequest 275 | 276 | ```js 277 | var request = new MParticle.IdentityRequest() 278 | ``` 279 | 280 | **Setting** user identities: 281 | 282 | ```js 283 | var request = new MParticle.IdentityRequest(); 284 | request.setUserIdentity('example@example.com', MParticle.UserIdentityType.Email); 285 | ``` 286 | 287 | ## Identity 288 | 289 | ```js 290 | MParticle.Identity.getCurrentUser((currentUser) => { 291 | console.debug(currentUser.userID); 292 | }); 293 | ``` 294 | 295 | ```js 296 | var request = new MParticle.IdentityRequest(); 297 | 298 | MParticle.Identity.identify(request, (error, userId) => { 299 | if (error) { 300 | console.debug(error); //error is an MParticleError 301 | } else { 302 | console.debug(userId); 303 | } 304 | }); 305 | ``` 306 | 307 | ```js 308 | var request = new MParticle.IdentityRequest(); 309 | request.email = 'test email'; 310 | 311 | MParticle.Identity.login(request, (error, userId) => { 312 | if (error) { 313 | console.debug(error); //error is an MParticleError 314 | } else { 315 | console.debug(userId); 316 | } 317 | }); 318 | ``` 319 | 320 | ```js 321 | var request = new MParticle.IdentityRequest(); 322 | 323 | MParticle.Identity.logout(request, (error, userId) => { 324 | if (error) { 325 | console.debug(error); 326 | } else { 327 | console.debug(userId); 328 | } 329 | }); 330 | ``` 331 | 332 | ```js 333 | var request = new MParticle.IdentityRequest(); 334 | request.email = 'test email 2'; 335 | 336 | MParticle.Identity.modify(request, (error, userId) => { 337 | if (error) { 338 | console.debug(error); //error is an MParticleError 339 | } else { 340 | console.debug(userId); 341 | } 342 | }); 343 | ``` 344 | 345 | ## Attribution 346 | ``` 347 | var attributions = MParticle.getAttributions(); 348 | ``` 349 | 350 | In order to listen for Attributions asynchronously, you need to set the proper field in `MParticleOptions` as shown in the [Android](#Android) or the [iOS](#iOS) SDK start examples. 351 | 352 | ## Kits 353 | Check if a kit is active 354 | 355 | ``` 356 | var isKitActive = MParticle.isKitActive(kitId); 357 | ``` 358 | 359 | Check and set the SDK's opt out status 360 | 361 | ``` 362 | var isOptedOut = MParticle.getOptOut(); 363 | MParticle.setOptOut(!isOptedOut); 364 | ``` 365 | 366 | ## Push Registration 367 | 368 | The method `MParticle.logPushRegistration()` accepts 2 parameters. For Android, provide both the `pushToken` and `senderId`. For iOS, provide the push token in the first parameter, and simply pass `null` for the second parameter. 369 | 370 | ### Android 371 | 372 | ``` 373 | MParticle.logPushRegistration(pushToken, senderId); 374 | ``` 375 | 376 | ### iOS 377 | 378 | ``` 379 | MParticle.logPushRegistration(pushToken, null); 380 | ``` 381 | 382 | ## GDPR Consent 383 | Add a GDPRConsent 384 | 385 | ``` 386 | var gdprConsent = GDPRConsent() 387 | .setConsented(true) 388 | .setDocument("the document") 389 | .setTimestamp(new Date().getTime()) // optional, native SDK will automatically set current timestamp if omitted 390 | .setLocation("the location") 391 | .setHardwareId("the hardwareId"); 392 | 393 | MParticle.addGDPRConsentState(gdprConsent, "the purpose"); 394 | ``` 395 | 396 | Remove a GDPRConsent 397 | ``` 398 | MParticle.removeGDPRConsentStateWithPurpose("the purpose"); 399 | ``` 400 | 401 | ## CCPA Consent 402 | Add a CCPAConsent 403 | 404 | ``` 405 | var ccpaConsent = CCPAConsent() 406 | .setConsented(true) 407 | .setDocument("the document") 408 | .setTimestamp(new Date().getTime()) // optional, native SDK will automatically set current timestamp if omitted 409 | .setLocation("the location") 410 | .setHardwareId("the hardwareId"); 411 | 412 | MParticle.addCCPAConsentState(ccpaConsent); 413 | ``` 414 | 415 | Remove CCPAConsent 416 | ``` 417 | MParticle.removeCCPAConsentState(); 418 | ``` 419 | 420 | 421 | # License 422 | 423 | Apache 2.0 424 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | mavenCentral() 4 | google() 5 | } 6 | dependencies { 7 | classpath 'com.android.tools.build:gradle:7.4.2' 8 | } 9 | } 10 | 11 | plugins { 12 | id "org.sonarqube" version "4.4.1.3373" 13 | id "org.jlleitschuh.gradle.ktlint" version "11.6.1" 14 | } 15 | 16 | sonarqube { 17 | properties { 18 | property "sonar.projectKey", "react-native-mparticle" 19 | property "sonar.organization", "mparticle" 20 | property "sonar.host.url", "https://sonarcloud.io" 21 | } 22 | } 23 | 24 | apply plugin: 'org.jlleitschuh.gradle.ktlint' 25 | apply plugin: 'com.android.library' 26 | 27 | android { 28 | compileSdkVersion 33 29 | 30 | defaultConfig { 31 | minSdkVersion 21 32 | targetSdkVersion 33 33 | versionCode 2 34 | versionName "2.0.0" 35 | } 36 | buildTypes { 37 | release { 38 | minifyEnabled false 39 | } 40 | } 41 | adbOptions { 42 | timeOutInMs 10 * 60 * 1000 43 | installOptions "-d","-t" 44 | } 45 | } 46 | 47 | repositories { 48 | maven { 49 | //update periodically - current version: 0.70.5 50 | url "$rootDir/react-native-android" 51 | } 52 | mavenCentral() 53 | google() 54 | 55 | } 56 | 57 | dependencies { 58 | compileOnly 'com.facebook.react:react-native:0.20.1' 59 | 60 | // 61 | // In your app, you should include mParticle core like this: 62 | // 63 | // compile 'com.mparticle:android-core:REPLACEME' 64 | // 65 | // (See https://github.com/mparticle/mparticle-android-sdk for the latest version) 66 | // 67 | compileOnly 'com.mparticle:android-core:[5.9.3, )' 68 | 69 | // 70 | // And, if you want to include kits, you can do so as follows: 71 | // 72 | // compile 'com.mparticle:android-example-kit:REPLACEME' 73 | // 74 | 75 | testImplementation 'org.mockito:mockito-core:5.8.0' 76 | androidTestImplementation 'org.mockito:mockito-android:5.8.0' 77 | testImplementation 'androidx.annotation:annotation:1.7.1' 78 | 79 | testImplementation 'junit:junit:4.13.2' 80 | testImplementation files('libs/java-json.jar') 81 | 82 | testImplementation 'com.mparticle:android-core:5.55.0' 83 | testImplementation 'com.facebook.react:react-native:0.20.1' 84 | } 85 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | # AndroidX package structure to make it clearer which packages are bundled with the 21 | # Android operating system, and which are packaged with your app's APK 22 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 23 | android.useAndroidX=true 24 | 25 | # Automatically convert third-party libraries to use AndroidX 26 | android.enableJetifier=true 27 | 28 | # Version of flipper SDK to use with React Native 29 | FLIPPER_VERSION=0.125.0 30 | 31 | # Use this property to specify which architecture you want to build. 32 | # You can also override it from the CLI using 33 | # ./gradlew -PreactNativeArchitectures=x86_64 34 | reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64 35 | 36 | # Use this property to enable support to the new architecture. 37 | # This will allow you to use TurboModules and the Fabric render in 38 | # your application. You should enable this flag either if you want 39 | # to write custom TurboModules/Fabric components OR use libraries that 40 | # are providing them. 41 | newArchEnabled=false 42 | 43 | # The hosted JavaScript engine 44 | # Supported values: expo.jsEngine = "hermes" | "jsc" 45 | expo.jsEngine=jsc 46 | 47 | # Enable GIF support in React Native images (~200 B increase) 48 | expo.gif.enabled=true 49 | # Enable webp support in React Native images (~85 KB increase) 50 | expo.webp.enabled=true 51 | # Enable animated webp support (~3.4 MB increase) 52 | # Disabled by default because iOS doesn't support animated webp 53 | expo.webp.animated=false 54 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 03 15:57:13 EDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip 7 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /android/libs/java-json.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/java-json.jar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 7b864274b543d21ee7d7c9c8e7f7b043 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 75340c383a5d55a37d68181f12b1d8d939a3f065 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 1fe6791aeefb0391d319d763c655a6f8232676141b886d0a467b8834a0b86497 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | b6d659b87a103dd21026d8715420d047b70e76219d39121795598811cff2c7bb6cf3a860d8836fe6eeb753f785d7c2f7b961ea48c5cba27626a6e1cb5b07ee62 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.md5: -------------------------------------------------------------------------------- 1 | 8f67048d84e52b2c37b14459567a5a9d -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha1: -------------------------------------------------------------------------------- 1 | f246204e16175a16e94ddab8556b5980c6241d14 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha256: -------------------------------------------------------------------------------- 1 | 98edd89a8c6b428921a71c83353b7c2ead7561ef78390d3d2f8bdec7ea0bccba -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-debug.aar.sha512: -------------------------------------------------------------------------------- 1 | ccbb56a7ba17357aa68c9ba685f118acae462481c186ba2e18a5dff3a779fb6cf1b6557965777282625b1fea8a82336ee3d6166d226ac494413770ade3369402 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.md5: -------------------------------------------------------------------------------- 1 | c8db891c3be1b407d7079c02c303243b -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 34cf662170d553da87ddd8ef2213f13212955d1d -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | e622d9a7db5ba1a2161785ab8745dda58d1012aad04f7f9489fce207cf567f8a -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | 205a0fd395d6d02c27c4611ae1ceca7ccb4f3554f17f44d338f9ffef2e3521e933616e74ac1b17bb7d300891ede5ecf58e966a11becda27f6760f862f2316783 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.md5: -------------------------------------------------------------------------------- 1 | 4eea565acfa26284caefb83ea547a27d -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha1: -------------------------------------------------------------------------------- 1 | 6d67ef0ee827fb500c5dae6e8de8497b7513b51f -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha256: -------------------------------------------------------------------------------- 1 | 3cf7d55a8e2a610cb293d91acc90881114df0150aea5bb19b2df78158c331134 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5-release.aar.sha512: -------------------------------------------------------------------------------- 1 | f114d26c0c757a2a333423738861dfcd225a790ba97a3a140e21cd131e9cf1c8cdc9e78372c735b6dc8f8ca004cf38e7b75b3c07afef5230fba7b57e71d332b3 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module: -------------------------------------------------------------------------------- 1 | { 2 | "formatVersion": "1.1", 3 | "component": { 4 | "group": "com.facebook.react", 5 | "module": "hermes-engine", 6 | "version": "0.70.5", 7 | "attributes": { 8 | "org.gradle.status": "release" 9 | } 10 | }, 11 | "createdBy": { 12 | "gradle": { 13 | "version": "7.5.1" 14 | } 15 | }, 16 | "variants": [ 17 | { 18 | "name": "debugVariantDefaultApiPublication", 19 | "attributes": { 20 | "com.android.build.api.attributes.BuildTypeAttr": "debug", 21 | "org.gradle.category": "library", 22 | "org.gradle.dependency.bundling": "external", 23 | "org.gradle.libraryelements": "aar", 24 | "org.gradle.usage": "java-api" 25 | }, 26 | "files": [ 27 | { 28 | "name": "hermes-engine-0.70.5-debug.aar", 29 | "url": "hermes-engine-0.70.5-debug.aar", 30 | "size": 4033701, 31 | "sha512": "ccbb56a7ba17357aa68c9ba685f118acae462481c186ba2e18a5dff3a779fb6cf1b6557965777282625b1fea8a82336ee3d6166d226ac494413770ade3369402", 32 | "sha256": "98edd89a8c6b428921a71c83353b7c2ead7561ef78390d3d2f8bdec7ea0bccba", 33 | "sha1": "f246204e16175a16e94ddab8556b5980c6241d14", 34 | "md5": "8f67048d84e52b2c37b14459567a5a9d" 35 | } 36 | ] 37 | }, 38 | { 39 | "name": "debugVariantDefaultRuntimePublication", 40 | "attributes": { 41 | "com.android.build.api.attributes.BuildTypeAttr": "debug", 42 | "org.gradle.category": "library", 43 | "org.gradle.dependency.bundling": "external", 44 | "org.gradle.libraryelements": "aar", 45 | "org.gradle.usage": "java-runtime" 46 | }, 47 | "dependencies": [ 48 | { 49 | "group": "com.facebook.fbjni", 50 | "module": "fbjni", 51 | "version": { 52 | "requires": "0.2.2" 53 | } 54 | }, 55 | { 56 | "group": "com.facebook.soloader", 57 | "module": "soloader", 58 | "version": { 59 | "requires": "0.10.3" 60 | } 61 | }, 62 | { 63 | "group": "com.facebook.yoga", 64 | "module": "proguard-annotations", 65 | "version": { 66 | "requires": "1.19.0" 67 | } 68 | }, 69 | { 70 | "group": "androidx.annotation", 71 | "module": "annotation", 72 | "version": { 73 | "requires": "1.3.0" 74 | } 75 | } 76 | ], 77 | "files": [ 78 | { 79 | "name": "hermes-engine-0.70.5-debug.aar", 80 | "url": "hermes-engine-0.70.5-debug.aar", 81 | "size": 4033701, 82 | "sha512": "ccbb56a7ba17357aa68c9ba685f118acae462481c186ba2e18a5dff3a779fb6cf1b6557965777282625b1fea8a82336ee3d6166d226ac494413770ade3369402", 83 | "sha256": "98edd89a8c6b428921a71c83353b7c2ead7561ef78390d3d2f8bdec7ea0bccba", 84 | "sha1": "f246204e16175a16e94ddab8556b5980c6241d14", 85 | "md5": "8f67048d84e52b2c37b14459567a5a9d" 86 | } 87 | ] 88 | }, 89 | { 90 | "name": "debugVariantDefaultSourcePublication", 91 | "attributes": { 92 | "com.android.build.api.attributes.BuildTypeAttr": "debug", 93 | "org.gradle.category": "documentation", 94 | "org.gradle.dependency.bundling": "external", 95 | "org.gradle.docstype": "sources", 96 | "org.gradle.usage": "java-runtime" 97 | }, 98 | "files": [ 99 | { 100 | "name": "hermes-engine-0.70.5-debug-sources.jar", 101 | "url": "hermes-engine-0.70.5-debug-sources.jar", 102 | "size": 62707, 103 | "sha512": "b6d659b87a103dd21026d8715420d047b70e76219d39121795598811cff2c7bb6cf3a860d8836fe6eeb753f785d7c2f7b961ea48c5cba27626a6e1cb5b07ee62", 104 | "sha256": "1fe6791aeefb0391d319d763c655a6f8232676141b886d0a467b8834a0b86497", 105 | "sha1": "75340c383a5d55a37d68181f12b1d8d939a3f065", 106 | "md5": "7b864274b543d21ee7d7c9c8e7f7b043" 107 | } 108 | ] 109 | }, 110 | { 111 | "name": "releaseVariantDefaultApiPublication", 112 | "attributes": { 113 | "com.android.build.api.attributes.BuildTypeAttr": "release", 114 | "org.gradle.category": "library", 115 | "org.gradle.dependency.bundling": "external", 116 | "org.gradle.libraryelements": "aar", 117 | "org.gradle.usage": "java-api" 118 | }, 119 | "files": [ 120 | { 121 | "name": "hermes-engine-0.70.5-release.aar", 122 | "url": "hermes-engine-0.70.5-release.aar", 123 | "size": 3458378, 124 | "sha512": "f114d26c0c757a2a333423738861dfcd225a790ba97a3a140e21cd131e9cf1c8cdc9e78372c735b6dc8f8ca004cf38e7b75b3c07afef5230fba7b57e71d332b3", 125 | "sha256": "3cf7d55a8e2a610cb293d91acc90881114df0150aea5bb19b2df78158c331134", 126 | "sha1": "6d67ef0ee827fb500c5dae6e8de8497b7513b51f", 127 | "md5": "4eea565acfa26284caefb83ea547a27d" 128 | } 129 | ] 130 | }, 131 | { 132 | "name": "releaseVariantDefaultRuntimePublication", 133 | "attributes": { 134 | "com.android.build.api.attributes.BuildTypeAttr": "release", 135 | "org.gradle.category": "library", 136 | "org.gradle.dependency.bundling": "external", 137 | "org.gradle.libraryelements": "aar", 138 | "org.gradle.usage": "java-runtime" 139 | }, 140 | "dependencies": [ 141 | { 142 | "group": "com.facebook.fbjni", 143 | "module": "fbjni", 144 | "version": { 145 | "requires": "0.2.2" 146 | } 147 | }, 148 | { 149 | "group": "com.facebook.soloader", 150 | "module": "soloader", 151 | "version": { 152 | "requires": "0.10.3" 153 | } 154 | }, 155 | { 156 | "group": "com.facebook.yoga", 157 | "module": "proguard-annotations", 158 | "version": { 159 | "requires": "1.19.0" 160 | } 161 | }, 162 | { 163 | "group": "androidx.annotation", 164 | "module": "annotation", 165 | "version": { 166 | "requires": "1.3.0" 167 | } 168 | } 169 | ], 170 | "files": [ 171 | { 172 | "name": "hermes-engine-0.70.5-release.aar", 173 | "url": "hermes-engine-0.70.5-release.aar", 174 | "size": 3458378, 175 | "sha512": "f114d26c0c757a2a333423738861dfcd225a790ba97a3a140e21cd131e9cf1c8cdc9e78372c735b6dc8f8ca004cf38e7b75b3c07afef5230fba7b57e71d332b3", 176 | "sha256": "3cf7d55a8e2a610cb293d91acc90881114df0150aea5bb19b2df78158c331134", 177 | "sha1": "6d67ef0ee827fb500c5dae6e8de8497b7513b51f", 178 | "md5": "4eea565acfa26284caefb83ea547a27d" 179 | } 180 | ] 181 | }, 182 | { 183 | "name": "releaseVariantDefaultSourcePublication", 184 | "attributes": { 185 | "com.android.build.api.attributes.BuildTypeAttr": "release", 186 | "org.gradle.category": "documentation", 187 | "org.gradle.dependency.bundling": "external", 188 | "org.gradle.docstype": "sources", 189 | "org.gradle.usage": "java-runtime" 190 | }, 191 | "files": [ 192 | { 193 | "name": "hermes-engine-0.70.5-release-sources.jar", 194 | "url": "hermes-engine-0.70.5-release-sources.jar", 195 | "size": 62694, 196 | "sha512": "205a0fd395d6d02c27c4611ae1ceca7ccb4f3554f17f44d338f9ffef2e3521e933616e74ac1b17bb7d300891ede5ecf58e966a11becda27f6760f862f2316783", 197 | "sha256": "e622d9a7db5ba1a2161785ab8745dda58d1012aad04f7f9489fce207cf567f8a", 198 | "sha1": "34cf662170d553da87ddd8ef2213f13212955d1d", 199 | "md5": "c8db891c3be1b407d7079c02c303243b" 200 | } 201 | ] 202 | } 203 | ] 204 | } 205 | -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.md5: -------------------------------------------------------------------------------- 1 | 4ff83d5a836dec90593a9de87e02b66f -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha1: -------------------------------------------------------------------------------- 1 | b5236e1fc7e7d9e5ddf5219e8a6bb08a0237d9da -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha256: -------------------------------------------------------------------------------- 1 | 4e27316d4f981093d6f73885dcdc5e64dc23a18ad892d68cf7b7fc22cdfc598d -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.module.sha512: -------------------------------------------------------------------------------- 1 | 8b5d314a29a4a5d578a43a7a5b8243736247084af2e36eb4830050fd29103ed930a3a6f8d1dfa68f3be226891f14d2e56e8122a4fef9c28464cbbcd1e52a6204 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 4.0.0 10 | com.facebook.react 11 | hermes-engine 12 | 0.70.5 13 | pom 14 | 15 | 16 | com.facebook.fbjni 17 | fbjni 18 | 0.2.2 19 | compile 20 | true 21 | 22 | 23 | com.facebook.soloader 24 | soloader 25 | 0.10.3 26 | compile 27 | true 28 | 29 | 30 | com.facebook.yoga 31 | proguard-annotations 32 | 1.19.0 33 | compile 34 | true 35 | 36 | 37 | androidx.annotation 38 | annotation 39 | 1.3.0 40 | compile 41 | true 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.md5: -------------------------------------------------------------------------------- 1 | 9182f5e678c542dba36f6bc0168d49a9 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha1: -------------------------------------------------------------------------------- 1 | 6a6ff8f12beb194ef2fb27de7c4594bfed44088b -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha256: -------------------------------------------------------------------------------- 1 | 7ddd030c89cc685a0061c3ec5340140161fd1fab1df7859699b23ad64a4fbd6f -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/0.70.5/hermes-engine-0.70.5.pom.sha512: -------------------------------------------------------------------------------- 1 | 0bf0740d048ee97daaa8771e6a8ca340a59b68e2d4c0f5e9feeb090b87a059c2ecfc993592d26c409a2fb5ea28c839846ea5567c7abde8b5e285e3c742ee1987 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.facebook.react 4 | hermes-engine 5 | 6 | 0.70.5 7 | 0.70.5 8 | 9 | 0.70.5 10 | 11 | 20221106211107 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | d696a517f905ef03db049e3498bed1d8 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 62474f1140166dd5b0cdb3a0433691fd413f6cc7 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha256: -------------------------------------------------------------------------------- 1 | 3e3e01b6b286761657f01a1a0b92386e2532badb0ceca6d54a29dfc032a00bfd -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/hermes-engine/maven-metadata.xml.sha512: -------------------------------------------------------------------------------- 1 | fbaf046e2812062b9c153695d7fd934b64959de73b084611b938c80e77e9b5df91aab55de42920103f564ba9b66423ac5ab74516f7a69355a7b4a6cbd360fc53 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 74d86431fd9bc24b8769b1dcff698814 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | c64ee18787feb457f9a4f3ffc888b0f312afe16c -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 947f3bb8fe00e0d72d10eb3fe1bd00c181ee366fdf28fcd6e35794575faa1fb1 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | 1cabc724dd44d1266c637d9db0a41e1d0d03d7b333770b173c7724bd56a318e43947bf1bd5f83734c4afdf5f695749bbb8e77c4df2268974cc23d8a7b399d179 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.md5: -------------------------------------------------------------------------------- 1 | 8b6106b2cab596fdcdf1de5b495419dd -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha1: -------------------------------------------------------------------------------- 1 | 650825ef196f2045dfe93cf7eff46ed6a9cb851e -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha256: -------------------------------------------------------------------------------- 1 | e9f11e2e7c0e95bdc8443566d9ba6cec9b9613ee09426832f38050edcf65b828 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-debug.aar.sha512: -------------------------------------------------------------------------------- 1 | a75e86a070303e119cc4875d194740bc99a70dc4c538e994fe68fd7320a47d91c1c7094bccb923e36c51231e8ce6b8d0b2665a3e9aad246a63ca073decce4a68 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.md5: -------------------------------------------------------------------------------- 1 | b4c3cdc59566abc5ea37bd6311ce818c -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 3fe922c099cf22070fb5131914012269c68337e6 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 19a94e1af4190b32e8ed0a463a7deeccfb4785a03cde91b88efafee0931f9c80 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | 253ca7b3b2b6953681ce77d43c2c75bbb6f4f6699e5fba3f2fdb657fd6e12ff578bc7ba8fa27945a017354daf2ef28f6bfaf22e87d68d34625b05c57d1999368 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.md5: -------------------------------------------------------------------------------- 1 | 50b3e7bf5bfc3acab1e9f498f988d3f0 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha1: -------------------------------------------------------------------------------- 1 | 00c9f58ad16f8e6f11bc75ad826bf4e805f6ac69 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha256: -------------------------------------------------------------------------------- 1 | 591fab93fa3ff09b66748007dd4bcd4ae5f9da14bbf5ab5d6109cb1a29f9c918 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5-release.aar.sha512: -------------------------------------------------------------------------------- 1 | 28f0e88dcd49bd32c355f11822fe299b81d88c69f9eb2f650ee933c09aa4a88364024b44e0237821a429dc1d7af4db46d4205a86755343bef91aa163b3e5c385 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.md5: -------------------------------------------------------------------------------- 1 | c0dfc07b0961a25ba9ceb2b494f46bb6 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha1: -------------------------------------------------------------------------------- 1 | 80f317430557db0de3088903d62818e3e3f9b90c -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha256: -------------------------------------------------------------------------------- 1 | a99732a86b4bc51cd3e2c1d87a16bec11f45ee151c264b2873b803a571caef1e -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.module.sha512: -------------------------------------------------------------------------------- 1 | cd3ab73cec4f59e339a1f3f08a35a89e7a28bfee744e53b8eefbef873dbf96a075d46bb0de4142a0ffddfdaf4d1f139afd5108d39521fe28cd95e21068bbaf10 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 4.0.0 10 | com.facebook.react 11 | react-native 12 | 0.70.5 13 | pom 14 | ReactNative 15 | A framework for building native apps with React 16 | https://github.com/facebook/react-native 17 | 18 | 19 | MIT License 20 | https://github.com/facebook/react-native/blob/HEAD/LICENSE 21 | repo 22 | 23 | 24 | 25 | 26 | facebook 27 | Facebook 28 | 29 | 30 | 31 | scm:git:https://github.com/facebook/react-native.git 32 | scm:git:git@github.com:facebook/react-native.git 33 | https://github.com/facebook/react-native.git 34 | 35 | 36 | 37 | androidx.appcompat 38 | appcompat-resources 39 | 1.4.1 40 | compile 41 | true 42 | 43 | 44 | androidx.appcompat 45 | appcompat 46 | 1.4.1 47 | compile 48 | true 49 | 50 | 51 | androidx.autofill 52 | autofill 53 | 1.1.0 54 | compile 55 | true 56 | 57 | 58 | androidx.swiperefreshlayout 59 | swiperefreshlayout 60 | 1.0.0 61 | compile 62 | true 63 | 64 | 65 | com.facebook.fbjni 66 | fbjni-java-only 67 | 0.2.2 68 | compile 69 | true 70 | 71 | 72 | com.facebook.fresco 73 | fresco 74 | 2.5.0 75 | compile 76 | true 77 | 78 | 79 | com.facebook.fresco 80 | imagepipeline-okhttp3 81 | 2.5.0 82 | compile 83 | true 84 | 85 | 86 | com.facebook.fresco 87 | ui-common 88 | 2.5.0 89 | compile 90 | true 91 | 92 | 93 | com.facebook.infer.annotation 94 | infer-annotation 95 | 0.18.0 96 | compile 97 | true 98 | 99 | 100 | com.facebook.soloader 101 | soloader 102 | 0.10.4 103 | compile 104 | true 105 | 106 | 107 | com.facebook.yoga 108 | proguard-annotations 109 | 1.19.0 110 | compile 111 | true 112 | 113 | 114 | com.google.code.findbugs 115 | jsr305 116 | 3.0.2 117 | compile 118 | true 119 | 120 | 121 | com.squareup.okhttp3 122 | okhttp-urlconnection 123 | 4.9.2 124 | compile 125 | true 126 | 127 | 128 | com.squareup.okhttp3 129 | okhttp 130 | 4.9.2 131 | compile 132 | true 133 | 134 | 135 | com.squareup.okio 136 | okio 137 | 2.9.0 138 | compile 139 | true 140 | 141 | 142 | javax.inject 143 | javax.inject 144 | 1 145 | compile 146 | true 147 | 148 | 149 | org.jetbrains.kotlin 150 | kotlin-stdlib-jdk8 151 | 1.6.10 152 | compile 153 | true 154 | 155 | 156 | 157 | -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.md5: -------------------------------------------------------------------------------- 1 | 314aca710fcde34076ae5994d7f9b97e -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha1: -------------------------------------------------------------------------------- 1 | 6a163a1b47caaf40d6e1073ea5c7e12985e5039a -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha256: -------------------------------------------------------------------------------- 1 | 801b36c31a6e9a37096d594bd2ab459c2506d6a25c8417e912a29af7b7d6507e -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/0.70.5/react-native-0.70.5.pom.sha512: -------------------------------------------------------------------------------- 1 | 2b7a31bf8d9b01bc8185de8a018e469e5eea59c311e4a1cd531004b016d2218ff0c683f1c4ad904d28248fa3b58d0c54384f9b19dfedb68e82ce3d226fa10b70 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.facebook.react 4 | react-native 5 | 6 | 0.70.5 7 | 0.70.5 8 | 9 | 0.70.5 10 | 11 | 20221106211052 12 | 13 | 14 | -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 2fd397e2d08ed150f66851e1e34dd67e -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | d4efb834e0463c9149216b52f559ffbb81710ece -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha256: -------------------------------------------------------------------------------- 1 | e3a583f456c35a1bd17a05d4627fec2fa5c7d80ea095f5d6d24c13b98b341453 -------------------------------------------------------------------------------- /android/libs/react-native-android/com/facebook/react/react-native/maven-metadata.xml.sha512: -------------------------------------------------------------------------------- 1 | 4b9cfbc4aed81b138b7942f7488f450c4475d60f0d352f9e67b54e38879873e7f78ee744835d46be66ba32925244d4916add618897b45180381fb95bb8082cd6 -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/java/com/mparticle/react/MParticlePackage.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react; 2 | 3 | import com.facebook.react.ReactPackage; 4 | import com.facebook.react.bridge.JavaScriptModule; 5 | import com.facebook.react.bridge.NativeModule; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.uimanager.ViewManager; 8 | 9 | import java.util.ArrayList; 10 | import java.util.Collections; 11 | import java.util.List; 12 | 13 | public class MParticlePackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules( 16 | ReactApplicationContext reactContext) { 17 | List modules = new ArrayList<>(); 18 | 19 | modules.add(new MParticleModule(reactContext)); 20 | 21 | return modules; 22 | } 23 | 24 | // Deprecated RN 0.47 25 | public List> createJSModules() { 26 | return Collections.emptyList(); 27 | } 28 | 29 | @Override 30 | public List createViewManagers( 31 | ReactApplicationContext reactContext) { 32 | return Collections.emptyList(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /android/src/main/java/com/mparticle/react/Utils.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react; 2 | 3 | import com.facebook.react.bridge.ReadableMap; 4 | 5 | public class Utils { 6 | 7 | public static long parseMpid(String longString) { 8 | try { 9 | return Long.parseLong(longString); 10 | } catch (NumberFormatException ex) { 11 | return 0L; 12 | } 13 | } 14 | 15 | public static Long getLong(ReadableMap readableMap, String key, boolean allowLossy) { 16 | switch (readableMap.getType(key)) { 17 | case String: 18 | return Long.valueOf(readableMap.getString(key)); 19 | case Number: 20 | if (allowLossy) { 21 | try { 22 | return Integer.valueOf(readableMap.getInt(key)).longValue(); 23 | } catch (Exception ex) { 24 | return Double.valueOf(readableMap.getDouble(key)).longValue(); 25 | } 26 | } 27 | break; 28 | case Null: 29 | return null; 30 | } 31 | throw new NumberFormatException("Expecting " + (allowLossy ? " Number or " : "") + "String representation of a Long. Received " + readableMap.getType(key)); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/IdentityApiTest.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.bridge.Callback; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.ReadableMap; 8 | import com.mparticle.MParticle; 9 | import com.mparticle.identity.AliasRequest; 10 | import com.mparticle.identity.IdentityApi; 11 | import com.mparticle.identity.MParticleUser; 12 | import com.mparticle.react.testutils.MockMParticleUser; 13 | import com.mparticle.react.testutils.MockMap; 14 | import com.mparticle.react.testutils.Mutable; 15 | 16 | import org.json.JSONException; 17 | import org.json.JSONObject; 18 | import org.junit.Before; 19 | import org.junit.Test; 20 | import org.junit.runner.RunWith; 21 | import org.mockito.ArgumentCaptor; 22 | import org.mockito.Mockito; 23 | import org.mockito.MockitoAnnotations; 24 | import org.mockito.junit.MockitoJUnitRunner; 25 | 26 | import java.util.Random; 27 | 28 | import static junit.framework.TestCase.assertEquals; 29 | import static org.junit.Assert.assertNull; 30 | import static org.junit.Assert.assertTrue; 31 | 32 | @RunWith(MockitoJUnitRunner.class) 33 | public class IdentityApiTest { 34 | MParticleModule identityApi; 35 | Random random = new Random(); 36 | 37 | @Before 38 | public void before() { 39 | MockitoAnnotations.openMocks(this); 40 | MParticle.setInstance(Mockito.mock(MParticle.class)); 41 | Mockito.when(MParticle.getInstance().Identity()).thenReturn(Mockito.mock(IdentityApi.class)); 42 | Mockito.lenient().when(MParticle.getInstance().Identity().getUser(0L)).thenReturn(null); 43 | identityApi = new MParticleModule(Mockito.mock(ReactApplicationContext.class)); 44 | } 45 | 46 | 47 | @Test 48 | public void testGetCurrentUser() { 49 | final Mutable callbackCalled = new Mutable<>(false); 50 | final Long mockId = random.nextLong(); 51 | 52 | MParticleUser mockUser = new MockMParticleUser() { 53 | @NonNull 54 | @Override 55 | public long getId() { 56 | return mockId; 57 | } 58 | }; 59 | Mockito.when(MParticle.getInstance().Identity().getCurrentUser()).thenReturn(mockUser); 60 | identityApi.getCurrentUserWithCompletion(new Callback() { 61 | @Override 62 | public void invoke(Object... args) { 63 | assertNull(args[0]); 64 | assertEquals(mockId.toString(), args[1]); 65 | callbackCalled.value = true; 66 | } 67 | }); 68 | 69 | assertTrue(callbackCalled.value); 70 | callbackCalled.value = false; 71 | 72 | Mockito.when(MParticle.getInstance().Identity().getCurrentUser()).thenReturn(null); 73 | identityApi.getCurrentUserWithCompletion(new Callback() { 74 | @Override 75 | public void invoke(Object... args) { 76 | assertNull(args[0]); 77 | assertNull(args[1]); 78 | callbackCalled.value = true; 79 | } 80 | }); 81 | assertTrue(callbackCalled.value); 82 | } 83 | 84 | 85 | @Test 86 | public void testAliasRequest() throws JSONException { 87 | ArgumentCaptor aliasCaptor = ArgumentCaptor.forClass(AliasRequest.class); 88 | final Mutable callbackResult = new Mutable<>(); 89 | 90 | Mockito.when(MParticle.getInstance().Identity().aliasUsers(Mockito.any(AliasRequest.class))).thenReturn(true); 91 | 92 | JSONObject aliasJson = new JSONObject() 93 | .put("sourceMpid", "1") 94 | .put("destinationMpid", "2") 95 | .put("startTime", "3") 96 | .put("endTime", "4"); 97 | ReadableMap map = new MockMap(aliasJson); 98 | 99 | identityApi.aliasUsers(map, new Callback() { 100 | @Override 101 | public void invoke(Object... args) { 102 | callbackResult.value = args; 103 | } 104 | }); 105 | 106 | Mockito.verify(MParticle.getInstance().Identity()).aliasUsers(aliasCaptor.capture()); 107 | assertEquals(1, callbackResult.value.length); 108 | assertEquals(true, callbackResult.value[0]); 109 | 110 | assertEquals(1, aliasCaptor.getValue().getSourceMpid()); 111 | assertEquals(2, aliasCaptor.getValue().getDestinationMpid()); 112 | assertEquals(3, aliasCaptor.getValue().getStartTime()); 113 | assertEquals(4, aliasCaptor.getValue().getEndTime()); 114 | 115 | //start time and end time can be longs 116 | aliasJson 117 | .put("startTime", 3) 118 | .put("endTime", 4); 119 | } 120 | 121 | @Test 122 | public void testAliasRequestPartial() throws JSONException { 123 | ArgumentCaptor aliasCaptor = ArgumentCaptor.forClass(AliasRequest.class); 124 | final Mutable callbackResult = new Mutable<>(); 125 | Long startTime = System.currentTimeMillis(); 126 | 127 | MParticleUser sourceUser = Mockito.mock(MParticleUser.class); 128 | Mockito.when(sourceUser.getId()).thenReturn(1L); 129 | Mockito.when(sourceUser.getFirstSeenTime()).thenReturn(startTime - 200); 130 | Mockito.when(sourceUser.getLastSeenTime()).thenReturn(startTime - 100L); 131 | 132 | MParticleUser destinationUser = Mockito.mock(MParticleUser.class); 133 | Mockito.when(destinationUser.getId()).thenReturn(2L); 134 | 135 | Mockito.when(MParticle.getInstance().Identity().getUser(1L)).thenReturn(sourceUser); 136 | Mockito.when(MParticle.getInstance().Identity().getUser(2L)).thenReturn(destinationUser); 137 | 138 | Mockito.when(MParticle.getInstance().Identity().aliasUsers(Mockito.any(AliasRequest.class))).thenReturn(true); 139 | 140 | JSONObject aliasJson = new JSONObject() 141 | .put("sourceMpid", "1") 142 | .put("destinationMpid", "2"); 143 | ReadableMap map = new MockMap(aliasJson); 144 | 145 | identityApi.aliasUsers(map, new Callback() { 146 | @Override 147 | public void invoke(Object... args) { 148 | callbackResult.value = args; 149 | } 150 | }); 151 | 152 | Mockito.verify(MParticle.getInstance().Identity()).aliasUsers(aliasCaptor.capture()); 153 | assertEquals(1, callbackResult.value.length); 154 | assertEquals(true, callbackResult.value[0]); 155 | 156 | assertEquals(1, aliasCaptor.getValue().getSourceMpid()); 157 | assertEquals(2, aliasCaptor.getValue().getDestinationMpid()); 158 | assertEquals(startTime - 200, aliasCaptor.getValue().getStartTime()); 159 | assertEquals(startTime - 100, aliasCaptor.getValue().getEndTime()); 160 | } 161 | 162 | @Test 163 | public void testAliasRejectedReactNative() throws JSONException { 164 | final Mutable callbackResult = new Mutable<>(); 165 | Callback callback = new Callback() { 166 | @Override 167 | public void invoke(Object... args) { 168 | callbackResult.value = args; 169 | } 170 | }; 171 | 172 | //MPIDs need to be Strings, this will fail 173 | JSONObject aliasJson = new JSONObject() 174 | .put("sourceMpid", 1) 175 | .put("destinationMpid", "2") 176 | .put("startTime", "3") 177 | .put("endTime", "4"); 178 | 179 | identityApi.aliasUsers(new MockMap(aliasJson), callback); 180 | 181 | Mockito.lenient().when(MParticle.getInstance().Identity().aliasUsers(Mockito.any(AliasRequest.class))).thenThrow(new RuntimeException("aliasUsers() should not be called")); 182 | assertEquals(2, callbackResult.value.length); 183 | assertEquals(false, callbackResult.value[0]); 184 | assertTrue(((String)callbackResult.value[1]).length() > 5); 185 | callbackResult.value = null; 186 | 187 | aliasJson 188 | .put("sourceMpid", "1") 189 | .put("destinationMpid", 2); 190 | 191 | identityApi.aliasUsers(new MockMap(aliasJson), callback); 192 | 193 | Mockito.lenient().when(MParticle.getInstance().Identity().aliasUsers(Mockito.any(AliasRequest.class))).thenThrow(new RuntimeException("aliasUsers() should not be called")); 194 | assertEquals(2, callbackResult.value.length); 195 | assertEquals(false, callbackResult.value[0]); 196 | assertTrue(((String)callbackResult.value[1]).length() > 5); 197 | callbackResult.value = null; 198 | } 199 | 200 | @Test 201 | public void testAliasRejectedNativeSdk() throws JSONException { 202 | ArgumentCaptor aliasCaptor = ArgumentCaptor.forClass(AliasRequest.class); 203 | final Mutable callbackResult = new Mutable<>(); 204 | 205 | Mockito.when(MParticle.getInstance().Identity().aliasUsers(Mockito.any(AliasRequest.class))).thenReturn(false); 206 | 207 | JSONObject aliasJson = new JSONObject() 208 | .put("sourceMpid", "1") 209 | .put("destinationMpid", "2") 210 | .put("startTime", "3") 211 | .put("endTime", "4"); 212 | ReadableMap map = new MockMap(aliasJson); 213 | 214 | identityApi.aliasUsers(map, new Callback() { 215 | @Override 216 | public void invoke(Object... args) { 217 | callbackResult.value = args; 218 | } 219 | }); 220 | 221 | Mockito.verify(MParticle.getInstance().Identity()).aliasUsers(aliasCaptor.capture()); 222 | assertEquals(1, callbackResult.value.length); 223 | assertEquals(false, callbackResult.value[0]); 224 | 225 | assertEquals(1, aliasCaptor.getValue().getSourceMpid()); 226 | assertEquals(2, aliasCaptor.getValue().getDestinationMpid()); 227 | assertEquals(3, aliasCaptor.getValue().getStartTime()); 228 | assertEquals(4, aliasCaptor.getValue().getEndTime()); 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/MParticleUserTest.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.bridge.Callback; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.WritableMap; 8 | import com.mparticle.MParticle; 9 | import com.mparticle.identity.IdentityApi; 10 | import com.mparticle.identity.MParticleUser; 11 | import com.mparticle.react.testutils.MockMParticleUser; 12 | import com.mparticle.react.testutils.MockMap; 13 | import com.mparticle.react.testutils.MockReadableArray; 14 | import com.mparticle.react.testutils.Mutable; 15 | 16 | import org.junit.Before; 17 | import org.junit.Test; 18 | import org.junit.runner.RunWith; 19 | import org.mockito.Mockito; 20 | import org.mockito.MockitoAnnotations; 21 | import org.mockito.junit.MockitoJUnitRunner; 22 | 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | import java.util.Random; 26 | 27 | import static junit.framework.TestCase.assertEquals; 28 | import static org.junit.Assert.assertNotNull; 29 | import static org.junit.Assert.assertNull; 30 | import static org.junit.Assert.assertTrue; 31 | 32 | @RunWith(MockitoJUnitRunner.class) 33 | public class MParticleUserTest { 34 | MParticleModule mParticleUser; 35 | Random random = new Random(); 36 | 37 | @Before 38 | public void before() { 39 | MockitoAnnotations.openMocks(this); 40 | MParticle.setInstance(Mockito.mock(MParticle.class)); 41 | Mockito.when(MParticle.getInstance().Identity()).thenReturn(Mockito.mock(IdentityApi.class)); 42 | Mockito.lenient().when(MParticle.getInstance().Identity().getUser(0L)).thenReturn(null); 43 | mParticleUser = new MParticleModule(Mockito.mock(ReactApplicationContext.class)) { 44 | @Override 45 | public WritableMap getWritableMap() { 46 | return new MockMap(); 47 | } 48 | }; 49 | } 50 | 51 | @Test 52 | public void tesNullMParticleUserSetters() { 53 | Exception exception = null; 54 | try { 55 | mParticleUser.setUserAttribute(null, "key", "values"); 56 | mParticleUser.setUserTag(null, "test"); 57 | mParticleUser.setUserAttributeArray(null, "keuy", new MockReadableArray()); 58 | } catch (Exception e) { 59 | exception = e; 60 | } 61 | assertNull(exception); 62 | } 63 | 64 | @Test 65 | public void testSetUserAttribute() { 66 | String testKey = "test key"; 67 | String testValue = "test value"; 68 | 69 | final Mutable uaKey = new Mutable<>(); 70 | final Mutable uaValue = new Mutable<>(); 71 | MParticleUser mockUser = new MockMParticleUser() { 72 | @Override 73 | public boolean setUserAttribute(@NonNull String s, @NonNull Object o) { 74 | uaKey.value = s; 75 | uaValue.value = o; 76 | return true; 77 | } 78 | }; 79 | Mockito.when(MParticle.getInstance().Identity().getUser(Mockito.anyLong())).thenReturn(mockUser); 80 | 81 | mParticleUser.setUserAttribute("1", testKey, testValue); 82 | 83 | assertEquals(testKey, uaKey.value); 84 | assertEquals(testValue, uaValue.value); 85 | } 86 | 87 | @Test 88 | public void getUserIdentitiesTest() { 89 | final Map identities = new HashMap<>(); 90 | for (MParticle.IdentityType identityType: MParticle.IdentityType.values()) { 91 | identities.put(identityType, random.nextInt() + ""); 92 | } 93 | MParticleUser mockUser = new MockMParticleUser() { 94 | @NonNull 95 | @Override 96 | public Map getUserIdentities() { 97 | return identities; 98 | } 99 | }; 100 | 101 | Mockito.when(MParticle.getInstance().Identity().getUser(Mockito.anyLong())).thenReturn(mockUser); 102 | 103 | final Mutable callbackResult = new Mutable<>(); 104 | mParticleUser.getUserIdentities("1", new Callback() { 105 | @Override 106 | public void invoke(Object... args) { 107 | assertEquals(2, args.length); 108 | assertNull(args[0]); 109 | callbackResult.value = (WritableMap)args[1]; 110 | } 111 | }); 112 | 113 | assertNotNull(callbackResult.value); 114 | for (Map.Entry entry: identities.entrySet()) { 115 | assertEquals(entry.getValue(), callbackResult.value.getString(String.valueOf(entry.getKey().getValue()))); 116 | } 117 | } 118 | 119 | @Test 120 | public void testGetUserIdentitiesNullUser() { 121 | final Mutable callbackInvoked = new Mutable<>(false); 122 | 123 | mParticleUser.getUserIdentities(null, new Callback() { 124 | @Override 125 | public void invoke(Object... args) { 126 | assertEquals(0, args.length); 127 | callbackInvoked.value = true; 128 | } 129 | }); 130 | 131 | assertTrue(callbackInvoked.value); 132 | } 133 | 134 | @Test 135 | public void testSetUserTag() { 136 | final Mutable tag = new Mutable<>(); 137 | String testTag = "testTag"; 138 | 139 | MParticleUser mockUser = new MockMParticleUser() { 140 | @Override 141 | public boolean setUserTag(@NonNull String s) { 142 | tag.value = s; 143 | return true; 144 | } 145 | }; 146 | 147 | Mockito.when(MParticle.getInstance().Identity().getUser(Mockito.anyLong())).thenReturn(mockUser); 148 | 149 | mParticleUser.setUserTag("1", testTag); 150 | 151 | assertEquals(testTag, tag.value); 152 | } 153 | 154 | 155 | 156 | @Test 157 | public void getFirstSeenTime() { 158 | final Mutable callbackInvoked = new Mutable<>(false); 159 | 160 | MParticleUser mockUser = new MockMParticleUser() { 161 | @Override 162 | public long getFirstSeenTime() { 163 | return 2; 164 | } 165 | }; 166 | Mockito.when(MParticle.getInstance().Identity().getUser(Mockito.anyLong())).thenReturn(mockUser); 167 | 168 | mParticleUser.getFirstSeen("1", new Callback() { 169 | @Override 170 | public void invoke(Object... args) { 171 | assertEquals(1, args.length); 172 | assertEquals("2", args[0]); 173 | callbackInvoked.value = true; 174 | } 175 | }); 176 | 177 | assertTrue(callbackInvoked.value); 178 | } 179 | 180 | @Test 181 | public void getFirstSeenTimeNullUser() { 182 | final Mutable callbackInvoked = new Mutable<>(false); 183 | 184 | mParticleUser.getFirstSeen(null, new Callback() { 185 | @Override 186 | public void invoke(Object... args) { 187 | assertEquals(0, args.length); 188 | callbackInvoked.value = true; 189 | } 190 | }); 191 | 192 | assertTrue(callbackInvoked.value); 193 | } 194 | 195 | @Test 196 | public void getLastSeenTime() { 197 | final Mutable callbackInvoked = new Mutable<>(false); 198 | 199 | MParticleUser mockUser = new MockMParticleUser() { 200 | @Override 201 | public long getLastSeenTime() { 202 | return 2; 203 | } 204 | }; 205 | Mockito.when(MParticle.getInstance().Identity().getUser(Mockito.anyLong())).thenReturn(mockUser); 206 | 207 | mParticleUser.getLastSeen("1", new Callback() { 208 | @Override 209 | public void invoke(Object... args) { 210 | assertEquals(1, args.length); 211 | assertEquals("2", args[0]); 212 | callbackInvoked.value = true; 213 | } 214 | }); 215 | 216 | assertTrue(callbackInvoked.value); 217 | } 218 | 219 | @Test 220 | public void getLastSeenTimeNullUser() { 221 | final Mutable callbackInvoked = new Mutable<>(false); 222 | 223 | mParticleUser.getLastSeen(null , new Callback() { 224 | @Override 225 | public void invoke(Object... args) { 226 | assertEquals(0, args.length); 227 | callbackInvoked.value = true; 228 | } 229 | }); 230 | 231 | assertTrue(callbackInvoked.value); 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/testutils/MockMParticleUser.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react.testutils; 2 | 3 | import androidx.annotation.NonNull; 4 | import androidx.annotation.Nullable; 5 | 6 | import com.mparticle.MParticle; 7 | import com.mparticle.UserAttributeListener; 8 | import com.mparticle.UserAttributeListenerType; 9 | import com.mparticle.consent.ConsentState; 10 | import com.mparticle.identity.MParticleUser; 11 | 12 | import java.util.Map; 13 | 14 | public class MockMParticleUser implements MParticleUser { 15 | Long mpid = 0L; 16 | 17 | public MockMParticleUser() {} 18 | 19 | public MockMParticleUser(Long mpid) { 20 | this.mpid = mpid; 21 | } 22 | 23 | @NonNull 24 | @Override 25 | public long getId() { 26 | return mpid; 27 | } 28 | 29 | @NonNull 30 | @Override 31 | public Map getUserAttributes() { 32 | return null; 33 | } 34 | 35 | @Nullable 36 | @Override 37 | public Map getUserAttributes(@Nullable UserAttributeListenerType userAttributeListener) { 38 | return null; 39 | } 40 | 41 | @Override 42 | public boolean setUserAttributes(@NonNull Map map) { 43 | return false; 44 | } 45 | 46 | @NonNull 47 | @Override 48 | public Map getUserIdentities() { 49 | return null; 50 | } 51 | 52 | @Override 53 | public boolean setUserAttribute(@NonNull String s, @NonNull Object o) { 54 | return false; 55 | } 56 | 57 | @Override 58 | public boolean setUserAttributeList(@NonNull String s, @NonNull Object o) { 59 | return false; 60 | } 61 | 62 | @Override 63 | public boolean incrementUserAttribute(@NonNull String s, Number i) { 64 | return false; 65 | } 66 | 67 | @Override 68 | public boolean removeUserAttribute(@NonNull String s) { 69 | return false; 70 | } 71 | 72 | @Override 73 | public boolean setUserTag(@NonNull String s) { 74 | return false; 75 | } 76 | 77 | @NonNull 78 | @Override 79 | public ConsentState getConsentState() { 80 | return null; 81 | } 82 | 83 | @Override 84 | public void setConsentState(@Nullable ConsentState consentState) { 85 | 86 | } 87 | 88 | @Override 89 | public boolean isLoggedIn() { 90 | return false; 91 | } 92 | 93 | @Override 94 | public long getFirstSeenTime() { 95 | return 0; 96 | } 97 | 98 | @Override 99 | public long getLastSeenTime() { 100 | return 0; 101 | } 102 | } 103 | 104 | -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/testutils/MockMap.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react.testutils; 2 | 3 | import com.facebook.react.bridge.ReadableArray; 4 | import com.facebook.react.bridge.ReadableMap; 5 | import com.facebook.react.bridge.ReadableMapKeySetIterator; 6 | import com.facebook.react.bridge.ReadableType; 7 | import com.facebook.react.bridge.WritableArray; 8 | import com.facebook.react.bridge.WritableMap; 9 | 10 | import org.json.JSONException; 11 | import org.json.JSONObject; 12 | 13 | import java.util.ArrayList; 14 | import java.util.Collection; 15 | import java.util.HashMap; 16 | import java.util.Iterator; 17 | import java.util.List; 18 | import java.util.Map; 19 | 20 | public class MockMap implements WritableMap { 21 | private Map map = new HashMap(); 22 | 23 | public MockMap() {} 24 | 25 | public MockMap(JSONObject jsonObject) throws JSONException { 26 | Map map = new HashMap(); 27 | Iterator keys = jsonObject.keys(); 28 | while(keys.hasNext()) { 29 | String key = keys.next(); 30 | map.put(key, jsonObject.get(key)); 31 | } 32 | this.map = map; 33 | } 34 | 35 | public MockMap(Map map) { 36 | this.map = map; 37 | } 38 | 39 | @Override 40 | public boolean hasKey(String name) { 41 | return map.containsKey(name); 42 | } 43 | 44 | @Override 45 | public boolean isNull(String name) { 46 | return map.get(name) == null; 47 | } 48 | 49 | @Override 50 | public boolean getBoolean(String name) { 51 | return (boolean) map.get(name); 52 | } 53 | 54 | @Override 55 | public double getDouble(String name) { 56 | return (double) map.get(name); 57 | } 58 | 59 | @Override 60 | public int getInt(String name) { 61 | return (int) map.get(name); 62 | } 63 | 64 | @Override 65 | public String getString(String name) { 66 | return (String) map.get(name); 67 | } 68 | 69 | @Override 70 | public ReadableArray getArray(String name) { 71 | return null; 72 | } 73 | 74 | @Override 75 | public ReadableMap getMap(String name) { 76 | return new MockMap((Map) map.get(name)); 77 | } 78 | 79 | @Override 80 | public ReadableType getType(String name) { 81 | Object obj = map.get(name); 82 | if (obj instanceof String) { 83 | return ReadableType.String; 84 | } 85 | if (obj instanceof Number) { 86 | return ReadableType.Number; 87 | } 88 | if (obj instanceof Collection) { 89 | return ReadableType.Array; 90 | } 91 | if (obj instanceof Map) { 92 | return ReadableType.Map; 93 | } 94 | if (obj instanceof Boolean) { 95 | return ReadableType.Boolean; 96 | } 97 | if (obj == null) { 98 | return ReadableType.Null; 99 | } 100 | return null; 101 | } 102 | 103 | @Override 104 | public ReadableMapKeySetIterator keySetIterator() { 105 | return new MockReadableMapKeySetIterator(map.keySet()); 106 | } 107 | 108 | @Override 109 | public void putNull(String key) { 110 | map.put(key, null); 111 | } 112 | 113 | @Override 114 | public void putBoolean(String key, boolean value) { 115 | map.put(key, value); 116 | } 117 | 118 | @Override 119 | public void putDouble(String key, double value) { 120 | map.put(key, value); 121 | } 122 | 123 | @Override 124 | public void putInt(String key, int value) { 125 | map.put(key, value); 126 | } 127 | 128 | @Override 129 | public void putString(String key, String value) { 130 | map.put(key, value); 131 | } 132 | 133 | @Override 134 | public void putArray(String key, WritableArray value) { 135 | map.put(key, value); 136 | } 137 | 138 | @Override 139 | public void putMap(String key, WritableMap value) { 140 | map.put(key, value); 141 | } 142 | 143 | @Override 144 | public void merge(ReadableMap source) { 145 | throw new RuntimeException("Not Implemented"); 146 | } 147 | 148 | 149 | class MockReadableMapKeySetIterator implements ReadableMapKeySetIterator { 150 | List keys; 151 | int index = 0; 152 | 153 | MockReadableMapKeySetIterator(Collection keys) { 154 | this.keys = new ArrayList(keys); 155 | } 156 | 157 | @Override 158 | public boolean hasNextKey() { 159 | return index < keys.size(); 160 | } 161 | 162 | @Override 163 | public String nextKey() { 164 | String val = keys.get(index); 165 | index++; 166 | return val; 167 | } 168 | } 169 | } -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/testutils/MockReadableArray.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react.testutils; 2 | 3 | import com.facebook.react.bridge.ReadableArray; 4 | import com.facebook.react.bridge.ReadableMap; 5 | import com.facebook.react.bridge.ReadableType; 6 | 7 | public class MockReadableArray implements ReadableArray { 8 | 9 | @Override 10 | public int size() { 11 | return 0; 12 | } 13 | 14 | @Override 15 | public boolean isNull(int index) { 16 | return false; 17 | } 18 | 19 | @Override 20 | public boolean getBoolean(int index) { 21 | return false; 22 | } 23 | 24 | @Override 25 | public double getDouble(int index) { 26 | return 0; 27 | } 28 | 29 | @Override 30 | public int getInt(int index) { 31 | return 0; 32 | } 33 | 34 | @Override 35 | public String getString(int index) { 36 | return null; 37 | } 38 | 39 | @Override 40 | public ReadableArray getArray(int index) { 41 | return null; 42 | } 43 | 44 | @Override 45 | public ReadableMap getMap(int index) { 46 | return null; 47 | } 48 | 49 | @Override 50 | public ReadableType getType(int index) { 51 | return null; 52 | } 53 | } -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/testutils/MockWritableMap.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react.testutils; 2 | 3 | public class MockWritableMap { 4 | } 5 | -------------------------------------------------------------------------------- /android/src/test/java/com/mparticle/react/testutils/Mutable.java: -------------------------------------------------------------------------------- 1 | package com.mparticle.react.testutils; 2 | 3 | public class Mutable { 4 | public T value; 5 | 6 | public Mutable() { 7 | value = null; 8 | } 9 | 10 | public Mutable(T t) { 11 | this.value = t; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/RNMParticle.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | DBDF24DC1E007EB1000F3D73 /* RNMParticle.m in Sources */ = {isa = PBXBuildFile; fileRef = DBDF24DB1E007EB1000F3D73 /* RNMParticle.m */; }; 11 | DBDF24DD1E007EB1000F3D73 /* RNMParticle.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = DBDF24DA1E007EB1000F3D73 /* RNMParticle.h */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXCopyFilesBuildPhase section */ 15 | DBDF24D51E007EB1000F3D73 /* CopyFiles */ = { 16 | isa = PBXCopyFilesBuildPhase; 17 | buildActionMask = 2147483647; 18 | dstPath = "include/$(PRODUCT_NAME)"; 19 | dstSubfolderSpec = 16; 20 | files = ( 21 | DBDF24DD1E007EB1000F3D73 /* RNMParticle.h in CopyFiles */, 22 | ); 23 | runOnlyForDeploymentPostprocessing = 0; 24 | }; 25 | /* End PBXCopyFilesBuildPhase section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | DBDF24D71E007EB1000F3D73 /* libRNMParticle.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNMParticle.a; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | DBDF24DA1E007EB1000F3D73 /* RNMParticle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNMParticle.h; sourceTree = ""; }; 30 | DBDF24DB1E007EB1000F3D73 /* RNMParticle.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNMParticle.m; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | DBDF24D41E007EB1000F3D73 /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | DBDF24CE1E007EB1000F3D73 = { 45 | isa = PBXGroup; 46 | children = ( 47 | DBDF24D91E007EB1000F3D73 /* RNMParticle */, 48 | DBDF24D81E007EB1000F3D73 /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | DBDF24D81E007EB1000F3D73 /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | DBDF24D71E007EB1000F3D73 /* libRNMParticle.a */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | DBDF24D91E007EB1000F3D73 /* RNMParticle */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | DBDF24DA1E007EB1000F3D73 /* RNMParticle.h */, 64 | DBDF24DB1E007EB1000F3D73 /* RNMParticle.m */, 65 | ); 66 | path = RNMParticle; 67 | sourceTree = ""; 68 | }; 69 | /* End PBXGroup section */ 70 | 71 | /* Begin PBXNativeTarget section */ 72 | DBDF24D61E007EB1000F3D73 /* RNMParticle */ = { 73 | isa = PBXNativeTarget; 74 | buildConfigurationList = DBDF24E01E007EB1000F3D73 /* Build configuration list for PBXNativeTarget "RNMParticle" */; 75 | buildPhases = ( 76 | DBDF24D31E007EB1000F3D73 /* Sources */, 77 | DBDF24D41E007EB1000F3D73 /* Frameworks */, 78 | DBDF24D51E007EB1000F3D73 /* CopyFiles */, 79 | ); 80 | buildRules = ( 81 | ); 82 | dependencies = ( 83 | ); 84 | name = RNMParticle; 85 | productName = RNMParticle; 86 | productReference = DBDF24D71E007EB1000F3D73 /* libRNMParticle.a */; 87 | productType = "com.apple.product-type.library.static"; 88 | }; 89 | /* End PBXNativeTarget section */ 90 | 91 | /* Begin PBXProject section */ 92 | DBDF24CF1E007EB1000F3D73 /* Project object */ = { 93 | isa = PBXProject; 94 | attributes = { 95 | LastUpgradeCheck = 0820; 96 | ORGANIZATIONNAME = mParticle; 97 | TargetAttributes = { 98 | DBDF24D61E007EB1000F3D73 = { 99 | CreatedOnToolsVersion = 8.1; 100 | ProvisioningStyle = Automatic; 101 | }; 102 | }; 103 | }; 104 | buildConfigurationList = DBDF24D21E007EB1000F3D73 /* Build configuration list for PBXProject "RNMParticle" */; 105 | compatibilityVersion = "Xcode 3.2"; 106 | developmentRegion = English; 107 | hasScannedForEncodings = 0; 108 | knownRegions = ( 109 | en, 110 | ); 111 | mainGroup = DBDF24CE1E007EB1000F3D73; 112 | productRefGroup = DBDF24D81E007EB1000F3D73 /* Products */; 113 | projectDirPath = ""; 114 | projectRoot = ""; 115 | targets = ( 116 | DBDF24D61E007EB1000F3D73 /* RNMParticle */, 117 | ); 118 | }; 119 | /* End PBXProject section */ 120 | 121 | /* Begin PBXSourcesBuildPhase section */ 122 | DBDF24D31E007EB1000F3D73 /* Sources */ = { 123 | isa = PBXSourcesBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | DBDF24DC1E007EB1000F3D73 /* RNMParticle.m in Sources */, 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | /* End PBXSourcesBuildPhase section */ 131 | 132 | /* Begin XCBuildConfiguration section */ 133 | DBDF24DE1E007EB1000F3D73 /* Debug */ = { 134 | isa = XCBuildConfiguration; 135 | buildSettings = { 136 | ALWAYS_SEARCH_USER_PATHS = NO; 137 | CLANG_ANALYZER_NONNULL = YES; 138 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 139 | CLANG_CXX_LIBRARY = "libc++"; 140 | CLANG_ENABLE_MODULES = YES; 141 | CLANG_ENABLE_OBJC_ARC = YES; 142 | CLANG_WARN_BOOL_CONVERSION = YES; 143 | CLANG_WARN_CONSTANT_CONVERSION = YES; 144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 145 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 146 | CLANG_WARN_EMPTY_BODY = YES; 147 | CLANG_WARN_ENUM_CONVERSION = YES; 148 | CLANG_WARN_INFINITE_RECURSION = YES; 149 | CLANG_WARN_INT_CONVERSION = YES; 150 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 151 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 152 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 153 | CLANG_WARN_UNREACHABLE_CODE = YES; 154 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 155 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 156 | COPY_PHASE_STRIP = NO; 157 | DEBUG_INFORMATION_FORMAT = dwarf; 158 | ENABLE_STRICT_OBJC_MSGSEND = YES; 159 | ENABLE_TESTABILITY = YES; 160 | GCC_C_LANGUAGE_STANDARD = gnu99; 161 | GCC_DYNAMIC_NO_PIC = NO; 162 | GCC_NO_COMMON_BLOCKS = YES; 163 | GCC_OPTIMIZATION_LEVEL = 0; 164 | GCC_PREPROCESSOR_DEFINITIONS = ( 165 | "DEBUG=1", 166 | "$(inherited)", 167 | ); 168 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 169 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 170 | GCC_WARN_UNDECLARED_SELECTOR = YES; 171 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 172 | GCC_WARN_UNUSED_FUNCTION = YES; 173 | GCC_WARN_UNUSED_VARIABLE = YES; 174 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 175 | MTL_ENABLE_DEBUG_INFO = YES; 176 | ONLY_ACTIVE_ARCH = YES; 177 | SDKROOT = iphoneos; 178 | }; 179 | name = Debug; 180 | }; 181 | DBDF24DF1E007EB1000F3D73 /* Release */ = { 182 | isa = XCBuildConfiguration; 183 | buildSettings = { 184 | ALWAYS_SEARCH_USER_PATHS = NO; 185 | CLANG_ANALYZER_NONNULL = YES; 186 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 187 | CLANG_CXX_LIBRARY = "libc++"; 188 | CLANG_ENABLE_MODULES = YES; 189 | CLANG_ENABLE_OBJC_ARC = YES; 190 | CLANG_WARN_BOOL_CONVERSION = YES; 191 | CLANG_WARN_CONSTANT_CONVERSION = YES; 192 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 193 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 194 | CLANG_WARN_EMPTY_BODY = YES; 195 | CLANG_WARN_ENUM_CONVERSION = YES; 196 | CLANG_WARN_INFINITE_RECURSION = YES; 197 | CLANG_WARN_INT_CONVERSION = YES; 198 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 199 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 200 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 201 | CLANG_WARN_UNREACHABLE_CODE = YES; 202 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 203 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 204 | COPY_PHASE_STRIP = NO; 205 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 206 | ENABLE_NS_ASSERTIONS = NO; 207 | ENABLE_STRICT_OBJC_MSGSEND = YES; 208 | GCC_C_LANGUAGE_STANDARD = gnu99; 209 | GCC_NO_COMMON_BLOCKS = YES; 210 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 211 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 212 | GCC_WARN_UNDECLARED_SELECTOR = YES; 213 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 214 | GCC_WARN_UNUSED_FUNCTION = YES; 215 | GCC_WARN_UNUSED_VARIABLE = YES; 216 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 217 | MTL_ENABLE_DEBUG_INFO = NO; 218 | SDKROOT = iphoneos; 219 | VALIDATE_PRODUCT = YES; 220 | }; 221 | name = Release; 222 | }; 223 | DBDF24E11E007EB1000F3D73 /* Debug */ = { 224 | isa = XCBuildConfiguration; 225 | buildSettings = { 226 | CLANG_CXX_LANGUAGE_STANDARD = "c++14"; 227 | HEADER_SEARCH_PATHS = ( 228 | "$(SRCROOT)/../sample/node_modules/react-native/React/**", 229 | "$(SRCROOT)/../../react-native/React/**", 230 | "$(SRCROOT)/../sample/node_modules/react-native/ReactCommon/**", 231 | "$(SRCROOT)/../../react-native/ReactCommon/**", 232 | ); 233 | OTHER_LDFLAGS = "-ObjC"; 234 | PRODUCT_NAME = "$(TARGET_NAME)"; 235 | SKIP_INSTALL = YES; 236 | USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/mParticle-Apple-SDK/mParticle-Apple-SDK/** $(SRCROOT)/../../../Pods/mParticle-Apple-SDK/mParticle-Apple-SDK/** $(SRCROOT)/../sample/ios/Pods/mParticle-Apple-SDK/mParticle-Apple-SDK/**"; 237 | }; 238 | name = Debug; 239 | }; 240 | DBDF24E21E007EB1000F3D73 /* Release */ = { 241 | isa = XCBuildConfiguration; 242 | buildSettings = { 243 | CLANG_CXX_LANGUAGE_STANDARD = "c++14"; 244 | HEADER_SEARCH_PATHS = ( 245 | "$(SRCROOT)/../sample/node_modules/react-native/React/**", 246 | "$(SRCROOT)/../../react-native/React/**", 247 | "$(SRCROOT)/../sample/node_modules/react-native/ReactCommon/**", 248 | "$(SRCROOT)/../../react-native/ReactCommon/**", 249 | ); 250 | OTHER_LDFLAGS = "-ObjC"; 251 | PRODUCT_NAME = "$(TARGET_NAME)"; 252 | SKIP_INSTALL = YES; 253 | USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../../ios/Pods/mParticle-Apple-SDK/mParticle-Apple-SDK/** $(SRCROOT)/../../../Pods/mParticle-Apple-SDK/mParticle-Apple-SDK/** $(SRCROOT)/../sample/ios/Pods/mParticle-Apple-SDK/mParticle-Apple-SDK/**"; 254 | }; 255 | name = Release; 256 | }; 257 | /* End XCBuildConfiguration section */ 258 | 259 | /* Begin XCConfigurationList section */ 260 | DBDF24D21E007EB1000F3D73 /* Build configuration list for PBXProject "RNMParticle" */ = { 261 | isa = XCConfigurationList; 262 | buildConfigurations = ( 263 | DBDF24DE1E007EB1000F3D73 /* Debug */, 264 | DBDF24DF1E007EB1000F3D73 /* Release */, 265 | ); 266 | defaultConfigurationIsVisible = 0; 267 | defaultConfigurationName = Release; 268 | }; 269 | DBDF24E01E007EB1000F3D73 /* Build configuration list for PBXNativeTarget "RNMParticle" */ = { 270 | isa = XCConfigurationList; 271 | buildConfigurations = ( 272 | DBDF24E11E007EB1000F3D73 /* Debug */, 273 | DBDF24E21E007EB1000F3D73 /* Release */, 274 | ); 275 | defaultConfigurationIsVisible = 0; 276 | defaultConfigurationName = Release; 277 | }; 278 | /* End XCConfigurationList section */ 279 | }; 280 | rootObject = DBDF24CF1E007EB1000F3D73 /* Project object */; 281 | } 282 | -------------------------------------------------------------------------------- /ios/RNMParticle/RNMParticle.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface RNMParticle : NSObject 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /js/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | import { NativeModules } from 'react-native' 4 | 5 | // ******** Constants ******** 6 | 7 | const EventType = { 8 | Navigation: 1, 9 | Location: 2, 10 | Search: 3, 11 | Transaction: 4, 12 | UserContent: 5, 13 | UserPreference: 6, 14 | Social: 7, 15 | Other: 8, 16 | Media: 9 17 | } 18 | 19 | const UserAttributeType = { 20 | FirstName: '$FirstName', 21 | LastName: '$LastName', 22 | Address: '$Address', 23 | State: '$State', 24 | City: '$City', 25 | Zipcode: '$Zip', 26 | Country: '$Country', 27 | Age: '$Age', 28 | Gender: '$Gender', 29 | MobileNumber: '$Mobile' 30 | } 31 | 32 | const UserIdentityType = { 33 | Other: 0, 34 | CustomerId: 1, 35 | Facebook: 2, 36 | Twitter: 3, 37 | Google: 4, 38 | Microsoft: 5, 39 | Yahoo: 6, 40 | Email: 7, 41 | Alias: 8, 42 | FacebookCustomAudienceId: 9, 43 | Other2: 10, 44 | Other3: 11, 45 | Other4: 12, 46 | Other5: 13, 47 | Other6: 14, 48 | Other7: 15, 49 | Other8: 16, 50 | Other9: 17, 51 | Other10: 18, 52 | MobileNumber: 19, 53 | PhoneNumber2: 20, 54 | PhoneNumber3: 21, 55 | IOSAdvertiserId: 22, 56 | IOSVendorId: 23, 57 | PushToken: 24, 58 | DeviceApplicationStamp: 25 59 | } 60 | 61 | const ProductActionType = { 62 | AddToCart: 1, 63 | RemoveFromCart: 2, 64 | Checkout: 3, 65 | CheckoutOption: 4, 66 | Click: 5, 67 | ViewDetail: 6, 68 | Purchase: 7, 69 | Refund: 8, 70 | AddToWishlist: 9, 71 | RemoveFromWishlist: 10 72 | } 73 | 74 | const PromotionActionType = { 75 | View: 0, 76 | Click: 1 77 | } 78 | 79 | const ATTAuthStatus = { 80 | NotDetermined: 0, 81 | Restricted: 1, 82 | Denied: 2, 83 | Authorized: 3 84 | } 85 | 86 | // ******** Main API ******** 87 | 88 | const upload = () => { 89 | NativeModules.MParticle.upload() 90 | } 91 | 92 | const setUploadInterval = (uploadInterval) => { 93 | NativeModules.MParticle.setUploadInterval(uploadInterval) 94 | } 95 | 96 | const logEvent = (eventName, type = EventType.Other, attributes = null) => { 97 | NativeModules.MParticle.logEvent(eventName, type, attributes) 98 | } 99 | 100 | const logMPEvent = (event) => { 101 | NativeModules.MParticle.logMPEvent(event) 102 | } 103 | 104 | const logCommerceEvent = (commerceEvent) => { 105 | NativeModules.MParticle.logCommerceEvent(commerceEvent) 106 | } 107 | 108 | const logScreenEvent = (screenName, attributes = null, shouldUploadEvent = true) => { 109 | NativeModules.MParticle.logScreenEvent(screenName, attributes, shouldUploadEvent) 110 | } 111 | 112 | // Use ATTAuthStatus constants for status 113 | const setATTStatus = (status) => { 114 | NativeModules.MParticle.setATTStatus(status) 115 | } 116 | 117 | const setATTStatusWithCustomTimestamp = (status, timestamp) => { 118 | NativeModules.MParticle.setATTStatus(status, timestamp) 119 | } 120 | 121 | const setOptOut = (optOut) => { 122 | NativeModules.MParticle.setOptOut(optOut) 123 | } 124 | 125 | const getOptOut = (completion) => { 126 | NativeModules.MParticle.getOptOut(completion) 127 | } 128 | 129 | const addGDPRConsentState = (newConsentState, purpose) => { 130 | NativeModules.MParticle.addGDPRConsentState(newConsentState, purpose) 131 | } 132 | 133 | const removeGDPRConsentStateWithPurpose = (purpose) => { 134 | NativeModules.MParticle.removeGDPRConsentStateWithPurpose(purpose) 135 | } 136 | 137 | const setCCPAConsentState = (newConsentState) => { 138 | NativeModules.MParticle.setCCPAConsentState(newConsentState) 139 | } 140 | 141 | const removeCCPAConsentState = () => { 142 | NativeModules.MParticle.removeCCPAConsentState() 143 | } 144 | 145 | const isKitActive = (kitId, completion) => { 146 | NativeModules.MParticle.isKitActive(kitId, completion) 147 | } 148 | 149 | const getAttributions = (completion) => { 150 | NativeModules.MParticle.getAttributions(completion) 151 | } 152 | 153 | const logPushRegistration = (registrationField1, registrationField2) => { 154 | NativeModules.MParticle.logPushRegistration(registrationField1, registrationField2) 155 | } 156 | 157 | const getSession = (completion) => { 158 | NativeModules.MParticle.getSession(completion) 159 | } 160 | 161 | const setLocation = (latitude, longitude) => { 162 | NativeModules.MParticle.setLocation(latitude, longitude) 163 | } 164 | 165 | // ******** Identity ******** 166 | class User { 167 | constructor (userId) { 168 | this.userId = userId 169 | } 170 | 171 | getMpid () { 172 | return this.userId 173 | } 174 | 175 | setUserAttribute (key, value) { 176 | if (value && value.constructor === Array) { 177 | NativeModules.MParticle.setUserAttributeArray(this.userId, key, value) 178 | } else { 179 | NativeModules.MParticle.setUserAttribute(this.userId, key, value) 180 | } 181 | } 182 | 183 | setUserAttributeArray (key, value) { 184 | NativeModules.MParticle.setUserAttributeArray(this.userId, key, value) 185 | } 186 | 187 | getUserAttributes (completion) { 188 | NativeModules.MParticle.getUserAttributes(this.userId, (error, userAttributes) => { 189 | if (error) { 190 | console.log(error.stack) 191 | } 192 | completion(userAttributes) 193 | }) 194 | } 195 | 196 | setUserTag (value) { 197 | NativeModules.MParticle.setUserTag(this.userId, value) 198 | } 199 | 200 | incrementUserAttribute (key, value) { 201 | NativeModules.MParticle.incrementUserAttribute(this.userId, key, value) 202 | } 203 | 204 | removeUserAttribute (key) { 205 | NativeModules.MParticle.removeUserAttribute(this.userId, key) 206 | } 207 | 208 | getUserIdentities (completion) { 209 | NativeModules.MParticle.getUserIdentities(this.userId, (error, userIdentities) => { 210 | if (error) { 211 | console.log(error.stack) 212 | } 213 | completion(userIdentities) 214 | }) 215 | } 216 | 217 | getFirstSeen (completion) { 218 | NativeModules.MParticle.getFirstSeen(this.userId, completion) 219 | } 220 | 221 | getLastSeen (completion) { 222 | NativeModules.MParticle.getLastSeen(this.userId, completion) 223 | } 224 | } 225 | 226 | class IdentityRequest { 227 | 228 | setEmail (email) { 229 | this[UserIdentityType.Email] = email 230 | return this 231 | } 232 | 233 | setCustomerID (customerId) { 234 | this[UserIdentityType.CustomerId] = customerId 235 | return this 236 | } 237 | 238 | setUserIdentity (userIdentity, identityType) { 239 | this[identityType] = userIdentity 240 | return this 241 | } 242 | 243 | setOnUserAlias (onUserAlias) { 244 | console.log("Warning: deprecated method 'setUserAlias(onUserAlias)', will be removed in future releases") 245 | } 246 | } 247 | 248 | class Identity { 249 | 250 | static getCurrentUser (completion) { 251 | NativeModules.MParticle.getCurrentUserWithCompletion((error, userId) => { 252 | if (error) { 253 | console.log(error.stack) 254 | } 255 | var currentUser = new User(userId) 256 | completion(currentUser) 257 | }) 258 | } 259 | 260 | static identify (IdentityRequest, completion) { 261 | NativeModules.MParticle.identify(IdentityRequest, (error, userId, previousUserId) => { 262 | if (error == null || error === undefined) { 263 | completion(error, userId, previousUserId) 264 | } else { 265 | var parsedError = new MParticleError(error) 266 | completion(parsedError, userId, previousUserId) 267 | } 268 | }) 269 | } 270 | 271 | static login (IdentityRequest, completion) { 272 | NativeModules.MParticle.login(IdentityRequest, (error, userId, previousUserId) => { 273 | if (error == null || error === undefined) { 274 | completion(error, userId, previousUserId) 275 | } else { 276 | var parsedError = new MParticleError(error) 277 | completion(parsedError, userId, previousUserId) 278 | } 279 | }) 280 | } 281 | 282 | static logout (IdentityRequest, completion) { 283 | NativeModules.MParticle.logout(IdentityRequest, (error, userId, previousUserId) => { 284 | if (error == null || error === undefined) { 285 | completion(error, userId, previousUserId) 286 | } else { 287 | var parsedError = new MParticleError(error) 288 | completion(parsedError, userId, previousUserId) 289 | } 290 | }) 291 | } 292 | 293 | static modify (IdentityRequest, completion) { 294 | NativeModules.MParticle.modify(IdentityRequest, (error, userId, previousUserId) => { 295 | if (error == null || error === undefined) { 296 | completion(error, userId, previousUserId) 297 | } else { 298 | var parsedError = new MParticleError(error) 299 | completion(parsedError, userId, previousUserId) 300 | } 301 | }) 302 | } 303 | 304 | static aliasUsers (AliasRequest, completion) { 305 | NativeModules.MParticle.aliasUsers(AliasRequest, completion) 306 | } 307 | 308 | } 309 | 310 | // ******** Commerce ******** 311 | 312 | class Impression { 313 | constructor (impressionListName, products) { 314 | this.impressionListName = impressionListName 315 | this.products = products 316 | } 317 | } 318 | 319 | class Promotion { 320 | constructor (id, name, creative, position) { 321 | this.id = id 322 | this.name = name 323 | this.creative = creative 324 | this.position = position 325 | } 326 | } 327 | 328 | class AliasRequest { 329 | 330 | sourceMpid (mpid) { 331 | this.sourceMpid = mpid 332 | return this 333 | } 334 | 335 | destinationMpid (mpid) { 336 | this.destinationMpid = mpid 337 | return this 338 | } 339 | 340 | endTime (mpid) { 341 | this.endTime = mpid 342 | return this 343 | } 344 | 345 | startTime (mpid) { 346 | this.startTime = mpid 347 | return this 348 | } 349 | } 350 | 351 | class TransactionAttributes { 352 | constructor (transactionId) { 353 | this.transactionId = transactionId 354 | } 355 | 356 | setAffiliation (affiliation) { 357 | this.affiliation = affiliation 358 | return this 359 | } 360 | 361 | setRevenue (revenue) { 362 | this.revenue = typeof revenue === 'string' ? parseFloat(revenue) : revenue 363 | return this 364 | } 365 | 366 | setShipping (shipping) { 367 | this.shipping = typeof shipping === 'string' ? parseFloat(shipping) : shipping 368 | return this 369 | } 370 | 371 | setTax (tax) { 372 | this.tax = typeof tax === 'string' ? parseFloat(tax) : tax 373 | return this 374 | } 375 | 376 | setCouponCode (couponCode) { 377 | this.couponCode = couponCode 378 | return this 379 | } 380 | } 381 | 382 | class Product { 383 | constructor (name, sku, price, quantity = 1) { 384 | this.name = name 385 | this.sku = sku 386 | this.price = price 387 | this.quantity = quantity 388 | } 389 | 390 | setBrand (brand) { 391 | this.brand = brand 392 | return this 393 | } 394 | 395 | setCouponCode (couponCode) { 396 | this.couponCode = couponCode 397 | return this 398 | } 399 | 400 | setPosition (position) { 401 | this.position = position 402 | return this 403 | } 404 | 405 | setCategory (category) { 406 | this.category = category 407 | return this 408 | } 409 | 410 | setVariant (variant) { 411 | this.variant = variant 412 | return this 413 | } 414 | 415 | setCustomAttributes (customAttributes) { 416 | this.customAttributes = customAttributes 417 | return this 418 | } 419 | } 420 | 421 | class GDPRConsent { 422 | 423 | constructor (consented, doc, timestamp, location, hardwareId) { 424 | this.consented = consented 425 | this.document = doc 426 | this.timestamp = timestamp 427 | this.location = location 428 | this.hardwareId = hardwareId 429 | } 430 | 431 | setConsented (consented) { 432 | this.consented = consented 433 | return this 434 | } 435 | 436 | setDocument (doc) { 437 | this.document = doc 438 | return this 439 | } 440 | 441 | setTimestamp (timestamp) { 442 | this.timestamp = timestamp 443 | return this 444 | } 445 | 446 | setLocation (location) { 447 | this.location = location 448 | return this 449 | } 450 | 451 | setHardwareId (hardwareId) { 452 | this.hardwareId = hardwareId 453 | return this 454 | } 455 | } 456 | 457 | class CCPAConsent { 458 | 459 | constructor (consented, doc, timestamp, location, hardwareId) { 460 | this.consented = consented 461 | this.document = doc 462 | this.timestamp = timestamp 463 | this.location = location 464 | this.hardwareId = hardwareId 465 | } 466 | 467 | setConsented (consented) { 468 | this.consented = consented 469 | return this 470 | } 471 | 472 | setDocument (doc) { 473 | this.document = doc 474 | return this 475 | } 476 | 477 | setTimestamp (timestamp) { 478 | this.timestamp = timestamp 479 | return this 480 | } 481 | 482 | setLocation (location) { 483 | this.location = location 484 | return this 485 | } 486 | 487 | setHardwareId (hardwareId) { 488 | this.hardwareId = hardwareId 489 | return this 490 | } 491 | } 492 | 493 | class CommerceEvent { 494 | 495 | static createProductActionEvent (productActionType, products, transactionAttributes = {}) { 496 | return new CommerceEvent() 497 | .setProductActionType(productActionType) 498 | .setProducts(products) 499 | .setTransactionAttributes(transactionAttributes) 500 | } 501 | 502 | static createPromotionEvent (promotionActionType, promotions) { 503 | return new CommerceEvent() 504 | .setPromotionActionType(promotionActionType) 505 | .setPromotions(promotions) 506 | } 507 | 508 | static createImpressionEvent (impressions) { 509 | return new CommerceEvent() 510 | .setImpressions(impressions) 511 | } 512 | 513 | setTransactionAttributes (transactionAttributes) { 514 | this.transactionAttributes = transactionAttributes 515 | return this 516 | } 517 | 518 | setProductActionType (productActionType) { 519 | this.productActionType = productActionType 520 | return this 521 | } 522 | 523 | setPromotionActionType (promotionActionType) { 524 | this.promotionActionType = promotionActionType 525 | return this 526 | } 527 | 528 | setProducts (products) { 529 | this.products = products 530 | return this 531 | } 532 | 533 | setPromotions (promotions) { 534 | this.promotions = promotions 535 | return this 536 | } 537 | 538 | setImpressions (impressions) { 539 | this.impressions = impressions 540 | return this 541 | } 542 | 543 | setScreenName (screenName) { 544 | this.screenName = screenName 545 | return this 546 | } 547 | 548 | setCurrency (currency) { 549 | this.currency = currency 550 | return this 551 | } 552 | 553 | setCustomAttributes (customAttributes) { 554 | this.customAttributes = customAttributes 555 | return this 556 | } 557 | 558 | setCheckoutOptions (checkoutOptions) { 559 | this.checkoutOptions = checkoutOptions 560 | return this 561 | } 562 | 563 | setProductActionListName (productActionListName) { 564 | this.productActionListName = productActionListName 565 | return this 566 | } 567 | 568 | setProductActionListSource (productActionListSource) { 569 | this.productActionListSource = productActionListSource 570 | return this 571 | } 572 | 573 | setCheckoutStep (checkoutStep) { 574 | this.checkoutStep = checkoutStep 575 | return this 576 | } 577 | 578 | setNonInteractive (nonInteractive) { 579 | this.nonInteractive = nonInteractive 580 | return this 581 | } 582 | 583 | setShouldUploadEvent (shouldUploadEvent) { 584 | this.shouldUploadEvent = shouldUploadEvent 585 | return this 586 | } 587 | } 588 | 589 | class Event { 590 | 591 | setCategory (category) { 592 | this.category = category 593 | return this 594 | } 595 | 596 | setDuration (duration) { 597 | this.duration = duration 598 | return this 599 | } 600 | 601 | setEndTime (endTime) { 602 | this.endTime = endTime 603 | return this 604 | } 605 | 606 | setInfo (info) { 607 | this.info = info 608 | return this 609 | } 610 | 611 | setName (name) { 612 | this.name = name 613 | return this 614 | } 615 | 616 | setStartTime (startTime) { 617 | this.startTime = startTime 618 | return this 619 | } 620 | 621 | setType (type) { 622 | this.type = type 623 | return this 624 | } 625 | 626 | setShouldUploadEvent (shouldUploadEvent) { 627 | this.shouldUploadEvent = shouldUploadEvent 628 | return this 629 | } 630 | 631 | setCustomFlags (customFlags) { 632 | this.customFlags = customFlags 633 | return this 634 | } 635 | } 636 | 637 | class MParticleError { 638 | constructor (errorResponse) { 639 | this.httpCode = errorResponse.httpCode 640 | 641 | this.responseCode = errorResponse.responseCode 642 | 643 | this.message = errorResponse.message 644 | 645 | this.mpid = errorResponse.mpid 646 | 647 | this.errors = errorResponse.errors 648 | } 649 | } 650 | 651 | // ******** Exports ******** 652 | 653 | const MParticle = { 654 | 655 | EventType, // Constants 656 | UserIdentityType, 657 | UserAttributeType, 658 | ProductActionType, 659 | PromotionActionType, 660 | ATTAuthStatus, 661 | 662 | Product, // Classes 663 | Impression, 664 | Promotion, 665 | CommerceEvent, 666 | TransactionAttributes, 667 | IdentityRequest, 668 | AliasRequest, 669 | Identity, 670 | User, 671 | Event, 672 | MParticleError, 673 | GDPRConsent, 674 | CCPAConsent, 675 | 676 | upload, // Methods 677 | setUploadInterval, 678 | logEvent, 679 | logMPEvent, 680 | logCommerceEvent, 681 | logScreenEvent, 682 | setATTStatus, 683 | setATTStatusWithCustomTimestamp, 684 | setOptOut, 685 | getOptOut, 686 | addGDPRConsentState, 687 | removeGDPRConsentStateWithPurpose, 688 | setCCPAConsentState, 689 | removeCCPAConsentState, 690 | isKitActive, 691 | getAttributions, 692 | logPushRegistration, 693 | getSession, 694 | setLocation 695 | } 696 | 697 | export default MParticle 698 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-mparticle", 3 | "description": "React Native module for mParticle", 4 | "homepage": "https://www.mparticle.com", 5 | "license": "Apache-2.0", 6 | "repository": "mParticle/react-native-mparticle", 7 | "version": "2.7.13", 8 | "main": "js/index.js", 9 | "scripts": { 10 | "test": "./node_modules/standard/bin/cmd.js", 11 | "fix": "./node_modules/standard/bin/cmd.js --fix" 12 | }, 13 | "standard": { 14 | "ignore": [ 15 | "/sample" 16 | ] 17 | }, 18 | "dependencies": {}, 19 | "peerDependencies": { 20 | "react": ">= 16.0.0-alpha.12", 21 | "react-native": ">= 0.45.0" 22 | }, 23 | "devDependencies": { 24 | "standard": "^8.6.0" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /react-native-mparticle.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1' 4 | ios_platform = new_arch_enabled ? '11.0' : '9.0' 5 | 6 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 7 | 8 | Pod::Spec.new do |s| 9 | s.name = package['name'] 10 | s.version = package['version'] 11 | s.summary = package['description'] 12 | 13 | s.author = { "mParticle" => "support@mparticle.com" } 14 | 15 | s.homepage = package['homepage'] 16 | s.license = package['license'] 17 | s.platforms = { :ios => ios_platform, :tvos => "9.2" } 18 | 19 | s.source = { :git => "https://github.com/mParticle/react-native-mparticle.git", :tag => "#{s.version}" } 20 | s.source_files = "ios/**/*.{h,m}" 21 | 22 | if defined?(install_modules_dependencies()) != nil 23 | install_modules_dependencies(s); 24 | else 25 | s.dependency 'React' 26 | end 27 | s.dependency 'mParticle-Apple-SDK', '~> 8.0' 28 | end 29 | -------------------------------------------------------------------------------- /release.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | : ${1?"NPM Token missing- usage: $0 {MY_NPM_TOKEN}"} 3 | 4 | touch .npmrc; 5 | echo "//registry.npmjs.org/:_authToken=$1" > .npmrc; 6 | npm publish; -------------------------------------------------------------------------------- /sample/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /sample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:26 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /sample/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /sample/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /sample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /sample/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /sample/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /sample/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.mparticlesample', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.mparticlesample', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /sample/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 28 87 | buildToolsVersion "28.0.3" 88 | 89 | defaultConfig { 90 | applicationId "com.mparticlesample" 91 | minSdkVersion 16 92 | targetSdkVersion 28 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | implementation project(':react-native-mparticle') 130 | implementation fileTree(dir: "libs", include: ["*.jar"]) 131 | implementation "com.facebook.react:react-native:+" // From node_modules 132 | 133 | // 134 | // In your app, you should include mParticle core like this: 135 | // 136 | // compile "com.mparticle.android-core:REPLACEME" 137 | // 138 | // (See https://github.com/mparticle/mparticle-android-sdk for the latest version) 139 | // 140 | implementation "com.mparticle:android-core:5.+" 141 | 142 | // 143 | // And, if you want to include kits, you can do so as follows: 144 | // 145 | // compile 'com.mparticle:android-example-kit:REPLACEME' 146 | // 147 | } 148 | 149 | // Run this once to be able to run the application with BUCK 150 | // puts all compile dependencies into folder libs for BUCK to use 151 | task copyDownloadableDepsToLibs(type: Copy) { 152 | from configurations.compile 153 | into 'libs' 154 | } 155 | -------------------------------------------------------------------------------- /sample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /sample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /sample/android/app/src/main/java/com/mparticlesample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.mparticlesample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "MParticleSample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sample/android/app/src/main/java/com/mparticlesample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.mparticlesample; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.mparticle.MParticle; 8 | import com.mparticle.identity.IdentityApiRequest; 9 | import com.mparticle.react.MParticlePackage; 10 | import com.facebook.react.ReactInstanceManager; 11 | import com.facebook.react.ReactNativeHost; 12 | import com.facebook.react.ReactPackage; 13 | import com.facebook.react.shell.MainReactPackage; 14 | import com.facebook.soloader.SoLoader; 15 | 16 | import java.util.Arrays; 17 | import java.util.List; 18 | 19 | import com.mparticle.MParticleOptions; 20 | import com.mparticle.identity.BaseIdentityTask; 21 | 22 | public class MainApplication extends Application implements ReactApplication { 23 | 24 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 25 | @Override 26 | public boolean getUseDeveloperSupport() { 27 | return BuildConfig.DEBUG; 28 | } 29 | 30 | @Override 31 | protected List getPackages() { 32 | return Arrays.asList( 33 | new MainReactPackage(), 34 | new MParticlePackage() 35 | ); 36 | } 37 | }; 38 | 39 | @Override 40 | public ReactNativeHost getReactNativeHost() { 41 | return mReactNativeHost; 42 | } 43 | 44 | @Override 45 | public void onCreate() { 46 | super.onCreate(); 47 | 48 | IdentityApiRequest.Builder identityRequest = IdentityApiRequest.withEmptyUser(); 49 | 50 | MParticleOptions options = MParticleOptions.builder(this) 51 | .credentials("us1-352af4d005e49047a7bcc78281f33e9c","flR34mIajnAA5F-Ouha7JQF5v0JqFUfo_QjJtM_16VESU2hS0ikp3hRILG70-aBk") 52 | .logLevel(MParticle.LogLevel.VERBOSE) 53 | .identify(identityRequest.build()) 54 | .build(); 55 | 56 | MParticle.start(options); 57 | SoLoader.init(this, /* native exopackage */ false); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/sample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/sample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/sample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/sample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | MParticleSample 3 | REPLACE ME WITH KEY 4 | REPLACE ME WITH SECRET 5 | 6 | -------------------------------------------------------------------------------- /sample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /sample/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.2.1' 10 | } 11 | } 12 | 13 | 14 | allprojects { 15 | repositories { 16 | mavenLocal() 17 | mavenCentral() 18 | google() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | maven { 24 | url 'https://maven.google.com' 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mParticle/react-native-mparticle/a09018ce0eb1d2b9c9404549d2f3b7eb8fbc2e14/sample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Apr 03 15:57:13 EDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip 7 | -------------------------------------------------------------------------------- /sample/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /sample/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /sample/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /sample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'MParticleSample' 2 | include ':react-native-mparticle' 3 | project(':react-native-mparticle').projectDir = new File(rootProject.projectDir, '../../android') 4 | 5 | include ':app' 6 | -------------------------------------------------------------------------------- /sample/build: -------------------------------------------------------------------------------- 1 | cp -r ../android node_modules/react-native-mparticle 2 | cp -r ../js node_modules/react-native-mparticle 3 | rm -rf node_modules/react-native-mparticle/ios 4 | cp -r ../ios node_modules/react-native-mparticle -------------------------------------------------------------------------------- /sample/index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { 9 | AppRegistry, 10 | StyleSheet, 11 | Text, 12 | View, 13 | Button 14 | } from 'react-native'; 15 | import MParticle from 'react-native-mparticle' 16 | 17 | 18 | export default class MParticleSample extends Component { 19 | constructor(props) { 20 | super(props); 21 | this.state = {isShowingText: true, 22 | optedOut: true, 23 | attributionResults: "{value: no attributionResults}", 24 | session: '', 25 | isKitActive: true}; 26 | 27 | this._toggleOptOut = this._toggleOptOut.bind(this) 28 | this._getAttributionResults = this._getAttributionResults.bind(this) 29 | this._isKitActive = this._isKitActive.bind(this) 30 | this.render = this.render.bind(this) 31 | 32 | // Example Login 33 | var request = new MParticle.IdentityRequest(); 34 | request.email = 'testing1@gmail.com'; 35 | request.customerId = "123" 36 | MParticle.Identity.login(request, (error, userId, previousUserId) => { 37 | if (error) { 38 | console.debug(error); 39 | } 40 | var previousUser = new MParticle.User(previousUserId); 41 | previousUser.getFirstSeen((firstSeen) => { 42 | previousUser.getLastSeen((lastSeen) => { 43 | var aliasRequest = new MParticle.AliasRequest() 44 | .sourceMpid(previousUser.getMpid()) 45 | .destinationMpid(userId) 46 | .startTime(firstSeen - 1000) 47 | .endTime(lastSeen - 1000) 48 | console.log("AliasRequest = " + JSON.stringify(aliasRequest)); 49 | MParticle.Identity.aliasUsers(aliasRequest, (success, error) => { 50 | if (error) { 51 | console.log("Alias error = " + error); 52 | } 53 | console.log("Alias result: " + success); 54 | }); 55 | 56 | var aliasRequest2 = new MParticle.AliasRequest() 57 | .sourceMpid(previousUser.getMpid()) 58 | .destinationMpid(userId) 59 | console.log("AliasRequest2 = " + JSON.stringify(aliasRequest2)); 60 | MParticle.Identity.aliasUsers(aliasRequest2, (success, error) => { 61 | if (error) { 62 | console.log("Alias 2 error = " + error); 63 | } 64 | console.log("Alias 2 result: " + success); 65 | }); 66 | }) 67 | }) 68 | 69 | var user = new MParticle.User(userId); 70 | console.debug("User Attributes = " + user.userAttributes); 71 | MParticle.Identity.logout({}, (error, userId) => { 72 | if (error) { 73 | console.debug("Logout error" + error); 74 | } 75 | var request = new MParticle.IdentityRequest(); 76 | request.email = 'testing2@gmail.com'; 77 | request.customerId = '456' 78 | MParticle.Identity.modify(request, (error) => { 79 | if (error) { 80 | console.debug("Modify error = " + error) 81 | } 82 | }); 83 | }); 84 | }); 85 | 86 | var i = 0; 87 | // Toggle the state every few seconds, 10 times 88 | var intervalId = setInterval(() => { 89 | MParticle.logEvent('Test event', MParticle.EventType.Other, { 'Test key': 'Test value', 'Test Boolean': true, 'Test Int': 1235, 'Test Double': 123.123 }) 90 | this.setState((previousState) => { 91 | return {isShowingText: !previousState.isShowingText} 92 | }) 93 | MParticle.Identity.getCurrentUser((currentUser) => { 94 | currentUser.setUserTag('regular'); 95 | }); 96 | var request = new MParticle.IdentityRequest(); 97 | request.email = 'testing1@gmail.com'; 98 | request.customerId = "vlknasdlknv" 99 | request.setUserIdentity('12345', MParticle.UserIdentityType.Alias); 100 | 101 | const product = new MParticle.Product('Test product for cart', '1234', 19.99) 102 | const transactionAttributes = new MParticle.TransactionAttributes('Test transaction id') 103 | const event = MParticle.CommerceEvent.createProductActionEvent(MParticle.ProductActionType.AddToCart, [product], transactionAttributes) 104 | 105 | MParticle.logCommerceEvent(event) 106 | MParticle.logPushRegistration("afslibvnoewtibnsgb", "vdasvadsdsav"); 107 | console.debug("interval") 108 | i++; 109 | if (i >= 10) { 110 | clearInterval(intervalId); 111 | } 112 | }, 5000); 113 | } 114 | 115 | componentDidMount() { 116 | MParticle.getSession(session => this.setState({ session })) 117 | } 118 | 119 | _toggleOptOut() { 120 | MParticle.getOptOut((optedOut) => { 121 | MParticle.setOptOut(!optedOut) 122 | console.debug("setOptout" + optedOut) 123 | this.setState((previousState) => { 124 | console.debug("returning state") 125 | return { optedOut: !optedOut }; 126 | }) 127 | }) 128 | } 129 | 130 | _getAttributionResults() { 131 | MParticle.getAttributions((_attributionResults) => { 132 | this.setState((previousState) => { 133 | return {attributionResults: _attributionResults} 134 | }) 135 | }) 136 | } 137 | 138 | _isKitActive() { 139 | MParticle.isKitActive(80, (active) => { 140 | this.setState((previousState) => { 141 | return {isKitActive: active} 142 | }) 143 | }) 144 | } 145 | 146 | _incrementAttribute() { 147 | MParticle.Identity.getCurrentUser((currentUser) => { 148 | currentUser.incrementUserAttribute("incrementedAttribute", 1) 149 | }) 150 | } 151 | 152 | render() { 153 | let display = this.state.isShowingText ? 'Sending Event' : ' ' 154 | let optedOut = this.state.optedOut ? 'true' : 'false' 155 | let optAction = this.state.optedOut ? 'In' : 'Out' 156 | let kitActive = this.state.isKitActive ? 'true' : 'false' 157 | return ( 158 | 159 | 160 | Welcome to React Native! {display} 161 | 162 | 163 | Opted Out = {optedOut} 164 | 165 |