@jmartins-tillster/analytics-react-native 2.21.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +10 -0
- package/.eslintignore +11 -0
- package/.eslintrc.js +60 -0
- package/.gitattributes +4 -0
- package/.github/ISSUE_TEMPLATE/BUG_REPORT.md +23 -0
- package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +18 -0
- package/.github/workflows/ci.yml +158 -0
- package/.github/workflows/create_jira.yml +41 -0
- package/.github/workflows/publish.yml +57 -0
- package/.husky/commit-msg +4 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc.js +7 -0
- package/.yarnrc.yml +2 -0
- package/CODE_OF_CONDUCT.md +84 -0
- package/CONTRIBUTING.md +141 -0
- package/LICENSE +21 -0
- package/MIGRATION_GUIDE.md +185 -0
- package/README.md +944 -0
- package/babel.config.js +3 -0
- package/commitlint.config.js +13 -0
- package/examples/AnalyticsReactNativeExample/.bundle/config +2 -0
- package/examples/AnalyticsReactNativeExample/.eslintrc.js +4 -0
- package/examples/AnalyticsReactNativeExample/.prettierrc.js +7 -0
- package/examples/AnalyticsReactNativeExample/.watchmanconfig +1 -0
- package/examples/AnalyticsReactNativeExample/App.tsx +164 -0
- package/examples/AnalyticsReactNativeExample/Gemfile +9 -0
- package/examples/AnalyticsReactNativeExample/Gemfile.lock +106 -0
- package/examples/AnalyticsReactNativeExample/Home.tsx +206 -0
- package/examples/AnalyticsReactNativeExample/Modal.tsx +25 -0
- package/examples/AnalyticsReactNativeExample/README.md +79 -0
- package/examples/AnalyticsReactNativeExample/SecondPage.tsx +25 -0
- package/examples/AnalyticsReactNativeExample/android/app/build.gradle +119 -0
- package/examples/AnalyticsReactNativeExample/android/app/debug.keystore +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/proguard-rules.pro +10 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/debug/AndroidManifest.xml +9 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/AndroidManifest.xml +26 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/java/com/analyticsreactnativeexample/MainActivity.kt +22 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/java/com/analyticsreactnativeexample/MainApplication.kt +44 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/drawable/rn_edit_text_material.xml +37 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/values/strings.xml +3 -0
- package/examples/AnalyticsReactNativeExample/android/app/src/main/res/values/styles.xml +9 -0
- package/examples/AnalyticsReactNativeExample/android/build.gradle +21 -0
- package/examples/AnalyticsReactNativeExample/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/AnalyticsReactNativeExample/android/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/examples/AnalyticsReactNativeExample/android/gradle.properties +39 -0
- package/examples/AnalyticsReactNativeExample/android/gradlew +252 -0
- package/examples/AnalyticsReactNativeExample/android/gradlew.bat +94 -0
- package/examples/AnalyticsReactNativeExample/android/settings.gradle +6 -0
- package/examples/AnalyticsReactNativeExample/app.json +4 -0
- package/examples/AnalyticsReactNativeExample/babel.config.js +3 -0
- package/examples/AnalyticsReactNativeExample/index.js +9 -0
- package/examples/AnalyticsReactNativeExample/ios/.xcode.env +11 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/AppDelegate.h +6 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/AppDelegate.mm +31 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/Images.xcassets/Contents.json +6 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/Info.plist +52 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/LaunchScreen.storyboard +47 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/PrivacyInfo.xcprivacy +37 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample/main.m +10 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample.xcodeproj/project.pbxproj +705 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample.xcodeproj/xcshareddata/xcschemes/AnalyticsReactNativeExample.xcscheme +88 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample.xcworkspace/contents.xcworkspacedata +10 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExampleTests/AnalyticsReactNativeExampleTests.m +66 -0
- package/examples/AnalyticsReactNativeExample/ios/AnalyticsReactNativeExampleTests/Info.plist +24 -0
- package/examples/AnalyticsReactNativeExample/ios/Podfile +40 -0
- package/examples/AnalyticsReactNativeExample/ios/Podfile.lock +1961 -0
- package/examples/AnalyticsReactNativeExample/metro.config.js +11 -0
- package/examples/AnalyticsReactNativeExample/package.json +55 -0
- package/examples/AnalyticsReactNativeExample/plugins/ConsentManager.tsx +75 -0
- package/examples/AnalyticsReactNativeExample/plugins/Logger.ts +16 -0
- package/examples/AnalyticsReactNativeExample/react-native.config.js +9 -0
- package/examples/AnalyticsReactNativeExample/tsconfig.json +3 -0
- package/examples/AnalyticsReactNativeExample/workspace.js +5 -0
- package/examples/AnalyticsReactNativeExample/yarn.lock +11110 -0
- package/examples/E2E/.bundle/config +2 -0
- package/examples/E2E/.detoxrc.js +96 -0
- package/examples/E2E/.mise.toml +5 -0
- package/examples/E2E/.prettierrc.js +7 -0
- package/examples/E2E/.watchmanconfig +1 -0
- package/examples/E2E/App.tsx +176 -0
- package/examples/E2E/Gemfile +7 -0
- package/examples/E2E/Gemfile.lock +101 -0
- package/examples/E2E/Home.tsx +206 -0
- package/examples/E2E/Modal.tsx +25 -0
- package/examples/E2E/README.md +79 -0
- package/examples/E2E/SecondPage.tsx +25 -0
- package/examples/E2E/android/app/build.gradle +128 -0
- package/examples/E2E/android/app/debug.keystore +0 -0
- package/examples/E2E/android/app/proguard-rules.pro +10 -0
- package/examples/E2E/android/app/src/androidTest/java/com/segmentanalyticsreactnativeexample/DetoxTest.java +29 -0
- package/examples/E2E/android/app/src/debug/AndroidManifest.xml +13 -0
- package/examples/E2E/android/app/src/debug/java/com/analyticsreactnativeexample/ReactNativeFlipper.java +75 -0
- package/examples/E2E/android/app/src/main/AndroidManifest.xml +26 -0
- package/examples/E2E/android/app/src/main/java/com/analyticsreactnativeexample/MainActivity.java +32 -0
- package/examples/E2E/android/app/src/main/java/com/analyticsreactnativeexample/MainApplication.java +62 -0
- package/examples/E2E/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
- package/examples/E2E/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/examples/E2E/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/examples/E2E/android/app/src/main/res/values/strings.xml +3 -0
- package/examples/E2E/android/app/src/main/res/values/styles.xml +9 -0
- package/examples/E2E/android/app/src/main/res/xml/network_security_config.xml +7 -0
- package/examples/E2E/android/app/src/release/java/com/analyticsreactnativeexample/ReactNativeFlipper.java +20 -0
- package/examples/E2E/android/build.gradle +37 -0
- package/examples/E2E/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/E2E/android/gradle/wrapper/gradle-wrapper.properties +6 -0
- package/examples/E2E/android/gradle.properties +44 -0
- package/examples/E2E/android/gradlew +244 -0
- package/examples/E2E/android/gradlew.bat +92 -0
- package/examples/E2E/android/settings.gradle +4 -0
- package/examples/E2E/app.json +4 -0
- package/examples/E2E/babel.config.js +14 -0
- package/examples/E2E/e2e/jest.config.js +13 -0
- package/examples/E2E/e2e/main.e2e.js +192 -0
- package/examples/E2E/e2e/matchers.js +34 -0
- package/examples/E2E/e2e/mockServer.js +56 -0
- package/examples/E2E/index.js +11 -0
- package/examples/E2E/ios/.xcode.env +11 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/AppDelegate.h +6 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/AppDelegate.mm +26 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/Images.xcassets/Contents.json +6 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/Info.plist +55 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/LaunchScreen.storyboard +47 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E/main.m +10 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E.xcodeproj/project.pbxproj +721 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E.xcworkspace/contents.xcworkspacedata +10 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2E.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2ETests/AnalyticsReactNativeExampleTests.m +66 -0
- package/examples/E2E/ios/AnalyticsReactNativeE2ETests/Info.plist +24 -0
- package/examples/E2E/ios/Podfile +62 -0
- package/examples/E2E/ios/Podfile.lock +763 -0
- package/examples/E2E/jest.config.js +3 -0
- package/examples/E2E/metro.config.js +45 -0
- package/examples/E2E/package.json +65 -0
- package/examples/E2E/plugins/Logger.ts +16 -0
- package/examples/E2E/react-native.config.js +7 -0
- package/examples/E2E/workspace.js +5 -0
- package/examples/E2E/yarn.lock +10898 -0
- package/examples/E2E-73/.bundle/config +2 -0
- package/examples/E2E-73/.detoxrc.js +96 -0
- package/examples/E2E-73/.eslintrc.js +4 -0
- package/examples/E2E-73/.mise.toml +5 -0
- package/examples/E2E-73/.prettierrc.js +7 -0
- package/examples/E2E-73/.watchmanconfig +1 -0
- package/examples/E2E-73/App.tsx +175 -0
- package/examples/E2E-73/Gemfile +7 -0
- package/examples/E2E-73/Gemfile.lock +99 -0
- package/examples/E2E-73/Home.tsx +206 -0
- package/examples/E2E-73/Modal.tsx +25 -0
- package/examples/E2E-73/README.md +79 -0
- package/examples/E2E-73/SecondPage.tsx +25 -0
- package/examples/E2E-73/android/app/build.gradle +119 -0
- package/examples/E2E-73/android/app/debug.keystore +0 -0
- package/examples/E2E-73/android/app/proguard-rules.pro +10 -0
- package/examples/E2E-73/android/app/src/debug/AndroidManifest.xml +9 -0
- package/examples/E2E-73/android/app/src/main/AndroidManifest.xml +25 -0
- package/examples/E2E-73/android/app/src/main/java/com/analyticsreactnativee2e73/MainActivity.kt +22 -0
- package/examples/E2E-73/android/app/src/main/java/com/analyticsreactnativee2e73/MainApplication.kt +45 -0
- package/examples/E2E-73/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
- package/examples/E2E-73/android/app/src/main/res/values/strings.xml +3 -0
- package/examples/E2E-73/android/app/src/main/res/values/styles.xml +9 -0
- package/examples/E2E-73/android/build.gradle +21 -0
- package/examples/E2E-73/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/E2E-73/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/examples/E2E-73/android/gradle.properties +41 -0
- package/examples/E2E-73/android/gradlew +249 -0
- package/examples/E2E-73/android/gradlew.bat +92 -0
- package/examples/E2E-73/android/settings.gradle +4 -0
- package/examples/E2E-73/app.json +4 -0
- package/examples/E2E-73/babel.config.js +14 -0
- package/examples/E2E-73/e2e/jest.config.js +13 -0
- package/examples/E2E-73/e2e/main.e2e.js +192 -0
- package/examples/E2E-73/e2e/matchers.js +34 -0
- package/examples/E2E-73/e2e/mockServer.js +56 -0
- package/examples/E2E-73/index.js +9 -0
- package/examples/E2E-73/ios/.xcode.env +11 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/AppDelegate.h +6 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/AppDelegate.mm +31 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/Images.xcassets/AppIcon.appiconset/Contents.json +53 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/Images.xcassets/Contents.json +6 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/Info.plist +51 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/LaunchScreen.storyboard +47 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73/main.m +10 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73.xcodeproj/project.pbxproj +700 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73.xcodeproj/xcshareddata/xcschemes/AnalyticsReactNativeE2E73.xcscheme +88 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73.xcworkspace/contents.xcworkspacedata +10 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73Tests/AnalyticsReactNativeE2E73Tests.m +66 -0
- package/examples/E2E-73/ios/AnalyticsReactNativeE2E73Tests/Info.plist +24 -0
- package/examples/E2E-73/ios/Podfile +55 -0
- package/examples/E2E-73/ios/Podfile.lock +1425 -0
- package/examples/E2E-73/jest.config.js +3 -0
- package/examples/E2E-73/metro.config.js +45 -0
- package/examples/E2E-73/package.json +62 -0
- package/examples/E2E-73/plugins/Logger.ts +16 -0
- package/examples/E2E-73/react-native.config.js +12 -0
- package/examples/E2E-73/tsconfig.json +3 -0
- package/examples/E2E-73/workspace.js +5 -0
- package/examples/E2E-73/yarn.lock +10789 -0
- package/examples/README.md +142 -0
- package/examples/linkHelper.js +45 -0
- package/jest.config.js +7 -0
- package/multi-release.config.js +7 -0
- package/package.json +79 -0
- package/packages/core/CHANGELOG.md +274 -0
- package/packages/core/LICENSE +21 -0
- package/packages/core/README.md +3 -0
- package/packages/core/android/build.gradle +96 -0
- package/packages/core/android/gradle.properties +5 -0
- package/packages/core/android/src/main/AndroidManifest.xml +4 -0
- package/packages/core/android/src/main/AndroidManifestNew.xml +3 -0
- package/packages/core/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativeModule.kt +265 -0
- package/packages/core/android/src/main/java/com/segmentanalyticsreactnative/AnalyticsReactNativePackage.kt +43 -0
- package/packages/core/babel.config.js +3 -0
- package/packages/core/constants-generator.js +17 -0
- package/packages/core/ios/AnalyticsReactNative-Bridging-Header.h +1 -0
- package/packages/core/ios/AnalyticsReactNative.m +7 -0
- package/packages/core/ios/AnalyticsReactNative.swift +142 -0
- package/packages/core/ios/AnalyticsReactNative.xcodeproj/project.pbxproj +281 -0
- package/packages/core/ios/PrivacyInfo.xcprivacy +70 -0
- package/packages/core/jest.config.js +5 -0
- package/packages/core/package.json +85 -0
- package/packages/core/release.config.js +3 -0
- package/packages/core/segment-analytics-react-native.podspec +35 -0
- package/packages/core/src/__tests__/__snapshots__/mapTransform.test.ts.snap +20 -0
- package/packages/core/src/__tests__/analytics.test.ts +252 -0
- package/packages/core/src/__tests__/api.test.ts +91 -0
- package/packages/core/src/__tests__/client.test.ts +27 -0
- package/packages/core/src/__tests__/context.test.ts +122 -0
- package/packages/core/src/__tests__/events.test.ts +234 -0
- package/packages/core/src/__tests__/internal/checkInstalledVersion.test.ts +221 -0
- package/packages/core/src/__tests__/internal/fetchSettings.test.ts +438 -0
- package/packages/core/src/__tests__/internal/handleAppStateChange.test.ts +178 -0
- package/packages/core/src/__tests__/internal/trackDeepLinks.test.ts +121 -0
- package/packages/core/src/__tests__/logger.test.ts +83 -0
- package/packages/core/src/__tests__/mapTransform.test.ts +63 -0
- package/packages/core/src/__tests__/methods/alias.test.ts +89 -0
- package/packages/core/src/__tests__/methods/flush.test.ts +120 -0
- package/packages/core/src/__tests__/methods/group.test.ts +48 -0
- package/packages/core/src/__tests__/methods/identify.test.ts +132 -0
- package/packages/core/src/__tests__/methods/process.test.ts +162 -0
- package/packages/core/src/__tests__/methods/screen.test.ts +48 -0
- package/packages/core/src/__tests__/methods/track.test.ts +49 -0
- package/packages/core/src/__tests__/timeline.test.ts +130 -0
- package/packages/core/src/__tests__/util.test.ts +200 -0
- package/packages/core/src/analytics.ts +1030 -0
- package/packages/core/src/api.ts +23 -0
- package/packages/core/src/client.tsx +76 -0
- package/packages/core/src/constants.ts +18 -0
- package/packages/core/src/context.ts +107 -0
- package/packages/core/src/errors.ts +123 -0
- package/packages/core/src/events.ts +75 -0
- package/packages/core/src/flushPolicies/__tests__/background-flush-policy.test.ts +39 -0
- package/packages/core/src/flushPolicies/__tests__/count-flush-policy.test.ts +28 -0
- package/packages/core/src/flushPolicies/__tests__/flush-policy-executer.test.ts +85 -0
- package/packages/core/src/flushPolicies/__tests__/timer-flush-policy.test.ts +30 -0
- package/packages/core/src/flushPolicies/background-flush-policy.ts +21 -0
- package/packages/core/src/flushPolicies/count-flush-policy.ts +31 -0
- package/packages/core/src/flushPolicies/flush-policy-executer.ts +100 -0
- package/packages/core/src/flushPolicies/index.ts +5 -0
- package/packages/core/src/flushPolicies/startup-flush-policy.ts +20 -0
- package/packages/core/src/flushPolicies/timer-flush-policy.ts +45 -0
- package/packages/core/src/flushPolicies/types.ts +93 -0
- package/packages/core/src/index.ts +28 -0
- package/packages/core/src/logger.ts +37 -0
- package/packages/core/src/mapTransform.ts +48 -0
- package/packages/core/src/plugin.ts +212 -0
- package/packages/core/src/plugins/ConsentPlugin.ts +200 -0
- package/packages/core/src/plugins/DestinationMetadataEnrichment.ts +67 -0
- package/packages/core/src/plugins/QueueFlushingPlugin.ts +149 -0
- package/packages/core/src/plugins/SegmentDestination.ts +153 -0
- package/packages/core/src/plugins/__tests__/QueueFlushingPlugin.test.ts +143 -0
- package/packages/core/src/plugins/__tests__/SegmentDestination.test.ts +549 -0
- package/packages/core/src/plugins/__tests__/consent/consentNotEnabledAtSegment.test.ts +123 -0
- package/packages/core/src/plugins/__tests__/consent/destinationMultipleCategories.test.ts +147 -0
- package/packages/core/src/plugins/__tests__/consent/idfa.test.ts +101 -0
- package/packages/core/src/plugins/__tests__/consent/mockSettings/ConsentNotEnabledAtSegment.json +70 -0
- package/packages/core/src/plugins/__tests__/consent/mockSettings/DestinationsMultipleCategories.json +73 -0
- package/packages/core/src/plugins/__tests__/consent/mockSettings/NoUnmappedDestinations.json +105 -0
- package/packages/core/src/plugins/__tests__/consent/mockSettings/UnmappedDestinations.json +101 -0
- package/packages/core/src/plugins/__tests__/consent/noUnmapped.test.ts +234 -0
- package/packages/core/src/plugins/__tests__/consent/unmapped.test.ts +265 -0
- package/packages/core/src/plugins/__tests__/consent/utils.ts +75 -0
- package/packages/core/src/storage/__tests__/sovranStorage.test.ts +153 -0
- package/packages/core/src/storage/helpers.ts +25 -0
- package/packages/core/src/storage/index.ts +3 -0
- package/packages/core/src/storage/sovranStorage.ts +558 -0
- package/packages/core/src/storage/types.ts +106 -0
- package/packages/core/src/test-helpers/index.ts +7 -0
- package/packages/core/src/test-helpers/mockDestinationPlugin.ts +7 -0
- package/packages/core/src/test-helpers/mockEventStore.ts +35 -0
- package/packages/core/src/test-helpers/mockLogger.ts +10 -0
- package/packages/core/src/test-helpers/mockSegmentStore.ts +266 -0
- package/packages/core/src/test-helpers/mockTimeline.ts +9 -0
- package/packages/core/src/test-helpers/setupSegmentClient.ts +59 -0
- package/packages/core/src/test-helpers/utils.ts +23 -0
- package/packages/core/src/timeline.ts +136 -0
- package/packages/core/src/types.ts +392 -0
- package/packages/core/src/util.ts +288 -0
- package/packages/core/src/uuid.ts +7 -0
- package/packages/core/tsconfig.json +10 -0
- package/packages/core/tsconfig.linter.json +11 -0
- package/packages/plugins/plugin-adjust/CHANGELOG.md +60 -0
- package/packages/plugins/plugin-adjust/LICENSE +21 -0
- package/packages/plugins/plugin-adjust/README.md +72 -0
- package/packages/plugins/plugin-adjust/babel.config.js +3 -0
- package/packages/plugins/plugin-adjust/jest.config.js +5 -0
- package/packages/plugins/plugin-adjust/package.json +72 -0
- package/packages/plugins/plugin-adjust/release.config.js +3 -0
- package/packages/plugins/plugin-adjust/src/AdjustPlugin.tsx +92 -0
- package/packages/plugins/plugin-adjust/src/index.ts +1 -0
- package/packages/plugins/plugin-adjust/src/methods/__mocks__/react-native-adjust.ts +19 -0
- package/packages/plugins/plugin-adjust/src/methods/__tests__/identify.test.ts +34 -0
- package/packages/plugins/plugin-adjust/src/methods/__tests__/reset.test.ts +15 -0
- package/packages/plugins/plugin-adjust/src/methods/__tests__/track.test.ts +148 -0
- package/packages/plugins/plugin-adjust/src/methods/identify.ts +14 -0
- package/packages/plugins/plugin-adjust/src/methods/reset.ts +9 -0
- package/packages/plugins/plugin-adjust/src/methods/track.ts +47 -0
- package/packages/plugins/plugin-adjust/src/util.ts +29 -0
- package/packages/plugins/plugin-adjust/tsconfig.json +10 -0
- package/packages/plugins/plugin-advertising-id/CHANGELOG.md +101 -0
- package/packages/plugins/plugin-advertising-id/CONTRIBUTING.md +196 -0
- package/packages/plugins/plugin-advertising-id/LICENSE +21 -0
- package/packages/plugins/plugin-advertising-id/README.md +40 -0
- package/packages/plugins/plugin-advertising-id/android/build.gradle +96 -0
- package/packages/plugins/plugin-advertising-id/android/gradle.properties +5 -0
- package/packages/plugins/plugin-advertising-id/android/src/main/AndroidManifest.xml +4 -0
- package/packages/plugins/plugin-advertising-id/android/src/main/AndroidManifestNew.xml +3 -0
- package/packages/plugins/plugin-advertising-id/android/src/main/java/com/reactnativeanalyticsreactnativepluginadvertisingid/AnalyticsReactNativePluginAdvertisingIdModule.kt +64 -0
- package/packages/plugins/plugin-advertising-id/android/src/main/java/com/reactnativeanalyticsreactnativepluginadvertisingid/AnalyticsReactNativePluginAdvertisingIdPackage.kt +17 -0
- package/packages/plugins/plugin-advertising-id/babel.config.js +3 -0
- package/packages/plugins/plugin-advertising-id/jest.config.js +5 -0
- package/packages/plugins/plugin-advertising-id/package.json +70 -0
- package/packages/plugins/plugin-advertising-id/release.config.js +3 -0
- package/packages/plugins/plugin-advertising-id/src/AdvertisingIdPlugin.ts +172 -0
- package/packages/plugins/plugin-advertising-id/src/index.ts +1 -0
- package/packages/plugins/plugin-advertising-id/src/types.ts +3 -0
- package/packages/plugins/plugin-advertising-id/tsconfig.json +10 -0
- package/packages/plugins/plugin-amplitudeSession/CHANGELOG.md +46 -0
- package/packages/plugins/plugin-amplitudeSession/LICENSE +21 -0
- package/packages/plugins/plugin-amplitudeSession/README.md +66 -0
- package/packages/plugins/plugin-amplitudeSession/babel.config.js +3 -0
- package/packages/plugins/plugin-amplitudeSession/jest.config.js +5 -0
- package/packages/plugins/plugin-amplitudeSession/package.json +71 -0
- package/packages/plugins/plugin-amplitudeSession/release.config.js +3 -0
- package/packages/plugins/plugin-amplitudeSession/src/AmplitudeSessionPlugin.tsx +327 -0
- package/packages/plugins/plugin-amplitudeSession/src/__tests__/AmplitudeSessionPlugin.test.ts +769 -0
- package/packages/plugins/plugin-amplitudeSession/src/index.ts +1 -0
- package/packages/plugins/plugin-amplitudeSession/tsconfig.json +10 -0
- package/packages/plugins/plugin-appsflyer/CHANGELOG.md +64 -0
- package/packages/plugins/plugin-appsflyer/LICENSE +21 -0
- package/packages/plugins/plugin-appsflyer/README.md +90 -0
- package/packages/plugins/plugin-appsflyer/babel.config.js +3 -0
- package/packages/plugins/plugin-appsflyer/jest.config.js +5 -0
- package/packages/plugins/plugin-appsflyer/package.json +74 -0
- package/packages/plugins/plugin-appsflyer/release.config.js +3 -0
- package/packages/plugins/plugin-appsflyer/src/AppsflyerPlugin.tsx +218 -0
- package/packages/plugins/plugin-appsflyer/src/__tests__/AppsflyerPlugin.test.ts +20 -0
- package/packages/plugins/plugin-appsflyer/src/index.ts +1 -0
- package/packages/plugins/plugin-appsflyer/src/methods/__mocks__/react-native-appsflyer.ts +11 -0
- package/packages/plugins/plugin-appsflyer/src/methods/__tests__/identify.test.ts +57 -0
- package/packages/plugins/plugin-appsflyer/src/methods/__tests__/track.test.ts +99 -0
- package/packages/plugins/plugin-appsflyer/src/methods/identify.ts +42 -0
- package/packages/plugins/plugin-appsflyer/src/methods/track.ts +61 -0
- package/packages/plugins/plugin-appsflyer/src/types.ts +9 -0
- package/packages/plugins/plugin-appsflyer/tsconfig.json +10 -0
- package/packages/plugins/plugin-branch/CHANGELOG.md +51 -0
- package/packages/plugins/plugin-branch/LICENSE +21 -0
- package/packages/plugins/plugin-branch/README.md +71 -0
- package/packages/plugins/plugin-branch/babel.config.js +3 -0
- package/packages/plugins/plugin-branch/jest.config.js +5 -0
- package/packages/plugins/plugin-branch/package.json +74 -0
- package/packages/plugins/plugin-branch/release.config.js +3 -0
- package/packages/plugins/plugin-branch/src/BranchPlugin.ts +42 -0
- package/packages/plugins/plugin-branch/src/index.ts +1 -0
- package/packages/plugins/plugin-branch/src/methods/__mocks__/react-native-branch.ts +16 -0
- package/packages/plugins/plugin-branch/src/methods/__tests__/alias.test.ts +23 -0
- package/packages/plugins/plugin-branch/src/methods/__tests__/identify.test.ts +23 -0
- package/packages/plugins/plugin-branch/src/methods/__tests__/screen.test.ts +38 -0
- package/packages/plugins/plugin-branch/src/methods/__tests__/track.test.ts +73 -0
- package/packages/plugins/plugin-branch/src/methods/alias.ts +9 -0
- package/packages/plugins/plugin-branch/src/methods/identify.ts +9 -0
- package/packages/plugins/plugin-branch/src/methods/parameterMapping.ts +109 -0
- package/packages/plugins/plugin-branch/src/methods/reset.ts +5 -0
- package/packages/plugins/plugin-branch/src/methods/screen.ts +17 -0
- package/packages/plugins/plugin-branch/src/methods/track.ts +18 -0
- package/packages/plugins/plugin-branch/src/methods/util.ts +64 -0
- package/packages/plugins/plugin-branch/tsconfig.json +10 -0
- package/packages/plugins/plugin-braze/CHANGELOG.md +101 -0
- package/packages/plugins/plugin-braze/LICENSE +21 -0
- package/packages/plugins/plugin-braze/README.md +72 -0
- package/packages/plugins/plugin-braze/babel.config.js +3 -0
- package/packages/plugins/plugin-braze/jest.config.js +5 -0
- package/packages/plugins/plugin-braze/package.json +74 -0
- package/packages/plugins/plugin-braze/release.config.js +3 -0
- package/packages/plugins/plugin-braze/src/BrazePlugin.tsx +346 -0
- package/packages/plugins/plugin-braze/src/index.ts +1 -0
- package/packages/plugins/plugin-braze/src/methods/__mocks__/@braze/react-native-sdk.ts +31 -0
- package/packages/plugins/plugin-braze/src/methods/__tests__/flush.test.ts +15 -0
- package/packages/plugins/plugin-braze/src/methods/__tests__/identify.test.ts +114 -0
- package/packages/plugins/plugin-braze/src/methods/__tests__/track.test.ts +321 -0
- package/packages/plugins/plugin-braze/src/methods/flush.ts +5 -0
- package/packages/plugins/plugin-braze/tsconfig.json +10 -0
- package/packages/plugins/plugin-braze-middleware/CHANGELOG.md +32 -0
- package/packages/plugins/plugin-braze-middleware/LICENSE +21 -0
- package/packages/plugins/plugin-braze-middleware/README.md +67 -0
- package/packages/plugins/plugin-braze-middleware/babel.config.js +3 -0
- package/packages/plugins/plugin-braze-middleware/jest.config.js +5 -0
- package/packages/plugins/plugin-braze-middleware/package.json +72 -0
- package/packages/plugins/plugin-braze-middleware/release.config.js +3 -0
- package/packages/plugins/plugin-braze-middleware/src/BrazeMiddlewarePlugin.tsx +38 -0
- package/packages/plugins/plugin-braze-middleware/src/index.ts +1 -0
- package/packages/plugins/plugin-braze-middleware/tsconfig.json +10 -0
- package/packages/plugins/plugin-clevertap/CHANGELOG.md +32 -0
- package/packages/plugins/plugin-clevertap/LICENSE +21 -0
- package/packages/plugins/plugin-clevertap/README.md +71 -0
- package/packages/plugins/plugin-clevertap/babel.config.js +3 -0
- package/packages/plugins/plugin-clevertap/jest.config.js +5 -0
- package/packages/plugins/plugin-clevertap/package.json +72 -0
- package/packages/plugins/plugin-clevertap/release.config.js +3 -0
- package/packages/plugins/plugin-clevertap/src/ClevertapPlugin.ts +75 -0
- package/packages/plugins/plugin-clevertap/src/__mocks__/clevertap-react-native.ts +5 -0
- package/packages/plugins/plugin-clevertap/src/__tests__/ClevertapPlugin.test.ts +164 -0
- package/packages/plugins/plugin-clevertap/src/index.ts +1 -0
- package/packages/plugins/plugin-clevertap/src/parameterMapping.ts +19 -0
- package/packages/plugins/plugin-clevertap/tsconfig.json +10 -0
- package/packages/plugins/plugin-destination-filters/CHANGELOG.md +39 -0
- package/packages/plugins/plugin-destination-filters/LICENSE +21 -0
- package/packages/plugins/plugin-destination-filters/README.md +71 -0
- package/packages/plugins/plugin-destination-filters/babel.config.js +3 -0
- package/packages/plugins/plugin-destination-filters/jest.config.js +5 -0
- package/packages/plugins/plugin-destination-filters/package.json +77 -0
- package/packages/plugins/plugin-destination-filters/release.config.js +3 -0
- package/packages/plugins/plugin-destination-filters/src/DestinationFilters.ts +90 -0
- package/packages/plugins/plugin-destination-filters/src/__tests__/DestinationFilters.test.ts +102 -0
- package/packages/plugins/plugin-destination-filters/src/index.tsx +1 -0
- package/packages/plugins/plugin-destination-filters/tsconfig.json +10 -0
- package/packages/plugins/plugin-device-token/CHANGELOG.md +71 -0
- package/packages/plugins/plugin-device-token/LICENSE +21 -0
- package/packages/plugins/plugin-device-token/README.md +98 -0
- package/packages/plugins/plugin-device-token/babel.config.js +3 -0
- package/packages/plugins/plugin-device-token/jest.config.js +5 -0
- package/packages/plugins/plugin-device-token/package.json +76 -0
- package/packages/plugins/plugin-device-token/release.config.js +3 -0
- package/packages/plugins/plugin-device-token/src/DeviceTokenPlugin.tsx +94 -0
- package/packages/plugins/plugin-device-token/src/index.ts +1 -0
- package/packages/plugins/plugin-device-token/src/methods/___tests__/DeviceTokenPlugin.test.ts +94 -0
- package/packages/plugins/plugin-device-token/tsconfig.json +10 -0
- package/packages/plugins/plugin-facebook-app-events/CHANGELOG.md +78 -0
- package/packages/plugins/plugin-facebook-app-events/LICENSE +21 -0
- package/packages/plugins/plugin-facebook-app-events/README.md +73 -0
- package/packages/plugins/plugin-facebook-app-events/babel.config.js +3 -0
- package/packages/plugins/plugin-facebook-app-events/jest.config.js +5 -0
- package/packages/plugins/plugin-facebook-app-events/package.json +72 -0
- package/packages/plugins/plugin-facebook-app-events/release.config.js +3 -0
- package/packages/plugins/plugin-facebook-app-events/src/FacebookAppEventsPlugin.ts +192 -0
- package/packages/plugins/plugin-facebook-app-events/src/__tests__/FacebookAppEventsPlugin.test.ts +284 -0
- package/packages/plugins/plugin-facebook-app-events/src/index.ts +1 -0
- package/packages/plugins/plugin-facebook-app-events/src/methods/__tests__/screen.test.ts +33 -0
- package/packages/plugins/plugin-facebook-app-events/src/methods/screen.ts +35 -0
- package/packages/plugins/plugin-facebook-app-events/src/parameterMapping.ts +46 -0
- package/packages/plugins/plugin-facebook-app-events/src/utils.ts +12 -0
- package/packages/plugins/plugin-facebook-app-events/tsconfig.json +10 -0
- package/packages/plugins/plugin-firebase/CHANGELOG.md +102 -0
- package/packages/plugins/plugin-firebase/LICENSE +21 -0
- package/packages/plugins/plugin-firebase/README.md +72 -0
- package/packages/plugins/plugin-firebase/babel.config.js +3 -0
- package/packages/plugins/plugin-firebase/jest.config.js +5 -0
- package/packages/plugins/plugin-firebase/package.json +74 -0
- package/packages/plugins/plugin-firebase/release.config.js +3 -0
- package/packages/plugins/plugin-firebase/src/FirebasePlugin.tsx +96 -0
- package/packages/plugins/plugin-firebase/src/index.ts +1 -0
- package/packages/plugins/plugin-firebase/src/methods/___tests__/identify.test.ts +73 -0
- package/packages/plugins/plugin-firebase/src/methods/___tests__/reset.test.ts +20 -0
- package/packages/plugins/plugin-firebase/src/methods/___tests__/screen.test.ts +33 -0
- package/packages/plugins/plugin-firebase/src/methods/___tests__/track.test.ts +85 -0
- package/packages/plugins/plugin-firebase/src/methods/parameterMapping.ts +45 -0
- package/packages/plugins/plugin-firebase/src/methods/reset.ts +5 -0
- package/packages/plugins/plugin-firebase/src/methods/screen.ts +12 -0
- package/packages/plugins/plugin-firebase/src/methods/track.ts +26 -0
- package/packages/plugins/plugin-firebase/tsconfig.json +10 -0
- package/packages/plugins/plugin-idfa/CHANGELOG.md +62 -0
- package/packages/plugins/plugin-idfa/LICENSE +21 -0
- package/packages/plugins/plugin-idfa/README.md +105 -0
- package/packages/plugins/plugin-idfa/babel.config.js +3 -0
- package/packages/plugins/plugin-idfa/ios/AnalyticsReactNativePluginIdfa-Bridging-Header.h +2 -0
- package/packages/plugins/plugin-idfa/ios/AnalyticsReactNativePluginIdfa.m +11 -0
- package/packages/plugins/plugin-idfa/ios/AnalyticsReactNativePluginIdfa.swift +68 -0
- package/packages/plugins/plugin-idfa/ios/AnalyticsReactNativePluginIdfa.xcodeproj/project.pbxproj +293 -0
- package/packages/plugins/plugin-idfa/jest.config.js +5 -0
- package/packages/plugins/plugin-idfa/package.json +70 -0
- package/packages/plugins/plugin-idfa/release.config.js +3 -0
- package/packages/plugins/plugin-idfa/segment-analytics-react-native-plugin-idfa.podspec +19 -0
- package/packages/plugins/plugin-idfa/src/AnalyticsReactNativePluginIdfa.e2e.mock.ts +12 -0
- package/packages/plugins/plugin-idfa/src/AnalyticsReactNativePluginIdfa.ts +18 -0
- package/packages/plugins/plugin-idfa/src/IdfaPlugin.tsx +80 -0
- package/packages/plugins/plugin-idfa/src/index.ts +1 -0
- package/packages/plugins/plugin-idfa/src/types.ts +13 -0
- package/packages/plugins/plugin-idfa/tsconfig.json +10 -0
- package/packages/plugins/plugin-mixpanel/CHANGELOG.md +73 -0
- package/packages/plugins/plugin-mixpanel/LICENSE +21 -0
- package/packages/plugins/plugin-mixpanel/README.md +71 -0
- package/packages/plugins/plugin-mixpanel/babel.config.js +3 -0
- package/packages/plugins/plugin-mixpanel/jest.config.js +5 -0
- package/packages/plugins/plugin-mixpanel/package.json +72 -0
- package/packages/plugins/plugin-mixpanel/release.config.js +3 -0
- package/packages/plugins/plugin-mixpanel/src/MixpanelPlugin.ts +106 -0
- package/packages/plugins/plugin-mixpanel/src/index.ts +1 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__mocks__/mixpanel-react-native.ts +67 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/MixpanelPlugin.test.ts +57 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/__helpers__/constants.ts +18 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/alias.test.ts +47 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/group.test.ts +49 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/identify.test.ts +103 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/screen.test.ts +119 -0
- package/packages/plugins/plugin-mixpanel/src/methods/__tests__/track.test.ts +110 -0
- package/packages/plugins/plugin-mixpanel/src/methods/alias.ts +28 -0
- package/packages/plugins/plugin-mixpanel/src/methods/group.ts +26 -0
- package/packages/plugins/plugin-mixpanel/src/methods/identify.ts +72 -0
- package/packages/plugins/plugin-mixpanel/src/methods/screen.ts +43 -0
- package/packages/plugins/plugin-mixpanel/src/methods/track.ts +60 -0
- package/packages/plugins/plugin-mixpanel/src/types.ts +15 -0
- package/packages/plugins/plugin-mixpanel/tsconfig.json +10 -0
- package/packages/plugins/plugin-onetrust/CHANGELOG.md +16 -0
- package/packages/plugins/plugin-onetrust/LICENSE +21 -0
- package/packages/plugins/plugin-onetrust/README.md +155 -0
- package/packages/plugins/plugin-onetrust/babel.config.js +3 -0
- package/packages/plugins/plugin-onetrust/jest.config.js +6 -0
- package/packages/plugins/plugin-onetrust/package.json +75 -0
- package/packages/plugins/plugin-onetrust/release.config.js +3 -0
- package/packages/plugins/plugin-onetrust/src/OneTrustProvider.ts +71 -0
- package/packages/plugins/plugin-onetrust/src/index.tsx +1 -0
- package/packages/plugins/plugin-onetrust/tsconfig.json +10 -0
- package/packages/shared/__mocks__/context.ts +35 -0
- package/packages/shared/__mocks__/react-native-get-random-values.ts +1 -0
- package/packages/shared/__mocks__/react-native.ts +53 -0
- package/packages/shared/__mocks__/uuid.ts +3 -0
- package/packages/shared/jest.config.base.js +38 -0
- package/packages/shared/package.json +19 -0
- package/packages/shared/src/setup.ts +7 -0
- package/packages/shared/tsconfig.json +15 -0
- package/packages/sovran/CHANGELOG.md +42 -0
- package/packages/sovran/CONTRIBUTING.md +196 -0
- package/packages/sovran/LICENSE +21 -0
- package/packages/sovran/README.md +174 -0
- package/packages/sovran/android/build.gradle +94 -0
- package/packages/sovran/android/gradle.properties +5 -0
- package/packages/sovran/android/src/main/AndroidManifest.xml +4 -0
- package/packages/sovran/android/src/main/AndroidManifestNew.xml +3 -0
- package/packages/sovran/android/src/main/java/com/reactnativesovran/Sovran.kt +45 -0
- package/packages/sovran/android/src/main/java/com/reactnativesovran/SovranModule.kt +55 -0
- package/packages/sovran/babel.config.js +3 -0
- package/packages/sovran/ios/Sovran-Bridging-Header.h +3 -0
- package/packages/sovran/ios/Sovran.m +8 -0
- package/packages/sovran/ios/Sovran.swift +67 -0
- package/packages/sovran/ios/Sovran.xcodeproj/project.pbxproj +279 -0
- package/packages/sovran/jest.config.js +5 -0
- package/packages/sovran/package.json +89 -0
- package/packages/sovran/release.config.js +3 -0
- package/packages/sovran/sovran-react-native.podspec +33 -0
- package/packages/sovran/src/__tests__/bridge.test.ts +39 -0
- package/packages/sovran/src/__tests__/index.test.tsx +1 -0
- package/packages/sovran/src/__tests__/store.test.ts +397 -0
- package/packages/sovran/src/bridge.ts +48 -0
- package/packages/sovran/src/index.tsx +52 -0
- package/packages/sovran/src/persistor/async-storage-persistor.ts +63 -0
- package/packages/sovran/src/persistor/index.ts +2 -0
- package/packages/sovran/src/persistor/persistor.ts +31 -0
- package/packages/sovran/src/store.ts +232 -0
- package/packages/sovran/tsconfig.json +9 -0
- package/release.config.js +13 -0
- package/tsconfig.json +44 -0
- package/tsconfig.linter.json +36 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
We want this community to be friendly and respectful to each other. Please follow it in all your interactions with the project.
|
|
4
|
+
|
|
5
|
+
## Development workflow
|
|
6
|
+
|
|
7
|
+
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
> While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development.
|
|
14
|
+
|
|
15
|
+
While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
|
|
16
|
+
|
|
17
|
+
To start the packager:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
yarn example start
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
To run the example app on Android:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
yarn example android
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To run the example app on iOS:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
yarn example ios
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Make sure your code passes TypeScript and ESLint. Run the following to verify:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
yarn typescript
|
|
39
|
+
yarn lint
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
To fix formatting errors, run the following:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
yarn lint --fix
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Remember to add tests for your change if possible. Run the unit tests by:
|
|
49
|
+
|
|
50
|
+
```sh
|
|
51
|
+
yarn test
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
To edit the Objective-C files, open `example/ios/SovranExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > sovran-react-native`.
|
|
55
|
+
|
|
56
|
+
To edit the Kotlin files, open `example/android` in Android studio and find the source files at `sovranreactnative` under `Android`.
|
|
57
|
+
|
|
58
|
+
### Commit message convention
|
|
59
|
+
|
|
60
|
+
We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
|
|
61
|
+
|
|
62
|
+
- `fix`: bug fixes, e.g. fix crash due to deprecated method.
|
|
63
|
+
- `feat`: new features, e.g. add new method to the module.
|
|
64
|
+
- `refactor`: code refactor, e.g. migrate from class components to hooks.
|
|
65
|
+
- `docs`: changes into documentation, e.g. add usage example for the module..
|
|
66
|
+
- `test`: adding or updating tests, e.g. add integration tests using detox.
|
|
67
|
+
- `chore`: tooling changes, e.g. change CI config.
|
|
68
|
+
|
|
69
|
+
Our pre-commit hooks verify that your commit message matches this format when committing.
|
|
70
|
+
|
|
71
|
+
### Linting and tests
|
|
72
|
+
|
|
73
|
+
[ESLint](https://eslint.org/), [Prettier](https://prettier.io/), [TypeScript](https://www.typescriptlang.org/)
|
|
74
|
+
|
|
75
|
+
We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.
|
|
76
|
+
|
|
77
|
+
Our pre-commit hooks verify that the linter and tests pass when committing.
|
|
78
|
+
|
|
79
|
+
### Publishing to npm
|
|
80
|
+
|
|
81
|
+
We use [release-it](https://github.com/release-it/release-it) to make it easier to publish new versions. It handles common tasks like bumping version based on semver, creating tags and releases etc.
|
|
82
|
+
|
|
83
|
+
To publish new versions, run the following:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
yarn release
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Scripts
|
|
90
|
+
|
|
91
|
+
The `package.json` file contains various scripts for common tasks:
|
|
92
|
+
|
|
93
|
+
- `yarn bootstrap`: setup project by installing all dependencies and pods.
|
|
94
|
+
- `yarn typescript`: type-check files with TypeScript.
|
|
95
|
+
- `yarn lint`: lint files with ESLint.
|
|
96
|
+
- `yarn test`: run unit tests with Jest.
|
|
97
|
+
- `yarn example start`: start the Metro server for the example app.
|
|
98
|
+
- `yarn example android`: run the example app on Android.
|
|
99
|
+
- `yarn example ios`: run the example app on iOS.
|
|
100
|
+
|
|
101
|
+
### Sending a pull request
|
|
102
|
+
|
|
103
|
+
> **Working on your first pull request?** You can learn how from this _free_ series: [How to Contribute to an Open Source Project on GitHub](https://app.egghead.io/playlists/how-to-contribute-to-an-open-source-project-on-github).
|
|
104
|
+
|
|
105
|
+
When you're sending a pull request:
|
|
106
|
+
|
|
107
|
+
- Prefer small pull requests focused on one change.
|
|
108
|
+
- Verify that linters and tests are passing.
|
|
109
|
+
- Review the documentation to make sure it looks good.
|
|
110
|
+
- Follow the pull request template when opening a pull request.
|
|
111
|
+
- For pull requests that change the API or implementation, discuss with maintainers first by opening an issue.
|
|
112
|
+
|
|
113
|
+
## Code of Conduct
|
|
114
|
+
|
|
115
|
+
### Our Pledge
|
|
116
|
+
|
|
117
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
118
|
+
|
|
119
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
|
120
|
+
|
|
121
|
+
### Our Standards
|
|
122
|
+
|
|
123
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
|
124
|
+
|
|
125
|
+
- Demonstrating empathy and kindness toward other people
|
|
126
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
127
|
+
- Giving and gracefully accepting constructive feedback
|
|
128
|
+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
|
129
|
+
- Focusing on what is best not just for us as individuals, but for the overall community
|
|
130
|
+
|
|
131
|
+
Examples of unacceptable behavior include:
|
|
132
|
+
|
|
133
|
+
- The use of sexualized language or imagery, and sexual attention or
|
|
134
|
+
advances of any kind
|
|
135
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
136
|
+
- Public or private harassment
|
|
137
|
+
- Publishing others' private information, such as a physical or email
|
|
138
|
+
address, without their explicit permission
|
|
139
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
|
140
|
+
professional setting
|
|
141
|
+
|
|
142
|
+
### Enforcement Responsibilities
|
|
143
|
+
|
|
144
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
145
|
+
|
|
146
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
|
147
|
+
|
|
148
|
+
### Scope
|
|
149
|
+
|
|
150
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
|
151
|
+
|
|
152
|
+
### Enforcement
|
|
153
|
+
|
|
154
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly.
|
|
155
|
+
|
|
156
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
|
157
|
+
|
|
158
|
+
### Enforcement Guidelines
|
|
159
|
+
|
|
160
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
|
161
|
+
|
|
162
|
+
#### 1. Correction
|
|
163
|
+
|
|
164
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
|
165
|
+
|
|
166
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
|
167
|
+
|
|
168
|
+
#### 2. Warning
|
|
169
|
+
|
|
170
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
|
171
|
+
|
|
172
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
|
173
|
+
|
|
174
|
+
#### 3. Temporary Ban
|
|
175
|
+
|
|
176
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
|
177
|
+
|
|
178
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
|
179
|
+
|
|
180
|
+
#### 4. Permanent Ban
|
|
181
|
+
|
|
182
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
|
183
|
+
|
|
184
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
|
185
|
+
|
|
186
|
+
### Attribution
|
|
187
|
+
|
|
188
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
|
189
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
190
|
+
|
|
191
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
|
192
|
+
|
|
193
|
+
[homepage]: https://www.contributor-covenant.org
|
|
194
|
+
|
|
195
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
196
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Oscar Bazaldua
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# @segment/sovran-react-native
|
|
2
|
+
|
|
3
|
+
A cross-platform lightweight local state management system designed for React Native.
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
Redux is a great global state management tool for React, but it's not a good fit when you need to have local state management at different scope levels.
|
|
8
|
+
|
|
9
|
+
The main advantages of Sovran vs Redux are:
|
|
10
|
+
|
|
11
|
+
- Sovran is lightweight and simple to use. Subscribing and dispatching actions is easy to setup.
|
|
12
|
+
- Sovran can manage state at different scope levels. From global to local to a single object.
|
|
13
|
+
- Sovran is designed to be used with React Native so it supports dispatching actions via the bridge native -> RN
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm install @segment/sovran-react-native
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
To use in JS/TS you just need to use `createStore` to create a sovran object.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createStore } from '@segment/sovran-react-native';
|
|
26
|
+
|
|
27
|
+
interface State {
|
|
28
|
+
count: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Create the sovran store with our type and initial state
|
|
32
|
+
const store = createStore<State>({
|
|
33
|
+
count: 0,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`createStore` accepts any object as a state.
|
|
38
|
+
You only need to pass the **initial state** as a parameter.
|
|
39
|
+
Returns a **Store** object:
|
|
40
|
+
|
|
41
|
+
### Store object
|
|
42
|
+
|
|
43
|
+
The returned store object has the following methods:
|
|
44
|
+
|
|
45
|
+
#### **subscribe(callback)**:
|
|
46
|
+
|
|
47
|
+
Subscribes a listener to updates on the store:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
const unsubscribe = store.subscribe((newState: State) => {
|
|
51
|
+
// do something with the new state
|
|
52
|
+
console.log(newState);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// When you want to get rid of the listener
|
|
56
|
+
unsubscribe();
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
#### **dispatch(action)**:
|
|
60
|
+
|
|
61
|
+
Dispatches an action to modify the state, actions can be async:
|
|
62
|
+
|
|
63
|
+
Remember to keep actions as pure functions.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
store.dispatch((state: State): State => {
|
|
67
|
+
return {
|
|
68
|
+
...state,
|
|
69
|
+
count: state.count + 1,
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### **getState()**:
|
|
75
|
+
|
|
76
|
+
Returns the current state on the store:
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
const currentState: State = store.getState();
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Native -> RN Updates
|
|
83
|
+
|
|
84
|
+
Sovran supports dispatching actions from native to RN. Very useful for brownfield apps.
|
|
85
|
+
|
|
86
|
+
To use this feature you first need to register which stores will listen to native updates and which actions can be sent from native:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { createStore, registerBridgeStore } from '@segment/sovran-react-native';
|
|
90
|
+
|
|
91
|
+
interface MessageQueue {
|
|
92
|
+
messages: string[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Create the sovran store with our type and initial state
|
|
96
|
+
const messages = createStore<MessageQueue>({
|
|
97
|
+
messages: [],
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Action to add new events
|
|
101
|
+
const addMessage = (message: Message) => (state: MessageQueue) =>
|
|
102
|
+
({ messages: [...state.messages, message] });
|
|
103
|
+
|
|
104
|
+
// Register the store to listen to native events
|
|
105
|
+
registerBridgeStore({
|
|
106
|
+
// Sets which store object is listenning
|
|
107
|
+
store: messages,
|
|
108
|
+
// Defines which action types can be sent from native and how to handle them
|
|
109
|
+
actions: {
|
|
110
|
+
'add-message': addMessage,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Now you are ready to send updates from native code!
|
|
116
|
+
|
|
117
|
+
### iOS
|
|
118
|
+
|
|
119
|
+
(Supports both Objective-C and Swift)
|
|
120
|
+
|
|
121
|
+
```objc
|
|
122
|
+
|
|
123
|
+
@import React;
|
|
124
|
+
@import sovran_react_native;
|
|
125
|
+
|
|
126
|
+
// ...
|
|
127
|
+
|
|
128
|
+
[Sovran dispatchWithAction:@"add-message" payload:@{ @"origin": @"Native", @"message": @"Hello from Objective-C!" }];
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Android
|
|
132
|
+
|
|
133
|
+
(Supports both Java and Kotlin)
|
|
134
|
+
|
|
135
|
+
```java
|
|
136
|
+
import com.sovranreactnative.Sovran;
|
|
137
|
+
|
|
138
|
+
public class MainApplication extends Application implements ReactApplication {
|
|
139
|
+
|
|
140
|
+
private Sovran sovran = new Sovran();
|
|
141
|
+
|
|
142
|
+
private final ReactNativeHost mReactNativeHost =
|
|
143
|
+
new ReactNativeHost(this) {
|
|
144
|
+
|
|
145
|
+
// Due to how Android registers modules for RN make sure you instantiate the Sovran Module package first and use the same one when you register it in you MainApplication
|
|
146
|
+
@Override
|
|
147
|
+
protected List<ReactPackage> getPackages() {
|
|
148
|
+
@SuppressWarnings("UnnecessaryLocalVariable")
|
|
149
|
+
List<ReactPackage> packages = new PackageList(this).getPackages();
|
|
150
|
+
// Register the same sovran object
|
|
151
|
+
packages.add(sovran);
|
|
152
|
+
return packages;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
// ...
|
|
157
|
+
|
|
158
|
+
Map<String, String> payload = new HashMap<>();
|
|
159
|
+
payload.put("origin", "Native");
|
|
160
|
+
payload.put("message", "Hello from Java/Kotlin!");
|
|
161
|
+
sovran.dispatch("add-message", payload);
|
|
162
|
+
|
|
163
|
+
//...
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
**Check out the Example project for a more in depth use case in an RN project!**
|
|
167
|
+
|
|
168
|
+
## Contributing
|
|
169
|
+
|
|
170
|
+
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : (project.properties["Sovran_kotlinVersion"]).toInteger()
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.2.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def isNewArchitectureEnabled() {
|
|
18
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
apply plugin: "com.android.library"
|
|
22
|
+
apply plugin: "kotlin-android"
|
|
23
|
+
|
|
24
|
+
if (isNewArchitectureEnabled()) {
|
|
25
|
+
apply plugin: "com.facebook.react"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
def getExtOrDefault(name) {
|
|
29
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Sovran_" + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Sovran_" + name]).toInteger()
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def supportsNamespace() {
|
|
37
|
+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
38
|
+
def major = parsed[0].toInteger()
|
|
39
|
+
def minor = parsed[1].toInteger()
|
|
40
|
+
|
|
41
|
+
// Namespace support was added in 7.3.0
|
|
42
|
+
return (major == 7 && minor >= 3) || major >= 8
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
android {
|
|
46
|
+
if (supportsNamespace()) {
|
|
47
|
+
namespace "com.sovranreactnative"
|
|
48
|
+
|
|
49
|
+
sourceSets {
|
|
50
|
+
main {
|
|
51
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
57
|
+
|
|
58
|
+
defaultConfig {
|
|
59
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
60
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
buildTypes {
|
|
65
|
+
release {
|
|
66
|
+
minifyEnabled false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
lintOptions {
|
|
71
|
+
disable "GradleCompatible"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compileOptions {
|
|
75
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
repositories {
|
|
81
|
+
mavenCentral()
|
|
82
|
+
google()
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
86
|
+
|
|
87
|
+
dependencies {
|
|
88
|
+
// For < 0.71, this will be from the local maven repo
|
|
89
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
90
|
+
//noinspection GradleDynamicVersion
|
|
91
|
+
implementation "com.facebook.react:react-native:+"
|
|
92
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
93
|
+
}
|
|
94
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package com.sovranreactnative
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.ReactPackage
|
|
5
|
+
import com.facebook.react.bridge.NativeModule
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
7
|
+
import com.facebook.react.uimanager.ViewManager
|
|
8
|
+
|
|
9
|
+
class Sovran : ReactPackage {
|
|
10
|
+
|
|
11
|
+
data class Action (val type: String, val payload: Map<String, Any?>)
|
|
12
|
+
|
|
13
|
+
private var isInitialized = false
|
|
14
|
+
private val queue = mutableListOf<Action>()
|
|
15
|
+
private var module: SovranModule? = null
|
|
16
|
+
|
|
17
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
18
|
+
module = SovranModule(reactContext)
|
|
19
|
+
|
|
20
|
+
module?.onInitialized = {
|
|
21
|
+
Log.v("SovranModule", "onInitialized queue: ${queue.size}")
|
|
22
|
+
isInitialized = true
|
|
23
|
+
queue.forEach {
|
|
24
|
+
module?.dispatch(it.type, it.payload)
|
|
25
|
+
}
|
|
26
|
+
queue.clear()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return listOf(module as NativeModule)
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
34
|
+
return emptyList()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun dispatch(action: String, payload: Map<String, Any?>) {
|
|
38
|
+
Log.v("SovranModule", "dispatch: $action isInitialized: $isInitialized")
|
|
39
|
+
if (isInitialized) {
|
|
40
|
+
module?.dispatch(action, payload)
|
|
41
|
+
} else {
|
|
42
|
+
queue.add(Action(action, payload))
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
package com.sovranreactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Arguments
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.Promise
|
|
8
|
+
import com.facebook.react.bridge.WritableMap
|
|
9
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
10
|
+
import com.facebook.react.module.annotations.ReactModule;
|
|
11
|
+
|
|
12
|
+
@ReactModule(name="Sovran")
|
|
13
|
+
class SovranModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
14
|
+
|
|
15
|
+
var onInitialized: () -> Unit = {};
|
|
16
|
+
|
|
17
|
+
override fun getName(): String {
|
|
18
|
+
return "Sovran"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
companion object {
|
|
22
|
+
const val ON_STORE_ACTION = "onStoreAction"
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override fun getConstants() = mapOf(
|
|
26
|
+
"ON_STORE_ACTION" to ON_STORE_ACTION
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
override fun initialize() {
|
|
30
|
+
super.initialize()
|
|
31
|
+
onInitialized()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Example method
|
|
35
|
+
// See https://reactnative.dev/docs/native-modules-android
|
|
36
|
+
@ReactMethod
|
|
37
|
+
fun addListener(eventName: String?) {
|
|
38
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ReactMethod
|
|
42
|
+
fun removeListeners(count: Int?) {
|
|
43
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
fun dispatch(action: String, payload: Map<String, Any?>) {
|
|
47
|
+
val map = mapOf(
|
|
48
|
+
"type" to action,
|
|
49
|
+
"payload" to payload
|
|
50
|
+
)
|
|
51
|
+
val event: WritableMap = Arguments.makeNativeMap(map)
|
|
52
|
+
reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
|
|
53
|
+
.emit(ON_STORE_ACTION, event)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React
|
|
2
|
+
|
|
3
|
+
struct Action {
|
|
4
|
+
var action: String
|
|
5
|
+
var payload: Any!
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@objc(Sovran)
|
|
9
|
+
public class Sovran: RCTEventEmitter {
|
|
10
|
+
|
|
11
|
+
@objc public static var emitter: RCTEventEmitter?
|
|
12
|
+
|
|
13
|
+
private static var isInitialized = false
|
|
14
|
+
|
|
15
|
+
private static var queue: [Action] = []
|
|
16
|
+
|
|
17
|
+
private static let onStoreActionEvent = "onStoreAction"
|
|
18
|
+
|
|
19
|
+
@objc override init() {
|
|
20
|
+
super.init()
|
|
21
|
+
Sovran.emitter = self
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@objc public override func constantsToExport() -> [AnyHashable : Any]! {
|
|
25
|
+
return ["ON_STORE_ACTION": Sovran.onStoreActionEvent]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override public static func requiresMainQueueSetup() -> Bool {
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@objc open override func supportedEvents() -> [String] {
|
|
33
|
+
[Sovran.onStoreActionEvent]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private static func sendStoreAction(_ action: Action) -> Void {
|
|
37
|
+
if let emitter = self.emitter {
|
|
38
|
+
emitter.sendEvent(withName: onStoreActionEvent, body: [
|
|
39
|
+
"type": action.action,
|
|
40
|
+
"payload": action.payload
|
|
41
|
+
])
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@objc public static func dispatch(action: String, payload: Any!) -> Void {
|
|
46
|
+
let actionObj = Action(action: action, payload: payload)
|
|
47
|
+
if isInitialized {
|
|
48
|
+
self.sendStoreAction(actionObj)
|
|
49
|
+
} else {
|
|
50
|
+
self.queue.append(actionObj)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@objc public override func startObserving() -> Void {
|
|
55
|
+
// Replay event queue
|
|
56
|
+
Sovran.isInitialized = true
|
|
57
|
+
for event in Sovran.queue {
|
|
58
|
+
Sovran.sendStoreAction(event)
|
|
59
|
+
}
|
|
60
|
+
Sovran.queue = []
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@objc public override func stopObserving() -> Void {
|
|
64
|
+
Sovran.isInitialized = false
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|