├── .gitattributes ├── .github └── workflows │ └── test-android.yaml ├── .gitignore ├── .maestro └── test-show-survey.yaml ├── README.md ├── android ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src │ ├── main │ ├── AndroidManifest.xml │ ├── AndroidManifestNew.xml │ └── java │ │ └── com │ │ └── survicate │ │ └── react │ │ ├── SurvicateModuleImpl.java │ │ ├── SurvicatePackage.java │ │ └── SurvicateRNEventListener.java │ ├── newarch │ └── java │ │ └── com │ │ └── survicate │ │ └── react │ │ └── SurvicateModule.java │ └── oldarch │ └── java │ └── com │ └── survicate │ └── react │ └── SurvicateModule.java ├── app.plugin.js ├── example └── react_native │ ├── .gitignore │ ├── App.tsx │ ├── Gemfile │ ├── README.md │ ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── react_native │ │ │ │ ├── MainActivity.kt │ │ │ │ └── MainApplication.kt │ │ │ └── res │ │ │ ├── drawable │ │ │ └── rn_edit_text_material.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── index.js │ ├── ios │ ├── .xcode.env │ ├── Podfile │ ├── Podfile.lock │ ├── react_native.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── react_native.xcscheme │ ├── react_native.xcworkspace │ │ └── contents.xcworkspacedata │ ├── react_native │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ ├── PrivacyInfo.xcprivacy │ │ └── main.m │ └── react_nativeTests │ │ ├── Info.plist │ │ └── react_nativeTests.m │ ├── metro.config.js │ ├── package.json │ ├── react-native.config.js │ └── yarn.lock ├── ios ├── SurvicateBindings.h ├── SurvicateBindings.mm ├── SurvicateBindings.xcodeproj │ └── project.pbxproj └── SurvicateBindings.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ └── IDEWorkspaceChecks.plist ├── package.json ├── react-native-survicate.podspec ├── src ├── NativeSurvicateModule.ts ├── expo │ ├── types.ts │ ├── withSurvicate.ts │ ├── withSurvicateAndroid.ts │ └── withSurvicateiOS.ts └── index.ts ├── test └── react_native │ ├── .gitignore │ ├── App.tsx │ ├── Gemfile │ ├── Gemfile.lock │ ├── README.md │ ├── android │ ├── app │ │ ├── build.gradle │ │ ├── debug.keystore │ │ ├── proguard-rules.pro │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── react_native │ │ │ │ ├── MainActivity.kt │ │ │ │ └── MainApplication.kt │ │ │ └── res │ │ │ ├── drawable │ │ │ └── rn_edit_text_material.xml │ │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle │ ├── app.json │ ├── babel.config.js │ ├── env.d.ts │ ├── index.js │ ├── ios │ ├── .xcode.env │ ├── Podfile │ ├── Podfile.lock │ ├── react_native.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── react_native.xcscheme │ ├── react_native.xcworkspace │ │ └── contents.xcworkspacedata │ ├── react_native │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ └── Contents.json │ │ ├── Info.plist │ │ ├── LaunchScreen.storyboard │ │ ├── PrivacyInfo.xcprivacy │ │ └── main.m │ └── react_nativeTests │ │ ├── Info.plist │ │ └── react_nativeTests.m │ ├── metro.config.js │ ├── package.json │ ├── react-native.config.js │ └── yarn.lock ├── tsconfig.build.json ├── tsconfig.json └── yarn.lock /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /.github/workflows/test-android.yaml: -------------------------------------------------------------------------------- 1 | name: Test Android App 2 | 3 | on: [push] 4 | 5 | env : 6 | SURVICATE_SDK: survicate_sdk.tgz 7 | SURVICATE: survicate 8 | ANDROID_APK: app-release.apk 9 | ANDROID: android-apk 10 | 11 | jobs: 12 | build-react-native-sdk: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout Repository 16 | uses: actions/checkout@v4 17 | 18 | - name: Set up Node.js 19 | uses: actions/setup-node@v4 20 | with: 21 | node-version: '20' 22 | 23 | - name: Install Dependencies 24 | run: | 25 | yarn 26 | 27 | - name: Generate Tarball 28 | run: | 29 | npm pack 30 | TARBALL_NAME=$(ls *.tgz) 31 | mv $TARBALL_NAME test/react_native/${{ env.SURVICATE_SDK }} 32 | 33 | - name: Upload Survicate SDK Tarball 34 | uses: actions/upload-artifact@v4 35 | with: 36 | name: ${{ env.SURVICATE }} 37 | path: test/react_native/${{ env.SURVICATE_SDK }} 38 | 39 | build-android-app: 40 | runs-on: ubuntu-latest 41 | needs: build-react-native-sdk 42 | steps: 43 | - name: Checkout Repository 44 | uses: actions/checkout@v4 45 | 46 | - name: Set up Node.js 47 | uses: actions/setup-node@v4 48 | with: 49 | node-version: '20' 50 | 51 | - name: Download Survicate SDK Tarball 52 | uses: actions/download-artifact@v4 53 | with: 54 | name: ${{ env.SURVICATE }} 55 | path: test/react_native 56 | 57 | - name: Install Test App Dependencies 58 | working-directory: test/react_native 59 | run: | 60 | yarn 61 | yarn add ./${{ env.SURVICATE_SDK }} 62 | 63 | - name: Setup Workspace Key 64 | working-directory: test/react_native 65 | run: | 66 | echo "WORKSPACE_KEY=${{ secrets.WORKSPACE_KEY }}" > .env 67 | 68 | - name: Setup Java 69 | uses: actions/setup-java@v4 70 | with: 71 | distribution: 'temurin' 72 | java-version: '17' 73 | 74 | - name: Validate Gradle wrapper 75 | uses: gradle/actions/wrapper-validation@v3 76 | 77 | - name: Setup Gradle 78 | uses: gradle/actions/setup-gradle@v3 79 | 80 | - name: Setup Android 81 | working-directory: test/react_native/android 82 | run: chmod +x gradlew 83 | 84 | - name: Build APK 85 | working-directory: test/react_native/android 86 | run: | 87 | ./gradlew app:assembleRelease 88 | 89 | - name: Upload Android APK 90 | uses: actions/upload-artifact@v4 91 | with: 92 | name: ${{ env.ANDROID }} 93 | path: test/react_native/android/app/build/outputs/apk/release/${{ env.ANDROID_APK }} 94 | 95 | 96 | run-android-tests: 97 | runs-on: ubuntu-latest 98 | needs: build-android-app 99 | steps: 100 | - name: Checkout Repository 101 | uses: actions/checkout@v4 102 | 103 | - name: Install Maestro 104 | run: | 105 | curl -Ls --retry 3 --retry-all-errors "https://get.maestro.mobile.dev" | bash 106 | echo "${HOME}/.maestro/bin" >> $GITHUB_PATH 107 | 108 | - name: Enable KVM 109 | run: | 110 | echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules 111 | sudo udevadm control --reload-rules 112 | sudo udevadm trigger --name-match=kvm 113 | 114 | - name: Download Android APK 115 | uses: actions/download-artifact@v4 116 | with: 117 | name: ${{ env.ANDROID }} 118 | 119 | - name: Run tests on emulator 120 | uses: reactivecircus/android-emulator-runner@v2 121 | with: 122 | api-level: 34 123 | target: google_apis 124 | arch: x86_64 125 | emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim -no-metrics 126 | script: | 127 | adb install -r ${{ env.ANDROID_APK }} 128 | maestro test .maestro/test-show-survey.yaml --format junit 129 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # node.js 6 | # 7 | node_modules/ 8 | npm-debug.log 9 | yarn-error.log 10 | 11 | # Xcode 12 | # 13 | build/ 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | *.xccheckout 24 | *.moved-aside 25 | DerivedData 26 | *.hmap 27 | *.ipa 28 | *.xcuserstate 29 | project.xcworkspace 30 | 31 | # Android/IntelliJ 32 | # 33 | build/ 34 | .idea 35 | .gradle 36 | local.properties 37 | *.iml 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # generated files by bob 45 | lib/ 46 | -------------------------------------------------------------------------------- /.maestro/test-show-survey.yaml: -------------------------------------------------------------------------------- 1 | appId: com.react_native 2 | --- 3 | - launchApp 4 | - assertVisible: "Test App" 5 | - tapOn: "Invoke Event: Event" 6 | - assertVisible: "Welcome to our Survey!" 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # @survicate/react-native-survicate ![npm version](https://img.shields.io/npm/v/%40survicate%2Freact-native-survicate) 2 | 3 | Integrate Survicate into your React Native application to collect user feedback seamlessly. 4 | 5 | ## Requirements: 6 | - iOS at least on version 14.0 7 | - Android at least on version 5 8 | - React Native at least on version 0.60.0 9 | 10 | ## Installation 11 | This package can be installed using npm or yarn. If you're using Expo, follow the Expo-specific instructions. 12 | 13 | ### Using npm 14 | ```sh 15 | npm install @survicate/react-native-survicate --save 16 | ``` 17 | 18 | ### Using yarn 19 | ```sh 20 | yarn add @survicate/react-native-survicate 21 | ``` 22 | 23 | ### Using expo 24 | > Please note that due to custom native code in this package "Expo Go" is not available. 25 | 26 | To use @survicate/react-native-survicate in an Expo managed project use npm, yarn or expo-cli. 27 | ```sh 28 | expo install @survicate/react-native-survicate 29 | ``` 30 | 31 | ## Configuration 32 | 33 | ### Configuring Survicate Bindings for iOS 34 | - Add your Survicate workspace key to `Info.plist` 35 | ``` 36 | Survicate 37 | 38 | WorkspaceKey 39 | YOUR_WORKSPACE_KEY 40 | 41 | ``` 42 | - run command `pod install` in your `ios` directory 43 | 44 | ### Configuring Survicate Bindings for Android 45 | 46 | - Add maven repository to your project `build.gradle` located under `android` directory 47 | ``` 48 | allprojects { 49 | repositories { 50 | // ... 51 | maven { url 'https://repo.survicate.com' } 52 | } 53 | } 54 | ``` 55 | - Add your Survicate workspace key to `AndroidManifest.xml` 56 | ```java 57 | 60 | 61 | 62 | 63 | ``` 64 | 65 | ### Configuring Survicate Bindings for Expo 66 | - Add [config plugin](https://docs.expo.dev/config-plugins/introduction/) to `plugins` array of your `app.json` or `app.config.js` 67 | ```json 68 | { 69 | "expo": { 70 | "plugins": [ 71 | [ 72 | "@survicate/react-native-survicate", 73 | { 74 | "workspaceKey": "YOUR_WORKSPACE_KEY" 75 | } 76 | ] 77 | ] 78 | } 79 | } 80 | ``` 81 | > Please note that every time you change the props or plugins, you'll need to [rebuild](https://docs.expo.dev/workflow/customizing/) the native app. 82 | 83 | 84 | ## Usage 85 | ```javascript 86 | import Survicate, {UserTrait} from '@survicate/react-native-survicate'; 87 | 88 | Survicate.initializeSdk(); 89 | Survicate.setWorkspaceKey('WORKSPACE_KEY'); 90 | Survicate.invokeEvent("eventName"); 91 | const properties = { 92 | "property1": "value1", 93 | "property2": "value2" 94 | }; 95 | Survicate.invokeEvent("eventName", properties); 96 | Survicate.enterScreen("screenName"); 97 | Survicate.leaveScreen("screenName"); 98 | const userIdTrait = new UserTrait('user_id', 'id'); 99 | Survicate.setUserTrait(userIdTrait); 100 | const textTrait = new UserTrait('name', 'John'); 101 | const numberTrait = new UserTrait('age', 25); 102 | const booleanTrait = new UserTrait('isPremium', true); 103 | const dateTrait = new UserTrait('lastLogin', new Date()); 104 | const timeIntervalTrait = new UserTrait('timeOfPurchase', new Date()); 105 | Survicate.setLocale('en-US'); 106 | const listener: SurvicateEventListener = { 107 | onSurveyDisplayed(event: SurveyDisplayedEvent) {}, 108 | onQuestionAnswered(event: QuestionAnsweredEvent) {}, 109 | onSurveyClosed(event: SurveyClosedEvent) {}, 110 | onSurveyCompleted(event: SurveyCompletedEvent) {}, 111 | } 112 | const subscription = Survicate.addSurvicateEventListener(listener); 113 | Survicate.reset(); 114 | ``` 115 | 116 | ## Issues 117 | 118 | Got an Issue? 119 | 120 | To make things more streamlined, we’ve transitioned our issue reporting to our customer support platform. If you encounter any bugs or have feedback, please reach out to our customer support team. Your insights are invaluable to us, and we’re here to help ensure your experience is top-notch! 121 | 122 | Contact us via Intercom in the application, or drop us an email at: [hello@survicate.com] 123 | 124 | Thank you for your support and understanding! 125 | 126 | ## Changelog 127 | 128 | The Survicate Mobile SDK change log can be found [here](https://developers.survicate.com/mobile-sdk/react-native/#changelog) 129 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // android/build.gradle 2 | 3 | // based on: 4 | // 5 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle 6 | // original location: 7 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle 8 | // 9 | // * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle 10 | // original location: 11 | // - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle 12 | 13 | def DEFAULT_COMPILE_SDK_VERSION = 31 14 | def DEFAULT_BUILD_TOOLS_VERSION = '31.0.0' 15 | def DEFAULT_MIN_SDK_VERSION = 21 16 | def DEFAULT_TARGET_SDK_VERSION = 31 17 | 18 | def safeExtGet(prop, fallback) { 19 | rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback 20 | } 21 | 22 | def isNewArchitectureEnabled() { 23 | return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" 24 | } 25 | 26 | buildscript { 27 | // The Android Gradle plugin is only required when opening the android folder stand-alone. 28 | // This avoids unnecessary downloads and potential conflicts when the library is included as a 29 | // module dependency in an application project. 30 | // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies 31 | if (project == rootProject) { 32 | repositories { 33 | google() 34 | gradlePluginPortal() 35 | jcenter() 36 | } 37 | dependencies { 38 | classpath 'com.android.tools.build:gradle:7.0.4' 39 | } 40 | } 41 | } 42 | 43 | apply plugin: 'com.android.library' 44 | apply plugin: "maven-publish" 45 | if (isNewArchitectureEnabled()) { 46 | apply plugin: 'com.facebook.react' 47 | } 48 | 49 | def supportsNamespace() { 50 | def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.') 51 | def major = parsed[0].toInteger() 52 | def minor = parsed[1].toInteger() 53 | 54 | // Namespace support was added in 7.3.0 55 | if (major == 7 && minor >= 3) { 56 | return true 57 | } 58 | 59 | return major >= 8 60 | } 61 | 62 | android { 63 | if (supportsNamespace()) { 64 | namespace "com.survicate.react" 65 | 66 | sourceSets { 67 | main { 68 | manifest.srcFile "src/main/AndroidManifestNew.xml" 69 | } 70 | } 71 | } 72 | compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION) 73 | buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION) 74 | defaultConfig { 75 | minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION) 76 | targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION) 77 | versionCode 1 78 | versionName "1.0" 79 | buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() 80 | } 81 | buildFeatures { 82 | buildConfig true 83 | } 84 | lintOptions { 85 | abortOnError false 86 | } 87 | sourceSets { 88 | main { 89 | if (isNewArchitectureEnabled()) { 90 | java.srcDirs += ['src/newarch', 91 | // This is needed to build Kotlin project with NewArch enabled 92 | "${project.buildDir}/generated/source/codegen/java"] 93 | } else { 94 | java.srcDirs += ['src/oldarch'] 95 | } 96 | } 97 | } 98 | } 99 | 100 | repositories { 101 | maven { 102 | // custom Survicate maven 103 | url "https://repo.survicate.com" 104 | } 105 | // ref: https://www.baeldung.com/maven-local-repository 106 | mavenLocal() 107 | maven { 108 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 109 | url "$rootDir/../node_modules/react-native/android" 110 | } 111 | maven { 112 | // Android JSC is installed from npm 113 | url "$rootDir/../node_modules/jsc-android/dist" 114 | } 115 | mavenCentral() 116 | google() 117 | jcenter() 118 | } 119 | 120 | dependencies { 121 | //noinspection GradleDynamicVersion 122 | implementation 'com.facebook.react:react-native:+' // From node_modules 123 | implementation ('com.survicate:survicate-sdk:6.3.0') 124 | } 125 | 126 | if (isNewArchitectureEnabled()) { 127 | react { 128 | jsRootDir = file("../") 129 | libraryName = "Survicate" 130 | codegenJavaPackageName = "com.survicate.react" 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useAndroidX=true 21 | android.enableJetifier=true 22 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Survicate/survicate-react-native-sdk/a1c216139fbf88cbf4b2bb3d2006593485cad484/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /android/gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Stop when "xargs" is not available. 209 | if ! command -v xargs >/dev/null 2>&1 210 | then 211 | die "xargs is not available" 212 | fi 213 | 214 | # Use "xargs" to parse quoted args. 215 | # 216 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 217 | # 218 | # In Bash we could simply go: 219 | # 220 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 221 | # set -- "${ARGS[@]}" "$@" 222 | # 223 | # but POSIX shell has neither arrays nor command substitution, so instead we 224 | # post-process each arg (as a line of input to sed) to backslash-escape any 225 | # character that might be a shell metacharacter, then use eval to reverse 226 | # that process (while maintaining the separation between arguments), and wrap 227 | # the whole thing up as a single "set" statement. 228 | # 229 | # This will of course break if any of these variables contains a newline or 230 | # an unmatched quote. 231 | # 232 | 233 | eval "set -- $( 234 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 235 | xargs -n1 | 236 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 237 | tr '\n' ' ' 238 | )" '"$@"' 239 | 240 | exec "$JAVACMD" "$@" 241 | -------------------------------------------------------------------------------- /android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if %ERRORLEVEL% equ 0 goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if %ERRORLEVEL% equ 0 goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | set EXIT_CODE=%ERRORLEVEL% 84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 86 | exit /b %EXIT_CODE% 87 | 88 | :mainEnd 89 | if "%OS%"=="Windows_NT" endlocal 90 | 91 | :omega 92 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /android/src/main/AndroidManifestNew.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /android/src/main/java/com/survicate/react/SurvicateModuleImpl.java: -------------------------------------------------------------------------------- 1 | package com.survicate.react; 2 | 3 | import com.facebook.react.bridge.ReactApplicationContext; 4 | import com.facebook.react.bridge.ReactMethod; 5 | import com.facebook.react.bridge.ReadableMap; 6 | import com.survicate.surveys.Survicate; 7 | import com.survicate.surveys.traits.UserTrait; 8 | 9 | import com.survicate.react.SurvicateModule; 10 | 11 | import java.util.Map; 12 | import java.util.HashMap; 13 | 14 | public class SurvicateModuleImpl extends SurvicateModule { 15 | 16 | public static final String NAME = "SurvicateBindings"; 17 | 18 | private final ReactApplicationContext reactContext; 19 | private final SurvicateRNEventListener eventListener; 20 | 21 | private int listenerCount = 0; 22 | private boolean isInitialized = false; 23 | 24 | public SurvicateModuleImpl(ReactApplicationContext reactContext) { 25 | super(reactContext); 26 | this.reactContext = reactContext; 27 | this.eventListener = new SurvicateRNEventListener(reactContext); 28 | } 29 | 30 | @Override 31 | public String getName() { 32 | return NAME; 33 | } 34 | 35 | @ReactMethod 36 | public void enterScreen(String screenName) { 37 | if (!isInitialized) { 38 | return; 39 | } 40 | Survicate.enterScreen(screenName); 41 | } 42 | 43 | @ReactMethod 44 | public void leaveScreen(String screenName) { 45 | if (!isInitialized) { 46 | return; 47 | } 48 | Survicate.leaveScreen(screenName); 49 | } 50 | 51 | @ReactMethod 52 | public void invokeEvent(String eventName, ReadableMap eventProperties) { 53 | if (!isInitialized) { 54 | return; 55 | } 56 | Map properties = new HashMap<>(); 57 | for (Map.Entry entry : eventProperties.toHashMap().entrySet()) { 58 | String key = entry.getKey(); 59 | String value = entry.getValue().toString(); 60 | properties.put(key, value); 61 | } 62 | 63 | Survicate.invokeEvent(eventName, properties); 64 | } 65 | 66 | @ReactMethod 67 | public void setUserId(String userId) { 68 | if (!isInitialized) { 69 | return; 70 | } 71 | 72 | Survicate.setUserTrait(new UserTrait("user_id", userId)); 73 | } 74 | 75 | @ReactMethod 76 | public void setUserTrait(String userTrait, String value) { 77 | if (!isInitialized) { 78 | return; 79 | } 80 | Survicate.setUserTrait(new UserTrait(userTrait, value)); 81 | } 82 | 83 | @ReactMethod 84 | public void initializeSdk() { 85 | Survicate.init(reactContext); 86 | isInitialized = true; 87 | } 88 | 89 | @ReactMethod 90 | public void reset() { 91 | if (!isInitialized) { 92 | return; 93 | } 94 | Survicate.reset(); 95 | } 96 | 97 | @ReactMethod 98 | public void setWorkspaceKey(String workspaceKey) { 99 | Survicate.setWorkspaceKey(workspaceKey); 100 | } 101 | 102 | @ReactMethod 103 | public void addListener(String eventName) { 104 | if (!isInitialized) { 105 | return; 106 | } 107 | if (listenerCount == 0) { 108 | Survicate.addEventListener(eventListener); 109 | } 110 | 111 | listenerCount++; 112 | } 113 | 114 | @ReactMethod 115 | public void removeListeners(int count) { 116 | if (!isInitialized) { 117 | return; 118 | } 119 | listenerCount -= count; 120 | 121 | if (listenerCount == 0) { 122 | Survicate.removeEventListener(eventListener); 123 | } 124 | } 125 | 126 | @ReactMethod 127 | public void removeListeners(double count) { 128 | removeListeners((int) count); 129 | } 130 | 131 | @ReactMethod 132 | public void setLocale(String locale) { 133 | if (!isInitialized) { 134 | return; 135 | } 136 | Survicate.setLocale(locale); 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /android/src/main/java/com/survicate/react/SurvicatePackage.java: -------------------------------------------------------------------------------- 1 | package com.survicate.react; 2 | 3 | import androidx.annotation.Nullable; 4 | 5 | import com.facebook.react.TurboReactPackage; 6 | import com.facebook.react.bridge.NativeModule; 7 | import com.facebook.react.bridge.ReactApplicationContext; 8 | import com.facebook.react.module.model.ReactModuleInfo; 9 | import com.facebook.react.module.model.ReactModuleInfoProvider; 10 | 11 | import com.survicate.react.SurvicateModule; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | public class SurvicatePackage extends TurboReactPackage { 16 | 17 | @Nullable 18 | @Override 19 | public NativeModule getModule(String name, ReactApplicationContext reactApplicationContext) { 20 | if (SurvicateModuleImpl.NAME.equals(name)) { 21 | return new SurvicateModuleImpl(reactApplicationContext); 22 | } else { 23 | return null; 24 | } 25 | } 26 | 27 | @Override 28 | public ReactModuleInfoProvider getReactModuleInfoProvider() { 29 | return () -> { 30 | final Map moduleInfos = new HashMap<>(); 31 | boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; 32 | moduleInfos.put( 33 | SurvicateModuleImpl.NAME, 34 | new ReactModuleInfo( 35 | SurvicateModuleImpl.NAME, 36 | SurvicateModuleImpl.NAME, 37 | false, // canOverrideExistingModule 38 | false, // needsEagerInit 39 | true, // hasConstants 40 | false, // isCxxModule 41 | isTurboModule // isTurboModule 42 | )); 43 | return moduleInfos; 44 | }; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /android/src/main/java/com/survicate/react/SurvicateRNEventListener.java: -------------------------------------------------------------------------------- 1 | package com.survicate.react; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.bridge.Arguments; 6 | import com.facebook.react.bridge.ReactApplicationContext; 7 | import com.facebook.react.bridge.ReactContext; 8 | import com.facebook.react.bridge.WritableMap; 9 | import com.facebook.react.bridge.WritableArray; 10 | import com.facebook.react.modules.core.DeviceEventManagerModule; 11 | import com.survicate.surveys.SurvicateAnswer; 12 | import com.survicate.surveys.SurvicateEventListener; 13 | import com.survicate.surveys.SurveyDisplayedEvent; 14 | import com.survicate.surveys.QuestionAnsweredEvent; 15 | import com.survicate.surveys.SurveyClosedEvent; 16 | import com.survicate.surveys.SurveyCompletedEvent; 17 | 18 | import javax.annotation.Nullable; 19 | 20 | class SurvicateRNEventListener extends SurvicateEventListener { 21 | 22 | private static final String SURVEY_ID = "surveyId"; 23 | private static final String SURVEY_NAME = "surveyName"; 24 | private static final String RESPONSE_UUID = "responseUuid"; 25 | private static final String VISITOR_UUID = "visitorUuid"; 26 | private static final String QUESTION_ID = "questionId"; 27 | private static final String QUESTION = "question"; 28 | private static final String ANSWER_TYPE = "answerType"; 29 | private static final String ANSWER_ID = "answerId"; 30 | private static final String ANSWER_IDS = "answerIds"; 31 | private static final String ANSWER_VALUE = "answerValue"; 32 | private static final String PANEL_ANSWER_URL = "panelAnswerUrl"; 33 | 34 | private ReactApplicationContext reactContext; 35 | 36 | public SurvicateRNEventListener(ReactApplicationContext reactContext) { 37 | this.reactContext = reactContext; 38 | } 39 | 40 | @Override 41 | public void onSurveyDisplayed(@NonNull SurveyDisplayedEvent event) { 42 | WritableMap params = Arguments.createMap(); 43 | params.putString(SURVEY_ID, event.getSurveyId()); 44 | sendEvent(reactContext, "onSurveyDisplayed", params); 45 | } 46 | 47 | @Override 48 | public void onQuestionAnswered(@NonNull QuestionAnsweredEvent event) { 49 | WritableMap params = Arguments.createMap(); 50 | params.putString(SURVEY_ID, event.getSurveyId()); 51 | params.putString(SURVEY_NAME, event.getSurveyName()); 52 | params.putString(RESPONSE_UUID, event.getResponseUuid()); 53 | params.putString(VISITOR_UUID, event.getVisitorUuid()); 54 | params.putString(PANEL_ANSWER_URL, event.getPanelAnswerUrl()); 55 | params.putDouble(QUESTION_ID, event.getQuestionId()); 56 | params.putString(QUESTION, event.getQuestionText()); 57 | 58 | if (event.getAnswer().getType() != null) { 59 | params.putString(ANSWER_TYPE, event.getAnswer().getType()); 60 | } else { 61 | params.putNull(ANSWER_TYPE); 62 | } 63 | 64 | if (event.getAnswer().getId() != null) { 65 | params.putDouble(ANSWER_ID, event.getAnswer().getId()); 66 | } else { 67 | params.putNull(ANSWER_ID); 68 | } 69 | 70 | if (event.getAnswer().getIds() != null) { 71 | WritableArray ids = Arguments.createArray(); 72 | for (long id : event.getAnswer().getIds()) { 73 | ids.pushDouble(id); 74 | } 75 | params.putArray(ANSWER_IDS, ids); 76 | } else { 77 | params.putArray(ANSWER_IDS, Arguments.createArray()); 78 | } 79 | 80 | if (event.getAnswer().getValue() != null) { 81 | params.putString(ANSWER_VALUE, event.getAnswer().getValue()); 82 | } else { 83 | params.putNull(ANSWER_VALUE); 84 | } 85 | 86 | sendEvent(reactContext, "onQuestionAnswered", params); 87 | } 88 | 89 | @Override 90 | public void onSurveyClosed(@NonNull SurveyClosedEvent event) { 91 | WritableMap params = Arguments.createMap(); 92 | params.putString(SURVEY_ID, event.getSurveyId()); 93 | sendEvent(reactContext, "onSurveyClosed", params); 94 | } 95 | 96 | @Override 97 | public void onSurveyCompleted(@NonNull SurveyCompletedEvent event) { 98 | WritableMap params = Arguments.createMap(); 99 | params.putString(SURVEY_ID, event.getSurveyId()); 100 | sendEvent(reactContext, "onSurveyCompleted", params); 101 | } 102 | 103 | private void sendEvent(ReactContext reactContext, String eventName, @Nullable WritableMap params) { 104 | reactContext 105 | .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class) 106 | .emit(eventName, params); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /android/src/newarch/java/com/survicate/react/SurvicateModule.java: -------------------------------------------------------------------------------- 1 | package com.survicate.react; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | 7 | public abstract class SurvicateModule extends NativeSurvicateModuleSpec { 8 | public SurvicateModule(@NonNull ReactApplicationContext reactContext) { 9 | super(reactContext); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /android/src/oldarch/java/com/survicate/react/SurvicateModule.java: -------------------------------------------------------------------------------- 1 | package com.survicate.react; 2 | 3 | import androidx.annotation.NonNull; 4 | 5 | import com.facebook.react.bridge.ReactApplicationContext; 6 | import com.facebook.react.bridge.ReactContextBaseJavaModule; 7 | import com.facebook.react.bridge.ReadableMap; 8 | 9 | public abstract class SurvicateModule extends ReactContextBaseJavaModule { 10 | 11 | public SurvicateModule(@NonNull ReactApplicationContext reactContext) { 12 | super(reactContext); 13 | } 14 | 15 | public abstract void enterScreen(String screenName); 16 | public abstract void leaveScreen(String screenName); 17 | public abstract void invokeEvent(String eventName, ReadableMap eventProperties); 18 | public abstract void setUserId(String userId); 19 | public abstract void setUserTrait(String userTrait, String value); 20 | public abstract void initializeSdk(); 21 | public abstract void reset(); 22 | public abstract void setWorkspaceKey(String workspaceKey); 23 | public abstract void setLocale(String locale); 24 | } 25 | -------------------------------------------------------------------------------- /app.plugin.js: -------------------------------------------------------------------------------- 1 | const packageJson = require('./package.json'); 2 | 3 | const pkg = { 4 | name: packageJson.name, 5 | version: packageJson.version, 6 | }; 7 | 8 | const plugin = require('./lib/commonjs/expo/withSurvicate'); 9 | 10 | module.exports = plugin.default(pkg); 11 | -------------------------------------------------------------------------------- /example/react_native/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | *.xcode.env.local 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | *.hprof 33 | .cxx/ 34 | *.keystore 35 | !debug.keystore 36 | 37 | # node.js 38 | # 39 | node_modules/ 40 | npm-debug.log 41 | yarn-error.log 42 | 43 | # Bundle artifact 44 | *.jsbundle 45 | 46 | # Ruby / CocoaPods 47 | /ios/Pods/ 48 | /vendor/bundle/ 49 | 50 | # Temporary files created by Metro to check the health of the file watcher 51 | .metro-health-check* 52 | 53 | *.xcarchive -------------------------------------------------------------------------------- /example/react_native/App.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import { Button, Text, SafeAreaView, ScrollView, StyleSheet, View } from "react-native"; 3 | import Survicate, {SurveyDisplayedEvent, QuestionAnsweredEvent, SurveyClosedEvent, SurveyCompletedEvent, UserTrait} from "@survicate/react-native-survicate"; 4 | 5 | const App = () => { 6 | useEffect(() => { 7 | // Initialize the SDK 8 | Survicate.initializeSdk(); 9 | 10 | const listener = { 11 | onSurveyDisplayed: (event: SurveyDisplayedEvent) => { 12 | // onSurveyDisplayed 13 | }, 14 | onQuestionAnswered: (event: QuestionAnsweredEvent) => { 15 | // onQuestionAnswered 16 | }, 17 | onSurveyClosed: (event: SurveyClosedEvent) => { 18 | // onSurveyClosed 19 | }, 20 | onSurveyCompleted: (event: SurveyCompletedEvent) => { 21 | // onSurveyCompleted 22 | }, 23 | }; 24 | 25 | const subscription = Survicate.addSurvicateEventListener(listener); 26 | return subscription; 27 | }, []); 28 | 29 | return ( 30 | 31 | 32 | 33 | Example App 34 | 35 | 36 | 37 |