@capgo/capacitor-appsflyer 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CapgoCapacitorAppsflyer.podspec +27 -0
  2. package/LICENSE +21 -0
  3. package/Package.swift +30 -0
  4. package/README.md +1257 -0
  5. package/android/build.gradle +178 -0
  6. package/android/src/main/AndroidManifest.xml +7 -0
  7. package/android/src/main/java/capacitor/plugin/appsflyer/sdk/AFHelpers.kt +76 -0
  8. package/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerConstants.kt +76 -0
  9. package/android/src/main/java/capacitor/plugin/appsflyer/sdk/AppsFlyerPlugin.kt +812 -0
  10. package/android/src/main/res/.gitkeep +0 -0
  11. package/dist/docs.json +2145 -0
  12. package/dist/esm/Appsflyer_constants.d.ts +29 -0
  13. package/dist/esm/Appsflyer_constants.js +33 -0
  14. package/dist/esm/Appsflyer_constants.js.map +1 -0
  15. package/dist/esm/appsflyer_interfaces.d.ts +200 -0
  16. package/dist/esm/appsflyer_interfaces.js +18 -0
  17. package/dist/esm/appsflyer_interfaces.js.map +1 -0
  18. package/dist/esm/definitions.d.ts +219 -0
  19. package/dist/esm/definitions.js +2 -0
  20. package/dist/esm/definitions.js.map +1 -0
  21. package/dist/esm/index.d.ts +6 -0
  22. package/dist/esm/index.js +7 -0
  23. package/dist/esm/index.js.map +1 -0
  24. package/dist/plugin.cjs.js +60 -0
  25. package/dist/plugin.cjs.js.map +1 -0
  26. package/dist/plugin.js +63 -0
  27. package/dist/plugin.js.map +1 -0
  28. package/ios/Sources/AppsFlyerPlugin/AppsFlyerAttribution.swift +60 -0
  29. package/ios/Sources/AppsFlyerPlugin/AppsFlyerConstants.swift +86 -0
  30. package/ios/Sources/AppsFlyerPlugin/AppsFlyerPlugin.swift +1007 -0
  31. package/ios/Sources/AppsFlyerPlugin/Extensions.swift +78 -0
  32. package/ios/Tests/AppsFlyerPluginTests/AppsFlyerPluginTests.swift +8 -0
  33. package/package.json +93 -0
