appsflyer-capacitor-plugin 6.15.1 → 6.15.2-rc1

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.
@@ -7,10 +7,40 @@ import java.nio.file.SimpleFileVisitor
7
7
  import java.nio.file.attribute.BasicFileAttributes
8
8
 
9
9
  String getPackageJsonPath() {
10
- return findProperty("APPSFLYER_PACKAGE_JSON") ?: "$rootDir/../node_modules/appsflyer-capacitor-plugin/package.json"
10
+ // If APPSFLYER_PACKAGE_JSON_PATH property is set by the developer, use it.
11
+ String envPath = findProperty("APPSFLYER_PACKAGE_JSON_PATH") as String
12
+ if (envPath) {
13
+ logger.lifecycle("package.json path from APPSFLYER_PACKAGE_JSON_PATH: $envPath")
14
+ return envPath
15
+ }
16
+
17
+ // Potential relative paths to the package.json.
18
+ def possiblePackageJsonPaths = [
19
+ "${projectDir.parentFile}/package.json",
20
+ "${buildDir.parentFile.parentFile}/package.json",
21
+ "${rootDir.parentFile}/node_modules/appsflyer-capacitor-plugin/package.json",
22
+ ]
23
+
24
+ // Loop through the possible paths and find the first one that exists
25
+ for (possiblePath in possiblePackageJsonPaths) {
26
+ File possibleFile = file(possiblePath)
27
+ if (possibleFile.exists()) {
28
+ logger.lifecycle("Found package.json at: ${possibleFile.absolutePath}")
29
+ return possibleFile.absolutePath
30
+ }
31
+ }
32
+
33
+ logger.lifecycle("Did not locate package.json in any of possiblePackageJsonPaths and APPSFLYER_PACKAGE_JSON_PATH is not specified.")
34
+ return null
11
35
  }
12
36
 
