@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,80 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ErrorType,
|
|
3
|
+
Plugin,
|
|
4
|
+
PluginType,
|
|
5
|
+
SegmentClient,
|
|
6
|
+
SegmentError,
|
|
7
|
+
} from '@segment/analytics-react-native';
|
|
8
|
+
import type { IdfaData } from './types';
|
|
9
|
+
import { AnalyticsReactNativePluginIdfa } from './AnalyticsReactNativePluginIdfa';
|
|
10
|
+
import { Platform } from 'react-native';
|
|
11
|
+
|
|
12
|
+
const { getTrackingAuthorizationStatus } = AnalyticsReactNativePluginIdfa;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* IDFA Plugin
|
|
16
|
+
* @constructor
|
|
17
|
+
* @param {boolean} shouldAskPermission - defaults to true. Passing false
|
|
18
|
+
* when initializing new `IDFA Plugin` will prevent plugin from
|
|
19
|
+
* requesting tracking status
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export class IdfaPlugin extends Plugin {
|
|
23
|
+
type = PluginType.enrichment;
|
|
24
|
+
|
|
25
|
+
private shouldAskPermission = true;
|
|
26
|
+
|
|
27
|
+
constructor(shouldAskPermission = true) {
|
|
28
|
+
super();
|
|
29
|
+
this.shouldAskPermission = shouldAskPermission;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
configure(analytics: SegmentClient): void {
|
|
33
|
+
this.analytics = analytics;
|
|
34
|
+
if (Platform.OS !== 'ios') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.shouldAskPermission === true) {
|
|
39
|
+
this.getTrackingStatus();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** `requestTrackingPermission()` will prompt the user for
|
|
44
|
+
tracking permission and returns a promise you can use to
|
|
45
|
+
make additional tracking decisions based on the user response
|
|
46
|
+
*/
|
|
47
|
+
async requestTrackingPermission(): Promise<boolean> {
|
|
48
|
+
try {
|
|
49
|
+
const idfaData: IdfaData = await getTrackingAuthorizationStatus();
|
|
50
|
+
|
|
51
|
+
await this.analytics?.context.set({ device: { ...idfaData } });
|
|
52
|
+
return idfaData.adTrackingEnabled;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
this.analytics?.reportInternalError(
|
|
55
|
+
new SegmentError(ErrorType.PluginError, JSON.stringify(error), error)
|
|
56
|
+
);
|
|
57
|
+
this.analytics?.logger.warn(error);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getTrackingStatus() {
|
|
63
|
+
getTrackingAuthorizationStatus()
|
|
64
|
+
.then((idfa: IdfaData) => {
|
|
65
|
+
// update our context with the idfa data
|
|
66
|
+
void this.analytics?.context.set({ device: { ...idfa } });
|
|
67
|
+
return idfa;
|
|
68
|
+
})
|
|
69
|
+
.catch((error) => {
|
|
70
|
+
this.analytics?.reportInternalError(
|
|
71
|
+
new SegmentError(
|
|
72
|
+
ErrorType.PluginError,
|
|
73
|
+
'Error retreiving IDFA',
|
|
74
|
+
error
|
|
75
|
+
)
|
|
76
|
+
);
|
|
77
|
+
this.analytics?.logger.warn(error);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './IdfaPlugin';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export enum TrackingStatus {
|
|
2
|
+
Authorized = 'authorized',
|
|
3
|
+
Denied = 'denied',
|
|
4
|
+
NotDetermined = 'notDetermined',
|
|
5
|
+
Restricted = 'restricted',
|
|
6
|
+
Unknown = 'unknown',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type IdfaData = {
|
|
10
|
+
adTrackingEnabled: boolean;
|
|
11
|
+
advertisingId: string;
|
|
12
|
+
trackingStatus: TrackingStatus;
|
|
13
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
### Dependencies
|
|
2
|
+
|
|
3
|
+
* **@segment/analytics-react-native:** upgraded to 2.18.0
|
|
4
|
+
* **@segment/sovran-react-native:** upgraded to 1.1.0
|
|
5
|
+
|
|
6
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.3.4](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.3.3...@segment/analytics-react-native-plugin-mixpanel-v0.3.4) (2023-09-14)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* package dependency fixes ([#869](https://github.com/segmentio/analytics-react-native/issues/869)) ([08d415e](https://github.com/segmentio/analytics-react-native/commit/08d415e3b1cfd8499f5f6984f2859a30a851da12))
|
|
12
|
+
|
|
13
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.3.3](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.3.2...@segment/analytics-react-native-plugin-mixpanel-v0.3.3) (2023-06-02)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* fix flush policies reference copy, add BackgroundPolicy ([#838](https://github.com/segmentio/analytics-react-native/issues/838)) ([e4b558a](https://github.com/segmentio/analytics-react-native/commit/e4b558a95e250b1b21d677e08ffeb02a4015bda6))
|
|
19
|
+
|
|
20
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.3.2](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.3.1...@segment/analytics-react-native-plugin-mixpanel-v0.3.2) (2023-04-18)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* stricter linting, improved handling of plugin errrors ([#795](https://github.com/segmentio/analytics-react-native/issues/795)) ([1ddb4d5](https://github.com/segmentio/analytics-react-native/commit/1ddb4d571df794bc7eaa5c5302ed27b90faf9a73)), closes [#799](https://github.com/segmentio/analytics-react-native/issues/799) [#803](https://github.com/segmentio/analytics-react-native/issues/803) [#802](https://github.com/segmentio/analytics-react-native/issues/802)
|
|
26
|
+
|
|
27
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.3.1](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.3.0...@segment/analytics-react-native-plugin-mixpanel-v0.3.1) (2023-03-15)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Bug Fixes
|
|
31
|
+
|
|
32
|
+
* switching UUID library, new depedencies ([#772](https://github.com/segmentio/analytics-react-native/issues/772)) ([4734389](https://github.com/segmentio/analytics-react-native/commit/4734389dd6c9debd08f6be0b59d3192428586ed9))
|
|
33
|
+
|
|
34
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.3.0](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.2.4...@segment/analytics-react-native-plugin-mixpanel-v0.3.0) (2023-01-09)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* added errorHandler option to client ([#713](https://github.com/segmentio/analytics-react-native/issues/713)) ([b95788b](https://github.com/segmentio/analytics-react-native/commit/b95788ba8ecb547ffc9f43ba94f628c25f3660d1))
|
|
40
|
+
|
|
41
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.2.4](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.2.3...@segment/analytics-react-native-plugin-mixpanel-v0.2.4) (2022-11-01)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* update mixpanel dependency to 2.0.1 ([#686](https://github.com/segmentio/analytics-react-native/issues/686)) ([511d6ac](https://github.com/segmentio/analytics-react-native/commit/511d6ac33d1fbe203776335c6cbc173ecfbb84b6))
|
|
47
|
+
|
|
48
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.2.3](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.2.2...@segment/analytics-react-native-plugin-mixpanel-v0.2.3) (2022-09-13)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Bug Fixes
|
|
52
|
+
|
|
53
|
+
* setting screen name as name property in mixpanel ([#672](https://github.com/segmentio/analytics-react-native/issues/672)) ([bf26f0b](https://github.com/segmentio/analytics-react-native/commit/bf26f0b3bb98f10fb96e0ff3a4f8d321e38ad39a))
|
|
54
|
+
|
|
55
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.2.2](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.2.1...@segment/analytics-react-native-plugin-mixpanel-v0.2.2) (2022-07-28)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* Add AdvertisingId Plugin ([#574](https://github.com/segmentio/analytics-react-native/issues/574)) ([9f47e67](https://github.com/segmentio/analytics-react-native/commit/9f47e67906c658519e13c022a19c3f4640622ad6))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
* replace allSettled shim, fix imports from plugins ([#620](https://github.com/segmentio/analytics-react-native/issues/620)) ([18f8ecd](https://github.com/segmentio/analytics-react-native/commit/18f8ecdb291d8c5ecb02e087aa0043df4fc72e97))
|
|
66
|
+
|
|
67
|
+
## [@segment/analytics-react-native-plugin-mixpanel-v0.2.1](https://github.com/segmentio/analytics-react-native/compare/@segment/analytics-react-native-plugin-mixpanel-v0.2.0...@segment/analytics-react-native-plugin-mixpanel-v0.2.1) (2022-06-24)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Bug Fixes
|
|
71
|
+
|
|
72
|
+
* import MixpanelPlugin from the right package ([#562](https://github.com/segmentio/analytics-react-native/issues/562)) ([d1b6af1](https://github.com/segmentio/analytics-react-native/commit/d1b6af1f0133549069cb0fb92e32f96a7ca43bf7))
|
|
73
|
+
* persist user traits across events ([#581](https://github.com/segmentio/analytics-react-native/issues/581)) ([d48ac83](https://github.com/segmentio/analytics-react-native/commit/d48ac834000a4a81524b30ec1e386f337d55adf2))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Segment
|
|
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,71 @@
|
|
|
1
|
+
# @segment/analytics-react-native-plugin-mixpanel
|
|
2
|
+
|
|
3
|
+
`DestinationPlugin` for [Mixpanel](https://https://mixpanel.com/). Wraps [`mixpanel-react-native`](https://github.com/mixpanel/mixpanel-react-native).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
You need to install the `@segment/analytics-react-native-plugin-mixpanel` and the `mixpanel-react-native` dependency.
|
|
8
|
+
|
|
9
|
+
Using NPM:
|
|
10
|
+
```bash
|
|
11
|
+
npm install --save @segment/analytics-react-native-plugin-mixpanel mixpanel-react-native
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Using Yarn:
|
|
15
|
+
```bash
|
|
16
|
+
yarn add @segment/analytics-react-native-plugin-mixpanel mixpanel-react-native
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Run `pod install` after the installation to autolink the Mixpanel SDK.
|
|
20
|
+
|
|
21
|
+
See [Mixpanel React Native SDK](https://github.com/mixpanel/mixpanel-react-native) for more details of this dependency.
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Follow the [instructions for adding plugins](https://github.com/segmentio/analytics-react-native#adding-plugins) on the main Analytics client:
|
|
25
|
+
|
|
26
|
+
In your code where you initialize the analytics client call the `.add(plugin)` method with an `MixpanelPlugin` instance:
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createClient } from '@segment/analytics-react-native';
|
|
30
|
+
|
|
31
|
+
import { MixpanelPlugin } from '@segment/analytics-react-native-plugin-mixpanel';
|
|
32
|
+
|
|
33
|
+
const segmentClient = createClient({
|
|
34
|
+
writeKey: 'SEGMENT_KEY'
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
segmentClient.add({ plugin: new MixpanelPlugin() });
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Support
|
|
41
|
+
|
|
42
|
+
Please use Github issues, Pull Requests, or feel free to reach out to our [support team](https://segment.com/help/).
|
|
43
|
+
|
|
44
|
+
## Integrating with Segment
|
|
45
|
+
|
|
46
|
+
Interested in integrating your service with us? Check out our [Partners page](https://segment.com/partners/) for more details.
|
|
47
|
+
|
|
48
|
+
## License
|
|
49
|
+
```
|
|
50
|
+
MIT License
|
|
51
|
+
|
|
52
|
+
Copyright (c) 2021 Segment
|
|
53
|
+
|
|
54
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
55
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
56
|
+
in the Software without restriction, including without limitation the rights
|
|
57
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
58
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
59
|
+
furnished to do so, subject to the following conditions:
|
|
60
|
+
|
|
61
|
+
The above copyright notice and this permission notice shall be included in all
|
|
62
|
+
copies or substantial portions of the Software.
|
|
63
|
+
|
|
64
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
65
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
66
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
67
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
68
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
69
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
70
|
+
SOFTWARE.
|
|
71
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@segment/analytics-react-native-plugin-mixpanel",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "The hassle-free way to add Segment analytics to your React-Native app.",
|
|
5
|
+
"main": "lib/commonjs/index",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "bob build",
|
|
8
|
+
"test": "jest",
|
|
9
|
+
"typescript": "tsc --noEmit",
|
|
10
|
+
"clean": "rimraf lib node_modules"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"segment",
|
|
14
|
+
"react-native",
|
|
15
|
+
"ios",
|
|
16
|
+
"android"
|
|
17
|
+
],
|
|
18
|
+
"module": "lib/module/index",
|
|
19
|
+
"types": "lib/typescript/src/index.d.ts",
|
|
20
|
+
"react-native": "src/index",
|
|
21
|
+
"source": "src/index",
|
|
22
|
+
"files": [
|
|
23
|
+
"src",
|
|
24
|
+
"lib",
|
|
25
|
+
"android",
|
|
26
|
+
"ios",
|
|
27
|
+
"cpp",
|
|
28
|
+
"segment-analytics-react-native.podspec",
|
|
29
|
+
"package.json",
|
|
30
|
+
"!src/**/*.e2e.mock.js",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__"
|
|
34
|
+
],
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "https://github.com/segmentio/analytics-react-native.git",
|
|
38
|
+
"directory": "packages/core"
|
|
39
|
+
},
|
|
40
|
+
"author": "Segment <hello@segment.com> (https://segment.com/)",
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/segmentio/analytics-react-native/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/segmentio/analytics-react-native/tree/master/packages/plugins/plugin-mixpanel#readme",
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@segment/analytics-react-native": "^2.18.0",
|
|
48
|
+
"mixpanel-react-native": "^2.1.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@segment/analytics-react-native": "^2.18.0",
|
|
52
|
+
"@segment/analytics-rn-shared": "workspace:^",
|
|
53
|
+
"@segment/sovran-react-native": "^1.1.0",
|
|
54
|
+
"jest": "^29.7.0",
|
|
55
|
+
"mixpanel-react-native": "^2.1.0",
|
|
56
|
+
"react-native-builder-bob": "^0.23.1",
|
|
57
|
+
"rimraf": "^5.0.5",
|
|
58
|
+
"typescript": "^5.2.2"
|
|
59
|
+
},
|
|
60
|
+
"react-native-builder-bob": {
|
|
61
|
+
"source": "src",
|
|
62
|
+
"output": "lib",
|
|
63
|
+
"targets": [
|
|
64
|
+
"commonjs",
|
|
65
|
+
"module",
|
|
66
|
+
"typescript"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=12"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DestinationPlugin,
|
|
3
|
+
PluginType,
|
|
4
|
+
TrackEventType,
|
|
5
|
+
ScreenEventType,
|
|
6
|
+
SegmentAPISettings,
|
|
7
|
+
UpdateType,
|
|
8
|
+
IdentifyEventType,
|
|
9
|
+
GroupEventType,
|
|
10
|
+
JsonMap,
|
|
11
|
+
AliasEventType,
|
|
12
|
+
SegmentError,
|
|
13
|
+
ErrorType,
|
|
14
|
+
} from '@segment/analytics-react-native';
|
|
15
|
+
import type { SegmentMixpanelSettings } from './types';
|
|
16
|
+
import { Mixpanel } from 'mixpanel-react-native';
|
|
17
|
+
import identify from './methods/identify';
|
|
18
|
+
import screen from './methods/screen';
|
|
19
|
+
import group from './methods/group';
|
|
20
|
+
import alias from './methods/alias';
|
|
21
|
+
import track from './methods/track';
|
|
22
|
+
|
|
23
|
+
export const EU_SERVER = 'api.eu.mixpanel.com';
|
|
24
|
+
export class MixpanelPlugin extends DestinationPlugin {
|
|
25
|
+
type = PluginType.destination;
|
|
26
|
+
key = 'Mixpanel';
|
|
27
|
+
trackScreens = false;
|
|
28
|
+
private mixpanel: Mixpanel | undefined;
|
|
29
|
+
private settings: SegmentMixpanelSettings | undefined;
|
|
30
|
+
private isInitialized = () =>
|
|
31
|
+
this.mixpanel !== undefined && this.settings !== undefined;
|
|
32
|
+
|
|
33
|
+
update(settings: SegmentAPISettings, _: UpdateType) {
|
|
34
|
+
const mixpanelSettings = settings.integrations[
|
|
35
|
+
this.key
|
|
36
|
+
] as SegmentMixpanelSettings;
|
|
37
|
+
|
|
38
|
+
if (mixpanelSettings === undefined || this.mixpanel !== undefined) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (mixpanelSettings.token.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.mixpanel = new Mixpanel(mixpanelSettings.token, false);
|
|
45
|
+
this.mixpanel.init().catch((error) => {
|
|
46
|
+
this.analytics?.reportInternalError(
|
|
47
|
+
new SegmentError(
|
|
48
|
+
ErrorType.PluginError,
|
|
49
|
+
'Error initializing Mixpanel',
|
|
50
|
+
error
|
|
51
|
+
)
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
this.settings = mixpanelSettings;
|
|
55
|
+
|
|
56
|
+
if (mixpanelSettings.enableEuropeanEndpoint === true) {
|
|
57
|
+
this.mixpanel?.setServerURL(EU_SERVER);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
identify(event: IdentifyEventType) {
|
|
62
|
+
if (this.isInitialized()) {
|
|
63
|
+
identify(event, this.mixpanel!, this.settings!);
|
|
64
|
+
}
|
|
65
|
+
return event;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
track(event: TrackEventType) {
|
|
69
|
+
const eventName = event.event;
|
|
70
|
+
const properties = event.properties as JsonMap;
|
|
71
|
+
|
|
72
|
+
if (this.isInitialized()) {
|
|
73
|
+
track(eventName, properties, this.settings!, this.mixpanel!);
|
|
74
|
+
}
|
|
75
|
+
return event;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
screen(event: ScreenEventType) {
|
|
79
|
+
if (this.isInitialized()) {
|
|
80
|
+
screen(event, this.mixpanel!, this.settings!);
|
|
81
|
+
}
|
|
82
|
+
return event;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
group(event: GroupEventType) {
|
|
86
|
+
if (this.isInitialized()) {
|
|
87
|
+
group(event, this.mixpanel!, this.settings!);
|
|
88
|
+
}
|
|
89
|
+
return event;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
async alias(event: AliasEventType) {
|
|
93
|
+
if (this.mixpanel !== undefined && this.analytics !== undefined) {
|
|
94
|
+
await alias(event, this.mixpanel, this.analytics);
|
|
95
|
+
}
|
|
96
|
+
return event;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
flush(): void {
|
|
100
|
+
this.mixpanel?.flush();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
reset(): void {
|
|
104
|
+
this.mixpanel?.reset();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './MixpanelPlugin';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const initMock = jest.fn().mockResolvedValue(undefined);
|
|
2
|
+
export const setServerMock = jest.fn();
|
|
3
|
+
export const identifyMock = jest.fn();
|
|
4
|
+
export const aliasMock = jest.fn();
|
|
5
|
+
export const trackMock = jest.fn();
|
|
6
|
+
export const trackWithGroupsMock = jest.fn();
|
|
7
|
+
export const setGroupMock = jest.fn();
|
|
8
|
+
|
|
9
|
+
export class Mixpanel {
|
|
10
|
+
public token: string;
|
|
11
|
+
|
|
12
|
+
constructor(token: string) {
|
|
13
|
+
this.token = token;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
init = initMock;
|
|
17
|
+
setServerURL = setServerMock;
|
|
18
|
+
setLoggingEnabled = jest.fn();
|
|
19
|
+
setUseIpAddressForGeolocation = jest.fn();
|
|
20
|
+
hasOptedOutTracking = jest.fn();
|
|
21
|
+
optInTracking = jest.fn();
|
|
22
|
+
optOutTracking = jest.fn();
|
|
23
|
+
identify = identifyMock;
|
|
24
|
+
alias = aliasMock;
|
|
25
|
+
track = trackMock;
|
|
26
|
+
getPeople = () => new People();
|
|
27
|
+
trackWithGroups = trackWithGroupsMock;
|
|
28
|
+
setGroup = setGroupMock;
|
|
29
|
+
getGroup = () => new MixpanelGroup();
|
|
30
|
+
addGroup = jest.fn();
|
|
31
|
+
removeGroup = jest.fn();
|
|
32
|
+
deleteGroup = jest.fn();
|
|
33
|
+
registerSuperProperties = jest.fn();
|
|
34
|
+
registerSuperPropertiesOnce = jest.fn();
|
|
35
|
+
unregisterSuperProperty = jest.fn();
|
|
36
|
+
getSuperProperties = jest.fn();
|
|
37
|
+
clearSuperProperties = jest.fn();
|
|
38
|
+
timeEvent = jest.fn();
|
|
39
|
+
eventElapsedTime = jest.fn();
|
|
40
|
+
reset = jest.fn();
|
|
41
|
+
getDistinctId = jest.fn(() => Promise.resolve('mixpanelId'));
|
|
42
|
+
flush = jest.fn();
|
|
43
|
+
getDeviceId = jest.fn();
|
|
44
|
+
setFlushOnBackground = jest.fn();
|
|
45
|
+
setFlushBatchSize = jest.fn();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class People {
|
|
49
|
+
set = jest.fn();
|
|
50
|
+
setOnce = jest.fn();
|
|
51
|
+
increment = jest.fn();
|
|
52
|
+
append = jest.fn();
|
|
53
|
+
union = jest.fn();
|
|
54
|
+
remove = jest.fn();
|
|
55
|
+
unset = jest.fn();
|
|
56
|
+
trackCharge = jest.fn();
|
|
57
|
+
clearCharges = jest.fn();
|
|
58
|
+
deleteUser = jest.fn();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class MixpanelGroup {
|
|
62
|
+
set = jest.fn();
|
|
63
|
+
setOnce = jest.fn();
|
|
64
|
+
unset = jest.fn();
|
|
65
|
+
remove = jest.fn();
|
|
66
|
+
union = jest.fn();
|
|
67
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { SegmentClient, UpdateType } from '@segment/analytics-react-native';
|
|
2
|
+
import {
|
|
3
|
+
getMockLogger,
|
|
4
|
+
MockSegmentStore,
|
|
5
|
+
} from '@segment/analytics-react-native/src/test-helpers';
|
|
6
|
+
|
|
7
|
+
import { EU_SERVER, MixpanelPlugin } from '../../MixpanelPlugin';
|
|
8
|
+
import { initMock, setServerMock } from '../__mocks__/mixpanel-react-native';
|
|
9
|
+
import { sampleIntegrationSettings } from './__helpers__/constants';
|
|
10
|
+
|
|
11
|
+
jest.mock('mixpanel-react-native');
|
|
12
|
+
|
|
13
|
+
describe('MixpanelPlugin', () => {
|
|
14
|
+
const store = new MockSegmentStore();
|
|
15
|
+
const clientArgs = {
|
|
16
|
+
logger: getMockLogger(),
|
|
17
|
+
config: {
|
|
18
|
+
writeKey: '123-456',
|
|
19
|
+
trackApplicationLifecycleEvents: true,
|
|
20
|
+
flushInterval: 0,
|
|
21
|
+
},
|
|
22
|
+
store,
|
|
23
|
+
};
|
|
24
|
+
let plugin: MixpanelPlugin = new MixpanelPlugin();
|
|
25
|
+
const settings = sampleIntegrationSettings;
|
|
26
|
+
const updateType: UpdateType = UpdateType.initial;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
store.reset();
|
|
30
|
+
jest.clearAllMocks();
|
|
31
|
+
plugin = new MixpanelPlugin();
|
|
32
|
+
plugin.analytics = new SegmentClient(clientArgs);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('calls update with settings', () => {
|
|
36
|
+
const updateSpy = jest.spyOn(plugin, 'update');
|
|
37
|
+
|
|
38
|
+
plugin.update(settings, updateType);
|
|
39
|
+
expect(updateSpy).toHaveBeenCalledWith(settings, updateType);
|
|
40
|
+
expect(initMock).toHaveBeenCalled();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('does not initialize Mixpanel when token is undefined', () => {
|
|
44
|
+
settings.integrations.Mixpanel.token = '';
|
|
45
|
+
|
|
46
|
+
plugin.update(settings, updateType);
|
|
47
|
+
expect(initMock).not.toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('enables the European endpoint', () => {
|
|
51
|
+
settings.integrations.Mixpanel.token = '1234';
|
|
52
|
+
settings.integrations.Mixpanel.enableEuropeanEndpoint = true;
|
|
53
|
+
|
|
54
|
+
plugin.update(settings, updateType);
|
|
55
|
+
expect(setServerMock).toHaveBeenCalledWith(EU_SERVER);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export const sampleIntegrationSettings = {
|
|
2
|
+
integrations: {
|
|
3
|
+
Mixpanel: {
|
|
4
|
+
token: '1234',
|
|
5
|
+
enableEuropeanEndpoint: false,
|
|
6
|
+
eventIncrements: [],
|
|
7
|
+
groupIdentiferTraits: [],
|
|
8
|
+
people: true,
|
|
9
|
+
peopleProperties: [],
|
|
10
|
+
propIncrements: ['prop1', 'prop2', 'prop3'],
|
|
11
|
+
setAllTraitsByDefault: false,
|
|
12
|
+
superProperties: [],
|
|
13
|
+
trackAllPages: false,
|
|
14
|
+
trackCategorizedPages: false,
|
|
15
|
+
trackNamedPages: false,
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SegmentClient } from '@segment/analytics-react-native';
|
|
2
|
+
import {
|
|
3
|
+
getMockLogger,
|
|
4
|
+
MockSegmentStore,
|
|
5
|
+
} from '@segment/analytics-react-native/src/test-helpers';
|
|
6
|
+
|
|
7
|
+
import { MixpanelPlugin } from '../../MixpanelPlugin';
|
|
8
|
+
import { Mixpanel } from '../__mocks__/mixpanel-react-native';
|
|
9
|
+
import alias from '../alias';
|
|
10
|
+
|
|
11
|
+
import type { AliasEventType } from '@segment/analytics-react-native';
|
|
12
|
+
jest.mock('mixpanel-react-native');
|
|
13
|
+
|
|
14
|
+
describe('#alias', () => {
|
|
15
|
+
const store = new MockSegmentStore();
|
|
16
|
+
const clientArgs = {
|
|
17
|
+
logger: getMockLogger(),
|
|
18
|
+
config: {
|
|
19
|
+
writeKey: '123-456',
|
|
20
|
+
trackApplicationLifecycleEvents: true,
|
|
21
|
+
flushInterval: 0,
|
|
22
|
+
},
|
|
23
|
+
store,
|
|
24
|
+
};
|
|
25
|
+
let plugin: MixpanelPlugin = new MixpanelPlugin();
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
jest.clearAllMocks();
|
|
29
|
+
plugin = new MixpanelPlugin();
|
|
30
|
+
plugin.analytics = new SegmentClient(clientArgs);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('calls the alias method', async () => {
|
|
34
|
+
const payload = {
|
|
35
|
+
type: 'alias',
|
|
36
|
+
userId: '123',
|
|
37
|
+
} as AliasEventType;
|
|
38
|
+
const mixpanel = new Mixpanel('123');
|
|
39
|
+
const analytics = plugin.analytics!;
|
|
40
|
+
|
|
41
|
+
await alias(payload, mixpanel, analytics);
|
|
42
|
+
|
|
43
|
+
expect(mixpanel.getDistinctId).toBeCalled();
|
|
44
|
+
// need to fix this one
|
|
45
|
+
// expect(mixpanel.alias).toBeCalled();
|
|
46
|
+
});
|
|
47
|
+
});
|