@@ -0,0 +1,178 @@
1
+ import groovy.json.JsonSlurper
2
+
3
+ import java.nio.file.FileVisitResult
4
+ import java.nio.file.Files
5
+ import java.nio.file.Path
6
+ import java.nio.file.SimpleFileVisitor
7
+ import java.nio.file.attribute.BasicFileAttributes
8
+
9
+ String getPackageJsonPath() {
10
+ String envPath = findProperty("APPSFLYER_PACKAGE_JSON_PATH") as String
11
+ if (envPath) {
12
+ logger.lifecycle("package.json path from APPSFLYER_PACKAGE_JSON_PATH: $envPath")
13
+ return envPath
14
+ }
15
+
16
+ def possiblePackageJsonPaths = [
17
+ "${projectDir.parentFile}/package.json",
18
+ "${buildDir.parentFile.parentFile}/package.json",
19
+ "${rootDir.parentFile}/node_modules/@capgo/capacitor-appsflyer/package.json",
20
+ ]
21
+
22
+ for (possiblePath in possiblePackageJsonPaths) {
23
+ File possibleFile = file(possiblePath)
24
+ if (possibleFile.exists()) {
25
+ logger.lifecycle("Found package.json at: ${possibleFile.absolutePath}")
26
+ return possibleFile.absolutePath
27
+ }
28
+ }
29
+
30
+ logger.lifecycle("Did not locate package.json in any of possiblePackageJsonPaths and APPSFLYER_PACKAGE_JSON_PATH is not specified.")
31
+ return null
32
+ }
33
+
34
+ static def findNodeModulesDir(File currentDir) {
35
+ def dir = currentDir
36
+ while (dir != null) {
37
+ def nodeModulesDir = new File(dir, 'node_modules')
38
+ if (nodeModulesDir.exists()) {
39
+ return nodeModulesDir
40
+ }
41
+ dir = dir.parentFile
42
+ }
43
+ return null
44
+ }
45
+
46
+ def findPackageJsonInDep(String packageName) {
47
+ def nodeModulesDir = findNodeModulesDir(project.rootDir)
48
+ if (nodeModulesDir == null) {
49
+ logger.lifecycle("node_modules directory not found in any parent directories.")
50
+ return null
51
+ }
52
+
53
+ def json = null
54
+
55
+ def walker = new SimpleFileVisitor<Path>() {
56
+ @Override
57
+ FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
58
+ if (file.toAbsolutePath().endsWith("@capgo/capacitor-appsflyer/package.json")) {
59
+ try {
60
+ def content = new JsonSlurper().parseText(file.toFile().text)
61
+ if (content.name == packageName) {
62
+ logger.lifecycle("Found package.json at: ${file.toAbsolutePath()}")
63
+ json = content
64
+ return FileVisitResult.TERMINATE
65
+ }
66
+ } catch (Exception e) {
67
+ logger.lifecycle("Error parsing JSON in file: ${file.toAbsolutePath().toString()}\n${e.message}\n\t")
68
+ }
69
+ }
70
+ return FileVisitResult.CONTINUE
71
+ }
72
+ }
73
+
74
+ while (json == null && nodeModulesDir != null) {
75
+ Files.walkFileTree(nodeModulesDir.toPath(), walker)
76
+ nodeModulesDir = findNodeModulesDir(nodeModulesDir.parentFile.parentFile)
77
+ }
78
+ return json
79
+ }
80
+
81
+ def getPackageJson() {
82
+ String packageJsonPath = getPackageJsonPath()
83
+ File inputFile = packageJsonPath ? new File(packageJsonPath) : null
84
+
85
+ if (inputFile?.exists()) {
86
+ try {
87
+ return new JsonSlurper().parseText(inputFile.getText('UTF-8'))
88
+ } catch (Exception e) {
89
+ logger.error("Failed to parse package.json at: ${inputFile.absolutePath}", e)
90
+ }
91
+ } else {
92
+ logger.lifecycle("Searching for package.json recursively in node_modules directories...")
93
+ def foundJson = findPackageJsonInDep("@capgo/capacitor-appsflyer")
94
+ if (foundJson) {
95
+ return foundJson
96
+ }
97
+ }
98
+
99
+ logger.error("The plugin package.json could not be loaded properly; @capgo/capacitor-appsflyer may not function as expected.")
100
+ return null
101
+ }
102
+
103
+ ext {
104
+ packageJson = getPackageJson()
105
+
106
+ junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
107
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.1'
108
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.3.0'
109
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.7.0'
110
+ af_sdk_version = packageJson?.androidSdkVersion
111
+ plugin_version = packageJson?.version
112
+ plugin_build_version = packageJson?.buildNumber
113
+ }
114
+
115
+ buildscript {
116
+ ext.kotlin_version = project.hasProperty("kotlin_version") ? rootProject.ext.kotlin_version : '2.2.20'
117
+ repositories {
118
+ google()
119
+ mavenCentral()
120
+ }
121
+ dependencies {
122
+ classpath 'com.android.tools.build:gradle:8.13.0'
123
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
124
+ classpath 'org.codehaus.groovy:groovy-json:3.0.9'
125
+ }
126
+ }
127
+
128
+ apply plugin: 'com.android.library'
129
+ apply plugin: 'kotlin-android'
130
+
131
+ android {
132
+ namespace = "capacitor.plugin.appsflyer.sdk"
133
+ compileSdk = project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 36
134
+ defaultConfig {
135
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 24
136
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 36
137
+ versionCode Integer.parseInt(plugin_build_version)
138
+ versionName "$plugin_version"
139
+ buildConfigField "int", "VERSION_CODE", plugin_build_version
140
+ buildConfigField "String", "VERSION_NAME", "\"$plugin_version\""
141
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
142
+ }
143
+ buildTypes {
144
+ release {
145
+ minifyEnabled false
146
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
147
+ }
148
+ }
149
+ lintOptions {
150
+ abortOnError = false
151
+ }
152
+ compileOptions {
153
+ sourceCompatibility JavaVersion.VERSION_21
154
+ targetCompatibility JavaVersion.VERSION_21
155
+ }
156
+ buildFeatures {
157
+ buildConfig = true
158
+ }
159
+ }
160
+
161
+ repositories {
162
+ google()
163
+ mavenCentral()
164
+ }
165
+
166
+ dependencies {
167
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
168
+ implementation project(':capacitor-android')
169
+ implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
170
+ testImplementation "junit:junit:$junitVersion"
171
+ androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
172
+ androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
173
+ implementation "androidx.core:core-ktx:1.8.0"
174
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
175
+
176
+ implementation "com.appsflyer:af-android-sdk:$af_sdk_version"
177
+ implementation "com.android.installreferrer:installreferrer:2.2"
178
+ }
@@ -0,0 +1,7 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ >
3
+ <uses-permission android:name="android.permission.INTERNET" />
4
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5
+ <uses-permission android:name="com.google.android.gms.permission.AD_ID" />
6
+
7
+ </manifest>
@@ -0,0 +1,76 @@
1
+ package capacitor.plugin.appsflyer.sdk
2
+
3
+ import android.os.Bundle
4
+ import android.util.Log
5
+ import com.getcapacitor.JSObject
6
+ import org.json.JSONException
7
+
8
+ object AFHelpers {
9
+
10
+ fun jsonToMap(json: JSObject?): Map<String, Any>? {
11
+ var newMap: MutableMap<String, Any>? = null
12
+ json?.run {
13
+ newMap = HashMap()
14
+ val iterator: Iterator<*> = keys()
15
+ while (iterator.hasNext()) {
16
+ val key = iterator.next() as String
17
+ newMap!![key] = get(key)
18
+ }
19
+ }
20
+ return newMap
21
+ }
22
+
23
+
24
+ fun jsonToStringMap(json: JSObject?): Map<String, String>? {
25
+ var newMap: MutableMap<String, String>? = null
26
+ json?.run {
27
+ newMap = HashMap()
28
+ try {
29
+ val iterator: Iterator<*> = keys()
30
+ while (iterator.hasNext()) {
31
+ val key = iterator.next() as String
32
+ newMap!![key] = get(key) as String
33
+ }
34
+ } catch (e: JSONException) {
35
+ afLogger(e.message)
36
+ return null
37
+ }
38
+
39
+
40
+ }
41
+ return newMap
42
+ }
43
+
44
+ fun jsonToBundle(json: JSObject?): Bundle? {
45
+ val bundle = Bundle()
46
+ json?.run {
47
+ val iterator: Iterator<*> = keys()
48
+ while (iterator.hasNext()) {
49
+ val key = iterator.next() as String
50
+ val value = get(key) as String
51
+ bundle.putString(key, value)
52
+ }
53
+ }
54
+ return bundle
55
+ }
56
+
57
+
58
+ fun mapToJson(map: Map<String, Any>?): JSObject? {
59
+ map?.run {
60
+ val json = JSObject()
61
+ for ((k, v) in map) {
62
+ json.put(k, v)
63
+ }
64
+ return json
65
+
66
+ }
67
+ return null
68
+ }
69
+
70
+ private fun afLogger(message: String?) {
71
+ if (!message.isNullOrEmpty())
72
+ Log.d(TAG, message)
73
+ }
74
+
75
+
76
+ }
@@ -0,0 +1,76 @@
1
+ package capacitor.plugin.appsflyer.sdk
2
+
3
+ const val TAG = "AppsFlyer_Cap"
4
+ const val AF_APP_ID = "appID"
5
+ const val AF_DEV_KEY = "devKey"
6
+ const val AF_DEBUG = "isDebug"
7
+ const val AF_CONVERSION_LISTENER = "registerConversionListener"
8
+ const val AF_OAOA = "registerConversionListener"
9
+ const val AF_UDL = "registerOnDeepLink"
10
+ const val AF_EVENT_NAME = "eventName"
11
+ const val AF_EVENT_VALUE = "eventValue"
12
+ const val CONVERSION_CALLBACK = "conversion_callback"
13
+ const val OAOA_CALLBACK = "oaoa_callback"
14
+ const val UDL_CALLBACK = "udl_callback"
15
+ const val AF_CUID = "cuid"
16
+ const val AF_CURRENCY_CODE = "currencyCode"
17
+ const val AF_TOKEN = "token"
18
+ const val AF_ONELINK_ID = "onelinkID"
19
+ const val AF_ONELINK_DOMAIN = "domains"
20
+ const val AF_DEEPLINK_URLS = "urls"
21
+ const val AF_UID = "uid"
22
+ const val AF_ANONYMIZE_USER = "anonymizeUser"
23
+ const val AF_DISABLE = "shouldDisable"
24
+ const val AF_STOP = "stop"
25
+ const val AF_IS_STOP = "isStopped"
26
+ const val AF_PATH = "path"
27
+ const val AF_FILTERS = "filters"
28
+ const val AF_ADDITIONAL_DATA = "additionalData"
29
+ const val AF_DISABLE_SKAD = "shouldDisable"
30
+ const val AF_HOST_PREFIX = "hostPrefixName"
31
+ const val AF_HOST_NAME = "hostName"
32
+ const val AF_BRAND_DOMAIN = "brandDomain"
33
+ const val AF_CAMPAIGN = "campaign"
34
+ const val AF_CHANNEL = "channel"
35
+ const val AF_REFERRER_NAME = "referrerName"
36
+ const val AF_REFERRER_IMAGE_URL = "referrerImageURL"
37
+ const val AF_ADD_PARAMETERS = "addParameters"
38
+ const val AF_REFERRER_CUSTOMER_ID = "referrerCustomerId"
39
+ const val AF_BASE_DEEPLINK = "baseDeeplink"
40
+ const val AF_LINK_READY = "link"
41
+ const val AF_PUBLIC_KEY = "publicKey"
42
+ const val AF_SIGNATURE = "signature"
43
+ const val AF_PURCHASE_DATA = "purchaseData"
44
+ const val AF_CURRENCY = "currency"
45
+ const val AF_PRICE = "price"
46
+ const val AF_ADDITIONAL_PARAMETERS = "additionalParameters"
47
+ const val AF_FB = "enableFacebookDAL"
48
+ const val AF_PUSH_PAYLOAD = "pushPayload"
49
+ const val AF_MIN_TIME = "minTimeBetweenSessions"
50
+ const val AF_PARAMETERS = "parameters"
51
+ const val AF_CONTAINS = "contains"
52
+ const val AF_EMAILS = "emails"
53
+ const val AF_ENCODE = "encode"
54
+ const val AF_NULL_DEV_KEY = "Dev key is null"
55
+ const val AF_LATITUDE = "latitude"
56
+ const val AF_LONGITUDE = "longitude"
57
+ const val AF_PHONE = "phone"
58
+ const val AF_DATA = "data"
59
+ const val AF_PARTNER_ID = "partnerId"
60
+ const val AF_DEEP_LINK_TIME_OUT = "deepLinkTimeout"
61
+ const val AF_EVENT_PARAMETERS = "eventParameters"
62
+ const val AF_ENABLE_TCF_DATA_COLLECTION = "shouldEnableTCFDataCollection"
63
+ const val AF_MANUAL_START = "manualStart"
64
+ const val AF_IS_SUBJECTED_TO_GDPR = "isUserSubjectToGDPR"
65
+ const val AF_CONSENT_FOR_DATA_USAGE = "hasConsentForDataUsage"
66
+ const val AF_CONSENT_FOR_ADS_PERSONALIZATION = "hasConsentForAdsPersonalization"
67
+ const val AF_CONSENT_FOR_ADS_STORAGE = "hasConsentForAdStorage"
68
+ const val AF_MONETIZATION_NETWORK = "monetizationNetwork"
69
+ const val AF_CURRENCY_ISO4217_CODE = "currencyIso4217Code"
70
+ const val AF_REVENUE = "revenue"
71
+ const val AF_MEDIATION_NETWORK = "mediationNetwork"
72
+ const val AF_PURCHASE_DETAILS = "purchaseDetails"
73
+ const val AF_PURCHASE_TYPE = "purchaseType"
74
+ const val AF_PURCHASE_TOKEN = "purchaseToken"
75
+ const val AF_PRODUCT_ID = "productId"
76
+