13
- def findNodeModulesDir(File currentDir) {
37
+ /**
38
+ * Finds the node_modules directory by traversing up the directory hierarchy starting from the given directory.
39
+ *
40
+ * @param currentDir The directory from which to start the search.
41
+ * @return The discovered node_modules directory, or null if not found.
42
+ */
43
+ static def findNodeModulesDir(File currentDir) {
14
44
  def dir = currentDir
15
45
  while (dir != null) {
16
46
  def nodeModulesDir = new File(dir, 'node_modules')
@@ -22,10 +52,20 @@ def findNodeModulesDir(File currentDir) {
22
52
  return null
23
53
  }
24
54
 
55
+ /**
56
+ * Searches for a package.json file corresponding to the given package name within the node_modules directory.
57
+ *
58
+ * The search begins from the root project directory and recursively checks each node_modules folder found
59
+ * in parent directories up until the root of the file system hierarchy.
60
+ *
61
+ * @param packageName The name of the package for which to find package.json.
62
+ * @return The contents of the package.json as a Map, or null if not found.
63
+ */
25
64
  def findPackageJsonInDep(String packageName) {
65
+ // Start the search from the root project directory
26
66
  def nodeModulesDir = findNodeModulesDir(project.rootDir)
27
67
  if (nodeModulesDir == null) {
28
- println "node_modules directory not found in any parent directories."
68
+ logger.lifecycle("node_modules directory not found in any parent directories.")
29
69
  return null
30
70
  }
31
71
 
@@ -34,68 +74,67 @@ def findPackageJsonInDep(String packageName) {
34
74
  def walker = new SimpleFileVisitor<Path>() {
35
75
  @Override
36
76
  FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
77
+ // Looking specifically for the package.json of the target package
37
78
  if (file.toAbsolutePath().endsWith("appsflyer-capacitor-plugin/package.json")) {
38
79
  try {
39
80
  def content = new JsonSlurper().parseText(file.toFile().text)
40
81
  if (content.name == packageName) {
41
- println "Found package.json: ${file.toAbsolutePath()}"
82
+ logger.lifecycle("Found package.json at: ${file.toAbsolutePath()}")
42
83
  json = content
43
84
  return FileVisitResult.TERMINATE
44
85
  }
45
86
  } catch (Exception e) {
46
- println "Error parsing JSON in file: ${file.toAbsolutePath().toString()}\n${e.message}\n\t"
87
+ logger.lifecycle("Error parsing JSON in file: ${file.toAbsolutePath().toString()}\n${e.message}\n\t")
47
88
  }
48
89
  }
49
90
  return FileVisitResult.CONTINUE
50
91
  }
51
92
  }
93
+ // Recursively walk through the file system starting from the node_modules directory
52
94
  while (json == null && nodeModulesDir != null) {
53
95
  Files.walkFileTree(nodeModulesDir.toPath(), walker)
54
- // parentFile will give us exact same directory so we have to go 2 level upper
55
- // and find another node_modules
96
+ // Search for another node_modules directory two levels up
56
97
  nodeModulesDir = findNodeModulesDir(nodeModulesDir.parentFile.parentFile)
57
98
  }
58
99
  return json
59
100
  }
60
101
 
61
102
  def getPackageJson() {
62
- def packageJson
63
- def inputFile = new File(getPackageJsonPath())
64
- if (inputFile.exists()) {
65
- println "found package.json from ENV variable"
66
- packageJson = new JsonSlurper().parseText(inputFile.text)
103
+ // Use the safe navigation operator when working with possible null values
104
+ String packageJsonPath = getPackageJsonPath()
105
+ File inputFile = packageJsonPath ? new File(packageJsonPath) : null
106
+
107
+ // Attempt to load the package.json if the path is found and the file exists
108
+ if (inputFile?.exists()) {
109
+ try {
110
+ return new JsonSlurper().parseText(inputFile.getText('UTF-8'))
111
+ } catch (Exception e) {
112
+ logger.error("Failed to parse package.json at: ${inputFile.absolutePath}", e)
113
+ }
67
114
  } else {
68
- println "could not found package.json from ENV variable"
69
- println "searching for package.json recursively"
70
- packageJson = findPackageJsonInDep("appsflyer-capacitor-plugin")
115
+ // package.json not found; search recursively
116
+ logger.lifecycle("Searching for package.json recursively in node_modules directories...")
117
+ def foundJson = findPackageJsonInDep("appsflyer-capacitor-plugin")
118
+ if (foundJson) {
119
+ return foundJson
120
+ }
71
121
  }
72
- return packageJson
73
- }
74
- // Create an easy to use function
75
- def getVersionFromNpm() {
76
- // Return the version, you can get any value this way
77
- return getPackageJson()["version"]
78
- }
79
-
80
- // Create an easy to use function
81
- def getSDKVersionFromNpm() {
82
- // Return the version, you can get any value this way
83
- return getPackageJson()["androidSdkVersion"]
84
- }
85
-
86
- def getPluginBuildVersionFromNpm() {
87
- // Return the version, you can get any value this way
88
- return getPackageJson()["buildNumber"]
122
+ // If we got here the package.json was not loaded, log an error and return null
123
+ logger.error("The plugin package.json could not be loaded properly; appsflyer-capacitor-plugin may not function as expected.")
124
+ return null
89
125
  }
90
126
 
91
127
  ext {
128
+ // Initialize only once and reuse it for all subsequent calls
129
+ packageJson = getPackageJson()
130
+
92
131
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
93
132
  androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
94
133
  androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
95
134
  androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
96
- af_sdk_version = getSDKVersionFromNpm()
97
- plugin_version = getVersionFromNpm()
98
- plugin_build_version = getPluginBuildVersionFromNpm()
135
+ af_sdk_version = packageJson?.androidSdkVersion
136
+ plugin_version = packageJson?.version
137
+ plugin_build_version = packageJson?.buildNumber
99
138
  }
100
139
 
101
140
  buildscript {
@@ -576,7 +576,12 @@ class AppsFlyerPlugin : Plugin() {
576
576
 
577
577
  // Convert the mediationNetwork string to the MediationNetwork enum
578
578
  val mediationNetworkValue = adRevenueDataJson.getString(AF_MEDIATION_NETWORK) ?: return call.reject("mediationNetwork is missing")
579
- val mediationNetwork = MediationNetwork.entries.find { it.value == mediationNetworkValue } ?: return call.reject("Invalid mediation network")
579
+ val mediationNetwork: MediationNetwork
580
+ try {
581
+ mediationNetwork = MediationNetwork.valueOf(mediationNetworkValue.uppercase())
582
+ } catch (e: IllegalArgumentException) {
583
+ return call.reject("Invalid mediation network")
584
+ }
580
585
 
581
586
  // Create the AFAdRevenueData object
582
587
  val adRevenueData = AFAdRevenueData(
@@ -5,7 +5,7 @@ import AppsFlyerLib
5
5
 
6
6
  @objc(AppsFlyerPlugin)
7
7
  public class AppsFlyerPlugin: CAPPlugin {
8
- private let APPSFLYER_PLUGIN_VERSION = "6.15.1"
8
+ private let APPSFLYER_PLUGIN_VERSION = "6.15.2-rc1"
9
9
  private var conversion = true
10
10
  private var oaoa = true
11
11
  private var udl = false
@@ -271,7 +271,7 @@ public class AppsFlyerPlugin: CAPPlugin {
271
271
  for url in arr {
272
272
  urls.append(url as! String)
273
273
  }
274
- AppsFlyerLib.shared().oneLinkCustomDomains = urls
274
+ AppsFlyerLib.shared().resolveDeepLinkURLs = urls
275
275
 
276
276
  }
277
277
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "appsflyer-capacitor-plugin",
3
- "version": "6.15.1",
3
+ "version": "6.15.2-rc1",
4
4
  "iosSdkVersion": "6.15.1",
5
5
  "androidSdkVersion": "6.15.1",
6
- "buildNumber": "17",
6
+ "buildNumber": "107",
7
7
  "description": "AppsFlyer SDK plugin for Capacitor",
8
8
  "main": "dist/plugin.cjs.js",
9
9
  "module": "dist/esm/index.js",