diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000..92dd101 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,81 @@ +name: Bug Report +description: Create a report to help us improve +body: + - type: textarea + id: description + attributes: + label: Describe the bug + description: A clear and concise description of what the bug is. + validations: + required: true + - type: textarea + id: repro + attributes: + label: Steps To Reproduce + description: How do you trigger this bug? Please walk us through it step by step. + value: | + Steps to reproduce the behavior: + 1. Go to '...' + 2. Click on '....' + 3. Scroll down to '....' + 4. See error + render: typescript + validations: + required: true + - type: textarea + id: behavior + attributes: + label: Expected behavior + description: A clear and concise description of what you expected to happen. + validations: + required: true + - type: input + id: clickstream-version + attributes: + label: ClickstreamAnalytic SDK Version + placeholder: e.g. 1.0.0 + validations: + required: true + - type: input + id: platform + attributes: + label: The platform of the bug + placeholder: | + - e.g. Android/iOS/Web/All + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: >- + Include any relevant log output + value: | +
+ Log Messages + + ``` + INSERT LOG MESSAGES HERE + ``` +
+ render: shell + - type: dropdown + id: regression + attributes: + label: Is this a regression? + multiple: false + options: + - "Yes" + - "No" + validations: + required: true + - type: textarea + id: regression-info + attributes: + label: Regression additional context + placeholder: If it was a regression provide the versions used before and after the upgrade. + - type: textarea + id: context + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.yaml b/.github/ISSUE_TEMPLATE/feature_request.yaml new file mode 100644 index 0000000..36105ac --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yaml @@ -0,0 +1,32 @@ +name: Feature request +description: Suggest an idea for this project +body: + - type: textarea + id: description + attributes: + label: Is your feature request related to a problem? Please describe. + description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + validations: + required: true + + - type: textarea + id: proposal + attributes: + label: Describe the solution you'd like + description: A clear and concise description of what you want to happen. + validations: + required: true + + - type: textarea + id: alternatives + attributes: + label: Describe alternatives you've considered + description: A clear and concise description of any alternative solutions or features you've considered. + validations: + required: true + + - type: textarea + id: context + attributes: + label: Additional context + description: Add any other context about the problem here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..c2a62b4 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Issue \# + + +## Description + + +## General Checklist + + +- [ ] Added new tests to cover change, if needed +- [ ] Security oriented best practices and standards are followed (e.g. using input sanitization, principle of least privilege, etc) +- [ ] Documentation update for the change if required +- [ ] PR title conforms to conventional commit style +- [ ] If breaking change, documentation/changelog update with migration instructions + +By submitting this pull request, I confirm that my contribution is made under the terms of the MIT-0 license. diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml new file mode 100644 index 0000000..e8ca0aa --- /dev/null +++ b/.github/workflows/build-android.yml @@ -0,0 +1,22 @@ +name: Build for Android + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-android: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + cache: gradle + - name: Build android apk + run: | + cd android + ./gradlew assembleDebug diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml new file mode 100644 index 0000000..b4a311c --- /dev/null +++ b/.github/workflows/build-ios.yml @@ -0,0 +1,22 @@ +name: Build for iOS + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-ios: + runs-on: macos-13-xl + steps: + - uses: actions/checkout@v3 + - name: Build ios + run: | + sudo xcode-select -s '/Applications/Xcode_15.2.app/Contents/Developer' + xcode-select --print-path + cd ios + xcodebuild -resolvePackageDependencies + echo "start build ios app" + set -o pipefail + xcodebuild -scheme "ModerneShopping" -sdk iphoneos -configuration Release -destination generic/platform=iOS CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO clean archive | xcpretty diff --git a/.github/workflows/build-rn.yml b/.github/workflows/build-rn.yml new file mode 100644 index 0000000..c04cca6 --- /dev/null +++ b/.github/workflows/build-rn.yml @@ -0,0 +1,49 @@ +name: Build for React Native + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + lint-rn: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run lint + run: | + cd react-native + yarn + yarn lint + + build-android: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + cache: gradle + - name: Build android apk + run: | + cd react-native + yarn + cd android + ./gradlew assembleDebug + + build-ios: + runs-on: macos-13-xl + steps: + - uses: actions/checkout@v3 + - name: Build ios + run: | + sudo xcode-select -s '/Applications/Xcode_15.2.app/Contents/Developer' + xcode-select --print-path + cd react-native + yarn + cd ios && pod install + echo "start build ios app" + set -o pipefail + xcodebuild -workspace app.xcworkspace -scheme app -sdk iphoneos -configuration Release -destination generic/platform=iOS CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO clean archive | xcpretty diff --git a/.github/workflows/build-web.yml b/.github/workflows/build-web.yml new file mode 100644 index 0000000..76be75c --- /dev/null +++ b/.github/workflows/build-web.yml @@ -0,0 +1,19 @@ +name: Build for Web + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build-web: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Run build + run: | + cd web + yarn + cd packages/vue2 + yarn build \ No newline at end of file diff --git a/.github/workflows/title-lint.yml b/.github/workflows/title-lint.yml new file mode 100644 index 0000000..d5f6cee --- /dev/null +++ b/.github/workflows/title-lint.yml @@ -0,0 +1,24 @@ +name: Pull Request Title Lint + +on: + pull_request: + branches: [ "*" ] + +jobs: + title-lint: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + types: |- + feat + fix + chore + docs + ci + tests + requireScope: false diff --git a/README.md b/README.md index 272c96d..c22b3e9 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,15 @@ More references: License: [MIT](https://github.com/Djallil14/SwiftUI-FakeShopping-App/blob/main/LICENSE.md) -## React-Native Example +## React Native SDK Example React-Native example app **v2ex** is forked from https://github.com/funnyzak/react-native-v2ex. To get started with the React-Native example, refer to the [React-Native Example README](react-native/README.md). -You can refer this [PR](https://github.com/aws-samples/clickstream-sdk-samples/pull/8/files) to learn how to integrate Clickstream Android and Swift SDK into react-native app. +Please refer this [PR](https://github.com/aws-samples/clickstream-sdk-samples/pull/25/files#diff-92545e618a4ce920ced0c68cb0dd77f476ad4613261b41b57e3d41e8ab84a4e8R12-R19) to learn how to integrate Clickstream React Native SDK into your app. + +You can also refer this [PR](https://github.com/aws-samples/clickstream-sdk-samples/pull/8/files) to learn how to manually integrate Clickstream Android and Swift SDK into react native app. + +### Record screen views when using React Navigation +Here's an [example](https://github.com/aws-samples/clickstream-sdk-samples/pull/25/files#diff-96a74db413b2f02988e5537fdbdf4f307334e8f5ef3a9999df7de3c6785af75bR344-R397) of globally logging React Native screen view events when using React Navigation 6.x: License: [Apache-2.0](https://github.com/funnyzak/react-native-v2ex/blob/dev/LICENSE) diff --git a/ios/ModerneShopping.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ios/ModerneShopping.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 43ed3c3..cfb4c1f 100644 --- a/ios/ModerneShopping.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ios/ModerneShopping.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -51,7 +51,7 @@ "location" : "https://github.com/awslabs/clickstream-swift.git", "state" : { "branch" : "main", - "revision" : "32f44a86c1674f8375e2de903a6aeb21420bd4d7" + "revision" : "a2c331eed23b8441aedc6de4e2fba2d339bf35b7" } }, { diff --git a/react-native/.github/FUNDING.yml b/react-native/.github/FUNDING.yml deleted file mode 100644 index a98d89e..0000000 --- a/react-native/.github/FUNDING.yml +++ /dev/null @@ -1,13 +0,0 @@ -# These are supported funding model platforms - -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -custom: ['https://github.com/funnyzak/funnyzak/blob/storage/assets/coffee.png'] diff --git a/react-native/.github/ISSUE_TEMPLATE/bug_report.yaml b/react-native/.github/ISSUE_TEMPLATE/bug_report.yaml deleted file mode 100644 index d815e7c..0000000 --- a/react-native/.github/ISSUE_TEMPLATE/bug_report.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Report a bug -description: ——— -labels: [bug] -body: - - type: markdown - attributes: - value: | - # Thanks for reporting this bug! - - Help us replicate and find a fix for the issue by filling in this form. - - type: textarea - attributes: - label: Description - description: | - Describe the issue and how to replicate it. If possible, please include - a minimal example to reproduce the issue. - validations: - required: true \ No newline at end of file diff --git a/react-native/.github/ISSUE_TEMPLATE/custom.md b/react-native/.github/ISSUE_TEMPLATE/custom.md deleted file mode 100644 index 34d97c1..0000000 --- a/react-native/.github/ISSUE_TEMPLATE/custom.md +++ /dev/null @@ -1,11 +0,0 @@ ---- -name: Custom Issue Template -about: Tell us something related to the project or general discussion -title: '' -labels: question -assignees: troublediehard ---- - -**Are there certain things to report that are not a bug or feature?** -Please tell us as exactly as possible about your request, thanks. -We will reply as soon as possible. diff --git a/react-native/.github/ISSUE_TEMPLATE/feature_request.yaml b/react-native/.github/ISSUE_TEMPLATE/feature_request.yaml deleted file mode 100644 index f60c611..0000000 --- a/react-native/.github/ISSUE_TEMPLATE/feature_request.yaml +++ /dev/null @@ -1,28 +0,0 @@ -name: Suggest an improvement or new feature -description: ——— -labels: [enhancement] -body: - - type: markdown - attributes: - value: | - # Thanks for filing this feature request! - - Help us understanding this feature and the need for it better by filling in this form. - - type: textarea - attributes: - label: Description - description: Describe the feature in detail - validations: - required: true - - type: textarea - attributes: - label: Why - description: Why should we add this feature? What are potential use cases for it? - validations: - required: true - - type: textarea - attributes: - label: Alternatives - description: Describe the alternatives you have considered, or existing workarounds - validations: - required: true diff --git a/react-native/.github/PULL_REQUEST_TEMPLATE/default.md b/react-native/.github/PULL_REQUEST_TEMPLATE/default.md deleted file mode 100644 index 8196834..0000000 --- a/react-native/.github/PULL_REQUEST_TEMPLATE/default.md +++ /dev/null @@ -1,54 +0,0 @@ - - -## Related Issues - - - -## Description - - - -### Added - - - -### Changed - - - -### Removed - - - -## Caveats/Problems/Issues - - - -## Checklist - -- [ ] The issues that this PR fixes/closes have been mentioned above. -- [ ] What this PR adds/changes/removes has been explained. -- [ ] All tests pass. -- [ ] The linter does not throw an errors. diff --git a/react-native/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/react-native/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md deleted file mode 100644 index eb634d2..0000000 --- a/react-native/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +++ /dev/null @@ -1,18 +0,0 @@ -**What does this implement/fix? Explain your changes.** -Please explain your changes in addition to your commit messages. - -**Does this close any currently open issues?** -If yes, please mention, else ignore. - -**Screenshots** -If applicable, add screenshots of end result. - -**Any other comments?** - -## **Where has this been tested?** - -- OS: [e.g. Windows 10] -- Version [e.g. 1.0.0] -- Node.js version [e.g. 12.16.1] -- Yarn version [e.g. 1.22.4] -- ...etc diff --git a/react-native/.github/config.yml b/react-native/.github/config.yml deleted file mode 100644 index 0f9eb8f..0000000 --- a/react-native/.github/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -newIssueWelcomeComment: > - 感谢你提交的问题或反馈,我会尽快回复,在此期间你可以看看[之前被解决的反馈](https://github.com/funnyzak/react-native-v2ex/issues?q=is%3Aissue+is%3Aclosed)说不定有你需要的答案。 - - Thanks for opening this issue, a maintainer will get back to you shortly! - -newPRWelcomeComment: > - 感谢你提交的问题或反馈,我会尽快来审查代码。 - - Thanks so much for opening your first PR here! -firstPRMergeComment: > - 感谢贡献 PR 来支持 Funnyzak! :tada: - - Congrats on merging your first pull request here! :tada: How awesome! \ No newline at end of file diff --git a/react-native/.github/config/changelog_configuration.json b/react-native/.github/config/changelog_configuration.json deleted file mode 100644 index ee21056..0000000 --- a/react-native/.github/config/changelog_configuration.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "categories": [ - { - "title": "## 🚀 Features", - "labels": [ - "feature", - "feat" - ] - }, - { - "title": "## 🐛 Fixes", - "labels": [ - "fix", - "bug", - "fixed" - ] - }, - { - "title": "## 🧪 Tests", - "labels": [ - "test" - ] - }, - { - "title": "## 💬 Other", - "labels": [ - "other" - ] - }, - { - "title": "## ✨ Refactors", - "labels": [ - "refactor" - ] - }, - { - "title": "## 📦 Dependencies", - "labels": [ - "dependencies" - ] - } - ], - "sort": "ASC", - "template": "${{CHANGELOG}}\n\n
\nUncategorized\n\n${{UNCATEGORIZED}}\n
", - "pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}", - "empty_template": "- no changes", - "transformers": [ - { - "pattern": "[\\-\\*] (\\[(...|TEST|CI|SKIP)\\])( )?(.+?)\n(.+?[\\-\\*] )(.+)", - "target": "- $4\n - $6" - } - ], - "max_tags_to_fetch": 500, - "max_pull_requests": 500, - "max_back_track_time_days": 500, - "exclude_merge_branches": [ - "Owner/qa" - ] -} \ No newline at end of file diff --git a/react-native/.github/dependabot.yml b/react-native/.github/dependabot.yml deleted file mode 100644 index 42cdbc1..0000000 --- a/react-native/.github/dependabot.yml +++ /dev/null @@ -1,9 +0,0 @@ -version: 2 -updates: -- package-ecosystem: npm - directory: "/" - schedule: - interval: daily - open-pull-requests-limit: 3 - ignore: - - dependency-name: "i18n-js" diff --git a/react-native/.github/stale.yml b/react-native/.github/stale.yml deleted file mode 100644 index 872c4f5..0000000 --- a/react-native/.github/stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -# Number of days of inactivity before an issue becomes stale -daysUntilStale: 30 -# Number of days of inactivity before a stale issue is closed -daysUntilClose: 7 -# Issues with these labels will never be considered stale -exemptLabels: - - pinned - - security -# Label to use when marking an issue as stale -staleLabel: wontfix -# Comment to post when marking an issue as stale. Set to `false` to disable -markComment: > - This issue has been automatically marked as stale because it has not had - recent activity. It will be closed if no further activity occurs. Thank you - for your contributions. -# Comment to post when closing a stale issue. Set to `false` to disable -closeComment: false \ No newline at end of file diff --git a/react-native/.github/workflows/release.yml b/react-native/.github/workflows/release.yml deleted file mode 100644 index 10e1e5f..0000000 --- a/react-native/.github/workflows/release.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: CI -on: - push: - tags: - - '*' - workflow_dispatch: - -env: - DIST_ARCHIVE_PREFIX_NAME: ${{ github.event.repository.name }} - -jobs: - lint-and-test: - name: Lint and Test - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - registry-url: 'https://registry.npmjs.org/' - cache: 'yarn' - - name: Install dependencies - run: | - yarn - - build-android-apk: - name: Build Android APK - needs: lint-and-test - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set variables - id: set_veriables - run: | - # Get the version from package.json - echo "PACKAGE_VERSION_NAME=$(node -p "require('./package.json').version")" >> $GITHUB_ENV - # Get the name from package.json - echo "PACKAGE_NAME=$(node -p "require('./package.json').name")" >> $GITHUB_ENV - # current push sha - echo "COMMIT_ID=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV - # current push tag - echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_ENV - # latest tag - echo "TAG_NAME=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV - # set current timestamp - echo "TIMESTAMP=$(date +%s)" >> $GITHUB_ENV - # set current time and format - echo "BUILD_TIME=$(date "+%Y-%m-%d-%H-%M")" >> $GITHUB_ENV - - name: Set apk name - id: set_apk_name - run: | - echo "APK_NAME=${{ env.PACKAGE_NAME }}-${{ env.PACKAGE_VERSION_NAME }}-${{ env.TIMESTAMP }}-${{ env.COMMIT_ID }}.apk" >> $GITHUB_ENV - - name: Build changelog - id: build_changelog - uses: mikepenz/release-changelog-builder-action@v3.4.0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - configuration: '.github/config/changelog_configuration.json' - ignorePreReleases: 'false' - - name: Use node - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - name: Restore yarn cache - uses: actions/cache@v3 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-node- - - name: Install dependencies - run: | - yarn - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '11' - - name: Build APK - run: | - cd android && ./gradlew assembleRelease - - name: Move apk to target directory - run: cp android/app/build/outputs/apk/release/app-release.apk android/app/build/outputs/apk/release/${{ env.APK_NAME }} - - name: Release - uses: softprops/action-gh-release@v1 - with: - body: ${{ steps.build_changelog.outputs.changelog }} - name: ${{ env.PACKAGE_VERSION_NAME }} - tag_name: ${{ env.TAG_NAME }} - files: | - android/app/build/outputs/apk/release/${{ env.APK_NAME }} - env: - GITHUB_TOKEN: ${{ secrets.github_token }} - - push-release-message: - name: Push release message - runs-on: ubuntu-latest - needs: [build-android-apk] - steps: - - name: Push message - uses: funnyzak/pushoo-action@main - with: - platforms: ifttt,wecombot,bark - tokens: ${{ secrets.PUSH_TOKEN }} - content: | - # ${{ github.event.repository.name }} Released - ## trigger: ${{ github.event_name }} at ${{ github.event.head_commit.timestamp }} - ## commit message: ${{ github.event.head_commit.message }} - ## commit url: ${{ github.event.head_commit.url }} - ## commit author: ${{ github.event.head_commit.author.name }} - ## commit email: ${{ github.event.head_commit.author.email }} - ## commit id: ${{ github.event.head_commit.id }} - title: | - ${{ github.repository }} ${{ github.event_name }} Message - options: '{"bark": { "url": "https://github.com/${{github.repository}}" }}' - debug: false diff --git a/react-native/.github/workflows/test.yml b/react-native/.github/workflows/test.yml deleted file mode 100644 index 1b0c3af..0000000 --- a/react-native/.github/workflows/test.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: test - -on: - push: - branches: [ dev, main ] - pull_request: - workflow_dispatch: -jobs: - lint: - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - - name: Get yarn cache directory path - id: yarn-cache-dir-path - run: echo "::set-output name=dir::$(yarn cache dir)" - - - uses: actions/cache@v3 - id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) - with: - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-yarn- - - - name: Lint - run: | - yarn - yarn lint diff --git a/react-native/.husky/pre-commit b/react-native/.husky/pre-commit deleted file mode 100755 index 0312b76..0000000 --- a/react-native/.husky/pre-commit +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" - -npx lint-staged \ No newline at end of file diff --git a/react-native/android/app/build.gradle b/react-native/android/app/build.gradle index 43be748..de29e2d 100644 --- a/react-native/android/app/build.gradle +++ b/react-native/android/app/build.gradle @@ -175,8 +175,7 @@ dependencies { } else { implementation jscFlavor } - implementation("software.aws.solution:clickstream:0.9.0") implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.10")) } -apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) \ No newline at end of file +apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) diff --git a/react-native/android/app/src/main/java/github/funnyzak/v2ex/ClickstreamModule.java b/react-native/android/app/src/main/java/github/funnyzak/v2ex/ClickstreamModule.java deleted file mode 100644 index d636e32..0000000 --- a/react-native/android/app/src/main/java/github/funnyzak/v2ex/ClickstreamModule.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"). - * You may not use this file except in compliance with the License. - * A copy of the License is located at - * - * http://aws.amazon.com/apache2.0 - * - * or in the "license" file accompanying this file. This file is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either - * express or implied. See the License for the specific language governing - * permissions and limitations under the License. - */ - -package github.funnyzak.v2ex; - -import androidx.annotation.NonNull; - -import com.facebook.react.bridge.ReactApplicationContext; -import com.facebook.react.bridge.ReactContextBaseJavaModule; -import com.facebook.react.bridge.ReactMethod; -import com.facebook.react.bridge.ReadableArray; -import com.facebook.react.bridge.ReadableMap; -import software.aws.solution.clickstream.ClickstreamAnalytics; -import software.aws.solution.clickstream.ClickstreamAttribute; -import software.aws.solution.clickstream.ClickstreamEvent; -import software.aws.solution.clickstream.ClickstreamUserAttribute; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -public class ClickstreamModule extends ReactContextBaseJavaModule { - - public ClickstreamModule(ReactApplicationContext context) { - super(context); - } - - @NonNull - @Override - public String getName() { - return "ClickstreamAnalytics"; - } - - @ReactMethod() - public void recordEventWithName(String eventName) { - ClickstreamAnalytics.recordEvent(eventName); - } - - @ReactMethod - public void recordEvent(String eventName, ReadableMap map) { - HashMap attributeMap = map.toHashMap(); - ClickstreamEvent.Builder builder = new ClickstreamEvent.Builder(); - builder.name(eventName); - for (Map.Entry entry : attributeMap.entrySet()) { - if (entry.getValue() instanceof String) { - builder.add(entry.getKey(), (String) entry.getValue()); - } else if (entry.getValue() instanceof Integer) { - builder.add(entry.getKey(), (Integer) entry.getValue()); - } else if (entry.getValue() instanceof Long) { - builder.add(entry.getKey(), (Long) entry.getValue()); - } else if (entry.getValue() instanceof Boolean) { - builder.add(entry.getKey(), (Boolean) entry.getValue()); - } else if (entry.getValue() instanceof Double) { - builder.add(entry.getKey(), (Double) entry.getValue()); - } - } - ClickstreamAnalytics.recordEvent(builder.build()); - } - - @ReactMethod - public void setUserId(String userId) { - ClickstreamAnalytics.setUserId(userId); - } - - @ReactMethod - public void addUserAttributes(ReadableMap map) { - HashMap attributeMap = map.toHashMap(); - ClickstreamUserAttribute.Builder builder = new ClickstreamUserAttribute.Builder(); - for (Map.Entry entry : attributeMap.entrySet()) { - if (entry.getValue() instanceof String) { - builder.add(entry.getKey(), (String) entry.getValue()); - } else if (entry.getValue() instanceof Integer) { - builder.add(entry.getKey(), (Integer) entry.getValue()); - } else if (entry.getValue() instanceof Long) { - builder.add(entry.getKey(), (Long) entry.getValue()); - } else if (entry.getValue() instanceof Boolean) { - builder.add(entry.getKey(), (Boolean) entry.getValue()); - } else if (entry.getValue() instanceof Double) { - builder.add(entry.getKey(), (Double) entry.getValue()); - } - } - ClickstreamAnalytics.addUserAttributes(builder.build()); - } - - @ReactMethod - public void addGlobalAttributes(ReadableMap map) { - HashMap attributeMap = map.toHashMap(); - ClickstreamAttribute.Builder builder = new ClickstreamAttribute.Builder(); - for (Map.Entry entry : attributeMap.entrySet()) { - if (entry.getValue() instanceof String) { - builder.add(entry.getKey(), (String) entry.getValue()); - } else if (entry.getValue() instanceof Integer) { - builder.add(entry.getKey(), (Integer) entry.getValue()); - } else if (entry.getValue() instanceof Long) { - builder.add(entry.getKey(), (Long) entry.getValue()); - } else if (entry.getValue() instanceof Boolean) { - builder.add(entry.getKey(), (Boolean) entry.getValue()); - } else if (entry.getValue() instanceof Double) { - builder.add(entry.getKey(), (Double) entry.getValue()); - } - } - ClickstreamAnalytics.addGlobalAttributes(builder.build()); - } - - @ReactMethod - public void deleteGlobalAttributes(ReadableArray attributes) { - ArrayList attributeArray = new ArrayList<>(); - for (Object attribute : attributes.toArrayList()) { - if (attribute instanceof String) { - attributeArray.add((String) attribute); - } - } - if (attributeArray.size() > 0) { - ClickstreamAnalytics.deleteGlobalAttributes(attributeArray.toArray(new String[0])); - } - } - - @ReactMethod - public void flushEvents() { - ClickstreamAnalytics.flushEvents(); - } - - @ReactMethod - public void enable() { - ClickstreamAnalytics.enable(); - } - - @ReactMethod - public void disable() { - ClickstreamAnalytics.disable(); - } -} diff --git a/react-native/android/app/src/main/java/github/funnyzak/v2ex/MainApplication.java b/react-native/android/app/src/main/java/github/funnyzak/v2ex/MainApplication.java index f0a835b..61ada75 100644 --- a/react-native/android/app/src/main/java/github/funnyzak/v2ex/MainApplication.java +++ b/react-native/android/app/src/main/java/github/funnyzak/v2ex/MainApplication.java @@ -2,8 +2,6 @@ import android.app.Application; -import com.amplifyframework.AmplifyException; - import com.facebook.react.PackageList; import com.facebook.react.ReactApplication; import com.facebook.react.ReactNativeHost; @@ -11,7 +9,6 @@ import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.defaults.DefaultReactNativeHost; import com.facebook.soloader.SoLoader; -import software.aws.solution.clickstream.ClickstreamAnalytics; import java.util.List; @@ -63,17 +60,5 @@ public void onCreate() { DefaultNewArchitectureEntryPoint.load(); } ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); - - // Init ClickstreamAnalytics - try { - ClickstreamAnalytics.init(getApplicationContext()); - - ClickstreamAnalytics.getClickStreamConfiguration() - .withLogEvents(true) - .withTrackScreenViewEvents(false) - .withTrackUserEngagementEvents(false); - } catch (AmplifyException e) { - e.printStackTrace(); - } } -} \ No newline at end of file +} diff --git a/react-native/android/app/src/main/java/github/funnyzak/v2ex/MyAppPackage.java b/react-native/android/app/src/main/java/github/funnyzak/v2ex/MyAppPackage.java index da85f18..94ba8ef 100644 --- a/react-native/android/app/src/main/java/github/funnyzak/v2ex/MyAppPackage.java +++ b/react-native/android/app/src/main/java/github/funnyzak/v2ex/MyAppPackage.java @@ -39,7 +39,6 @@ public List createNativeModules( @NonNull ReactApplicationContext reactContext) { List modules = new ArrayList<>(); - modules.add(new ClickstreamModule(reactContext)); return modules; } } \ No newline at end of file diff --git a/react-native/android/app/src/main/res/raw/amplifyconfiguration.json b/react-native/android/app/src/main/res/raw/amplifyconfiguration.json deleted file mode 100644 index 2b38354..0000000 --- a/react-native/android/app/src/main/res/raw/amplifyconfiguration.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "UserAgent": "aws-solution/clickstream", - "Version": "1.0", - "analytics": { - "plugins": { - "awsClickstreamPlugin": { - "appId": "your appId", - "endpoint": "your endpoint", - "isCompressEvents": true, - "autoFlushEventsInterval": 10000, - "isTrackAppExceptionEvents": false - } - } - } -} diff --git a/react-native/index.js b/react-native/index.js index 87c40b3..0d00d23 100644 --- a/react-native/index.js +++ b/react-native/index.js @@ -1,6 +1,7 @@ import { AppRegistry, LogBox } from 'react-native' import App from './src/App' import { name as appName } from './app.json' +import { ClickstreamAnalytics } from '@aws/clickstream-react-native' // Ignore log notification by message: LogBox.ignoreLogs(['required dispatch_sync', 'flexWrap']) @@ -8,4 +9,13 @@ LogBox.ignoreLogs(['required dispatch_sync', 'flexWrap']) // Ignore all log notifications: // LogBox.ignoreAllLogs(); +ClickstreamAnalytics.init({ + appId: 'your appId', + endpoint: 'https://example.com/collect', + isLogEvents: true, + isTrackScreenViewEvents: false +}).then((result) => { + console.log('Initial Clickstream SDK result: ' + result) +}) + AppRegistry.registerComponent(appName, () => App) diff --git a/react-native/ios/ClickstreamManager.h b/react-native/ios/ClickstreamManager.h deleted file mode 100644 index 2cdefc6..0000000 --- a/react-native/ios/ClickstreamManager.h +++ /dev/null @@ -1,4 +0,0 @@ -// ClickstreamManager.h -#import -@interface ClickstreamManager : NSObject -@end diff --git a/react-native/ios/ClickstreamManager.m b/react-native/ios/ClickstreamManager.m deleted file mode 100644 index 50d12cf..0000000 --- a/react-native/ios/ClickstreamManager.m +++ /dev/null @@ -1,55 +0,0 @@ -// ClickstreamManager.m -#import "ClickstreamManager.h" -#import -@import Clickstream; - -@implementation ClickstreamManager - -// To export a module named ClickstreamManager -RCT_EXPORT_MODULE(ClickstreamAnalytics); - -RCT_EXPORT_METHOD(recordEventWithName:(NSString *)name) -{ - [ClickstreamObjc recordEvent:name]; -} - -RCT_EXPORT_METHOD(recordEvent:(NSString *)name :(NSDictionary *)attributes) -{ - [ClickstreamObjc recordEvent:name :attributes]; -} - -RCT_EXPORT_METHOD(setUserId:(NSString *)userId) -{ - [ClickstreamObjc setUserId:userId]; -} - -RCT_EXPORT_METHOD(addUserAttributes:(NSDictionary *)attributes) -{ - [ClickstreamObjc addUserAttributes:attributes]; -} - -RCT_EXPORT_METHOD(addGlobalAttributes:(NSDictionary *)attributes) -{ - [ClickstreamObjc addGlobalAttributes:attributes]; -} - -RCT_EXPORT_METHOD(deleteGlobalAttributes:(NSArray *)attributes) -{ - [ClickstreamObjc deleteGlobalAttributes:attributes]; -} - -RCT_EXPORT_METHOD(flushEvents) -{ - [ClickstreamObjc flushEvents]; -} - -RCT_EXPORT_METHOD(enable) -{ - [ClickstreamObjc enable]; -} - -RCT_EXPORT_METHOD(disable) -{ - [ClickstreamObjc disable]; -} -@end diff --git a/react-native/ios/Podfile b/react-native/ios/Podfile index 90dc26f..361a3a7 100644 --- a/react-native/ios/Podfile +++ b/react-native/ios/Podfile @@ -1,7 +1,7 @@ require_relative '../node_modules/react-native/scripts/react_native_pods' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' -platform :ios, min_ios_version_supported +platform :ios, 13 prepare_react_native_project! # https://github.com/facebook/react-native/pull/36759 @@ -12,7 +12,7 @@ def __apply_Xcode_14_3_RC_post_install_workaround(installer) installer.pods_project.targets.each do |target| target.build_configurations.each do |config| current_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] - minimum_target = min_ios_version_supported + minimum_target = 13 if current_target.to_f < minimum_target.to_f config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = minimum_target end @@ -72,7 +72,12 @@ target 'app' do # necessary for Mac Catalyst builds :mac_catalyst_enabled => false ) + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION'] + end + end __apply_Xcode_12_5_M1_post_install_workaround(installer) __apply_Xcode_14_3_RC_post_install_workaround(installer) end -end \ No newline at end of file +end diff --git a/react-native/ios/amplifyconfiguration.json b/react-native/ios/amplifyconfiguration.json deleted file mode 100644 index 08c4e47..0000000 --- a/react-native/ios/amplifyconfiguration.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "analytics": { - "plugins": { - "awsClickstreamPlugin": { - "appId": "your appId", - "endpoint": "your endpoint", - "isCompressEvents": true, - "autoFlushEventsInterval": 10000, - "isTrackAppExceptionEvents": false - } - } - } -} diff --git a/react-native/ios/app-Bridging-Header.h b/react-native/ios/app-Bridging-Header.h deleted file mode 100644 index 1b2cb5d..0000000 --- a/react-native/ios/app-Bridging-Header.h +++ /dev/null @@ -1,4 +0,0 @@ -// -// Use this file to import your target's public headers that you would like to expose to Swift. -// - diff --git a/react-native/ios/app.xcodeproj/project.pbxproj b/react-native/ios/app.xcodeproj/project.pbxproj index a3db3dc..800f801 100644 --- a/react-native/ios/app.xcodeproj/project.pbxproj +++ b/react-native/ios/app.xcodeproj/project.pbxproj @@ -11,10 +11,6 @@ 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.mm */; }; 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 3A46E88B2B26B70F0042C324 /* Clickstream in Frameworks */ = {isa = PBXBuildFile; productRef = 3A46E88A2B26B70F0042C324 /* Clickstream */; }; - 3A78F5E02B26DB16006001B7 /* ClickstreamManager.h in Sources */ = {isa = PBXBuildFile; fileRef = 3A78F5DF2B26DB16006001B7 /* ClickstreamManager.h */; }; - 3A78F5E22B26DC73006001B7 /* ClickstreamManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 3A78F5E12B26DC73006001B7 /* ClickstreamManager.m */; }; - 3A78F5E72B26E58A006001B7 /* amplifyconfiguration.json in Resources */ = {isa = PBXBuildFile; fileRef = 3A78F5E62B26E58A006001B7 /* amplifyconfiguration.json */; }; 6172F2D35A4C3AA820D92908 /* libPods-app.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 6423831EA8574132BED9D8CC /* libPods-app.a */; }; 7EF68E3733C33B6898317E18 /* libPods-app-appTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = ABFE59519B596E51CEFDCCC0 /* libPods-app-appTests.a */; }; 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */; }; @@ -41,10 +37,6 @@ 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = app/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = app/main.m; sourceTree = ""; }; 1D0AE47A65C8663E3B452821 /* Pods-app-appTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app-appTests.release.xcconfig"; path = "Target Support Files/Pods-app-appTests/Pods-app-appTests.release.xcconfig"; sourceTree = ""; }; - 3A78F5DF2B26DB16006001B7 /* ClickstreamManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ClickstreamManager.h; sourceTree = ""; }; - 3A78F5E12B26DC73006001B7 /* ClickstreamManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ClickstreamManager.m; sourceTree = ""; }; - 3A78F5E32B26E493006001B7 /* app-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "app-Bridging-Header.h"; sourceTree = ""; }; - 3A78F5E62B26E58A006001B7 /* amplifyconfiguration.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = amplifyconfiguration.json; sourceTree = ""; }; 6423831EA8574132BED9D8CC /* libPods-app.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-app.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 6C97AB639B58BBB4B15BBE30 /* Pods-app-appTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-app-appTests.debug.xcconfig"; path = "Target Support Files/Pods-app-appTests/Pods-app-appTests.debug.xcconfig"; sourceTree = ""; }; 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = app/LaunchScreen.storyboard; sourceTree = ""; }; @@ -68,7 +60,6 @@ buildActionMask = 2147483647; files = ( 6172F2D35A4C3AA820D92908 /* libPods-app.a in Frameworks */, - 3A46E88B2B26B70F0042C324 /* Clickstream in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -95,16 +86,12 @@ 13B07FAE1A68108700A75B9A /* app */ = { isa = PBXGroup; children = ( - 3A78F5E62B26E58A006001B7 /* amplifyconfiguration.json */, 13B07FAF1A68108700A75B9A /* AppDelegate.h */, 13B07FB01A68108700A75B9A /* AppDelegate.mm */, 13B07FB51A68108700A75B9A /* Images.xcassets */, 13B07FB61A68108700A75B9A /* Info.plist */, 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 13B07FB71A68108700A75B9A /* main.m */, - 3A78F5DF2B26DB16006001B7 /* ClickstreamManager.h */, - 3A78F5E12B26DC73006001B7 /* ClickstreamManager.m */, - 3A78F5E32B26E493006001B7 /* app-Bridging-Header.h */, ); name = app; sourceTree = ""; @@ -203,9 +190,6 @@ dependencies = ( ); name = app; - packageProductDependencies = ( - 3A46E88A2B26B70F0042C324 /* Clickstream */, - ); productName = app; productReference = 13B07F961A680F5B00A75B9A /* app.app */; productType = "com.apple.product-type.application"; @@ -236,9 +220,6 @@ Base, ); mainGroup = 83CBB9F61A601CBA00E9B192; - packageReferences = ( - 3A46E8892B26B70F0042C324 /* XCRemoteSwiftPackageReference "clickstream-swift" */, - ); productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; projectDirPath = ""; projectRoot = ""; @@ -262,7 +243,6 @@ buildActionMask = 2147483647; files = ( 81AB9BB82411601600AC10FF /* LaunchScreen.storyboard in Resources */, - 3A78F5E72B26E58A006001B7 /* amplifyconfiguration.json in Resources */, 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -430,10 +410,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 3A78F5E22B26DC73006001B7 /* ClickstreamManager.m in Sources */, 13B07FBC1A68108700A75B9A /* AppDelegate.mm in Sources */, 13B07FC11A68108700A75B9A /* main.m in Sources */, - 3A78F5E02B26DB16006001B7 /* ClickstreamManager.h in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -453,6 +431,7 @@ baseConfigurationReference = 6C97AB639B58BBB4B15BBE30 /* Pods-app-appTests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; + DEVELOPMENT_TEAM = ""; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -481,6 +460,7 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = appTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = ( @@ -506,9 +486,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Distribution"; + CODE_SIGN_IDENTITY = "Apple Development"; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 29; - DEVELOPMENT_TEAM = ED4U2734MB; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; INFOPLIST_FILE = app/Info.plist; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; @@ -525,7 +506,7 @@ ); PRODUCT_BUNDLE_IDENTIFIER = github.funnyzak.v2ex; PRODUCT_NAME = app; - PROVISIONING_PROFILE_SPECIFIER = "v2ex dist"; + PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "app-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VER6.0 = SWIFT_VER6.0; @@ -543,11 +524,9 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES; CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "Apple Development"; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; - CODE_SIGN_STYLE = Manual; + CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 29; DEVELOPMENT_TEAM = ""; - "DEVELOPMENT_TEAM[sdk=iphoneos*]" = ED4U2734MB; INFOPLIST_FILE = app/Info.plist; INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities"; IPHONEOS_DEPLOYMENT_TARGET = 12.4; @@ -564,7 +543,6 @@ PRODUCT_BUNDLE_IDENTIFIER = github.funnyzak.v2ex; PRODUCT_NAME = app; PROVISIONING_PROFILE_SPECIFIER = ""; - "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "v2ex app dis m1"; SWIFT_OBJC_BRIDGING_HEADER = "app-Bridging-Header.h"; SWIFT_VER6.0 = SWIFT_VER6.0; SWIFT_VERSION = 6.0; @@ -729,25 +707,6 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ - -/* Begin XCRemoteSwiftPackageReference section */ - 3A46E8892B26B70F0042C324 /* XCRemoteSwiftPackageReference "clickstream-swift" */ = { - isa = XCRemoteSwiftPackageReference; - repositoryURL = "https://github.com/awslabs/clickstream-swift.git"; - requirement = { - kind = upToNextMajorVersion; - minimumVersion = 0.8.0; - }; - }; -/* End XCRemoteSwiftPackageReference section */ - -/* Begin XCSwiftPackageProductDependency section */ - 3A46E88A2B26B70F0042C324 /* Clickstream */ = { - isa = XCSwiftPackageProductDependency; - package = 3A46E8892B26B70F0042C324 /* XCRemoteSwiftPackageReference "clickstream-swift" */; - productName = Clickstream; - }; -/* End XCSwiftPackageProductDependency section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; } diff --git a/react-native/ios/app/AppDelegate.mm b/react-native/ios/app/AppDelegate.mm index cc143fb..68438d7 100644 --- a/react-native/ios/app/AppDelegate.mm +++ b/react-native/ios/app/AppDelegate.mm @@ -1,7 +1,6 @@ #import "AppDelegate.h" #import #import "RNSplashScreen.h" // react-native-splash-screen -@import Clickstream; @implementation AppDelegate @@ -16,21 +15,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( [RNSplashScreen show]; // react-native-splash-screen - NSError *error = nil; - [ClickstreamObjc initSDKAndReturnError:&error]; - - if (error) { - NSLog(@"Failed to initialize ClickstreamAnalytics: %@", error.localizedDescription); - } - ClickstreamContextConfiguration *configuration = [ClickstreamObjc getClickstreamConfigurationAndReturnError:&error]; - if (configuration) { - [configuration setIsLogEvents:true]; - [configuration setIsTrackScreenViewEvents:false]; - [configuration setIsTrackUserEngagementEvents:false]; - }else{ - NSLog(@"Failed to get configuration: %@", error.localizedDescription); - } - return YES; } diff --git a/react-native/package.json b/react-native/package.json index 426361b..eb0b6d4 100644 --- a/react-native/package.json +++ b/react-native/package.json @@ -17,7 +17,7 @@ "lint:style:fix": "prettier --write '**/*.{ts,js,jsx,tsx}'", "lint": "yarn lint:code && yarn lint:style", "lint:fix": "yarn lint:style:fix && yarn lint:code --fix", - "prepare": "if [[ $NODE_ENV != \"production\" ]]; then husky install; fi && patch-package", + "prepare": "patch-package", "p": "plop", "upgrade": "react-native upgrade", "check-dependencies": "rnx-dep-check", @@ -48,6 +48,7 @@ }, "homepage": "https://v2hub.yycc.dev/", "dependencies": { + "@aws/clickstream-react-native": "0.1.1", "@bugsnag/react-native": "7.18.2", "@react-native-async-storage/async-storage": "^1.17.11", "@react-native-masked-view/masked-view": "^0.2.8", diff --git a/react-native/src/actions/MemberActions.ts b/react-native/src/actions/MemberActions.ts index a3fab99..230da17 100644 --- a/react-native/src/actions/MemberActions.ts +++ b/react-native/src/actions/MemberActions.ts @@ -28,16 +28,18 @@ import { AppObject } from '../types' import { cacheMemberFollowing, cacheMemberInterestNodes, cacheMemberLikeTopicss } from './CacheAction' -import { NativeModules } from 'react-native' - -const { ClickstreamAnalytics } = NativeModules +import { ClickstreamAnalytics } from '@aws/clickstream-react-native' export const myProfile = () => async (dispatch: Dispatch, getState: () => RootState) => { const _member = await ApiLib.member.myProfile() console.log('member:' + JSON.stringify(_member)) ClickstreamAnalytics.setUserId(_member.id.toString()) - ClickstreamAnalytics.addUserAttributes({ user_name: _member.username }) - ClickstreamAnalytics.recordEventWithName('login') + ClickstreamAnalytics.setUserAttributes({ + user_name: _member.username + }) + ClickstreamAnalytics.record({ + name: 'login' + }) dispatch({ type: MEMBER_PROFILE, payload: _member diff --git a/react-native/src/navigation/Navigator.tsx b/react-native/src/navigation/Navigator.tsx index 3e38fb1..ca79858 100755 --- a/react-native/src/navigation/Navigator.tsx +++ b/react-native/src/navigation/Navigator.tsx @@ -38,6 +38,8 @@ import SplashScreen from 'react-native-splash-screen' import '../components/actions-sheet' import NavigationService from './NavigationService' import { CommonScreenProps, RootStackParamList, ROUTES } from './routes' +import { ClickstreamAnalytics } from '@aws/clickstream-react-native' + /** * dayjs */ @@ -339,6 +341,29 @@ const MainAppNavigator = () => { } const StackNavigator = createNativeStackNavigator() export const AppNavigationContainer = () => { + let mNavigationRef: NavigationContainerRefWithCurrent + let currentScreenName = '' + const recordScreenView = (name: string) => { + ClickstreamAnalytics.record({ + name: ClickstreamAnalytics.Event.SCREEN_VIEW, + attributes: { + [ClickstreamAnalytics.Attr.SCREEN_NAME]: name + } + }) + console.log('Recorded screen view: ' + name) + } + const onReady = () => { + recordScreenView('Hot') + } + + const onStateChange = () => { + const routeName = mNavigationRef?.getCurrentRoute()?.name + if (routeName && currentScreenName !== routeName) { + recordScreenView(routeName) + currentScreenName = routeName + } + } + const { token } = useAppSelector((state: RootState) => state.member) const { login: { tokenGeneratedLink } @@ -365,7 +390,10 @@ export const AppNavigationContainer = () => { ) => { NavigationService.setTopLevelNavigator(navigatorRef) + mNavigationRef = navigatorRef }} + onReady={onReady} + onStateChange={onStateChange} theme={{ dark: theme.name === 'dark', colors: { diff --git a/react-native/src/screens/my/Home.tsx b/react-native/src/screens/my/Home.tsx index 1e31f7f..6da5e60 100644 --- a/react-native/src/screens/my/Home.tsx +++ b/react-native/src/screens/my/Home.tsx @@ -11,11 +11,11 @@ import { SylCommon, useTheme } from '@src/theme' import { IState, AppObject } from '@src/types' import { linking } from '@src/utils' import React, { useEffect } from 'react' -import { NativeModules, ScrollView } from 'react-native' +import { ScrollView } from 'react-native' import { connect } from 'react-redux' import { Footer, HeaderButton, ProfileCard, SetStatusBar, TableList, TableRow } from '../components' +import { ClickstreamAnalytics } from '@aws/clickstream-react-native' -const { ClickstreamAnalytics } = NativeModules const My = ({ navigation, app, @@ -51,16 +51,19 @@ const My = ({ text={translate('common.more')} onPress={() => { console.log('click_user_more') - ClickstreamAnalytics.recordEvent('button_click', { - location: 'user_more', - profile_url: profile?.url + ClickstreamAnalytics.record({ + name: 'button_click', + attributes: { + location: 'user_more', + profile_url: profile?.url + } }) - ClickstreamAnalytics.addGlobalAttributes({ + ClickstreamAnalytics.setGlobalAttributes({ user_name: 'test_username', test_global_attribute: 'test_global_attribute_value' }) - ClickstreamAnalytics.deleteGlobalAttributes(['test_global_attribute', 'location']) + ClickstreamAnalytics.deleteGlobalAttributes(['test_global_attribute']) ClickstreamAnalytics.disable() ClickstreamAnalytics.enable() navigation.navigate(ROUTES.WebViewer, { url: profile?.url }) diff --git a/react-native/yarn.lock b/react-native/yarn.lock index 468f1aa..7ba6c51 100644 --- a/react-native/yarn.lock +++ b/react-native/yarn.lock @@ -15,6 +15,11 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" +"@aws/clickstream-react-native@0.1.1": + version "0.1.1" + resolved "https://registry.npmjs.org/@aws/clickstream-react-native/-/clickstream-react-native-0.1.1.tgz#227daaba2bebbbd8cef79efe1b3ed689420ee703" + integrity sha512-FWOgDh/vf0eOVVeBbzRjrcvwBq3mwieBtMw5efZeU1VrUEw63lvgixT2vufc2cNW/rLpSnwCVIM+dehJAIR4vg== + "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.22.5", "@babel/code-frame@^7.23.5": version "7.23.5" resolved "https://registry.npmmirror.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244" diff --git a/web/.gitignore b/web/.gitignore index 2d7ec5c..7b4dd92 100644 --- a/web/.gitignore +++ b/web/.gitignore @@ -1,2 +1,3 @@ .env node_modules/ +dist