From 77bfe2aa029e8e2c850f5b196dba69858d4bc3f0 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Tue, 18 Apr 2023 17:07:33 +0900 Subject: [PATCH 01/25] fix ci --- .github/workflows/create-release-branch-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 3dea954..2fd738d 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -40,7 +40,7 @@ jobs: run: | .github/workflows/scripts/updatePlugin.sh pluginVersion=${{ github.event.inputs.versionName }} buildNumber=${{ github.event.inputs.BuildNumber }} iOSVersion=${{ github.event.inputs.iosVersion }} androidVersion=${{ github.event.inputs.AndroidVersion }} git commit -m "update versions using CI" - git push + git push -u origin --all - name: create pull request env: From 72c9b820a77b00099d0329ea01eb27d5673ba2b9 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Thu, 30 Mar 2023 14:04:30 +0300 Subject: [PATCH 02/25] update SDK to 6.10.2 --- .github/workflows/build-apps-workflow.yml | 50 + .github/workflows/close-inactive-issue.yml | 19 + .github/workflows/deploy-to-QA.yml | 58 + .github/workflows/pre-release-workflow.yml | 49 + .../workflows/release-Production-workflow.yml | 79 ++ .github/workflows/release-QA-workflow.yml | 23 + .github/workflows/scripts/archiveApp.sh | 8 + .github/workflows/scripts/decryptSecrets.sh | 19 + .../scripts/releaseNotesGenerator.sh | 19 + AppsflyerCapacitorPlugin.podspec | 1 - README.md | 4 +- android/build.gradle | 42 +- .../plugin/appsflyer/sdk/AppsFlyerPlugin.kt | 10 +- ios/Plugin.xcodeproj/project.pbxproj | 10 +- ios/Plugin/AppsFlyerPlugin.swift | 1154 +++++++++-------- ios/Podfile | 9 +- package.json | 6 +- src/definitions.ts | 1 + 18 files changed, 987 insertions(+), 574 deletions(-) create mode 100644 .github/workflows/build-apps-workflow.yml create mode 100644 .github/workflows/close-inactive-issue.yml create mode 100644 .github/workflows/deploy-to-QA.yml create mode 100644 .github/workflows/pre-release-workflow.yml create mode 100644 .github/workflows/release-Production-workflow.yml create mode 100644 .github/workflows/release-QA-workflow.yml create mode 100644 .github/workflows/scripts/archiveApp.sh create mode 100644 .github/workflows/scripts/decryptSecrets.sh create mode 100644 .github/workflows/scripts/releaseNotesGenerator.sh diff --git a/.github/workflows/build-apps-workflow.yml b/.github/workflows/build-apps-workflow.yml new file mode 100644 index 0000000..c75572a --- /dev/null +++ b/.github/workflows/build-apps-workflow.yml @@ -0,0 +1,50 @@ +name: Build apps with AppsFlyer plugin + +on: + workflow_call: + +jobs: + Build-Capacitor-android: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: install capacitor-appsflyer on an Android app + run: | + cd examples/CapacitorReact + npm install + npm install ../../ + npx cap sync android + - name: Build apk + run: | + cd examples/CapacitorReact/android + echo "pwd: $(pwd)" + gradle wrapper + echo "ls: $(ls)" + chmod +x ./gradlew + ./gradlew assembleRelease + # Build-Capacitor-ios: + # runs-on: macos-latest + # steps: + # - uses: actions/checkout@v3 + # - name: install react-native-appsflyer on an iOS app + # run: | + # cd demos/appsflyer-react-native-app + # yarn install --force + # yarn add ../../ --save + # - name: Install Dependencies + # run: | + # cd demos/appsflyer-react-native-app/ios + # pod install --repo-update + + # - name: Setup provisioning profile + # env: + # IOS_KEYS: ${{ secrets.IOS_KEYS }} + # run: | + # chmod +x .github/workflows/scripts/decryptSecrets.sh + # ./.github/workflows/scripts/decryptSecrets.sh + # - name: Archive app + # run: | + # sudo xcode-select --switch /Applications/Xcode_12.5.1.app + # chmod +x .github/workflows/scripts/archiveApp.sh + # cd demos/appsflyer-react-native-app/ios + # ./../../../.github/workflows/scripts/archiveApp.sh diff --git a/.github/workflows/close-inactive-issue.yml b/.github/workflows/close-inactive-issue.yml new file mode 100644 index 0000000..97cc463 --- /dev/null +++ b/.github/workflows/close-inactive-issue.yml @@ -0,0 +1,19 @@ + +# This workflow close issue and add comment after the issue labaled as 'inactive' + +name: Close issue +on: + issues: + types: + - labeled +jobs: + close-inactive-issue: + if: github.event.label.name == 'Inactive' + runs-on: ubuntu-latest + steps: + - name: Close issue due to inactivity + uses: peter-evans/close-issue@v2 + with: + issue-number: ${{ github.event.issue.number }} + comment: | + This issue is closed due to inactivity. If the issue continue, please open a new one. \ No newline at end of file diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml new file mode 100644 index 0000000..fb41e41 --- /dev/null +++ b/.github/workflows/deploy-to-QA.yml @@ -0,0 +1,58 @@ +name: Deploy To QA + +on: + workflow_call: + +jobs: + Deploy-to-QA: + runs-on: ubuntu-latest + environment: Staging + steps: + - uses: actions/checkout@v3 + - name: Login to Github + env: + COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} + COMMIT_EMAIL: ${{ secrets.CI_COMMIT_EMAIL }} + run: | + git config --global user.name $COMMIT_AUTHOR + git config --global user.email $COMMIT_EMAIL + + - name: Check if fixed version is on Jira + env: + JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} + BRANCH_NAME: ${{github.ref_name}} + run: | + fixed_version_found=false + plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9].[0-9].[0-9]+') + jira_fixed_version="Capacitor SDK v$plugin_version" + # echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV + echo "JIRA_FIXED_VERSION=$jira_fixed_version" >> $GITHUB_ENV + chmod +x .github/workflows/scripts/releaseNotesGenerator.sh + .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$jira_fixed_version" + - name: Update package.json file + run: | + plugin_rc_version=$(echo "${{github.ref_name}}" | grep -Eo '[0-9].[0-9].[0-9]+-rc[0-9]+') + echo "Updating plugin to version $plugin_rc_version" + npm version $plugin_rc_version --no-git-tag-version + echo "Updating package.json and AppsFlyerPlugin.swift to version $plugin_rc_version" + chmod +x .github/workflows/scripts/updatePluginVersion.sh + .github/workflows/scripts/updatePluginVersion.sh $plugin_rc_version + git add package.json + git add ios/Plugin/AppsFlyerPlugin.swift + git commit -m "update package.json" + git push + - name: Push to NPM + env: + CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc + npm run build + npm publish --tag QA + - name: Generate and send slack report + env: + SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} + run: | + ios_sdk_version=$(cat README.md | grep 'iOS AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') + android_sdk_version=$(cat README.md | grep 'Android AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') + CHANGES=$(cat "${{env.JIRA_FIXED_VERSION}}-releasenotes".txt) + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"${{github.ref_name}}"'", "changes_and_fixes": "'"$CHANGES"'", "android_dependency": "'"$android_sdk_version"'", "ios_dependency": "'"$ios_sdk_version"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/pre-release-workflow.yml b/.github/workflows/pre-release-workflow.yml new file mode 100644 index 0000000..bb90d76 --- /dev/null +++ b/.github/workflows/pre-release-workflow.yml @@ -0,0 +1,49 @@ +name: Prepare plugin for production + +on: + pull_request: + types: + - opened + branches: + - 'master' + +jobs: + Prepare-Plugin-For-Production: + if: startsWith(github.head_ref, 'releases/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Login to Github + env: + COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} + COMMIT_EMAIL: ${{ secrets.CI_COMMIT_EMAIL }} + run: | + git config --global user.name $COMMIT_AUTHOR + git config --global user.email $COMMIT_EMAIL + - uses: mdecoleman/pr-branch-name@1.2.0 + id: vars + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Update package.json file + run: | + plugin_version=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9].[0-9]+') + # we export plugin_version and release branch name as env so we can use them in the next step + echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV + echo "GIT_BRANCH_RELEASE=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV + echo "Updating plugin to version $plugin_version" + npm version $plugin_version + git push origin HEAD:${{ steps.vars.outputs.branch }} --force + + - name: Update CHANGELOG.md + env: + JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} + JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}" + run: | + chmod +x .github/workflows/scripts/releaseNotesGenerator.sh + .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" + NEW_VERSION_RELEASE_NOTES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) + NEW_VERSION_SECTION="## ${{ env.PLUGIN_VERSION }}\n Release date: *$(date +%F)*\n\n$NEW_VERSION_RELEASE_NOTES\n" + echo -e "$NEW_VERSION_SECTION\n$(cat CHANGELOG.md)" > CHANGELOG.md + git add CHANGELOG.md + git commit -m "Update CHANGELOG.md" + git push origin HEAD:${{ env.GIT_BRANCH_RELEASE }} --force diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml new file mode 100644 index 0000000..59245a2 --- /dev/null +++ b/.github/workflows/release-Production-workflow.yml @@ -0,0 +1,79 @@ +name: Release plugin to production + +on: + pull_request: + types: + - closed + branches: + - 'master' + paths-ignore: + - '**.md' + - '**.yml' + - 'examples/**' + - 'docs/**' + - 'assets/**' +jobs: + Deploy-To-Production: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Login to Github + env: + COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} + COMMIT_EMAIL: ${{ secrets.CI_COMMIT_EMAIL }} + run: | + git config --global user.name $COMMIT_AUTHOR + git config --global user.email $COMMIT_EMAIL + - uses: mdecoleman/pr-branch-name@1.2.0 + id: vars + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Determine release tag and release branch + run: | + TAG=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9].[0-9]+') + echo "PLUGIN_VERSION=$TAG" >> $GITHUB_ENV + echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV + echo "push new release >> $TAG" + + - name: "Create release" + env: + TAG: ${{env.PLUGIN_VERSION}} + uses: "actions/github-script@v5" + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + script: | + try { + await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: false, + name: process.env.TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.TAG + }); + } catch (error) { + core.setFailed(error.message); + } + - name: Push to NPM + env: + CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} + run: | + echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc + nmp run build + npm publish + + - name: Generate and send slack report + env: + SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} + JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} + JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}" + RELEASE_BRACH_NAME: ${{env.RELEASE_BRANCH_NAME}} + run: | + chmod +x .github/workflows/scripts/releaseNotesGenerator.sh + .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" + ios_sdk_version=$(cat README.md | grep 'iOS AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') + android_sdk_version=$(cat README.md | grep 'Android AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') + CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRACH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "android_dependencie": "'"$android_sdk_version"'", "ios_dependencie": "'"$ios_sdk_version"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml new file mode 100644 index 0000000..93d7b7b --- /dev/null +++ b/.github/workflows/release-QA-workflow.yml @@ -0,0 +1,23 @@ +name: Release plugin to QA + +on: + push: + branches: + - releases/[0-9].x.x/[0-9].[0-9].x/[0-9].[0-9].[0-9]+-rc[0-9]+ + paths-ignore: + - '**.md' + - '**.yml' + - 'examples/**' + - 'assets/**' + - 'docs/**' + +jobs: + + Build-Sample-Apps: + uses: ./.github/workflows/build-apps-workflow.yml + secrets: inherit + + Deploy-To-QA: + needs: [Build-Sample-Apps] + uses: ./.github/workflows/deploy-to-QA.yml + secrets: inherit diff --git a/.github/workflows/scripts/archiveApp.sh b/.github/workflows/scripts/archiveApp.sh new file mode 100644 index 0000000..11b3162 --- /dev/null +++ b/.github/workflows/scripts/archiveApp.sh @@ -0,0 +1,8 @@ +set -eo pipefail + +xcodebuild -workspace AppsFlyerExample.xcworkspace \ + -scheme AppsFlyerExample \ + -sdk iphoneos \ + -allowProvisioningUpdates \ + -archivePath $PWD/build/AppsFlyerExample.xcarchive \ + clean archive | xcpretty diff --git a/.github/workflows/scripts/decryptSecrets.sh b/.github/workflows/scripts/decryptSecrets.sh new file mode 100644 index 0000000..48776fb --- /dev/null +++ b/.github/workflows/scripts/decryptSecrets.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -eo pipefail + +gpg --quiet --batch --yes --decrypt --passphrase="$IOS_KEYS" --output ./.github/secrets/GithubCIApp.mobileprovision.mobileprovision ./.github/secrets/GithubCIApp.mobileprovision.gpg +gpg --quiet --batch --yes --decrypt --passphrase="$IOS_KEYS" --output ./.github/secrets/GithubCICer.p12 ./.github/secrets/GithubCICer.p12.gpg + +mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles + +cp ./.github/secrets/GithubCIApp.mobileprovision.mobileprovision ~/Library/MobileDevice/Provisioning\ Profiles/GithubCIApp.mobileprovision.mobileprovision + + +security create-keychain -p "$IOS_KEYS" build.keychain +security import ./.github/secrets/GithubCICer.p12 -t agg -k ~/Library/Keychains/build.keychain -P "$IOS_KEYS" -A + +security list-keychains -s ~/Library/Keychains/build.keychain +security default-keychain -s ~/Library/Keychains/build.keychain +security unlock-keychain -p "$IOS_KEYS" ~/Library/Keychains/build.keychain + +security set-key-partition-list -S apple-tool:,apple: -s -k "$IOS_KEYS" ~/Library/Keychains/build.keychain diff --git a/.github/workflows/scripts/releaseNotesGenerator.sh b/.github/workflows/scripts/releaseNotesGenerator.sh new file mode 100644 index 0000000..2c0f589 --- /dev/null +++ b/.github/workflows/scripts/releaseNotesGenerator.sh @@ -0,0 +1,19 @@ +JIRA_TOKEN=$1 +JIRA_FIXED_VERSION=$2 + +fixed_version_found=false +curl -X GET -H "Authorization: Basic $JIRA_TOKEN=" https://appsflyer.atlassian.net/rest/api/3/project/11723/versions | jq -r '.[] | .name+""+.id' | while read version ; do +if [[ "$version" == *"$JIRA_FIXED_VERSION"* ]] ;then + echo "$JIRA_FIXED_VERSION Found!" + fixed_version_found=true + version_id=${version#"$JIRA_FIXED_VERSION"} + echo $(curl -X GET -H "Authorization: Basic $JIRA_TOKEN=" https://appsflyer.atlassian.net/rest/api/3/search?jql=fixVersion=$version_id | jq -r '.issues[] | "- " + .fields["summary"]+"@"') > "$JIRA_FIXED_VERSION-releasenotes".txt + sed -i -r -e "s/@ /\n/gi" "$JIRA_FIXED_VERSION-releasenotes".txt + sed -i -r -e "s/@/\n/gi" "$JIRA_FIXED_VERSION-releasenotes".txt + cat "$JIRA_FIXED_VERSION-releasenotes".txt +fi +done +if [ fixed_version_found == false ];then +echo "$JIRA_FIXED_VERSION is not found!" +exit 1 +fi \ No newline at end of file diff --git a/AppsflyerCapacitorPlugin.podspec b/AppsflyerCapacitorPlugin.podspec index f4c7bf7..5765969 100644 --- a/AppsflyerCapacitorPlugin.podspec +++ b/AppsflyerCapacitorPlugin.podspec @@ -1,7 +1,6 @@ require 'json' package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) - Pod::Spec.new do |s| s.name = 'AppsflyerCapacitorPlugin' s.version = package['version'] diff --git a/README.md b/README.md index 479799d..d473964 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ ### This plugin is built for -- Android AppsFlyer SDK **6.9.2️** -- iOS AppsFlyer SDK **6.9.0** +- Android AppsFlyer SDK **6.10.2** +- iOS AppsFlyer SDK **6.10.1** ## ❗❗ Breaking changes when updating to v6.9.2❗❗ Starting from v6.9.2, this plugin works only with Capacitor 4.
diff --git a/android/build.gradle b/android/build.gradle index 638035f..d841a3b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,8 +1,37 @@ +// On top of your file import a JSON parser +import groovy.json.JsonSlurper + +def getPackageJson() { + // Read and parse package.json file from project root + def dir = "$rootDir/../node_modules/appsflyer-capacitor-plugin/package.json" + def inputFile = new File(dir) + def packageJson = new JsonSlurper().parseText(inputFile.text) + return packageJson +} +// Create an easy to use function +def getVersionFromNpm() { + // Return the version, you can get any value this way + return getPackageJson()["version"] +} + +// Create an easy to use function +def getSDKVersionFromNpm() { + // Return the version, you can get any value this way + return getPackageJson()["androidSdkVersion"] +} +def getPluginBuildVersionFromNpm() { + // Return the version, you can get any value this way + return getPackageJson()["buildNumber"] +} + ext { junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2' androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2' androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3' androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0' + af_sdk_version = getSDKVersionFromNpm() + plugin_version = getVersionFromNpm() + plugin_build_version = getPluginBuildVersionFromNpm() } buildscript { @@ -14,7 +43,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - + classpath 'org.codehaus.groovy:groovy-json:3.0.9' } } @@ -26,8 +55,10 @@ android { defaultConfig { minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22 targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32 - versionCode 1 - versionName "1.0" + versionCode Integer.parseInt(plugin_build_version) + versionName "$plugin_version" + buildConfigField "int", "VERSION_CODE", plugin_build_version + buildConfigField "String", "VERSION_NAME", "\"$plugin_version\"" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -60,11 +91,10 @@ dependencies { androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion" androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" implementation "androidx.core:core-ktx:1.8.0" - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" - implementation 'com.appsflyer:af-android-sdk:6.9.2' + implementation "com.appsflyer:af-android-sdk:$af_sdk_version" implementation "com.android.installreferrer:installreferrer:2.2" - } diff --git a/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt b/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt index a0d7c49..1fd75ab 100644 --- a/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt +++ b/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt @@ -7,6 +7,7 @@ import com.appsflyer.* import com.appsflyer.attribution.AppsFlyerRequestListener import com.appsflyer.deeplink.DeepLinkListener import com.appsflyer.deeplink.DeepLinkResult +import com.appsflyer.internal.platform_extension.PluginInfo import com.appsflyer.share.CrossPromotionHelper import com.appsflyer.share.ShareInviteHelper import com.getcapacitor.JSObject @@ -53,6 +54,13 @@ class AppsFlyerPlugin : Plugin() { val timeout = call.getInt(AF_DEEP_LINK_TIME_OUT)?.toLong() AppsFlyerLib.getInstance().apply { + setPluginInfo( + PluginInfo( + com.appsflyer.internal.platform_extension.Plugin.CAPACITOR, + BuildConfig.VERSION_NAME + //, mapOf("build_number" to BuildConfig.VERSION_CODE.toString()) + ) + ) if (debug == true) { setDebugLog(true) } @@ -578,5 +586,3 @@ class AppsFlyerPlugin : Plugin() { } } } - - diff --git a/ios/Plugin.xcodeproj/project.pbxproj b/ios/Plugin.xcodeproj/project.pbxproj index f792921..31188b8 100644 --- a/ios/Plugin.xcodeproj/project.pbxproj +++ b/ios/Plugin.xcodeproj/project.pbxproj @@ -15,6 +15,7 @@ 50ADFFA42020D75100D50D53 /* Capacitor.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 50ADFFA52020D75100D50D53 /* Capacitor.framework */; }; 50ADFFA82020EE4F00D50D53 /* AppsFlyerPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = 50ADFFA72020EE4F00D50D53 /* AppsFlyerPlugin.m */; }; 50E1A94820377CB70090CE1A /* AppsFlyerPlugin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E1A94720377CB70090CE1A /* AppsFlyerPlugin.swift */; }; + C6820C0629D1EBA50020BBCA /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 50ADFF8C201F53D600D50D53 /* Info.plist */; }; C689C26C26CBBD7B000B51D0 /* AppsFlyerLib.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = C689C26B26CBBD7B000B51D0 /* AppsFlyerLib.xcframework */; }; C689C26D26CBBD7B000B51D0 /* AppsFlyerLib.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C689C26B26CBBD7B000B51D0 /* AppsFlyerLib.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C69497B72696FDC300219F77 /* AppsFlyerConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69497B62696FDC300219F77 /* AppsFlyerConstants.swift */; }; @@ -60,6 +61,7 @@ 5E23F77F099397094342571A /* Pods-Plugin.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig"; sourceTree = ""; }; 91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Plugin.release.xcconfig"; path = "Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig"; sourceTree = ""; }; 96ED1B6440D6672E406C8D19 /* Pods-PluginTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-PluginTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig"; sourceTree = ""; }; + C6820C0A29D322AA0020BBCA /* XcodeKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XcodeKit.framework; path = Library/Frameworks/XcodeKit.framework; sourceTree = DEVELOPER_DIR; }; C689C26B26CBBD7B000B51D0 /* AppsFlyerLib.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AppsFlyerLib.xcframework; path = "Pods/appsflyer-apple-sdk-qa/AppsFlyerLib.xcframework"; sourceTree = ""; }; C69497B62696FDC300219F77 /* AppsFlyerConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppsFlyerConstants.swift; sourceTree = ""; }; C69497B82697012D00219F77 /* AppsFlyerLib.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = AppsFlyerLib.xcframework; path = Pods/AppsFlyerFramework/AppsFlyerLib.xcframework; sourceTree = ""; }; @@ -149,6 +151,7 @@ A797B9EFA3DCEFEA1FBB66A9 /* Frameworks */ = { isa = PBXGroup; children = ( + C6820C0A29D322AA0020BBCA /* XcodeKit.framework */, C689C26B26CBBD7B000B51D0 /* AppsFlyerLib.xcframework */, C69497B82697012D00219F77 /* AppsFlyerLib.xcframework */, 50ADFFA52020D75100D50D53 /* Capacitor.framework */, @@ -258,6 +261,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + C6820C0629D1EBA50020BBCA /* Info.plist in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -492,9 +496,10 @@ baseConfigurationReference = 5E23F77F099397094342571A /* Pods-Plugin.debug.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = 6UQAD4B3U2; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; @@ -522,9 +527,10 @@ baseConfigurationReference = 91781294A431A2A7CC6EB714 /* Pods-Plugin.release.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = ""; + CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; + DEVELOPMENT_TEAM = 6UQAD4B3U2; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; diff --git a/ios/Plugin/AppsFlyerPlugin.swift b/ios/Plugin/AppsFlyerPlugin.swift index 51884c0..10b61ac 100644 --- a/ios/Plugin/AppsFlyerPlugin.swift +++ b/ios/Plugin/AppsFlyerPlugin.swift @@ -5,604 +5,656 @@ import AppsFlyerLib @objc(AppsFlyerPlugin) public class AppsFlyerPlugin: CAPPlugin { - private var conversion = true - private var oaoa = true - private var udl = false - - override public func load() { + private let APPSFLYER_PLUGIN_VERSION = "6.10.2-rc1" + private var conversion = true + private var oaoa = true + private var udl = false - NotificationCenter.default.addObserver(self, selector: #selector(self.handleUrlOpened(notification:)), name: Notification.Name.capacitorOpenURL, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: Notification.Name.capacitorOpenUniversalLink, object: nil) + override public func load() { + + NotificationCenter.default.addObserver(self, selector: #selector(self.handleUrlOpened(notification:)), name: Notification.Name.capacitorOpenURL, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(self.handleUniversalLink(notification:)), name: Notification.Name.capacitorOpenUniversalLink, object: nil) + + } + + + @objc func initSDK(_ call: CAPPluginCall){ + let appsflyer = AppsFlyerLib.shared() + + appsflyer.setPluginInfo(plugin: .capacitor, version: APPSFLYER_PLUGIN_VERSION, additionalParams: nil) + guard let devKey = call.getString(AppsFlyerConstants.AF_DEV_KEY) else{ + call.reject("devkey is missing") + return + } + guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else{ + call.reject("appID is missing") + return + } + let attInterval = call.getInt(AppsFlyerConstants.AF_ATT) + + let debug = call.getBool(AppsFlyerConstants.AF_DEBUG, false) + let sandbox = call.getBool(AppsFlyerConstants.AF_SANDBOX, false) + let receiptSandbox = call.getBool(AppsFlyerConstants.AF_RECEIPT_SANDBOX , false) + + conversion = call.getBool(AppsFlyerConstants.AF_CONVERSION_LISTENER, true) + oaoa = call.getBool(AppsFlyerConstants.AF_OAOA, true) + udl = call.getBool(AppsFlyerConstants.AF_UDL, false) + + appsflyer.isDebug = debug + appsflyer.appsFlyerDevKey = devKey + appsflyer.appleAppID = appID + appsflyer.useUninstallSandbox = sandbox + appsflyer.useReceiptValidationSandbox = receiptSandbox + + if let minTime = call.getInt(AppsFlyerConstants.AF_MIN_TIME){ + appsflyer.minTimeBetweenSessions = UInt(minTime) + } + + if let timeout = call.getInt(AppsFlyerConstants.AF_DEEP_LINK_TIME_OUT){ + appsflyer.deepLinkTimeout = UInt(timeout) + } + + if conversion || oaoa { + appsflyer.delegate = self + } + + if udl { + appsflyer.deepLinkDelegate = self + } + + reportBridgeReady() + +#if !AFSDK_NO_IDFA + if attInterval != nil { + appsflyer.waitForATTUserAuthorization(timeoutInterval: Double(attInterval!)) + } +#endif + + NotificationCenter.default.addObserver(self, selector: #selector(sendLaunch), name: UIApplication.didBecomeActiveNotification, object: nil) + + appsflyer.start(completionHandler: { (dictionnary, error) in + if (error != nil){ + call.reject(error!.localizedDescription) + return + } else { + call.resolve(["res":"ok"]) + return + } + }) + } + + @objc func logEvent(_ call: CAPPluginCall){ + guard let eventName = call.getString(AppsFlyerConstants.AF_EVENT_NAME) else{ + call.reject("missing event name") + return + } + let eventValue = call.getObject(AppsFlyerConstants.AF_EVENT_VALUE) + + AppsFlyerLib.shared().logEvent(name: eventName, values: eventValue) { (response: [String : Any]?, error: Error?) in + if let response = response { + call.resolve(["res":response]) + } + if let error = error { + call.reject(error.localizedDescription, nil, error) + } + } + } + + @objc func setCustomerUserId(_ call: CAPPluginCall){ + guard let cuid = call.getString(AppsFlyerConstants.AF_CUID) else { + call.reject("Invalid Customer User ID") + return + } + AppsFlyerLib.shared().customerUserID = cuid + + } + + @objc func setCurrencyCode(_ call: CAPPluginCall){ + guard let code = call.getString(AppsFlyerConstants.AF_CURRENCY_CODE) else { + call.reject("Invalid Currency Code") + return + } + AppsFlyerLib.shared().currencyCode = code + + + } + + @objc func updateServerUninstallToken(_ call: CAPPluginCall){ + guard let token = call.getString(AppsFlyerConstants.AF_TOKEN) else { + call.reject("Invalid device token") + + return + } + + guard let deviceTokenData = token.hexadecimalToData else{ + call.reject("Invalid device token") + return + } + AppsFlyerLib.shared().registerUninstall(deviceTokenData) + } + + @objc func setAppInviteOneLink(_ call: CAPPluginCall){ + guard let id = call.getString(AppsFlyerConstants.AF_ONELINK_ID) else { + call.reject("Onelink id is missing") + return + } + AppsFlyerLib.shared().appInviteOneLinkID = id + + } + + @objc func setOneLinkCustomDomain(_ call: CAPPluginCall){ + guard let arr = call.getArray(AppsFlyerConstants.AF_ONELINK_DOMAIN) else { + call.reject("Domains are missing") + return + } + var domains :[String] = [] + for dom in arr { + domains.append(dom as! String) + } + AppsFlyerLib.shared().oneLinkCustomDomains = domains + + } + + @objc func appendParametersToDeepLinkingURL(_ call: CAPPluginCall){ + guard let contains = call.getString(AppsFlyerConstants.AF_CONTAINS) else { + return + } + guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else { + return + } + var params: [String:String] = [:] + for (k,v) in parameters{ + params[k] = (v as! String) + } + AppsFlyerLib.shared().appendParametersToDeeplinkURL(contains: contains, parameters:params ) + + } - } - - - @objc func initSDK(_ call: CAPPluginCall){ - let appsflyer = AppsFlyerLib.shared() - guard let devKey = call.getString(AppsFlyerConstants.AF_DEV_KEY) else{ - call.reject("devkey is missing") - return + + @objc func setResolveDeepLinkURLs(_ call: CAPPluginCall){ + guard let arr = call.getArray(AppsFlyerConstants.AF_DEEPLINK_URLS) else { + call.reject("URLs are missing") + return + } + var urls :[String] = [] + for url in arr { + urls.append(url as! String) + } + AppsFlyerLib.shared().oneLinkCustomDomains = urls + } - guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else{ - call.reject("appID is missing") - return + + @objc func addPushNotificationDeepLinkPath(_ call: CAPPluginCall){ + guard let arr = call.getArray(AppsFlyerConstants.AF_PATH) else { + call.reject("Path is missing") + return + } + var path :[String] = [] + for p in arr { + path.append(p as! String) + } + AppsFlyerLib.shared().addPushNotificationDeepLinkPath(path) + } - let attInterval = call.getInt(AppsFlyerConstants.AF_ATT) - let debug = call.getBool(AppsFlyerConstants.AF_DEBUG, false) - let sandbox = call.getBool(AppsFlyerConstants.AF_SANDBOX, false) - let receiptSandbox = call.getBool(AppsFlyerConstants.AF_RECEIPT_SANDBOX , false) + @available(*, deprecated, message: "Use setSharingFilterForPartners") + @objc func setSharingFilter(_ call: CAPPluginCall){ + let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self) + + AppsFlyerLib.shared().sharingFilter = filters + + } - conversion = call.getBool(AppsFlyerConstants.AF_CONVERSION_LISTENER, true) - oaoa = call.getBool(AppsFlyerConstants.AF_OAOA, true) - udl = call.getBool(AppsFlyerConstants.AF_UDL, false) + @available(*, deprecated, message: "Use setSharingFilterForPartners") + @objc func setSharingFilterForAllPartners(_ call: CAPPluginCall){ + + AppsFlyerLib.shared().setSharingFilterForAllPartners() + + } - appsflyer.isDebug = debug - appsflyer.appsFlyerDevKey = devKey - appsflyer.appleAppID = appID - appsflyer.useUninstallSandbox = sandbox - appsflyer.useReceiptValidationSandbox = receiptSandbox + @objc func setSharingFilterForPartners(_ call: CAPPluginCall){ + guard let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self) else{ + return call.reject("cannot extract the filters value") + } + + AppsFlyerLib.shared().setSharingFilterForPartners(filters) + + } - if let minTime = call.getInt(AppsFlyerConstants.AF_MIN_TIME){ - appsflyer.minTimeBetweenSessions = UInt(minTime) + @objc func setAdditionalData(_ call: CAPPluginCall){ + guard let data = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_DATA) else { + call.reject("Data is missing") + return + } + AppsFlyerLib.shared().customData = data + } - if let timeout = call.getInt(AppsFlyerConstants.AF_DEEP_LINK_TIME_OUT){ - appsflyer.deepLinkTimeout = UInt(timeout) + + @objc func getAppsFlyerUID(_ call: CAPPluginCall){ + let uid = AppsFlyerLib.shared().getAppsFlyerUID() + call.resolve(["uid":uid]) + } - if conversion || oaoa { - appsflyer.delegate = self + @objc func setDisableNetworkData(_ call: CAPPluginCall){ + call.unavailable("Android only method - has no effact on iOS apps") } - if udl { - appsflyer.deepLinkDelegate = self + @objc func anonymizeUser(_ call: CAPPluginCall){ + guard let anonymize = call.getBool(AppsFlyerConstants.AF_ANONYMIZE_USER) else{ + call.reject("Missing boolean value anonymizeUser") + return + } + AppsFlyerLib.shared().anonymizeUser = anonymize + } - reportBridgeReady() + @objc func stop(_ call: CAPPluginCall){ + let stop = call.getBool(AppsFlyerConstants.AF_STOP) + if stop != nil { + AppsFlyerLib.shared().isStopped = stop! + } + call.resolve([AppsFlyerConstants.AF_IS_STOP : AppsFlyerLib.shared().isStopped ]) + } + + @objc func disableSKAdNetwork(_ call: CAPPluginCall){ + guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else { + call.reject("Missing boolean value shouldDisable") + return + } + AppsFlyerLib.shared().disableSKAdNetwork = disable + + } #if !AFSDK_NO_IDFA - if attInterval != nil { - appsflyer.waitForATTUserAuthorization(timeoutInterval: Double(attInterval!)) + @objc func disableAdvertisingIdentifier(_ call: CAPPluginCall){ + guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else { + call.reject("Missing boolean value shouldDisable") + return + } + AppsFlyerLib.shared().disableAdvertisingIdentifier = disable + } #endif - NotificationCenter.default.addObserver(self, selector: #selector(sendLaunch), name: UIApplication.didBecomeActiveNotification, object: nil) - - appsflyer.start(completionHandler: { (dictionnary, error) in - if (error != nil){ - call.reject(error!.localizedDescription) - return - } else { - call.resolve(["res":"ok"]) - return - } - }) - } - - @objc func logEvent(_ call: CAPPluginCall){ - guard let eventName = call.getString(AppsFlyerConstants.AF_EVENT_NAME) else{ - call.reject("missing event name") - return - } - let eventValue = call.getObject(AppsFlyerConstants.AF_EVENT_VALUE) - - AppsFlyerLib.shared().logEvent(name: eventName, values: eventValue) { (response: [String : Any]?, error: Error?) in - if let response = response { - call.resolve(["res":response]) - } - if let error = error { - call.reject(error.localizedDescription, nil, error) - } - } - } - - @objc func setCustomerUserId(_ call: CAPPluginCall){ - guard let cuid = call.getString(AppsFlyerConstants.AF_CUID) else { - call.reject("Invalid Customer User ID") - return - } - AppsFlyerLib.shared().customerUserID = cuid - - } - - @objc func setCurrencyCode(_ call: CAPPluginCall){ - guard let code = call.getString(AppsFlyerConstants.AF_CURRENCY_CODE) else { - call.reject("Invalid Currency Code") - return - } - AppsFlyerLib.shared().currencyCode = code - - - } - - @objc func updateServerUninstallToken(_ call: CAPPluginCall){ - guard let token = call.getString(AppsFlyerConstants.AF_TOKEN) else { - call.reject("Invalid device token") - - return - } - - guard let deviceTokenData = token.hexadecimalToData else{ - call.reject("Invalid device token") - return - } - AppsFlyerLib.shared().registerUninstall(deviceTokenData) - } - - @objc func setAppInviteOneLink(_ call: CAPPluginCall){ - guard let id = call.getString(AppsFlyerConstants.AF_ONELINK_ID) else { - call.reject("Onelink id is missing") - return - } - AppsFlyerLib.shared().appInviteOneLinkID = id - - } - - @objc func setOneLinkCustomDomain(_ call: CAPPluginCall){ - guard let arr = call.getArray(AppsFlyerConstants.AF_ONELINK_DOMAIN) else { - call.reject("Domains are missing") - return - } - var domains :[String] = [] - for dom in arr { - domains.append(dom as! String) - } - AppsFlyerLib.shared().oneLinkCustomDomains = domains - - } - - @objc func appendParametersToDeepLinkingURL(_ call: CAPPluginCall){ - guard let contains = call.getString(AppsFlyerConstants.AF_CONTAINS) else { - return - } - guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else { - return - } - var params: [String:String] = [:] - for (k,v) in parameters{ - params[k] = (v as! String) - } - AppsFlyerLib.shared().appendParametersToDeeplinkURL(contains: contains, parameters:params ) - - } - - - @objc func setResolveDeepLinkURLs(_ call: CAPPluginCall){ - guard let arr = call.getArray(AppsFlyerConstants.AF_DEEPLINK_URLS) else { - call.reject("URLs are missing") - return - } - var urls :[String] = [] - for url in arr { - urls.append(url as! String) - } - AppsFlyerLib.shared().oneLinkCustomDomains = urls - - } - - @objc func addPushNotificationDeepLinkPath(_ call: CAPPluginCall){ - guard let arr = call.getArray(AppsFlyerConstants.AF_PATH) else { - call.reject("Path is missing") - return - } - var path :[String] = [] - for p in arr { - path.append(p as! String) - } - AppsFlyerLib.shared().addPushNotificationDeepLinkPath(path) - - } - - @available(*, deprecated, message: "Use setSharingFilterForPartners") - @objc func setSharingFilter(_ call: CAPPluginCall){ - let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self) - - AppsFlyerLib.shared().sharingFilter = filters - - } - - @available(*, deprecated, message: "Use setSharingFilterForPartners") - @objc func setSharingFilterForAllPartners(_ call: CAPPluginCall){ - - AppsFlyerLib.shared().setSharingFilterForAllPartners() - - } - - @objc func setSharingFilterForPartners(_ call: CAPPluginCall){ - guard let filters = call.getArray(AppsFlyerConstants.AF_FILTERS , String.self) else{ - return call.reject("cannot extract the filters value") - } - - AppsFlyerLib.shared().setSharingFilterForPartners(filters) - - } - - @objc func setAdditionalData(_ call: CAPPluginCall){ - guard let data = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_DATA) else { - call.reject("Data is missing") - return - } - AppsFlyerLib.shared().customData = data - - } - - - @objc func getAppsFlyerUID(_ call: CAPPluginCall){ - let uid = AppsFlyerLib.shared().getAppsFlyerUID() - call.resolve(["uid":uid]) - - } - - @objc func setDisableNetworkData(_ call: CAPPluginCall){ - call.unavailable("Android only method - has no effact on iOS apps") - } - - @objc func anonymizeUser(_ call: CAPPluginCall){ - guard let anonymize = call.getBool(AppsFlyerConstants.AF_ANONYMIZE_USER) else{ - call.reject("Missing boolean value anonymizeUser") - return - } - AppsFlyerLib.shared().anonymizeUser = anonymize - - } - - @objc func stop(_ call: CAPPluginCall){ - let stop = call.getBool(AppsFlyerConstants.AF_STOP) - if stop != nil { - AppsFlyerLib.shared().isStopped = stop! - } - call.resolve([AppsFlyerConstants.AF_IS_STOP : AppsFlyerLib.shared().isStopped ]) - } - - @objc func disableSKAdNetwork(_ call: CAPPluginCall){ - guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else { - call.reject("Missing boolean value shouldDisable") - return - } - AppsFlyerLib.shared().disableSKAdNetwork = disable - - } - -#if !AFSDK_NO_IDFA - @objc func disableAdvertisingIdentifier(_ call: CAPPluginCall){ - guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else { - call.reject("Missing boolean value shouldDisable") - return + @objc func disableCollectASA(_ call: CAPPluginCall){ + guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else { + call.reject("Missing boolean value shouldDisable") + return + } + AppsFlyerLib.shared().disableCollectASA = disable + + } + @objc func setHost(_ call: CAPPluginCall){ + let pre = call.getString(AppsFlyerConstants.AF_HOST_PREFIX) + let post = call.getString(AppsFlyerConstants.AF_HOST_POSTFIX) + if (pre != nil && post != nil) { + AppsFlyerLib.shared().setHost(post!, withHostPrefix: pre!) + } else { + call.reject("Missing host prefix and/or host name") + } } - AppsFlyerLib.shared().disableAdvertisingIdentifier = disable - } -#endif - - @objc func disableCollectASA(_ call: CAPPluginCall){ - guard let disable = call.getBool(AppsFlyerConstants.AF_DISABLE_SKAD) else { - call.reject("Missing boolean value shouldDisable") - return - } - AppsFlyerLib.shared().disableCollectASA = disable - - } - @objc func setHost(_ call: CAPPluginCall){ - let pre = call.getString(AppsFlyerConstants.AF_HOST_PREFIX) - let post = call.getString(AppsFlyerConstants.AF_HOST_POSTFIX) - if (pre != nil && post != nil) { - AppsFlyerLib.shared().setHost(post!, withHostPrefix: pre!) - } else { - call.reject("Missing host prefix and/or host name") - } - } - - @objc func generateInviteLink(_ call: CAPPluginCall){ - AppsFlyerShareInviteHelper.generateInviteUrl(linkGenerator: - {(_ generator: AppsFlyerLinkGenerator) -> AppsFlyerLinkGenerator in - if let channel = call.getString(AppsFlyerConstants.AF_CHANNEL){ - generator.setChannel(channel) - } - if let brandDomain = call.getString(AppsFlyerConstants.AF_BRAND_DOMAIN){ - generator.brandDomain = brandDomain - } - if let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN){ - generator.setCampaign(campaign) - } - if let referrerName = call.getString(AppsFlyerConstants.AF_REFERRER_NAME){ - generator.setReferrerName(referrerName) - } - if let referrerImageURL = call.getString(AppsFlyerConstants.AF_REFERRER_IMAGE_URL){ - generator.setReferrerImageURL(referrerImageURL) - } - if let referrerCustomerId = call.getString(AppsFlyerConstants.AF_REFERRER_CUSTOMER_ID){ - generator.setReferrerCustomerId(referrerCustomerId) - } - if let baseDeeplink = call.getString(AppsFlyerConstants.AF_BASE_DEEPLINK){ - generator.setBaseDeeplink(baseDeeplink) - } - if let addParameters = call.getObject(AppsFlyerConstants.AF_ADD_PARAMETERS){ - generator.addParameters(addParameters) - } - - return generator },completionHandler: {url in - if url != nil{ - call.resolve([AppsFlyerConstants.AF_LINK_READY: url!.absoluteString]) + @objc func generateInviteLink(_ call: CAPPluginCall){ + AppsFlyerShareInviteHelper.generateInviteUrl(linkGenerator: + {(_ generator: AppsFlyerLinkGenerator) -> AppsFlyerLinkGenerator in + if let channel = call.getString(AppsFlyerConstants.AF_CHANNEL){ + generator.setChannel(channel) + } + if let brandDomain = call.getString(AppsFlyerConstants.AF_BRAND_DOMAIN){ + generator.brandDomain = brandDomain + } + if let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN){ + generator.setCampaign(campaign) + } + if let referrerName = call.getString(AppsFlyerConstants.AF_REFERRER_NAME){ + generator.setReferrerName(referrerName) + } + if let referrerImageURL = call.getString(AppsFlyerConstants.AF_REFERRER_IMAGE_URL){ + generator.setReferrerImageURL(referrerImageURL) + } + if let referrerCustomerId = call.getString(AppsFlyerConstants.AF_REFERRER_CUSTOMER_ID){ + generator.setReferrerCustomerId(referrerCustomerId) + } + if let baseDeeplink = call.getString(AppsFlyerConstants.AF_BASE_DEEPLINK){ + generator.setBaseDeeplink(baseDeeplink) + } + if let addParameters = call.getObject(AppsFlyerConstants.AF_ADD_PARAMETERS){ + generator.addParameters(addParameters) + } + + return generator },completionHandler: {url in + if url != nil{ + call.resolve([AppsFlyerConstants.AF_LINK_READY: url!.absoluteString]) + }else{ + call.reject("Failed to generate a link") + } + } + ) + + } + @objc func validateAndLogInAppPurchaseAndroid(_ call: CAPPluginCall){ + call.unavailable() + } + + @objc func validateAndLogInAppPurchaseIos(_ call: CAPPluginCall){ + let currency = call.getString(AppsFlyerConstants.AF_CURRENCY) + let price = call.getString(AppsFlyerConstants.AF_PRICE) + let _inAppPurchase = call.getString(AppsFlyerConstants.AF_IN_APP_PURCHASE) + let transactionId = call.getString(AppsFlyerConstants.AF_TRANSACTION_ID) + let additionalParameters = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_PARAMETERS) ?? [:] + + if currency != nil && price != nil && _inAppPurchase != nil && transactionId != nil && currency != nil { + AppsFlyerLib.shared().validateAndLog( + inAppPurchase: _inAppPurchase, + price: price, + currency: currency, + transactionId: transactionId, + additionalParameters: additionalParameters, + success: {result in + call.resolve(["res":result]) + }, + failure: { error, result in + guard let emptyInApp = result as? [String:Any] + else + { + call.reject((error)?.localizedDescription ?? "error" ) + return + } + call.reject((error)?.localizedDescription ?? "error" , emptyInApp.jsonStringRepresentation) + + }) }else{ - call.reject("Failed to generate a link") - } - } - ) - - } - @objc func validateAndLogInAppPurchaseAndroid(_ call: CAPPluginCall){ - call.unavailable() - } - - @objc func validateAndLogInAppPurchaseIos(_ call: CAPPluginCall){ - let currency = call.getString(AppsFlyerConstants.AF_CURRENCY) - let price = call.getString(AppsFlyerConstants.AF_PRICE) - let _inAppPurchase = call.getString(AppsFlyerConstants.AF_IN_APP_PURCHASE) - let transactionId = call.getString(AppsFlyerConstants.AF_TRANSACTION_ID) - let additionalParameters = call.getObject(AppsFlyerConstants.AF_ADDITIONAL_PARAMETERS) ?? [:] - - if currency != nil && price != nil && _inAppPurchase != nil && transactionId != nil && currency != nil { - AppsFlyerLib.shared().validateAndLog( - inAppPurchase: _inAppPurchase, - price: price, - currency: currency, - transactionId: transactionId, - additionalParameters: additionalParameters, - success: {result in - call.resolve(["res":result]) - }, - failure: { error, result in - guard let emptyInApp = result as? [String:Any] - else - { - call.reject((error)?.localizedDescription ?? "error" ) - return - } - call.reject((error)?.localizedDescription ?? "error" , emptyInApp.jsonStringRepresentation) - - }) - }else{ - call.reject("Missing some fields") + call.reject("Missing some fields") + } + + } - - } - - @objc func getSdkVersion(_ call: CAPPluginCall){ - - call.resolve(["res": AppsFlyerLib.shared().getSDKVersion()]) - } - - @objc func enableFacebookDeferredApplinks(_ call: CAPPluginCall){ - guard let enable = call.getBool(AppsFlyerConstants.AF_FB) else { - call.reject("missing boolean value: \(AppsFlyerConstants.AF_FB)") - return + @objc func getSdkVersion(_ call: CAPPluginCall){ + + call.resolve(["res": AppsFlyerLib.shared().getSDKVersion()]) } - if enable{ + + @objc func enableFacebookDeferredApplinks(_ call: CAPPluginCall){ + guard let enable = call.getBool(AppsFlyerConstants.AF_FB) else { + call.reject("missing boolean value: \(AppsFlyerConstants.AF_FB)") + return + } + if enable{ #if canImport(FacebookCore) - AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: FBSDKAppLinkUtility.self) - call.resolve(["res": "enabled"]) + AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: FBSDKAppLinkUtility.self) + call.resolve(["res": "enabled"]) #else - call.reject("Please install FBSDK First!") + call.reject("Please install FBSDK First!") #endif - }else{ - AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: nil) - call.resolve(["res": "disabled"]) - - } - - } - - @objc func sendPushNotificationData(_ call: CAPPluginCall){ - let json = call.getObject(AppsFlyerConstants.AF_PUSH_PAYLOAD) - AppsFlyerLib.shared().handlePushNotification(json) - - } - - - @objc func setCurrentDeviceLanguage(_ call: CAPPluginCall){ - guard let language = call.getString(AppsFlyerConstants.AF_LANGUAGE) else { - call.reject("cannot extract the language value") - return - } - AppsFlyerLib.shared().currentDeviceLanguage = language - call.resolve(["res": "ok"]) - - } - - @objc func logCrossPromoteImpression(_ call: CAPPluginCall){ - guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else { - call.reject("cannot extract the appID value") - return - } - guard let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN) else { - call.reject("cannot extract the campaign value") - return - } - guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else { - call.reject("cannot extract the parameters value") - return - } - AppsFlyerCrossPromotionHelper.logCrossPromoteImpression(appID, campaign: campaign, parameters: parameters) - call.resolve(["res": "ok"]) - - } - - @objc func setUserEmails(_ call: CAPPluginCall){ - guard let emails = call.getArray(AppsFlyerConstants.AF_EMAILS, String.self) else { - call.reject("cannot extract the emails value") - return - } - if let enc = call.getBool(AppsFlyerConstants.AF_ENCODE) , enc == true{ - AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeSHA256) - - }else{ - AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeNone) - - } - call.resolve(["res": "ok"]) - - } - - @objc func logLocation(_ call: CAPPluginCall){ - guard let longitude = call.getDouble(AppsFlyerConstants.AF_LONGITUDE) else { - call.reject("cannot extract the longitude value") - return - } - guard let latitude = call.getDouble(AppsFlyerConstants.AF_LATITUDE) else { - call.reject("cannot extract the longitude value") - return - } - - AppsFlyerLib.shared().logLocation(longitude: longitude, latitude: latitude) - call.resolve(["res": "ok"]) - - } - - @objc func setPhoneNumber(_ call: CAPPluginCall){ - guard let phone = call.getString(AppsFlyerConstants.AF_PHONE) else { - call.reject("cannot extract the phone value") - return - } - - AppsFlyerLib.shared().phoneNumber = phone - call.resolve(["res": "ok"]) - - } - - @objc func setPartnerData(_ call: CAPPluginCall){ - guard let data = call.getObject(AppsFlyerConstants.AF_DATA) else { - call.reject("cannot extract the data value") - return - } - guard let pid = call.getString(AppsFlyerConstants.AF_PARTNER_ID) else { - call.reject("cannot extract the partnerId value") - return - } - - AppsFlyerLib.shared().setPartnerData(partnerId: pid, partnerInfo: data) - call.resolve(["res": "ok"]) - - } - - @objc func logInvite(_ call: CAPPluginCall){ - guard let data = call.getObject(AppsFlyerConstants.AF_EVENT_PARAMETERS) else { - call.reject("cannot extract the eventParameters value") - return + }else{ + AppsFlyerLib.shared().enableFacebookDeferredApplinks(with: nil) + call.resolve(["res": "disabled"]) + + } + + } + + @objc func sendPushNotificationData(_ call: CAPPluginCall){ + let json = call.getObject(AppsFlyerConstants.AF_PUSH_PAYLOAD) + AppsFlyerLib.shared().handlePushNotification(json) + + } + + + @objc func setCurrentDeviceLanguage(_ call: CAPPluginCall){ + guard let language = call.getString(AppsFlyerConstants.AF_LANGUAGE) else { + call.reject("cannot extract the language value") + return + } + AppsFlyerLib.shared().currentDeviceLanguage = language + call.resolve(["res": "ok"]) + + } + + @objc func logCrossPromoteImpression(_ call: CAPPluginCall){ + guard let appID = call.getString(AppsFlyerConstants.AF_APP_ID) else { + call.reject("cannot extract the appID value") + return + } + guard let campaign = call.getString(AppsFlyerConstants.AF_CAMPAIGN) else { + call.reject("cannot extract the campaign value") + return + } + guard let parameters = call.getObject(AppsFlyerConstants.AF_PARAMETERS) else { + call.reject("cannot extract the parameters value") + return + } + AppsFlyerCrossPromotionHelper.logCrossPromoteImpression(appID, campaign: campaign, parameters: parameters) + call.resolve(["res": "ok"]) + + } + + @objc func setUserEmails(_ call: CAPPluginCall){ + guard let emails = call.getArray(AppsFlyerConstants.AF_EMAILS, String.self) else { + call.reject("cannot extract the emails value") + return + } + if let enc = call.getBool(AppsFlyerConstants.AF_ENCODE) , enc == true{ + AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeSHA256) + + }else{ + AppsFlyerLib.shared().setUserEmails(emails, with: EmailCryptTypeNone) + + } + call.resolve(["res": "ok"]) + + } + + @objc func logLocation(_ call: CAPPluginCall){ + guard let longitude = call.getDouble(AppsFlyerConstants.AF_LONGITUDE) else { + call.reject("cannot extract the longitude value") + return + } + guard let latitude = call.getDouble(AppsFlyerConstants.AF_LATITUDE) else { + call.reject("cannot extract the longitude value") + return + } + + AppsFlyerLib.shared().logLocation(longitude: longitude, latitude: latitude) + call.resolve(["res": "ok"]) + + } + + @objc func setPhoneNumber(_ call: CAPPluginCall){ + guard let phone = call.getString(AppsFlyerConstants.AF_PHONE) else { + call.reject("cannot extract the phone value") + return + } + + AppsFlyerLib.shared().phoneNumber = phone + call.resolve(["res": "ok"]) + + } + + @objc func setPartnerData(_ call: CAPPluginCall){ + guard let data = call.getObject(AppsFlyerConstants.AF_DATA) else { + call.reject("cannot extract the data value") + return + } + guard let pid = call.getString(AppsFlyerConstants.AF_PARTNER_ID) else { + call.reject("cannot extract the partnerId value") + return + } + + AppsFlyerLib.shared().setPartnerData(partnerId: pid, partnerInfo: data) + call.resolve(["res": "ok"]) + + } + + @objc func logInvite(_ call: CAPPluginCall){ + guard let data = call.getObject(AppsFlyerConstants.AF_EVENT_PARAMETERS) else { + call.reject("cannot extract the eventParameters value") + return + } + guard let channel = call.getString(AppsFlyerConstants.AF_CHANNEL) else { + call.reject("cannot extract the channel value") + return + } + + AppsFlyerShareInviteHelper.logInvite(channel, parameters: data) + call.resolve(["res": "ok"]) + } - guard let channel = call.getString(AppsFlyerConstants.AF_CHANNEL) else { - call.reject("cannot extract the channel value") - return - } - - AppsFlyerShareInviteHelper.logInvite(channel, parameters: data) - call.resolve(["res": "ok"]) - - } } extension AppsFlyerPlugin{ - private func reportBridgeReady(){ - AppsFlyerAttribution.shared.bridgReady = true - NotificationCenter.default.post(name: Notification.Name.appsflyerBridge, object: nil) - } - - @objc private func sendLaunch(){ - AppsFlyerLib.shared().start() - } - - @objc func handleUrlOpened(notification: NSNotification) { - guard let object = notification.object as? [String: Any?] else { - return - } - guard let url = object["url"] else { - afLogger(msg: "handleUrlOpened url is nil") - return - } - guard let options = object["options"] else { - afLogger(msg: "handleUrlOpened options is nil") - - return - } - afLogger(msg: "handleUrlOpened with \((url as! URL).absoluteString)") - AppsFlyerAttribution.shared.handleOpenUrl(open: url as! URL, options: options as! [UIApplication.OpenURLOptionsKey: Any]) - - } - - @objc func handleUniversalLink(notification: NSNotification) { - guard let object = notification.object as? [String: Any?] else { - return - } - let user = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb) - guard let url = object["url"] else { - afLogger(msg: "handleUrlOpened options is url") - return - } - user.webpageURL = (url as! URL) - afLogger(msg: "handleUniversalLink with \(user.webpageURL?.absoluteString ?? "null")") - AppsFlyerAttribution.shared.continueUserActivity(userActivity: user) - - } - + private func reportBridgeReady(){ + AppsFlyerAttribution.shared.bridgReady = true + NotificationCenter.default.post(name: Notification.Name.appsflyerBridge, object: nil) + } + + @objc private func sendLaunch(){ + AppsFlyerLib.shared().start() + } + + @objc func handleUrlOpened(notification: NSNotification) { + guard let object = notification.object as? [String: Any?] else { + return + } + guard let url = object["url"] else { + afLogger(msg: "handleUrlOpened url is nil") + return + } + guard let options = object["options"] else { + afLogger(msg: "handleUrlOpened options is nil") + + return + } + afLogger(msg: "handleUrlOpened with \((url as! URL).absoluteString)") + AppsFlyerAttribution.shared.handleOpenUrl(open: url as! URL, options: options as! [UIApplication.OpenURLOptionsKey: Any]) + + } + + @objc func handleUniversalLink(notification: NSNotification) { + guard let object = notification.object as? [String: Any?] else { + return + } + let user = NSUserActivity(activityType: NSUserActivityTypeBrowsingWeb) + guard let url = object["url"] else { + afLogger(msg: "handleUrlOpened options is url") + return + } + user.webpageURL = (url as! URL) + afLogger(msg: "handleUniversalLink with \(user.webpageURL?.absoluteString ?? "null")") + AppsFlyerAttribution.shared.continueUserActivity(userActivity: user) + + } + } extension AppsFlyerPlugin : AppsFlyerLibDelegate { - public func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) { - let json : [String: Any] = ["callbackName":"onConversionDataSuccess", "data":conversionInfo] - self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json) - - } - - public func onConversionDataFail(_ error: Error) { - let json : [String: Any] = ["callbackName":"onConversionDataFail", "status":error.localizedDescription] - self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json) - } - public func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]) { - let json : [String: Any] = ["callbackName":"onAppOpenAttribution", "data":attributionData] - self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json) - } - - public func onAppOpenAttributionFailure(_ error: Error) { - let json : [String: Any] = ["callbackName":"onAppOpenAttributionFailure", "status":error.localizedDescription] - self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json) - - } - + public func onConversionDataSuccess(_ conversionInfo: [AnyHashable : Any]) { + let json : [String: Any] = ["callbackName":"onConversionDataSuccess", "data":conversionInfo] + self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json) + + } + + public func onConversionDataFail(_ error: Error) { + let json : [String: Any] = ["callbackName":"onConversionDataFail", "status":error.localizedDescription] + self.notifyListeners(AppsFlyerConstants.CONVERSION_CALLBACK, data: json) + } + public func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]) { + let json : [String: Any] = ["callbackName":"onAppOpenAttribution", "data":attributionData] + self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json) + } + + public func onAppOpenAttributionFailure(_ error: Error) { + let json : [String: Any] = ["callbackName":"onAppOpenAttributionFailure", "status":error.localizedDescription] + self.notifyListeners(AppsFlyerConstants.OAOA_CALLBACK, data: json) + + } + } // Mark - extension AppsFlyerPlugin : DeepLinkDelegate{ - public func didResolveDeepLink(_ result: DeepLinkResult) { - var json : [String: Any] = [:] + public func didResolveDeepLink(_ result: DeepLinkResult) { + var json : [String: Any] = [:] + + switch result.status { + case .notFound : + json["status"] = "NOT_FOUND" + case .failure : + json["status"] = "FAILURE" + case .found : + json["status"] = "FOUND" + } + + if result.error != nil { + json["error"] = result.error!.localizedDescription + } + if result.deepLink != nil { + var deepLinkDic = result.deepLink!.clickEvent + deepLinkDic["is_deferred"] = result.deepLink!.isDeferred + json["deepLink"] = deepLinkDic + } + self.notifyListeners(AppsFlyerConstants.UDL_CALLBACK, data: json) + } - switch result.status { - case .notFound : - json["status"] = "NOT_FOUND" - case .failure : - json["status"] = "FAILURE" - case .found : - json["status"] = "FOUND" +} + +extension AppsFlyerPlugin{ + private func afLogger(msg : String){ + NSLog ("AppsFlyer [Debug][Capacitor]: \(msg)"); } - if result.error != nil { - json["error"] = result.error!.localizedDescription + private func getPluginVersion2() -> String { + let plist = readPlist(name: "AppsFlyerCap") + let version = plist["AppsFlyerPluginVersion"] as? String + return version ?? "err" } - if result.deepLink != nil { - var deepLinkDic = result.deepLink!.clickEvent - deepLinkDic["is_deferred"] = result.deepLink!.isDeferred - json["deepLink"] = deepLinkDic + + private func readPlist2(name: String) -> [String: Any] { + if let fileUrl = Bundle.main.url(forResource: name, withExtension: "plist"), + let data = try? Data(contentsOf: fileUrl) { + if let result = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] { + return result + } + } + + return [:] + } + + private func readPlist(name: String) -> NSDictionary { + // Get the path to the plist file in your project + if let plistPath = Bundle.main.path(forResource: "AppsflyerCapacitorPlugin-Info", ofType: "plist"){ + // Load the contents of the plist file into a Data object + guard let plistData = NSDictionary(contentsOfFile: plistPath) else { + return [:] + } + return plistData + } + + guard let plistPath = Bundle(for: AppsFlyerPlugin.self).path(forResource: "AppsflyerCapacitorPlugin-Info", ofType: "plist")else { + return [:] + } + + // Load the contents of the plist file into a Data object + guard let plistData = NSDictionary(contentsOfFile: plistPath) else { + return [:] + } + return plistData + } - self.notifyListeners(AppsFlyerConstants.UDL_CALLBACK, data: json) - } - -} + + private func getPluginVersion() -> String { + if let versionNumber = ProcessInfo.processInfo.environment["APPSFLYER_PLUGIN_VERSION"] { + print("APPSFLYER_PLUGIN_VERSION: \(versionNumber)") + } else { + print("APPSFLYER_PLUGIN_VERSION not defined") + } -extension AppsFlyerPlugin{ - private func afLogger(msg : String){ - NSLog ("AppsFlyer [Debug][Capacitor]: \(msg)"); - } -} + return Bundle(for: AppsFlyerPlugin.self).infoDictionary?["APPSFLYER_PLUGIN_VERSION"] as? String ?? "failed_to_fetch" + } +} diff --git a/ios/Podfile b/ios/Podfile index b2b8c96..78905ba 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -1,5 +1,3 @@ -require_relative '../node_modules/@capacitor/ios/scripts/pods_helpers' - platform :ios, '13.0' def capacitor_pods @@ -12,14 +10,9 @@ end target 'Plugin' do capacitor_pods - pod 'AppsFlyerFramework', ' 6.8.0' - + pod 'AppsFlyerFramework', ' 6.10.1' end target 'PluginTests' do capacitor_pods end - -post_install do |installer| - assertDeploymentTarget(installer) -end \ No newline at end of file diff --git a/package.json b/package.json index 1ed8e3f..edc022f 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,9 @@ { "name": "appsflyer-capacitor-plugin", - "version": "6.9.2", - "iosSdkVersion": "6.9.0", + "version": "6.10.2-rc1", + "iosSdkVersion": "6.10.1", + "androidSdkVersion": "6.10.2", + "buildNumber": "120", "description": "AppsFlyer SDK plugin for Capacitor", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", diff --git a/src/definitions.ts b/src/definitions.ts index af622be..afb7d03 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -166,6 +166,7 @@ export interface AppsFlyerPlugin { /** * Opt-out of Apple Search Ads attributions. + * @Deprecated deprecated since 6.10.2. This API has no effect, since the SDK is no longer fetching Apple Search Ads data from the iAd Framework. */ disableCollectASA(stop: AFDisable): Promise From f270a78797e4ee95d601a39fd86cea9de8209d17 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Thu, 30 Mar 2023 14:07:26 +0300 Subject: [PATCH 03/25] cleanup --- ios/Plugin/AppsFlyerPlugin.swift | 51 -------------------------------- 1 file changed, 51 deletions(-) diff --git a/ios/Plugin/AppsFlyerPlugin.swift b/ios/Plugin/AppsFlyerPlugin.swift index 10b61ac..c32e3cb 100644 --- a/ios/Plugin/AppsFlyerPlugin.swift +++ b/ios/Plugin/AppsFlyerPlugin.swift @@ -606,55 +606,4 @@ extension AppsFlyerPlugin{ private func afLogger(msg : String){ NSLog ("AppsFlyer [Debug][Capacitor]: \(msg)"); } - - private func getPluginVersion2() -> String { - let plist = readPlist(name: "AppsFlyerCap") - let version = plist["AppsFlyerPluginVersion"] as? String - return version ?? "err" - } - - private func readPlist2(name: String) -> [String: Any] { - if let fileUrl = Bundle.main.url(forResource: name, withExtension: "plist"), - let data = try? Data(contentsOf: fileUrl) { - if let result = try? PropertyListSerialization.propertyList(from: data, options: [], format: nil) as? [String: Any] { - return result - } - } - - return [:] - } - - private func readPlist(name: String) -> NSDictionary { - // Get the path to the plist file in your project - if let plistPath = Bundle.main.path(forResource: "AppsflyerCapacitorPlugin-Info", ofType: "plist"){ - // Load the contents of the plist file into a Data object - guard let plistData = NSDictionary(contentsOfFile: plistPath) else { - return [:] - } - return plistData - } - - guard let plistPath = Bundle(for: AppsFlyerPlugin.self).path(forResource: "AppsflyerCapacitorPlugin-Info", ofType: "plist")else { - return [:] - } - - // Load the contents of the plist file into a Data object - guard let plistData = NSDictionary(contentsOfFile: plistPath) else { - return [:] - } - return plistData - - } - - private func getPluginVersion() -> String { - if let versionNumber = ProcessInfo.processInfo.environment["APPSFLYER_PLUGIN_VERSION"] { - print("APPSFLYER_PLUGIN_VERSION: \(versionNumber)") - } else { - print("APPSFLYER_PLUGIN_VERSION not defined") - } - - return Bundle(for: AppsFlyerPlugin.self).infoDictionary?["APPSFLYER_PLUGIN_VERSION"] as? String ?? "failed_to_fetch" - - } - } From 06d216a3e03d7c6a11cefe372f1cd685898fb947 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Tue, 18 Apr 2023 16:28:32 +0900 Subject: [PATCH 04/25] CI ci CI CI CI --- .github/workflows/create-release-branch-workflow.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 2fd738d..7bd5eab 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -3,6 +3,10 @@ name: Create Release Branch on: workflow_dispatch: inputs: + branchFrom: + default: 'develop' + description: 'The name of the branch to checkout to create a release from' + required: true versionName: description: 'Name of version (ie 5.5.0)' required: true From 5b8703e8df06fd25a16a4c828b06d30557ae99ae Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Tue, 18 Apr 2023 17:19:27 +0900 Subject: [PATCH 05/25] undeprecated --- src/definitions.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/definitions.ts b/src/definitions.ts index afb7d03..af622be 100644 --- a/src/definitions.ts +++ b/src/definitions.ts @@ -166,7 +166,6 @@ export interface AppsFlyerPlugin { /** * Opt-out of Apple Search Ads attributions. - * @Deprecated deprecated since 6.10.2. This API has no effect, since the SDK is no longer fetching Apple Search Ads data from the iAd Framework. */ disableCollectASA(stop: AFDisable): Promise From 99316d0fdaa4a0c0d6c8380613a1a5c918a607bf Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Tue, 18 Apr 2023 17:40:24 +0900 Subject: [PATCH 06/25] fix ci --- .github/workflows/deploy-to-QA.yml | 4 ++-- .github/workflows/pre-release-workflow.yml | 2 +- .github/workflows/release-Production-workflow.yml | 2 +- .github/workflows/release-QA-workflow.yml | 2 +- .github/workflows/scripts/releaseNotesGenerator.sh | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml index fb41e41..094c4a7 100644 --- a/.github/workflows/deploy-to-QA.yml +++ b/.github/workflows/deploy-to-QA.yml @@ -23,7 +23,7 @@ jobs: BRANCH_NAME: ${{github.ref_name}} run: | fixed_version_found=false - plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9].[0-9].[0-9]+') + plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9].[0-9]+.[0-9]+') jira_fixed_version="Capacitor SDK v$plugin_version" # echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV echo "JIRA_FIXED_VERSION=$jira_fixed_version" >> $GITHUB_ENV @@ -31,7 +31,7 @@ jobs: .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$jira_fixed_version" - name: Update package.json file run: | - plugin_rc_version=$(echo "${{github.ref_name}}" | grep -Eo '[0-9].[0-9].[0-9]+-rc[0-9]+') + plugin_rc_version=$(echo "${{github.ref_name}}" | grep -Eo '[0-9].[0-9]+.[0-9]+-rc[0-9]+') echo "Updating plugin to version $plugin_rc_version" npm version $plugin_rc_version --no-git-tag-version echo "Updating package.json and AppsFlyerPlugin.swift to version $plugin_rc_version" diff --git a/.github/workflows/pre-release-workflow.yml b/.github/workflows/pre-release-workflow.yml index bb90d76..0649ca2 100644 --- a/.github/workflows/pre-release-workflow.yml +++ b/.github/workflows/pre-release-workflow.yml @@ -26,7 +26,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Update package.json file run: | - plugin_version=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9].[0-9]+') + plugin_version=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9]+.[0-9]+') # we export plugin_version and release branch name as env so we can use them in the next step echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV echo "GIT_BRANCH_RELEASE=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml index 59245a2..a3a9112 100644 --- a/.github/workflows/release-Production-workflow.yml +++ b/.github/workflows/release-Production-workflow.yml @@ -31,7 +31,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Determine release tag and release branch run: | - TAG=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9].[0-9]+') + TAG=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9]+.[0-9]+') echo "PLUGIN_VERSION=$TAG" >> $GITHUB_ENV echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV echo "push new release >> $TAG" diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index 93d7b7b..5798a98 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -3,7 +3,7 @@ name: Release plugin to QA on: push: branches: - - releases/[0-9].x.x/[0-9].[0-9].x/[0-9].[0-9].[0-9]+-rc[0-9]+ + - releases/[0-9].x.x/[0-9].[0-9].x/[0-9].[0-9]+.[0-9]+-rc[0-9]+ paths-ignore: - '**.md' - '**.yml' diff --git a/.github/workflows/scripts/releaseNotesGenerator.sh b/.github/workflows/scripts/releaseNotesGenerator.sh index 2c0f589..92a976a 100644 --- a/.github/workflows/scripts/releaseNotesGenerator.sh +++ b/.github/workflows/scripts/releaseNotesGenerator.sh @@ -2,12 +2,12 @@ JIRA_TOKEN=$1 JIRA_FIXED_VERSION=$2 fixed_version_found=false -curl -X GET -H "Authorization: Basic $JIRA_TOKEN=" https://appsflyer.atlassian.net/rest/api/3/project/11723/versions | jq -r '.[] | .name+""+.id' | while read version ; do +curl -X GET https://appsflyer.atlassian.net/rest/api/3/project/11723/versions --user $JIRA_TOKEN | jq -r '.[] | .name+""+.id' | while read version ; do if [[ "$version" == *"$JIRA_FIXED_VERSION"* ]] ;then echo "$JIRA_FIXED_VERSION Found!" fixed_version_found=true version_id=${version#"$JIRA_FIXED_VERSION"} - echo $(curl -X GET -H "Authorization: Basic $JIRA_TOKEN=" https://appsflyer.atlassian.net/rest/api/3/search?jql=fixVersion=$version_id | jq -r '.issues[] | "- " + .fields["summary"]+"@"') > "$JIRA_FIXED_VERSION-releasenotes".txt + echo $(curl -X GET https://appsflyer.atlassian.net/rest/api/3/search?jql=fixVersion=$version_id --user $JIRA_TOKEN | jq -r '.issues[] | "- " + .fields["summary"]+"@"') > "$JIRA_FIXED_VERSION-releasenotes".txt sed -i -r -e "s/@ /\n/gi" "$JIRA_FIXED_VERSION-releasenotes".txt sed -i -r -e "s/@/\n/gi" "$JIRA_FIXED_VERSION-releasenotes".txt cat "$JIRA_FIXED_VERSION-releasenotes".txt From 9820022f5337dc1a1472b446b3f9ceee83c380ee Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 16:55:40 +0300 Subject: [PATCH 07/25] add CI --- .github/workflows/build-apps-workflow.yml | 1 + .../create-release-branch-workflow.yml | 2 +- .github/workflows/deploy-to-QA.yml | 29 ++++++++----------- .github/workflows/pre-release-workflow.yml | 14 ++++----- .../workflows/release-Production-workflow.yml | 28 ++++++++++++++---- .github/workflows/release-QA-workflow.yml | 24 ++++++++++----- 6 files changed, 59 insertions(+), 39 deletions(-) diff --git a/.github/workflows/build-apps-workflow.yml b/.github/workflows/build-apps-workflow.yml index c75572a..d3938df 100644 --- a/.github/workflows/build-apps-workflow.yml +++ b/.github/workflows/build-apps-workflow.yml @@ -10,6 +10,7 @@ jobs: - uses: actions/checkout@v3 - name: install capacitor-appsflyer on an Android app run: | + npm run build cd examples/CapacitorReact npm install npm install ../../ diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 7bd5eab..f46988e 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -49,4 +49,4 @@ jobs: - name: create pull request env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr create -B main --title 'Merge $branchName into main' --body 'Created by Github action' + run: gh pr create -B main --title "Merge $branchName into main" --body 'Created by Github action' diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml index 094c4a7..67801cc 100644 --- a/.github/workflows/deploy-to-QA.yml +++ b/.github/workflows/deploy-to-QA.yml @@ -23,24 +23,12 @@ jobs: BRANCH_NAME: ${{github.ref_name}} run: | fixed_version_found=false - plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9].[0-9]+.[0-9]+') + plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9]+.[0-9]+.[0-9]+') jira_fixed_version="Capacitor SDK v$plugin_version" # echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV echo "JIRA_FIXED_VERSION=$jira_fixed_version" >> $GITHUB_ENV chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$jira_fixed_version" - - name: Update package.json file - run: | - plugin_rc_version=$(echo "${{github.ref_name}}" | grep -Eo '[0-9].[0-9]+.[0-9]+-rc[0-9]+') - echo "Updating plugin to version $plugin_rc_version" - npm version $plugin_rc_version --no-git-tag-version - echo "Updating package.json and AppsFlyerPlugin.swift to version $plugin_rc_version" - chmod +x .github/workflows/scripts/updatePluginVersion.sh - .github/workflows/scripts/updatePluginVersion.sh $plugin_rc_version - git add package.json - git add ios/Plugin/AppsFlyerPlugin.swift - git commit -m "update package.json" - git push - name: Push to NPM env: CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} @@ -51,8 +39,15 @@ jobs: - name: Generate and send slack report env: SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} + JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} + JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}" + RELEASE_BRACH_NAME: ${{env.RELEASE_BRANCH_NAME}} + ANDROID_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).androidSdkVersion}} + IOS_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).iosSdkVersion}} + PLUGIN_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).version}} + BUILD_NUMBER: ${{fromJson(steps.set_var.outputs.packageJson).buildNumber}} run: | - ios_sdk_version=$(cat README.md | grep 'iOS AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') - android_sdk_version=$(cat README.md | grep 'Android AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') - CHANGES=$(cat "${{env.JIRA_FIXED_VERSION}}-releasenotes".txt) - curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"${{github.ref_name}}"'", "changes_and_fixes": "'"$CHANGES"'", "android_dependency": "'"$android_sdk_version"'", "ios_dependency": "'"$ios_sdk_version"'"}' "$SLACK_TOKEN" + chmod +x .github/workflows/scripts/releaseNotesGenerator.sh + .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" + CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"$RELEASE_BRACH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependencie": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependencie": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/pre-release-workflow.yml b/.github/workflows/pre-release-workflow.yml index 0649ca2..14563d0 100644 --- a/.github/workflows/pre-release-workflow.yml +++ b/.github/workflows/pre-release-workflow.yml @@ -1,15 +1,11 @@ name: Prepare plugin for production on: - pull_request: - types: - - opened - branches: - - 'master' + workflow_call: jobs: Prepare-Plugin-For-Production: - if: startsWith(github.head_ref, 'releases/') + if: startsWith(github.head_ref, 'Release/') runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -26,12 +22,14 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Update package.json file run: | - plugin_version=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9]+.[0-9]+') + plugin_version=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9]+.[0-9]+.[0-9]+') # we export plugin_version and release branch name as env so we can use them in the next step echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV echo "GIT_BRANCH_RELEASE=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV echo "Updating plugin to version $plugin_version" - npm version $plugin_version + chmod +x .github/workflows/scripts/updatePluginVersion.sh + .github/workflows/scripts/updatePluginVersion.sh $plugin_version + git commit -m "Update Plugin Version" git push origin HEAD:${{ steps.vars.outputs.branch }} --force - name: Update CHANGELOG.md diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml index a3a9112..6efc2e4 100644 --- a/.github/workflows/release-Production-workflow.yml +++ b/.github/workflows/release-Production-workflow.yml @@ -5,7 +5,7 @@ on: types: - closed branches: - - 'master' + - 'main' paths-ignore: - '**.md' - '**.yml' @@ -13,7 +13,13 @@ on: - 'docs/**' - 'assets/**' jobs: + Pre-Release-To-Prod: + if: github.event.pull_request.merged == true + uses: ./.github/workflows/pre-release-workflow.yml + secrets: inherit + Deploy-To-Production: + needs: [ Pre-Release-To-Prod ] if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: @@ -31,7 +37,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Determine release tag and release branch run: | - TAG=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9].[0-9]+.[0-9]+') + TAG=$(echo "${{ steps.vars.outputs.branch }}" | grep -Eo '[0-9]+.[0-9]+.[0-9]+') echo "PLUGIN_VERSION=$TAG" >> $GITHUB_ENV echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV echo "push new release >> $TAG" @@ -64,16 +70,28 @@ jobs: nmp run build npm publish + - id: set_var + run: | + content=`cat ./path/to/package.json` + # the following lines are only required for multi line json + content="${content//'%'/'%25'}" + content="${content//$'\n'/'%0A'}" + content="${content//$'\r'/'%0D'}" + # end of optional handling for multi line json + echo "::set-output name=packageJson::$content" + - name: Generate and send slack report env: SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}" RELEASE_BRACH_NAME: ${{env.RELEASE_BRANCH_NAME}} + ANDROID_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).androidSdkVersion}} + IOS_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).iosSdkVersion}} + PLUGIN_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).version}} + BUILD_NUMBER: ${{fromJson(steps.set_var.outputs.packageJson).buildNumber}} run: | chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" - ios_sdk_version=$(cat README.md | grep 'iOS AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') - android_sdk_version=$(cat README.md | grep 'Android AppsFlyer SDK \*\*v[0-9].[0-9].[0-9]\*\*') CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) - curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRACH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "android_dependencie": "'"$android_sdk_version"'", "ios_dependencie": "'"$ios_sdk_version"'"}' "$SLACK_TOKEN" + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRACH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependencie": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependencie": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index 5798a98..cb97691 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -1,23 +1,31 @@ name: Release plugin to QA on: - push: + pull_request: + types: + - opened branches: - - releases/[0-9].x.x/[0-9].[0-9].x/[0-9].[0-9]+.[0-9]+-rc[0-9]+ - paths-ignore: - - '**.md' - - '**.yml' - - 'examples/**' - - 'assets/**' - - 'docs/**' + - 'main' + +# push: +# branches: +# - releases/[0-9]+.x.x/[0-9]+.[0-9]+.x/[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ +# paths-ignore: +# - '**.md' +# - '**.yml' +# - 'examples/**' +# - 'assets/**' +# - 'docs/**' jobs: Build-Sample-Apps: + if: startsWith(github.head_ref, 'Release/') uses: ./.github/workflows/build-apps-workflow.yml secrets: inherit Deploy-To-QA: + if: startsWith(github.head_ref, 'Release/') needs: [Build-Sample-Apps] uses: ./.github/workflows/deploy-to-QA.yml secrets: inherit From 0ac68e1e9838789ab2ed962fc18322425d2c5e03 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 17:05:46 +0300 Subject: [PATCH 08/25] fix PR msg --- .github/workflows/create-release-branch-workflow.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index f46988e..38990eb 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -39,6 +39,7 @@ jobs: patch=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 3) branchName=$(printf "Release/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) export branchName + echo "BRANCH_NAME=$branchName" >> $GITHUB_ENV git checkout -b $branchName - name: Update Codebase run: | @@ -49,4 +50,4 @@ jobs: - name: create pull request env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr create -B main --title "Merge $branchName into main" --body 'Created by Github action' + run: gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' From 46c9c506f69580e0f34846931f258d43b2ce7d34 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 18:38:49 +0300 Subject: [PATCH 09/25] CI --- .github/workflows/release-QA-workflow.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index cb97691..9a44cd4 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -7,18 +7,9 @@ on: branches: - 'main' -# push: -# branches: -# - releases/[0-9]+.x.x/[0-9]+.[0-9]+.x/[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ -# paths-ignore: -# - '**.md' -# - '**.yml' -# - 'examples/**' -# - 'assets/**' -# - 'docs/**' - jobs: - + Print-Ref-Head: + run: echo "head_ref = ${{github.head_ref}}" Build-Sample-Apps: if: startsWith(github.head_ref, 'Release/') uses: ./.github/workflows/build-apps-workflow.yml From 40969e1554330112acd42e3f3edef2f88cfe5bf1 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 18:38:59 +0300 Subject: [PATCH 10/25] Revert "Merge branch 'dev/DELIVERY32128/create_release_ci' into develop" This reverts commit 0da5292707095f3eae6557ad3f8fb14487aebe10. --- .github/workflows/release-QA-workflow.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index 9a44cd4..cb97691 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -7,9 +7,18 @@ on: branches: - 'main' +# push: +# branches: +# - releases/[0-9]+.x.x/[0-9]+.[0-9]+.x/[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ +# paths-ignore: +# - '**.md' +# - '**.yml' +# - 'examples/**' +# - 'assets/**' +# - 'docs/**' + jobs: - Print-Ref-Head: - run: echo "head_ref = ${{github.head_ref}}" + Build-Sample-Apps: if: startsWith(github.head_ref, 'Release/') uses: ./.github/workflows/build-apps-workflow.yml From 995d1ff8d7da6f4b5e8f17052d33e22297a482fd Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 18:52:08 +0300 Subject: [PATCH 11/25] update ci --- .../workflows/create-release-branch-workflow.yml | 2 +- .github/workflows/pre-release-workflow.yml | 2 +- .github/workflows/release-QA-workflow.yml | 15 ++------------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 38990eb..7d38489 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -37,7 +37,7 @@ jobs: major=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 1) minor=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 2) patch=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 3) - branchName=$(printf "Release/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) + branchName=$(printf "releases/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) export branchName echo "BRANCH_NAME=$branchName" >> $GITHUB_ENV git checkout -b $branchName diff --git a/.github/workflows/pre-release-workflow.yml b/.github/workflows/pre-release-workflow.yml index 14563d0..d71035d 100644 --- a/.github/workflows/pre-release-workflow.yml +++ b/.github/workflows/pre-release-workflow.yml @@ -5,7 +5,7 @@ on: jobs: Prepare-Plugin-For-Production: - if: startsWith(github.head_ref, 'Release/') + if: startsWith(github.head_ref, 'releases/') runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index cb97691..898e661 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -1,5 +1,4 @@ name: Release plugin to QA - on: pull_request: types: @@ -7,25 +6,15 @@ on: branches: - 'main' -# push: -# branches: -# - releases/[0-9]+.x.x/[0-9]+.[0-9]+.x/[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ -# paths-ignore: -# - '**.md' -# - '**.yml' -# - 'examples/**' -# - 'assets/**' -# - 'docs/**' - jobs: Build-Sample-Apps: - if: startsWith(github.head_ref, 'Release/') + if: startsWith(github.head_ref, 'releases/') uses: ./.github/workflows/build-apps-workflow.yml secrets: inherit Deploy-To-QA: - if: startsWith(github.head_ref, 'Release/') + if: startsWith(github.head_ref, 'releases/') needs: [Build-Sample-Apps] uses: ./.github/workflows/deploy-to-QA.yml secrets: inherit From 4d28447ca3a3dd1b49ab2c3af857a89ea57877ba Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 19:18:03 +0300 Subject: [PATCH 12/25] improve CI --- .github/workflows/create-release-branch-workflow.yml | 11 +++++++++++ .github/workflows/release-QA-workflow.yml | 1 + 2 files changed, 12 insertions(+) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 7d38489..7002fa6 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -19,6 +19,11 @@ on: AndroidVersion: description: 'Android SDK version number (5.5.0)' required: true + DeployToQA: + required: false + type: boolean + default: false + jobs: createRelease: @@ -51,3 +56,9 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' + + deployToQA: + if: startsWith(github.head_ref, 'releases/') && ${{ github.event.inputs.DeployToQA }} + needs: [ createRelease ] + uses: ./.github/workflows/release-QA-workflow.yml + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index 898e661..d83e42d 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -1,5 +1,6 @@ name: Release plugin to QA on: + workflow_call: pull_request: types: - opened From 43b587a43c1765f43dc47736b6c3ba4c443ce0bf Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 19:19:56 +0300 Subject: [PATCH 13/25] improve ci --- .github/workflows/create-release-branch-workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 7002fa6..87940d8 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -21,6 +21,7 @@ on: required: true DeployToQA: required: false + description: 'Should the workflow trigger RC deployment' type: boolean default: false From afff66b9f695286b74f6a8ac73dfb77d3bc904c1 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 19:23:02 +0300 Subject: [PATCH 14/25] fix CI --- .github/workflows/create-release-branch-workflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 87940d8..108f054 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -21,7 +21,7 @@ on: required: true DeployToQA: required: false - description: 'Should the workflow trigger RC deployment' + description: 'Deploy to QA (publish RC)' type: boolean default: false @@ -59,7 +59,7 @@ jobs: run: gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' deployToQA: - if: startsWith(github.head_ref, 'releases/') && ${{ github.event.inputs.DeployToQA }} + if: ${{ github.event.inputs.DeployToQA }} needs: [ createRelease ] uses: ./.github/workflows/release-QA-workflow.yml secrets: inherit \ No newline at end of file From d1f0f68474c3654968416a49c142c55c1b8e3b46 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 19:56:47 +0300 Subject: [PATCH 15/25] improve ci --- .github/workflows/create-release-branch-workflow.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 108f054..fc920cb 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -29,6 +29,8 @@ on: jobs: createRelease: runs-on: ubuntu-latest + outputs: + output1: ${{ steps.createBranch.outputs.test }} steps: - uses: actions/checkout@v3 - name: Login to Github @@ -39,13 +41,14 @@ jobs: git config --global user.name $COMMIT_AUTHOR git config --global user.email $COMMIT_EMAIL - name: Create New Branch + id: createBranch run: | major=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 1) minor=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 2) patch=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 3) branchName=$(printf "releases/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) export branchName - echo "BRANCH_NAME=$branchName" >> $GITHUB_ENV + echo "BRANCH_NAME=$branchName" >> $GITHUB_OUTPUT git checkout -b $branchName - name: Update Codebase run: | @@ -61,5 +64,7 @@ jobs: deployToQA: if: ${{ github.event.inputs.DeployToQA }} needs: [ createRelease ] - uses: ./.github/workflows/release-QA-workflow.yml + env: + BRANCH_NAME: ${{needs.createRelease.outputs.output1}} + uses: "./.github/workflows/release-QA-workflow.yml@$BRANCH_NAME" secrets: inherit \ No newline at end of file From c462369e34d84f1b1c17327b8bcc04474d5a98c9 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 20:29:46 +0300 Subject: [PATCH 16/25] update CI --- .../workflows/create-release-branch-workflow.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index fc920cb..8bfbefe 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -29,8 +29,8 @@ on: jobs: createRelease: runs-on: ubuntu-latest - outputs: - output1: ${{ steps.createBranch.outputs.test }} + env: + GITHUB_TOKEN: ${{ secrets.CI_DEV_GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 - name: Login to Github @@ -61,10 +61,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' - deployToQA: - if: ${{ github.event.inputs.DeployToQA }} - needs: [ createRelease ] - env: - BRANCH_NAME: ${{needs.createRelease.outputs.output1}} - uses: "./.github/workflows/release-QA-workflow.yml@$BRANCH_NAME" - secrets: inherit \ No newline at end of file +# deployToQA: +# if: ${{ github.event.inputs.DeployToQA }} +# needs: [ createRelease ] +# uses: ./.github/workflows/release-QA-workflow.yml +# secrets: inherit \ No newline at end of file From 033804e4bcfd1c87176a08e31a5d063a8ab54850 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 24 Apr 2023 20:35:57 +0300 Subject: [PATCH 17/25] CI --- .github/workflows/create-release-branch-workflow.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 8bfbefe..8ace179 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -29,8 +29,6 @@ on: jobs: createRelease: runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.CI_DEV_GITHUB_TOKEN }} steps: - uses: actions/checkout@v3 - name: Login to Github @@ -48,7 +46,7 @@ jobs: patch=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 3) branchName=$(printf "releases/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) export branchName - echo "BRANCH_NAME=$branchName" >> $GITHUB_OUTPUT + echo "BRANCH_NAME=$branchName" >> $GITHUB_ENV git checkout -b $branchName - name: Update Codebase run: | @@ -58,7 +56,7 @@ jobs: - name: create pull request env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.CI_DEV_GITHUB_TOKEN }} run: gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' # deployToQA: From 57fc998f5ee37c2e60bb95bcc9a7efc127a854cb Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Tue, 25 Apr 2023 11:25:03 +0300 Subject: [PATCH 18/25] update CI --- .github/workflows/build-apps-workflow.yml | 18 ++++++++++++++++-- .github/workflows/deploy-to-QA.yml | 6 +++++- .../workflows/release-Production-workflow.yml | 11 ++++++++++- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-apps-workflow.yml b/.github/workflows/build-apps-workflow.yml index d3938df..8252902 100644 --- a/.github/workflows/build-apps-workflow.yml +++ b/.github/workflows/build-apps-workflow.yml @@ -8,11 +8,25 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 19.x + + - name: Install plugin dependencies + run: npm install + - name: Build plugin + run: npm run build - name: install capacitor-appsflyer on an Android app run: | - npm run build cd examples/CapacitorReact - npm install npm install ../../ npx cap sync android - name: Build apk diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml index 67801cc..b15b75e 100644 --- a/.github/workflows/deploy-to-QA.yml +++ b/.github/workflows/deploy-to-QA.yml @@ -9,6 +9,10 @@ jobs: environment: Staging steps: - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 19.x - name: Login to Github env: COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} @@ -35,7 +39,7 @@ jobs: run: | echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc npm run build - npm publish --tag QA + npm publish --tag QA --dry-run - name: Generate and send slack report env: SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml index 6efc2e4..9393924 100644 --- a/.github/workflows/release-Production-workflow.yml +++ b/.github/workflows/release-Production-workflow.yml @@ -18,12 +18,21 @@ jobs: uses: ./.github/workflows/pre-release-workflow.yml secrets: inherit - Deploy-To-Production: + Build-Sample-Apps: needs: [ Pre-Release-To-Prod ] + uses: ./.github/workflows/build-apps-workflow.yml + secrets: inherit + + Deploy-To-Production: + needs: [ Build-Sample-Apps ] if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 19.x - name: Login to Github env: COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} From f8d31c8d29fdd577a862cf01270b14341e813a55 Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Sun, 30 Apr 2023 19:53:30 +0300 Subject: [PATCH 19/25] Update CI --- .github/workflows/build-apps-workflow.yml | 23 +++++++++- .../create-release-branch-workflow.yml | 30 +++++++------ .github/workflows/deploy-to-QA.yml | 39 ++++++++++++----- .github/workflows/pre-release-workflow.yml | 28 ++++++++++-- .../workflows/release-Production-workflow.yml | 43 ++++++++++--------- .github/workflows/release-QA-workflow.yml | 9 ++-- .../scripts/releaseNotesGenerator.sh | 2 + 7 files changed, 118 insertions(+), 56 deletions(-) diff --git a/.github/workflows/build-apps-workflow.yml b/.github/workflows/build-apps-workflow.yml index d3938df..e6883dc 100644 --- a/.github/workflows/build-apps-workflow.yml +++ b/.github/workflows/build-apps-workflow.yml @@ -8,12 +8,29 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + + - name: Setup java + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + + - name: Install plugin dependencies + run: npm install + - name: Build plugin + run: npm run build - name: install capacitor-appsflyer on an Android app run: | - npm run build cd examples/CapacitorReact npm install npm install ../../ + npx cap add android + npm run build npx cap sync android - name: Build apk run: | @@ -22,7 +39,9 @@ jobs: gradle wrapper echo "ls: $(ls)" chmod +x ./gradlew - ./gradlew assembleRelease + ./gradlew wrapper --gradle-version 7.6.1 + ./gradlew clean assembleRelease + # Build-Capacitor-ios: # runs-on: macos-latest # steps: diff --git a/.github/workflows/create-release-branch-workflow.yml b/.github/workflows/create-release-branch-workflow.yml index 38990eb..2d5445d 100644 --- a/.github/workflows/create-release-branch-workflow.yml +++ b/.github/workflows/create-release-branch-workflow.yml @@ -3,22 +3,21 @@ name: Create Release Branch on: workflow_dispatch: inputs: - branchFrom: - default: 'develop' - description: 'The name of the branch to checkout to create a release from' - required: true versionName: description: 'Name of version (ie 5.5.0)' required: true - BuildNumber: - description: 'Version number (5500)' - required: true iosVersion: description: 'iOS SDK version number (5.5.0)' required: true AndroidVersion: description: 'Android SDK version number (5.5.0)' required: true + DeployToQA: + required: false + description: 'Deploy to QA (open PR and publish RC)' + type: boolean + default: false + jobs: createRelease: @@ -33,21 +32,24 @@ jobs: git config --global user.name $COMMIT_AUTHOR git config --global user.email $COMMIT_EMAIL - name: Create New Branch + id: createBranch run: | - major=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 1) - minor=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 2) - patch=$(echo ${{ github.event.inputs.versionName }}| cut -d'.' -f 3) - branchName=$(printf "Release/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) + major=$(echo ${{ inputs.versionName }}| cut -d'.' -f 1) + minor=$(echo ${{ inputs.versionName }}| cut -d'.' -f 2) + patch=$(echo ${{ inputs.versionName }}| cut -d'.' -f 3) + branchName=$(printf "releases/%s.x.x/%s.%s.x/%s.%s.%s" $major $major $minor $major $minor $patch) export branchName echo "BRANCH_NAME=$branchName" >> $GITHUB_ENV git checkout -b $branchName - name: Update Codebase run: | - .github/workflows/scripts/updatePlugin.sh pluginVersion=${{ github.event.inputs.versionName }} buildNumber=${{ github.event.inputs.BuildNumber }} iOSVersion=${{ github.event.inputs.iosVersion }} androidVersion=${{ github.event.inputs.AndroidVersion }} + .github/workflows/scripts/updatePlugin.sh pluginVersion=${{ inputs.versionName }} buildNumber=${{ github.run_number }} iOSVersion=${{ inputs.iosVersion }} androidVersion=${{ inputs.AndroidVersion }} git commit -m "update versions using CI" git push -u origin --all - name: create pull request + if: ${{ inputs.DeployToQA }} env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' + GITHUB_TOKEN: ${{ secrets.CI_DEV_GITHUB_TOKEN }} + run: | + gh pr create -B main --title "Merge ${{ env.BRANCH_NAME }} into main" --body 'Created by Github action' diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml index 67801cc..cc3056d 100644 --- a/.github/workflows/deploy-to-QA.yml +++ b/.github/workflows/deploy-to-QA.yml @@ -9,6 +9,13 @@ jobs: environment: Staging steps: - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Install dependency + run: | + npm i rimraf - name: Login to Github env: COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} @@ -16,38 +23,48 @@ jobs: run: | git config --global user.name $COMMIT_AUTHOR git config --global user.email $COMMIT_EMAIL - + - uses: mdecoleman/pr-branch-name@2.0.0 + id: vars + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Export branch name + run: | + echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV - name: Check if fixed version is on Jira env: JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} - BRANCH_NAME: ${{github.ref_name}} + BRANCH_NAME: ${{ github.head_ref || github.ref_name }} + run: | fixed_version_found=false plugin_version=$(echo "$BRANCH_NAME" | grep -Eo '[0-9]+.[0-9]+.[0-9]+') jira_fixed_version="Capacitor SDK v$plugin_version" - # echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV + echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV echo "JIRA_FIXED_VERSION=$jira_fixed_version" >> $GITHUB_ENV chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$jira_fixed_version" + - name: Build Plugin + run: | + npm run build - name: Push to NPM env: CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc - npm run build - npm publish --tag QA + npm publish --tag QA --dry-run + - name: Generate and send slack report env: SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}" - RELEASE_BRACH_NAME: ${{env.RELEASE_BRANCH_NAME}} - ANDROID_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).androidSdkVersion}} - IOS_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).iosSdkVersion}} - PLUGIN_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).version}} - BUILD_NUMBER: ${{fromJson(steps.set_var.outputs.packageJson).buildNumber}} + RELEASE_BRANCH_NAME: ${{env.RELEASE_BRANCH_NAME}} run: | + ANDROID_SDK_VERSION=`cat package.json | jq .androidSdkVersion` + IOS_SDK_VERSION=`cat package.json | jq .iosSdkVersion` + PLUGIN_VERSION=`cat package.json | jq .version` + BUILD_NUMBER=`cat package.json | jq .buildNumber` chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) - curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"$RELEASE_BRACH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependencie": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependencie": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependency": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/pre-release-workflow.yml b/.github/workflows/pre-release-workflow.yml index 14563d0..3f9d788 100644 --- a/.github/workflows/pre-release-workflow.yml +++ b/.github/workflows/pre-release-workflow.yml @@ -1,11 +1,12 @@ name: Prepare plugin for production on: - workflow_call: + pull_request: + types: [ labeled ] jobs: Prepare-Plugin-For-Production: - if: startsWith(github.head_ref, 'Release/') + if: startsWith(github.head_ref, 'releases/') && github.event.label.name == 'Ready For Production' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -16,7 +17,7 @@ jobs: run: | git config --global user.name $COMMIT_AUTHOR git config --global user.email $COMMIT_EMAIL - - uses: mdecoleman/pr-branch-name@1.2.0 + - uses: mdecoleman/pr-branch-name@2.0.0 id: vars with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -28,7 +29,9 @@ jobs: echo "GIT_BRANCH_RELEASE=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV echo "Updating plugin to version $plugin_version" chmod +x .github/workflows/scripts/updatePluginVersion.sh + chmod +x .github/workflows/scripts/updateBuildNumber.sh .github/workflows/scripts/updatePluginVersion.sh $plugin_version + .github/workflows/scripts/updateBuildNumber.sh ${{github.run_number}} git commit -m "Update Plugin Version" git push origin HEAD:${{ steps.vars.outputs.branch }} --force @@ -45,3 +48,22 @@ jobs: git add CHANGELOG.md git commit -m "Update CHANGELOG.md" git push origin HEAD:${{ env.GIT_BRANCH_RELEASE }} --force + + Approve-Pull-Request: + needs: [ Prepare-Plugin-For-Production ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: mdecoleman/pr-branch-name@2.0.0 + id: vars + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Export branch name + run: | + echo "RELEASE_BRANCH_NAME=${{ steps.vars.outputs.branch }}" >> $GITHUB_ENV + - name: approve pull request + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | # approve the pull request of the current branch + gh pr review "$PR_NUMBER" --approve diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml index 6efc2e4..9330e4a 100644 --- a/.github/workflows/release-Production-workflow.yml +++ b/.github/workflows/release-Production-workflow.yml @@ -13,17 +13,29 @@ on: - 'docs/**' - 'assets/**' jobs: - Pre-Release-To-Prod: - if: github.event.pull_request.merged == true - uses: ./.github/workflows/pre-release-workflow.yml +# Pre-Release-To-Prod: +# if: github.event.pull_request.merged == true +# uses: ./.github/workflows/pre-release-workflow.yml +# secrets: inherit + + Build-Sample-Apps: +# needs: [ Pre-Release-To-Prod ] + uses: ./.github/workflows/build-apps-workflow.yml secrets: inherit Deploy-To-Production: - needs: [ Pre-Release-To-Prod ] + needs: [ Build-Sample-Apps ] if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 16.x + - name: Install dependency + run: | + npm i rimraf - name: Login to Github env: COMMIT_AUTHOR: ${{ secrets.CI_COMMIT_AUTHOR }} @@ -31,7 +43,7 @@ jobs: run: | git config --global user.name $COMMIT_AUTHOR git config --global user.email $COMMIT_EMAIL - - uses: mdecoleman/pr-branch-name@1.2.0 + - uses: mdecoleman/pr-branch-name@2.0.0 id: vars with: repo-token: ${{ secrets.GITHUB_TOKEN }} @@ -70,28 +82,17 @@ jobs: nmp run build npm publish - - id: set_var - run: | - content=`cat ./path/to/package.json` - # the following lines are only required for multi line json - content="${content//'%'/'%25'}" - content="${content//$'\n'/'%0A'}" - content="${content//$'\r'/'%0D'}" - # end of optional handling for multi line json - echo "::set-output name=packageJson::$content" - - name: Generate and send slack report env: SLACK_TOKEN: ${{ secrets.CI_SLACK_TOKEN }} JIRA_TOKEN: ${{ secrets.CI_JIRA_TOKEN }} JIRA_FIXED_VERSION: "Capacitor SDK v${{env.PLUGIN_VERSION}}" - RELEASE_BRACH_NAME: ${{env.RELEASE_BRANCH_NAME}} - ANDROID_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).androidSdkVersion}} - IOS_SDK_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).iosSdkVersion}} - PLUGIN_VERSION: ${{fromJson(steps.set_var.outputs.packageJson).version}} - BUILD_NUMBER: ${{fromJson(steps.set_var.outputs.packageJson).buildNumber}} run: | + ANDROID_SDK_VERSION=`cat package.json | jq .androidSdkVersion` + IOS_SDK_VERSION=`cat package.json | jq .iosSdkVersion` + PLUGIN_VERSION=`cat package.json | jq .version` + BUILD_NUMBER=`cat package.json | jq .buildNumber` chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) - curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRACH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependencie": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependencie": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependency": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/release-QA-workflow.yml b/.github/workflows/release-QA-workflow.yml index 9a44cd4..d83e42d 100644 --- a/.github/workflows/release-QA-workflow.yml +++ b/.github/workflows/release-QA-workflow.yml @@ -1,6 +1,6 @@ name: Release plugin to QA - on: + workflow_call: pull_request: types: - opened @@ -8,15 +8,14 @@ on: - 'main' jobs: - Print-Ref-Head: - run: echo "head_ref = ${{github.head_ref}}" + Build-Sample-Apps: - if: startsWith(github.head_ref, 'Release/') + if: startsWith(github.head_ref, 'releases/') uses: ./.github/workflows/build-apps-workflow.yml secrets: inherit Deploy-To-QA: - if: startsWith(github.head_ref, 'Release/') + if: startsWith(github.head_ref, 'releases/') needs: [Build-Sample-Apps] uses: ./.github/workflows/deploy-to-QA.yml secrets: inherit diff --git a/.github/workflows/scripts/releaseNotesGenerator.sh b/.github/workflows/scripts/releaseNotesGenerator.sh index 92a976a..4aa85bb 100644 --- a/.github/workflows/scripts/releaseNotesGenerator.sh +++ b/.github/workflows/scripts/releaseNotesGenerator.sh @@ -1,6 +1,8 @@ JIRA_TOKEN=$1 JIRA_FIXED_VERSION=$2 +echo "Trying to fetch release note for $JIRA_FIXED_VERSION" + fixed_version_found=false curl -X GET https://appsflyer.atlassian.net/rest/api/3/project/11723/versions --user $JIRA_TOKEN | jq -r '.[] | .name+""+.id' | while read version ; do if [[ "$version" == *"$JIRA_FIXED_VERSION"* ]] ;then From c1f3dbd46aad5a77199f954d1f2d3524e6caee2d Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Sun, 30 Apr 2023 20:07:49 +0300 Subject: [PATCH 20/25] remove dry run --- .github/workflows/deploy-to-QA.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml index cc3056d..3bca58c 100644 --- a/.github/workflows/deploy-to-QA.yml +++ b/.github/workflows/deploy-to-QA.yml @@ -51,7 +51,7 @@ jobs: CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc - npm publish --tag QA --dry-run + npm publish --tag QA - name: Generate and send slack report env: From efc68cf1eaa07fe64c6b00a60ca0aace9e14d2eb Mon Sep 17 00:00:00 2001 From: pazlavi Date: Mon, 1 May 2023 12:01:05 +0000 Subject: [PATCH 21/25] update versions using CI --- README.md | 2 +- ios/Plugin/AppsFlyerPlugin.swift | 2 +- package.json | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d473964..63847e3 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ ###
This plugin is built for -- Android AppsFlyer SDK **6.10.2** +- Android AppsFlyer SDK **6.10.3** - iOS AppsFlyer SDK **6.10.1** ## ❗❗ Breaking changes when updating to v6.9.2❗❗ diff --git a/ios/Plugin/AppsFlyerPlugin.swift b/ios/Plugin/AppsFlyerPlugin.swift index c32e3cb..c05532d 100644 --- a/ios/Plugin/AppsFlyerPlugin.swift +++ b/ios/Plugin/AppsFlyerPlugin.swift @@ -5,7 +5,7 @@ import AppsFlyerLib @objc(AppsFlyerPlugin) public class AppsFlyerPlugin: CAPPlugin { - private let APPSFLYER_PLUGIN_VERSION = "6.10.2-rc1" + private let APPSFLYER_PLUGIN_VERSION = "6.10.3-rc1" private var conversion = true private var oaoa = true private var udl = false diff --git a/package.json b/package.json index edc022f..ebf5786 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "appsflyer-capacitor-plugin", - "version": "6.10.2-rc1", + "version": "6.10.3-rc1", "iosSdkVersion": "6.10.1", - "androidSdkVersion": "6.10.2", - "buildNumber": "120", + "androidSdkVersion": "6.10.3", + "buildNumber": "65", "description": "AppsFlyer SDK plugin for Capacitor", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", From 2d661ff0734e61c7de404624f571de4ee26717bd Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 1 May 2023 15:27:24 +0300 Subject: [PATCH 22/25] fix slack msg --- .github/workflows/deploy-to-QA.yml | 2 +- .github/workflows/release-Production-workflow.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-QA.yml b/.github/workflows/deploy-to-QA.yml index d81997e..f82a279 100644 --- a/.github/workflows/deploy-to-QA.yml +++ b/.github/workflows/deploy-to-QA.yml @@ -69,4 +69,4 @@ jobs: chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) - curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependency": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "QA", "install_tag": "QA", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"$ANDROID_SDK_VERSION"'", "ios_dependency": "'"$IOS_SDK_VERSION"'"}' "$SLACK_TOKEN" diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml index 393e0f2..cfc6242 100644 --- a/.github/workflows/release-Production-workflow.yml +++ b/.github/workflows/release-Production-workflow.yml @@ -96,4 +96,4 @@ jobs: chmod +x .github/workflows/scripts/releaseNotesGenerator.sh .github/workflows/scripts/releaseNotesGenerator.sh $JIRA_TOKEN "$JIRA_FIXED_VERSION" CHANGES=$(cat "$JIRA_FIXED_VERSION-releasenotes".txt) - curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"${{env.ANDROID_SDK_VERSION}}"'", "ios_dependency": "'"${{env.IOS_SDK_VERSION}}"'"}' "$SLACK_TOKEN" + curl -X POST -H 'Content-type: application/json' --data '{"jira_fixed_version": "'"${{env.JIRA_FIXED_VERSION}}"'", "deploy_type": "Production", "install_tag": "latest", "git_branch": "'"$RELEASE_BRANCH_NAME"'", "changes_and_fixes": "'"$CHANGES"'", "plugin_version": "'"${{env.PLUGIN_VERSION}}"'", "android_dependency": "'"$ANDROID_SDK_VERSION"'", "ios_dependency": "'"$IOS_SDK_VERSION"'"}' "$SLACK_TOKEN" From c4a7db2040410c7413cd294e2a8c1e7c2c986034 Mon Sep 17 00:00:00 2001 From: pazlavi Date: Mon, 1 May 2023 12:55:15 +0000 Subject: [PATCH 23/25] Update Plugin Version --- ios/Plugin/AppsFlyerPlugin.swift | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ios/Plugin/AppsFlyerPlugin.swift b/ios/Plugin/AppsFlyerPlugin.swift index c05532d..39d1d4d 100644 --- a/ios/Plugin/AppsFlyerPlugin.swift +++ b/ios/Plugin/AppsFlyerPlugin.swift @@ -5,7 +5,7 @@ import AppsFlyerLib @objc(AppsFlyerPlugin) public class AppsFlyerPlugin: CAPPlugin { - private let APPSFLYER_PLUGIN_VERSION = "6.10.3-rc1" + private let APPSFLYER_PLUGIN_VERSION = "6.10.3" private var conversion = true private var oaoa = true private var udl = false diff --git a/package.json b/package.json index ebf5786..d45bd96 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "appsflyer-capacitor-plugin", - "version": "6.10.3-rc1", + "version": "6.10.3", "iosSdkVersion": "6.10.1", "androidSdkVersion": "6.10.3", - "buildNumber": "65", + "buildNumber": "7", "description": "AppsFlyer SDK plugin for Capacitor", "main": "dist/plugin.cjs.js", "module": "dist/esm/index.js", From a793fbfe624f6a5462d04fcb52bb3e2eb6986dd6 Mon Sep 17 00:00:00 2001 From: pazlavi Date: Mon, 1 May 2023 12:55:18 +0000 Subject: [PATCH 24/25] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d748aff..00e6c03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 6.10.3 + Release date: *2023-05-01* + +- Capacitor >> create CI for release +- Capacitor >> Update Plugin to v6.10.3 + # Release Notes ### 6.9.2 Release date: *2022-November-13* From d0e6697a3b850b41859143cb57a8d3dae75aab3f Mon Sep 17 00:00:00 2001 From: Paz Lavi Date: Mon, 1 May 2023 16:14:42 +0300 Subject: [PATCH 25/25] fix typo --- .github/workflows/release-Production-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-Production-workflow.yml b/.github/workflows/release-Production-workflow.yml index cfc6242..bd37fc8 100644 --- a/.github/workflows/release-Production-workflow.yml +++ b/.github/workflows/release-Production-workflow.yml @@ -80,7 +80,7 @@ jobs: CI_NPM_TOKEN: ${{ secrets.CI_NPM_TOKEN }} run: | echo "//registry.npmjs.org/:_authToken=$CI_NPM_TOKEN" > ~/.npmrc - nmp run build + npm run build npm publish - name: Generate and send slack report