@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,96 @@
|
|
|
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["AnalyticsReactNative_kotlinVersion"]
|
|
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["AnalyticsReactNative_" + name]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
def getExtOrIntegerDefault(name) {
|
|
33
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AnalyticsReactNative_" + 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.segmentanalyticsreactnative"
|
|
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_11
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_11
|
|
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
|
+
// Requires sovran for communication
|
|
94
|
+
implementation project(path: ':segment_sovran-react-native')
|
|
95
|
+
}
|
|
96
|
+
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
package com.segmentanalyticsreactnative
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import android.app.Activity
|
|
5
|
+
import android.content.Context
|
|
6
|
+
import android.content.Intent
|
|
7
|
+
import android.content.pm.PackageInfo
|
|
8
|
+
import android.content.res.Resources
|
|
9
|
+
import android.media.MediaDrm
|
|
10
|
+
import android.net.ConnectivityManager
|
|
11
|
+
import android.net.NetworkCapabilities
|
|
12
|
+
import android.net.Uri
|
|
13
|
+
import android.os.Build
|
|
14
|
+
import android.util.Log
|
|
15
|
+
import androidx.core.content.pm.PackageInfoCompat
|
|
16
|
+
import com.facebook.react.ReactActivity
|
|
17
|
+
import com.facebook.react.ReactApplication
|
|
18
|
+
import com.facebook.react.bridge.*
|
|
19
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
20
|
+
import com.sovranreactnative.SovranModule
|
|
21
|
+
import java.lang.Exception
|
|
22
|
+
import java.util.*
|
|
23
|
+
import java.security.MessageDigest
|
|
24
|
+
import java.util.UUID
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
enum class ConnectionType {
|
|
28
|
+
Cellular, Unknown, Wifi
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@ReactModule(name="AnalyticsReactNative")
|
|
32
|
+
class AnalyticsReactNativeModule : ReactContextBaseJavaModule, ActivityEventListener, LifecycleEventListener {
|
|
33
|
+
|
|
34
|
+
var onInitialized: () -> Unit = {};
|
|
35
|
+
|
|
36
|
+
constructor(reactContext: ReactApplicationContext) : super(reactContext) {
|
|
37
|
+
this.pInfo = reactContext.packageManager.getPackageInfo(reactContext.packageName, 0)
|
|
38
|
+
// Listen for new intents when app is in the background
|
|
39
|
+
reactContext.addActivityEventListener(this)
|
|
40
|
+
// Listen for resume events when it is cold started, or in the background
|
|
41
|
+
reactContext.addLifecycleEventListener(this)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
override fun initialize() {
|
|
45
|
+
super.initialize()
|
|
46
|
+
onInitialized()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private var isColdLaunch = true
|
|
50
|
+
private val pInfo: PackageInfo
|
|
51
|
+
|
|
52
|
+
override fun getName(): String {
|
|
53
|
+
return "AnalyticsReactNative"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private fun getBuildNumber(): String {
|
|
57
|
+
return PackageInfoCompat.getLongVersionCode(pInfo).toString()
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fun ByteArray.toHexString() = joinToString("") { "%02x".format(it) }
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Workaround for not able to get device id on Android 10 or above using DRM API
|
|
64
|
+
* {@see https://stackoverflow.com/questions/58103580/android-10-imei-no-longer-available-on-api-29-looking-for-alternatives}
|
|
65
|
+
* {@see https://developer.android.com/training/articles/user-data-ids}
|
|
66
|
+
*/
|
|
67
|
+
private fun getUniqueId(collectDeviceId : Boolean): String? {
|
|
68
|
+
if (collectDeviceId) {
|
|
69
|
+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
|
|
70
|
+
return null
|
|
71
|
+
|
|
72
|
+
val WIDEVINE_UUID = UUID(-0x121074568629b532L, -0x5c37d8232ae2de13L)
|
|
73
|
+
var wvDrm: MediaDrm? = null
|
|
74
|
+
try {
|
|
75
|
+
wvDrm = MediaDrm(WIDEVINE_UUID)
|
|
76
|
+
val wideVineId = wvDrm.getPropertyByteArray(MediaDrm.PROPERTY_DEVICE_UNIQUE_ID)
|
|
77
|
+
val md = MessageDigest.getInstance("SHA-256")
|
|
78
|
+
md.update(wideVineId)
|
|
79
|
+
return md.digest().toHexString()
|
|
80
|
+
} catch (e: Exception) {
|
|
81
|
+
return null
|
|
82
|
+
} finally {
|
|
83
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
|
84
|
+
wvDrm?.close()
|
|
85
|
+
} else {
|
|
86
|
+
wvDrm?.release()
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private fun getConnectionType(context: Context): ConnectionType {
|
|
94
|
+
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager?
|
|
95
|
+
var result: ConnectionType = ConnectionType.Unknown
|
|
96
|
+
|
|
97
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
98
|
+
cm?.run {
|
|
99
|
+
cm.getNetworkCapabilities(cm.activeNetwork)?.run {
|
|
100
|
+
if (hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
|
|
101
|
+
result = ConnectionType.Wifi
|
|
102
|
+
} else if (hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
|
|
103
|
+
result = ConnectionType.Cellular
|
|
104
|
+
} else {
|
|
105
|
+
result = ConnectionType.Unknown
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
cm?.run {
|
|
111
|
+
cm.activeNetworkInfo?.run {
|
|
112
|
+
if (type == ConnectivityManager.TYPE_WIFI) {
|
|
113
|
+
result = ConnectionType.Wifi
|
|
114
|
+
} else if (type == ConnectivityManager.TYPE_MOBILE) {
|
|
115
|
+
result = ConnectionType.Cellular
|
|
116
|
+
} else {
|
|
117
|
+
result = ConnectionType.Unknown
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@ReactMethod
|
|
126
|
+
fun getContextInfo(config: ReadableMap, promise: Promise) {
|
|
127
|
+
val appName: String = reactApplicationContext.applicationInfo.loadLabel(reactApplicationContext.packageManager).toString()
|
|
128
|
+
val appVersion: String = pInfo.versionName.toString()
|
|
129
|
+
val buildNumber = getBuildNumber()
|
|
130
|
+
val bundleId = reactApplicationContext.packageName
|
|
131
|
+
|
|
132
|
+
val connectionType: ConnectionType = getConnectionType(reactApplicationContext)
|
|
133
|
+
val timezone: TimeZone = TimeZone.getDefault()
|
|
134
|
+
val currentLocale: Locale = Locale.getDefault()
|
|
135
|
+
val locale: String = "${currentLocale.language}-${currentLocale.country}"
|
|
136
|
+
|
|
137
|
+
val screenWidth = Resources.getSystem().displayMetrics.widthPixels
|
|
138
|
+
val screenHeight = Resources.getSystem().displayMetrics.heightPixels
|
|
139
|
+
|
|
140
|
+
val screenDensity = Resources.getSystem().displayMetrics.density;
|
|
141
|
+
|
|
142
|
+
val contextInfo: WritableMap = Arguments.createMap()
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
if (config.hasKey("collectDeviceId") && config.getBoolean("collectDeviceId")) {
|
|
146
|
+
val fallbackDeviceId = UUID.randomUUID().toString()
|
|
147
|
+
val deviceId = getUniqueId(config.hasKey("collectDeviceId") && config.getBoolean("collectDeviceId"))?: fallbackDeviceId
|
|
148
|
+
|
|
149
|
+
contextInfo.putString("deviceId", deviceId)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
contextInfo.putString("appName", appName)
|
|
153
|
+
contextInfo.putString("appVersion", appVersion)
|
|
154
|
+
contextInfo.putString("buildNumber", buildNumber)
|
|
155
|
+
contextInfo.putString("bundleId", bundleId)
|
|
156
|
+
|
|
157
|
+
contextInfo.putString("deviceName", Build.DEVICE)
|
|
158
|
+
contextInfo.putString("deviceType", "android")
|
|
159
|
+
contextInfo.putString("manufacturer", Build.MANUFACTURER)
|
|
160
|
+
contextInfo.putString("model", Build.MODEL)
|
|
161
|
+
|
|
162
|
+
contextInfo.putString("timezone", timezone.id)
|
|
163
|
+
contextInfo.putString("locale", locale)
|
|
164
|
+
contextInfo.putString("networkType", connectionType.toString().lowercase(currentLocale))
|
|
165
|
+
|
|
166
|
+
contextInfo.putString("osName", "Android")
|
|
167
|
+
contextInfo.putString("osVersion", Build.VERSION.RELEASE)
|
|
168
|
+
|
|
169
|
+
contextInfo.putInt("screenWidth", screenWidth)
|
|
170
|
+
contextInfo.putInt("screenHeight", screenHeight)
|
|
171
|
+
contextInfo.putDouble("screenDensity", screenDensity.toDouble())
|
|
172
|
+
|
|
173
|
+
promise.resolve(contextInfo)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
fun getReferrer(activity: Activity): Uri? {
|
|
177
|
+
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
|
178
|
+
activity.referrer
|
|
179
|
+
} else {
|
|
180
|
+
null
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
fun trackDeepLinks(intent: Intent?) {
|
|
185
|
+
if (intent == null || intent.data == null) {
|
|
186
|
+
Log.d(name, "No Intent data found")
|
|
187
|
+
return
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
val properties = Hashtable<String, String>()
|
|
191
|
+
|
|
192
|
+
if (reactApplicationContext.currentActivity == null) {
|
|
193
|
+
Log.d(name, "No activity found")
|
|
194
|
+
return
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
val referrer = getReferrer(reactApplicationContext.currentActivity!!)
|
|
198
|
+
|
|
199
|
+
if (referrer != null) {
|
|
200
|
+
val referringApplication = referrer.toString()
|
|
201
|
+
properties["referring_application"] = referringApplication
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
val uri = intent.data
|
|
205
|
+
try {
|
|
206
|
+
properties["url"] = uri.toString()
|
|
207
|
+
for (parameter in uri!!.queryParameterNames) {
|
|
208
|
+
val value = uri.getQueryParameter(parameter)
|
|
209
|
+
if (value != null && value.trim { it <= ' ' }.isNotEmpty()) {
|
|
210
|
+
properties[parameter] = value
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (e: Exception) {
|
|
214
|
+
// handle error
|
|
215
|
+
Log.d(name, "Error getting URL: ${e.message}")
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
Log.d(name, "Sending Deeplink data to store: uri=${uri}, referrer=${referrer}")
|
|
220
|
+
val sovran = (reactApplicationContext.currentActivity?.application as ReactApplication)
|
|
221
|
+
?.currentReactContext
|
|
222
|
+
?.getNativeModule(SovranModule::class.java)
|
|
223
|
+
sovran?.dispatch("add-deepLink-data", properties)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
fun setAnonymousId(anonymousId: String) {
|
|
229
|
+
val properties = Hashtable<String, String>()
|
|
230
|
+
properties["anonymousId"] = anonymousId
|
|
231
|
+
|
|
232
|
+
val currentContext = getReactApplicationContext()
|
|
233
|
+
|
|
234
|
+
if (currentContext != null) {
|
|
235
|
+
val sovran = currentContext.getNativeModule(SovranModule::class.java)
|
|
236
|
+
sovran?.dispatch("add-anonymous-id", properties)
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
override fun onActivityResult(activity: Activity, requestCode: Int, resultCode: Int, data: Intent?) {
|
|
241
|
+
// Do nothing
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
override fun onNewIntent(intent: Intent) {
|
|
245
|
+
Log.d(name, "onNewIntent = ${intent}")
|
|
246
|
+
trackDeepLinks(intent)
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
override fun onHostResume() {
|
|
250
|
+
if (reactApplicationContext.currentActivity != null && isColdLaunch) {
|
|
251
|
+
isColdLaunch = false
|
|
252
|
+
Log.d(name, "onHostResume = ${reactApplicationContext.currentActivity!!.intent}")
|
|
253
|
+
trackDeepLinks(reactApplicationContext.currentActivity!!.intent)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
override fun onHostPause() {
|
|
258
|
+
// Do nothing
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
override fun onHostDestroy() {
|
|
262
|
+
isColdLaunch = true
|
|
263
|
+
// Do nothing
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
package com.segmentanalyticsreactnative
|
|
2
|
+
|
|
3
|
+
import java.util.Arrays
|
|
4
|
+
import java.util.Collections
|
|
5
|
+
|
|
6
|
+
import com.facebook.react.ReactPackage
|
|
7
|
+
import com.facebook.react.bridge.NativeModule
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
+
import com.facebook.react.uimanager.ViewManager
|
|
10
|
+
import com.facebook.react.bridge.JavaScriptModule
|
|
11
|
+
|
|
12
|
+
class AnalyticsReactNativePackage : ReactPackage {
|
|
13
|
+
|
|
14
|
+
private var isInitialized = false
|
|
15
|
+
private var anonymousId: String? = null
|
|
16
|
+
private var module: AnalyticsReactNativeModule? = null
|
|
17
|
+
|
|
18
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
19
|
+
module = AnalyticsReactNativeModule(reactContext)
|
|
20
|
+
module?.onInitialized = {
|
|
21
|
+
isInitialized = true
|
|
22
|
+
anonymousId?.let { anonId ->
|
|
23
|
+
module?.setAnonymousId(anonId)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return listOf(module as NativeModule)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
30
|
+
return emptyList<ViewManager<*, *>>()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun setAnonymousId(nativeAnonymousId: String) {
|
|
34
|
+
if (isInitialized) {
|
|
35
|
+
anonymousId = nativeAnonymousId;
|
|
36
|
+
anonymousId?.let { anonId ->
|
|
37
|
+
module?.setAnonymousId(anonId)
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
anonymousId = nativeAnonymousId
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const packageJson = require('./package.json');
|
|
3
|
+
|
|
4
|
+
const body = `
|
|
5
|
+
export const libraryInfo = {
|
|
6
|
+
name: '${packageJson.name}',
|
|
7
|
+
version: '${packageJson.version}',
|
|
8
|
+
}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
fs.writeFile('./src/info.ts', body, function (err) {
|
|
12
|
+
if (err) {
|
|
13
|
+
return console.log(err);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
console.log('Configuration file has generated');
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#import <React/RCTBridgeModule.h>
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import CoreTelephony
|
|
2
|
+
import SystemConfiguration
|
|
3
|
+
import UIKit
|
|
4
|
+
import AdSupport
|
|
5
|
+
import sovran_react_native
|
|
6
|
+
|
|
7
|
+
enum ConnectionType: String {
|
|
8
|
+
case wifi = "wifi"
|
|
9
|
+
case cellular = "cellular"
|
|
10
|
+
case unknown = "unknown"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@objc(AnalyticsReactNative)
|
|
14
|
+
public class AnalyticsReactNative: NSObject {
|
|
15
|
+
|
|
16
|
+
@objc
|
|
17
|
+
static func requiresMainQueueSetup() -> Bool {
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func getAppName() -> String {
|
|
22
|
+
guard let displayName = Bundle.main.infoDictionary!["CFBundleDisplayName"] else {
|
|
23
|
+
return Bundle.main.infoDictionary!["CFBundleName"] as! String
|
|
24
|
+
}
|
|
25
|
+
return displayName as! String
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
func getDeviceModel() -> String {
|
|
29
|
+
var systemInfo = utsname()
|
|
30
|
+
uname(&systemInfo)
|
|
31
|
+
let machineMirror = Mirror(reflecting: systemInfo.machine)
|
|
32
|
+
return machineMirror.children.reduce("") { identifier, element in
|
|
33
|
+
guard let value = element.value as? Int8, value != 0 else { return identifier }
|
|
34
|
+
return identifier + String(UnicodeScalar(UInt8(value)))
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
func getDeviceId() -> String {
|
|
39
|
+
guard let deviceId = UIDevice.current.identifierForVendor else {
|
|
40
|
+
return "UNKNOWN_ID"
|
|
41
|
+
}
|
|
42
|
+
return deviceId.uuidString
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
func getNetworkType() -> ConnectionType {
|
|
46
|
+
guard let reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, "google.com") else {
|
|
47
|
+
return ConnectionType.unknown
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var flags = SCNetworkReachabilityFlags()
|
|
51
|
+
SCNetworkReachabilityGetFlags(reachability, &flags)
|
|
52
|
+
|
|
53
|
+
let isReachable = flags.contains(.reachable)
|
|
54
|
+
let isWWAN = flags.contains(.isWWAN)
|
|
55
|
+
|
|
56
|
+
if isReachable {
|
|
57
|
+
if isWWAN {
|
|
58
|
+
let networkInfo = CTTelephonyNetworkInfo()
|
|
59
|
+
|
|
60
|
+
if #available(iOS 12.1, *) {
|
|
61
|
+
let carrierType = networkInfo.serviceCurrentRadioAccessTechnology
|
|
62
|
+
guard let _ = carrierType?.first?.value else {
|
|
63
|
+
return ConnectionType.unknown
|
|
64
|
+
}
|
|
65
|
+
return ConnectionType.cellular
|
|
66
|
+
} else {
|
|
67
|
+
let carrierType = networkInfo.currentRadioAccessTechnology
|
|
68
|
+
if (carrierType == nil) {
|
|
69
|
+
return ConnectionType.unknown
|
|
70
|
+
}
|
|
71
|
+
return ConnectionType.cellular
|
|
72
|
+
}
|
|
73
|
+
} else {
|
|
74
|
+
return ConnectionType.wifi
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return ConnectionType.unknown
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@objc(getContextInfo:resolver:rejecter:)
|
|
82
|
+
func getContextInfo(config: NSDictionary, resolver resolve:RCTPromiseResolveBlock, rejecter reject:RCTPromiseRejectBlock) -> Void {
|
|
83
|
+
let infoDictionary = Bundle.main.infoDictionary!
|
|
84
|
+
|
|
85
|
+
let appName = getAppName()
|
|
86
|
+
let appVersion = infoDictionary["CFBundleShortVersionString"] as? String ?? ""
|
|
87
|
+
let bundleId = Bundle.main.bundleIdentifier ?? ""
|
|
88
|
+
let buildNumber = infoDictionary["CFBundleVersion"] as? String ?? ""
|
|
89
|
+
|
|
90
|
+
let connectionType: ConnectionType = getNetworkType()
|
|
91
|
+
var locale = ""
|
|
92
|
+
if let languageCode = NSLocale.current.languageCode,
|
|
93
|
+
let regionCode = NSLocale.current.regionCode {
|
|
94
|
+
locale = "\(languageCode)-\(regionCode)"
|
|
95
|
+
}
|
|
96
|
+
let timezone = TimeZone.current.identifier
|
|
97
|
+
|
|
98
|
+
let osName = UIDevice.current.systemName
|
|
99
|
+
let osVersion = UIDevice.current.systemVersion
|
|
100
|
+
|
|
101
|
+
let screenWidth = Int(UIScreen.main.bounds.size.width)
|
|
102
|
+
let screenHeight = Int(UIScreen.main.bounds.size.height)
|
|
103
|
+
|
|
104
|
+
let context: [String: Any] = [
|
|
105
|
+
"appName": appName,
|
|
106
|
+
"appVersion": appVersion,
|
|
107
|
+
"buildNumber": buildNumber,
|
|
108
|
+
"bundleId": bundleId,
|
|
109
|
+
|
|
110
|
+
"deviceId": getDeviceId(),
|
|
111
|
+
"deviceName": UIDevice.current.model,
|
|
112
|
+
"deviceType": "ios",
|
|
113
|
+
"manufacturer": "Apple",
|
|
114
|
+
"model": getDeviceModel(),
|
|
115
|
+
|
|
116
|
+
"locale": locale,
|
|
117
|
+
"networkType": "\(connectionType)",
|
|
118
|
+
"timezone": timezone,
|
|
119
|
+
|
|
120
|
+
"osName": osName,
|
|
121
|
+
"osVersion": osVersion,
|
|
122
|
+
|
|
123
|
+
"screenWidth": screenWidth,
|
|
124
|
+
"screenHeight": screenHeight
|
|
125
|
+
]
|
|
126
|
+
resolve(context)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
@objc(trackDeepLink:withOptions:)
|
|
130
|
+
public static func trackDeepLink(url: NSURL, options: Dictionary<UIApplication.OpenURLOptionsKey, Any>) -> Void {
|
|
131
|
+
let urlString = url.absoluteString
|
|
132
|
+
let referringApp = options[.sourceApplication] as? String ?? ""
|
|
133
|
+
Sovran.dispatch(action: "add-deepLink-data", payload: [ "referring_application": referringApp, "url":urlString])
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@objc(setAnonymousId:)
|
|
137
|
+
public static func setAnonymousId(anonymousId: String) -> Void {
|
|
138
|
+
|
|
139
|
+
Sovran.dispatch(action: "add-anonymous-id", payload: ["anonymousId": anonymousId])
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
}
|