@luciq/react-native 18.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 (239) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/FONTS_SETUP_GUIDE.md +521 -0
  3. package/Gemfile +1 -0
  4. package/Gemfile.lock +11 -0
  5. package/LICENSE +21 -0
  6. package/README.md +148 -0
  7. package/RNLuciq.podspec +21 -0
  8. package/android/build.gradle +88 -0
  9. package/android/gradle.properties +4 -0
  10. package/android/jacoco.gradle +52 -0
  11. package/android/native.gradle +7 -0
  12. package/android/proguard-rules.txt +1 -0
  13. package/android/sourcemaps.gradle +255 -0
  14. package/android/src/main/AndroidManifest.xml +4 -0
  15. package/android/src/main/java/ai/luciq/reactlibrary/ArgsRegistry.java +278 -0
  16. package/android/src/main/java/ai/luciq/reactlibrary/Constants.java +20 -0
  17. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciq.java +328 -0
  18. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqAPMModule.java +392 -0
  19. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqBugReportingModule.java +444 -0
  20. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqCrashReportingModule.java +169 -0
  21. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqFeatureRequestsModule.java +98 -0
  22. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqNetworkLoggerModule.java +195 -0
  23. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativeModule.java +1611 -0
  24. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqReactnativePackage.java +41 -0
  25. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqRepliesModule.java +298 -0
  26. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSessionReplayModule.java +213 -0
  27. package/android/src/main/java/ai/luciq/reactlibrary/RNLuciqSurveysModule.java +237 -0
  28. package/android/src/main/java/ai/luciq/reactlibrary/utils/ArrayUtil.java +167 -0
  29. package/android/src/main/java/ai/luciq/reactlibrary/utils/EventEmitterModule.java +35 -0
  30. package/android/src/main/java/ai/luciq/reactlibrary/utils/LuciqUtil.java +58 -0
  31. package/android/src/main/java/ai/luciq/reactlibrary/utils/MainThreadHandler.java +13 -0
  32. package/android/src/main/java/ai/luciq/reactlibrary/utils/MapUtil.java +171 -0
  33. package/android/src/main/java/ai/luciq/reactlibrary/utils/RNTouchedViewExtractor.java +167 -0
  34. package/android/src/main/java/ai/luciq/reactlibrary/utils/ReportUtil.java +67 -0
  35. package/app.plugin.js +1 -0
  36. package/babel.config.js +3 -0
  37. package/bin/commands/MigrateCommand.d.ts +6 -0
  38. package/bin/commands/UploadEasUpdatesSourcemaps.d.ts +2 -0
  39. package/bin/commands/UploadSoFiles.d.ts +6 -0
  40. package/bin/commands/UploadSourcemaps.d.ts +2 -0
  41. package/bin/config/migration-config.json +125 -0
  42. package/bin/index.d.ts +2 -0
  43. package/bin/index.js +19179 -0
  44. package/bin/upload/index.d.ts +4 -0
  45. package/bin/upload/migrate.d.ts +14 -0
  46. package/bin/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
  47. package/bin/upload/uploadSoFiles.d.ts +21 -0
  48. package/bin/upload/uploadSourcemaps.d.ts +21 -0
  49. package/cli/commands/MigrateCommand.ts +32 -0
  50. package/cli/commands/UploadEasUpdatesSourcemaps.ts +34 -0
  51. package/cli/commands/UploadSoFiles.ts +38 -0
  52. package/cli/commands/UploadSourcemaps.ts +40 -0
  53. package/cli/config/migration-config.json +125 -0
  54. package/cli/index.ts +21 -0
  55. package/cli/upload/index.ts +4 -0
  56. package/cli/upload/migrate.ts +271 -0
  57. package/cli/upload/uploadEasUpdatesSourcemaps.ts +74 -0
  58. package/cli/upload/uploadSoFiles.ts +112 -0
  59. package/cli/upload/uploadSourcemaps.ts +73 -0
  60. package/dangerfile.ts +44 -0
  61. package/dist/index.d.ts +19 -0
  62. package/dist/index.js +14 -0
  63. package/dist/models/FeatureFlag.d.ts +11 -0
  64. package/dist/models/FeatureFlag.js +1 -0
  65. package/dist/models/LuciqConfig.d.ts +42 -0
  66. package/dist/models/LuciqConfig.js +1 -0
  67. package/dist/models/NonFatalOptions.d.ts +15 -0
  68. package/dist/models/NonFatalOptions.js +1 -0
  69. package/dist/models/OverAirUpdate.d.ts +12 -0
  70. package/dist/models/OverAirUpdate.js +1 -0
  71. package/dist/models/Report.d.ts +70 -0
  72. package/dist/models/Report.js +109 -0
  73. package/dist/models/ReproConfig.d.ts +27 -0
  74. package/dist/models/ReproConfig.js +1 -0
  75. package/dist/models/SessionMetadata.d.ts +55 -0
  76. package/dist/models/SessionMetadata.js +1 -0
  77. package/dist/models/ThemeConfig.d.ts +27 -0
  78. package/dist/models/ThemeConfig.js +1 -0
  79. package/dist/models/W3cExternalTraceAttributes.d.ts +22 -0
  80. package/dist/models/W3cExternalTraceAttributes.js +1 -0
  81. package/dist/modules/APM.d.ts +77 -0
  82. package/dist/modules/APM.js +104 -0
  83. package/dist/modules/BugReporting.d.ts +138 -0
  84. package/dist/modules/BugReporting.js +202 -0
  85. package/dist/modules/CrashReporting.d.ts +19 -0
  86. package/dist/modules/CrashReporting.js +40 -0
  87. package/dist/modules/FeatureRequests.d.ts +20 -0
  88. package/dist/modules/FeatureRequests.js +28 -0
  89. package/dist/modules/Luciq.d.ts +362 -0
  90. package/dist/modules/Luciq.js +797 -0
  91. package/dist/modules/NetworkLogger.d.ts +52 -0
  92. package/dist/modules/NetworkLogger.js +208 -0
  93. package/dist/modules/Replies.d.ts +78 -0
  94. package/dist/modules/Replies.js +121 -0
  95. package/dist/modules/SessionReplay.d.ts +78 -0
  96. package/dist/modules/SessionReplay.js +98 -0
  97. package/dist/modules/Surveys.d.ts +75 -0
  98. package/dist/modules/Surveys.js +101 -0
  99. package/dist/native/NativeAPM.d.ts +18 -0
  100. package/dist/native/NativeAPM.js +4 -0
  101. package/dist/native/NativeBugReporting.d.ts +32 -0
  102. package/dist/native/NativeBugReporting.js +10 -0
  103. package/dist/native/NativeConstants.d.ts +182 -0
  104. package/dist/native/NativeConstants.js +1 -0
  105. package/dist/native/NativeCrashReporting.d.ts +18 -0
  106. package/dist/native/NativeCrashReporting.js +2 -0
  107. package/dist/native/NativeFeatureRequests.d.ts +8 -0
  108. package/dist/native/NativeFeatureRequests.js +2 -0
  109. package/dist/native/NativeLuciq.d.ts +86 -0
  110. package/dist/native/NativeLuciq.js +10 -0
  111. package/dist/native/NativeNetworkLogger.d.ts +21 -0
  112. package/dist/native/NativeNetworkLogger.js +14 -0
  113. package/dist/native/NativePackage.d.ts +21 -0
  114. package/dist/native/NativePackage.js +2 -0
  115. package/dist/native/NativeReplies.d.ts +21 -0
  116. package/dist/native/NativeReplies.js +8 -0
  117. package/dist/native/NativeSessionReplay.d.ts +16 -0
  118. package/dist/native/NativeSessionReplay.js +8 -0
  119. package/dist/native/NativeSurveys.d.ts +22 -0
  120. package/dist/native/NativeSurveys.js +9 -0
  121. package/dist/utils/AppStatesHandler.d.ts +3 -0
  122. package/dist/utils/AppStatesHandler.js +16 -0
  123. package/dist/utils/Enums.d.ts +244 -0
  124. package/dist/utils/Enums.js +266 -0
  125. package/dist/utils/FeatureFlags.d.ts +7 -0
  126. package/dist/utils/FeatureFlags.js +24 -0
  127. package/dist/utils/LuciqConstants.d.ts +14 -0
  128. package/dist/utils/LuciqConstants.js +15 -0
  129. package/dist/utils/LuciqUtils.d.ts +97 -0
  130. package/dist/utils/LuciqUtils.js +301 -0
  131. package/dist/utils/UnhandledRejectionTracking.d.ts +9 -0
  132. package/dist/utils/UnhandledRejectionTracking.js +99 -0
  133. package/dist/utils/XhrNetworkInterceptor.d.ts +39 -0
  134. package/dist/utils/XhrNetworkInterceptor.js +253 -0
  135. package/dist/utils/config.d.ts +5 -0
  136. package/dist/utils/config.js +6 -0
  137. package/dist/utils/logger.d.ts +10 -0
  138. package/dist/utils/logger.js +39 -0
  139. package/expo.d.ts +1 -0
  140. package/expo.js +1 -0
  141. package/ios/RNLuciq/ArgsRegistry.h +32 -0
  142. package/ios/RNLuciq/ArgsRegistry.m +276 -0
  143. package/ios/RNLuciq/LuciqAPMBridge.h +26 -0
  144. package/ios/RNLuciq/LuciqAPMBridge.m +99 -0
  145. package/ios/RNLuciq/LuciqBugReportingBridge.h +60 -0
  146. package/ios/RNLuciq/LuciqBugReportingBridge.m +241 -0
  147. package/ios/RNLuciq/LuciqCrashReportingBridge.h +18 -0
  148. package/ios/RNLuciq/LuciqCrashReportingBridge.m +68 -0
  149. package/ios/RNLuciq/LuciqFeatureRequestsBridge.h +30 -0
  150. package/ios/RNLuciq/LuciqFeatureRequestsBridge.m +61 -0
  151. package/ios/RNLuciq/LuciqNetworkLoggerBridge.h +44 -0
  152. package/ios/RNLuciq/LuciqNetworkLoggerBridge.m +206 -0
  153. package/ios/RNLuciq/LuciqReactBridge.h +151 -0
  154. package/ios/RNLuciq/LuciqReactBridge.m +548 -0
  155. package/ios/RNLuciq/LuciqRepliesBridge.h +40 -0
  156. package/ios/RNLuciq/LuciqRepliesBridge.m +80 -0
  157. package/ios/RNLuciq/LuciqSessionReplayBridge.h +32 -0
  158. package/ios/RNLuciq/LuciqSessionReplayBridge.m +107 -0
  159. package/ios/RNLuciq/LuciqSurveysBridge.h +46 -0
  160. package/ios/RNLuciq/LuciqSurveysBridge.m +107 -0
  161. package/ios/RNLuciq/RCTConvert+LuciqEnums.h +18 -0
  162. package/ios/RNLuciq/RCTConvert+LuciqEnums.m +127 -0
  163. package/ios/RNLuciq/RNLuciq.h +35 -0
  164. package/ios/RNLuciq/RNLuciq.m +107 -0
  165. package/ios/RNLuciq/Util/LCQAPM+PrivateAPIs.h +15 -0
  166. package/ios/RNLuciq/Util/LCQCrashReporting+CP.h +13 -0
  167. package/ios/RNLuciq/Util/LCQNetworkLogger+CP.h +68 -0
  168. package/ios/RNLuciq/Util/Luciq+CP.h +12 -0
  169. package/ios/RNLuciq.xcodeproj/project.pbxproj +352 -0
  170. package/ios/native.rb +12 -0
  171. package/ios/sourcemaps.sh +120 -0
  172. package/migrate.js +569 -0
  173. package/package.json +92 -0
  174. package/plugin/build/index.js +42078 -0
  175. package/plugin/src/index.ts +5 -0
  176. package/plugin/src/pluginProps.ts +6 -0
  177. package/plugin/src/withLuciq.ts +51 -0
  178. package/plugin/src/withLuciqAndroid.ts +99 -0
  179. package/plugin/src/withLuciqIOS.ts +109 -0
  180. package/plugin/tsconfig.json +7 -0
  181. package/react-native.config.js +16 -0
  182. package/scripts/customize-ios-endpoints.sh +28 -0
  183. package/scripts/dream-11-delete-unused-features.sh +62 -0
  184. package/scripts/find-token.js +58 -0
  185. package/scripts/find-token.sh +70 -0
  186. package/scripts/notify-github.sh +15 -0
  187. package/scripts/replace.js +58 -0
  188. package/scripts/snapshot-comment.md +15 -0
  189. package/scripts/snapshot-version.sh +11 -0
  190. package/src/index.ts +40 -0
  191. package/src/models/FeatureFlag.ts +12 -0
  192. package/src/models/LuciqConfig.ts +48 -0
  193. package/src/models/NonFatalOptions.ts +16 -0
  194. package/src/models/OverAirUpdate.ts +14 -0
  195. package/src/models/Report.ts +124 -0
  196. package/src/models/ReproConfig.ts +31 -0
  197. package/src/models/SessionMetadata.ts +57 -0
  198. package/src/models/ThemeConfig.ts +34 -0
  199. package/src/models/W3cExternalTraceAttributes.ts +22 -0
  200. package/src/modules/APM.ts +117 -0
  201. package/src/modules/BugReporting.ts +254 -0
  202. package/src/modules/CrashReporting.ts +54 -0
  203. package/src/modules/FeatureRequests.ts +32 -0
  204. package/src/modules/Luciq.ts +934 -0
  205. package/src/modules/NetworkLogger.ts +270 -0
  206. package/src/modules/Replies.ts +137 -0
  207. package/src/modules/SessionReplay.ts +111 -0
  208. package/src/modules/Surveys.ts +118 -0
  209. package/src/native/NativeAPM.ts +51 -0
  210. package/src/native/NativeBugReporting.ts +70 -0
  211. package/src/native/NativeConstants.ts +215 -0
  212. package/src/native/NativeCrashReporting.ts +29 -0
  213. package/src/native/NativeFeatureRequests.ts +12 -0
  214. package/src/native/NativeLuciq.ts +179 -0
  215. package/src/native/NativeNetworkLogger.ts +42 -0
  216. package/src/native/NativePackage.ts +25 -0
  217. package/src/native/NativeReplies.ts +34 -0
  218. package/src/native/NativeSessionReplay.ts +21 -0
  219. package/src/native/NativeSurveys.ts +34 -0
  220. package/src/promise.d.ts +11 -0
  221. package/src/utils/AppStatesHandler.ts +19 -0
  222. package/src/utils/Enums.ts +266 -0
  223. package/src/utils/FeatureFlags.ts +33 -0
  224. package/src/utils/LuciqConstants.ts +24 -0
  225. package/src/utils/LuciqUtils.ts +417 -0
  226. package/src/utils/UnhandledRejectionTracking.ts +118 -0
  227. package/src/utils/XhrNetworkInterceptor.ts +333 -0
  228. package/src/utils/config.ts +7 -0
  229. package/src/utils/logger.ts +54 -0
  230. package/tsconfig.json +32 -0
  231. package/tsconfig.test.json +4 -0
  232. package/tsconfig.upload.json +10 -0
  233. package/upload/index.d.ts +4 -0
  234. package/upload/index.js +17314 -0
  235. package/upload/migrate.d.ts +14 -0
  236. package/upload/package.json +5 -0
  237. package/upload/uploadEasUpdatesSourcemaps.d.ts +21 -0
  238. package/upload/uploadSoFiles.d.ts +21 -0
  239. package/upload/uploadSourcemaps.d.ts +21 -0
@@ -0,0 +1,21 @@
1
+ require 'json'
2
+ require_relative './ios/native'
3
+
4
+ package = JSON.parse(File.read('package.json'))
5
+
6
+ Pod::Spec.new do |s|
7
+ s.name = 'RNLuciq'
8
+ s.version = package["version"]
9
+ s.summary = package["description"]
10
+ s.author = package["author"]
11
+ s.license = package["license"]
12
+ s.homepage = package["homepage"]
13
+ s.source = { :git => "https://github.com/Instabug/Instabug-React-Native.git", :tag => 'v' + package["version"] }
14
+
15
+ s.platform = :ios, "13.0"
16
+ s.source_files = "ios/**/*.{h,m,mm}"
17
+
18
+ s.dependency 'React-Core'
19
+ use_luciq!(s)
20
+
21
+ end
@@ -0,0 +1,88 @@
1
+ apply plugin: 'com.android.library'
2
+
3
+ apply from: './jacoco.gradle'
4
+ apply from: './native.gradle'
5
+ apply from: './sourcemaps.gradle'
6
+
7
+ String getExtOrDefault(String name) {
8
+ def defaultPropertyKey = 'LuciqReactNative_' + name
9
+ if (rootProject.ext.has(name)) {
10
+ return rootProject.ext.get(name)
11
+ }
12
+ return project.properties[defaultPropertyKey]
13
+ }
14
+
15
+ static boolean supportsNamespace() {
16
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
17
+ def major = parsed[0].toInteger()
18
+ def minor = parsed[1].toInteger()
19
+
20
+ // Namespace support was added in 7.3.0
21
+ return (major == 7 && minor >= 3) || major >= 8
22
+ }
23
+
24
+ void updateManifestPackage() {
25
+ def packageProp = 'package="ai.luciq.reactlibrary"'
26
+ def manifestFile = file("$projectDir/src/main/AndroidManifest.xml")
27
+ def currentContent = manifestFile.getText()
28
+ def content = currentContent
29
+ def hasPackage = currentContent.contains(packageProp)
30
+
31
+ if (supportsNamespace()) {
32
+ content = content.replaceAll(packageProp, '')
33
+ } else if (!hasPackage) {
34
+ content = content.replace(
35
+ '<manifest',
36
+ "<manifest $packageProp "
37
+ )
38
+ }
39
+
40
+ def shouldUpdateManifest = content != currentContent
41
+ if (shouldUpdateManifest) {
42
+ manifestFile.write(content)
43
+ }
44
+ }
45
+
46
+ updateManifestPackage()
47
+
48
+ android {
49
+ if (supportsNamespace()) {
50
+ namespace "ai.luciq.reactlibrary"
51
+ }
52
+
53
+ compileSdkVersion getExtOrDefault('compileSdkVersion').toInteger()
54
+ buildToolsVersion getExtOrDefault('buildToolsVersion')
55
+
56
+ defaultConfig {
57
+ minSdkVersion getExtOrDefault('minSdkVersion').toInteger()
58
+ targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger()
59
+ versionCode 1
60
+ versionName "15.0.1"
61
+ multiDexEnabled true
62
+ ndk {
63
+ abiFilters "armeabi-v7a", "x86"
64
+ }
65
+ consumerProguardFiles 'proguard-rules.txt'
66
+ }
67
+ lintOptions {
68
+ warning 'InvalidPackage'
69
+ abortOnError true
70
+ // SuppressLint WrongConstant was used to suppress errors when using arrays of ints to represent annotations.
71
+ }
72
+ }
73
+
74
+ dependencies {
75
+ implementation "androidx.multidex:multidex:2.0.1"
76
+ implementation 'com.facebook.react:react-native:+'
77
+
78
+ testImplementation "org.mockito:mockito-inline:3.12.1"
79
+ testImplementation "org.mockito:mockito-android:3.4.0"
80
+ testImplementation 'junit:junit:4.13.2'
81
+ }
82
+
83
+ rootProject.allprojects {
84
+ repositories {
85
+ google()
86
+ jcenter()
87
+ }
88
+ }
@@ -0,0 +1,4 @@
1
+ LuciqReactNative_compileSdkVersion=30
2
+ LuciqReactNative_buildToolsVersion=30.0.2
3
+ LuciqReactNative_targetSdkVersion=31
4
+ LuciqReactNative_minSdkVersion=16
@@ -0,0 +1,52 @@
1
+ apply plugin: 'jacoco'
2
+
3
+ jacoco {
4
+ toolVersion '0.8.8'
5
+ }
6
+
7
+ task jacocoTestReport(type: JacocoReport) {
8
+ group = 'Reporting'
9
+ description = 'Generate Jacoco coverage reports for the debug build.'
10
+
11
+ dependsOn 'testDebugUnitTest'
12
+
13
+ reports {
14
+ html.required = true
15
+ xml.required = true
16
+ }
17
+
18
+ def excludes = [
19
+ '**/R.class',
20
+ '**/R$*.class',
21
+ '**/BuildConfig.*',
22
+ '**/Manifest*.*',
23
+ '**/*Test*.*',
24
+ 'android/**/*.*',
25
+ 'androidx/**/*.*',
26
+ '**/*$ViewInjector*.*',
27
+ '**/*Dagger*.*',
28
+ '**/*MembersInjector*.*',
29
+ '**/*_Factory.*',
30
+ '**/*_Provide*Factory*.*',
31
+ '**/*_ViewBinding*.*',
32
+ '**/AutoValue_*.*',
33
+ '**/R2.class',
34
+ '**/R2$*.class',
35
+ '**/*Directions$*',
36
+ '**/*Directions.*',
37
+ '**/*Binding.*'
38
+ ]
39
+
40
+ def jClasses = "${project.buildDir}/intermediates/javac/debug/compileDebugJavaWithJavac/classes"
41
+ def javaClasses = fileTree(dir: jClasses, excludes: excludes)
42
+ def sourceDirs = ["${project.projectDir}/src/main/java"]
43
+ classDirectories.from = files(javaClasses)
44
+ sourceDirectories.from = files(sourceDirs)
45
+ executionData.from = files(["${project.buildDir}/jacoco/testDebugUnitTest.exec"])
46
+ }
47
+
48
+ tasks.whenTaskAdded { task ->
49
+ if (task.name == 'testDebugUnitTest') {
50
+ task.finalizedBy jacocoTestReport
51
+ }
52
+ }
@@ -0,0 +1,7 @@
1
+ project.ext.luciq = [
2
+ version: '18.0.0'
3
+ ]
4
+
5
+ dependencies {
6
+ api "ai.luciq.library:luciq:${project.ext.luciq.version}"
7
+ }
@@ -0,0 +1 @@
1
+ -keep class com.luciq.** {*;}
@@ -0,0 +1,255 @@
1
+ import org.apache.tools.ant.taskdefs.condition.Os
2
+
3
+ project.afterEvaluate {
4
+ // Works for both `bundleReleaseJsAndAssets` and `createBundleReleaseJsAndAssets` and product flavors
5
+ def suffix = 'ReleaseJsAndAssets'
6
+ def bundleTasks = project(':app').tasks.findAll {
7
+ task -> task.name.endsWith(suffix)
8
+ }
9
+
10
+ bundleTasks.forEach { task ->
11
+ def name = task.name
12
+ def prefixes = ['bundle', 'createBundle']
13
+ def start = name.startsWith(prefixes[0]) ? prefixes[0].length() : prefixes[1].length()
14
+ def end = name.length() - suffix.length()
15
+ def flavor = name.substring(start, end).uncapitalize()
16
+ def defaultVersion = getDefaultVersion(flavor)
17
+
18
+
19
+
20
+ task.finalizedBy createUploadSourcemapsTask(flavor, defaultVersion.name, defaultVersion.code,task)
21
+ }
22
+ }
23
+
24
+ Task createUploadSourcemapsTask(String flavor, String defaultVersionName, String defaultVersionCode, Task task) {
25
+ def name = 'uploadSourcemaps' + flavor.capitalize()
26
+
27
+ // Don't recreate the task if it already exists.
28
+ // This prevents the build from failing in an edge case where the user has
29
+ // both `bundleReleaseJsAndAssets` and `createBundleReleaseJsAndAssets`
30
+ def taskExists = tasks.getNames().contains(name)
31
+ if (taskExists) {
32
+ return tasks.named(name).get()
33
+ }
34
+
35
+ def provider = tasks.register(name) {
36
+ group 'luciq'
37
+ description 'Uploads sourcemaps file to Luciq server'
38
+ enabled = isUploadSourcemapsEnabled()
39
+
40
+ doLast {
41
+ try {
42
+ def appProject = project(':app')
43
+ def appDir = appProject.projectDir
44
+ def sourceMapFile = getSourceMapFile(appDir, flavor,task)
45
+
46
+ def jsProjectDir = rootDir.parentFile
47
+ def luciqDir = new File(['node', '-p', 'require.resolve("@luciq/react-native/package.json")'].execute(null, rootDir).text.trim()).getParentFile()
48
+
49
+ def tokenJsFile = new File(luciqDir, 'scripts/find-token.js')
50
+ def inferredToken = executeNodeScript(tokenJsFile, jsProjectDir)
51
+
52
+
53
+ def appToken = resolveVar('App Token', 'LUCIQ_APP_TOKEN', inferredToken)
54
+
55
+ if (!appToken) {
56
+ throw new GradleException("❌ Unable to infer Luciq token from script: ${tokenShellFile.absolutePath}")
57
+ }
58
+
59
+ def versionName = resolveVar('Version Name', 'LUCIQ_VERSION_NAME', defaultVersionName)
60
+ def versionCode = resolveVar('Version Code', 'LUCIQ_VERSION_CODE', defaultVersionCode)
61
+
62
+ println "📦 Uploading with versionName=${versionName}, versionCode=${versionCode}, appToken=${appToken.take(5)}..."
63
+
64
+ exec {
65
+ def osCompatibility = Os.isFamily(Os.FAMILY_WINDOWS) ? ['cmd', '/c'] : []
66
+ def args = [
67
+ 'npx', 'luciq', 'upload-sourcemaps',
68
+ '--platform', 'android',
69
+ '--file', sourceMapFile.absolutePath,
70
+ '--token', appToken,
71
+ '--name', versionName,
72
+ '--code', versionCode
73
+ ]
74
+
75
+ commandLine(*osCompatibility, *args)
76
+ }
77
+ } catch (exception) {
78
+ project.logger.error "Failed to upload source map file.\n" +
79
+ "Reason: ${exception.message}"
80
+ throw exception
81
+
82
+ }
83
+ }
84
+ }
85
+
86
+ return provider.get()
87
+ }
88
+
89
+ File getSourceMapFile(File appDir, String flavor, Task task) {
90
+ def defaultFlavorPath = flavor.empty ? 'release' : "${flavor}Release"
91
+ def defaultSourceMapDest = "build/generated/sourcemaps/react/${defaultFlavorPath}/index.android.bundle.map"
92
+ def defaultSourceMapFile = new File(appDir, defaultSourceMapDest)
93
+ def props = task.getProperties()
94
+
95
+ def bundleAssetName = props.containsKey("bundleAssetName") ? props.bundleAssetName?.getOrNull() : null
96
+ def jsSourceMapsDir = props.containsKey("jsSourceMapsDir") ? props.jsSourceMapsDir?.getOrNull() : null
97
+ def jsIntermediateSourceMapsDir = props.containsKey("jsIntermediateSourceMapsDir") ? props.jsIntermediateSourceMapsDir?.getOrNull() : null
98
+
99
+ if (bundleAssetName && jsSourceMapsDir) {
100
+ def outputSourceMap = new File(jsSourceMapsDir.asFile.absolutePath, "${bundleAssetName}.map")
101
+ if (outputSourceMap.exists()) {
102
+ return outputSourceMap
103
+ }
104
+ }
105
+
106
+ if (bundleAssetName && jsIntermediateSourceMapsDir) {
107
+ def packagerOutputSourceMap = new File(jsIntermediateSourceMapsDir.asFile.absolutePath, "${bundleAssetName}.packager.map")
108
+ if (packagerOutputSourceMap.exists()) {
109
+ return packagerOutputSourceMap
110
+ }
111
+ }
112
+
113
+ if (defaultSourceMapFile.exists()) {
114
+ return defaultSourceMapFile
115
+ }
116
+
117
+ if (flavor.empty) {
118
+ println"Source map file not found at: ${defaultSourceMapFile.absolutePath}. Skipping."
119
+ return null
120
+ }
121
+
122
+ def fallbackSourceMapDest = "build/generated/sourcemaps/react/${flavor}/release/index.android.bundle.map"
123
+ def fallbackSourceMapFile = new File(appDir, fallbackSourceMapDest)
124
+
125
+ println "Unable to find source map file at: ${defaultSourceMapFile.absolutePath}.\n" +
126
+ "Falling back to ${fallbackSourceMapFile.absolutePath}."
127
+
128
+ if (!fallbackSourceMapFile.exists()) {
129
+ println "Fallback source map file not found at: ${fallbackSourceMapFile.absolutePath}. Skipping."
130
+ return null
131
+ }
132
+
133
+ return fallbackSourceMapFile
134
+ }
135
+
136
+ /**
137
+ * Infers the app version to use in source map upload based on the flavor.
138
+ * This is needed since different flavors may have different version codes and names (e.g. version suffixes).
139
+ *
140
+ * It checks the version for the flavor's variant.
141
+ * If no variant is found it falls back to the app's default config.
142
+ *
143
+ *
144
+ * @param flavor The flavor to get the app version for.
145
+ * @return A map containing the version code and version name.
146
+ */
147
+ Map<String, String> getDefaultVersion(String flavor) {
148
+ def appProject = project(':app')
149
+ def defaultConfig = appProject.android.defaultConfig
150
+
151
+ def variants = appProject.android.applicationVariants
152
+
153
+ // uncapitalize is used to turn "Release" into "release" if the flavor is empty
154
+ def variantName = "${flavor}Release".uncapitalize()
155
+ def variant = variants.find { it.name.uncapitalize() == variantName }
156
+
157
+ def versionName = variant?.versionName ?: defaultConfig.versionName
158
+ def versionCode = variant?.versionCode ?: defaultConfig.versionCode
159
+
160
+ return [name: "${versionName}", code: "${versionCode}"]
161
+ }
162
+
163
+ boolean isUploadSourcemapsEnabled() {
164
+ def luciqEnvValue = System.getenv('LUCIQ_SOURCEMAPS_UPLOAD_DISABLE')?.toBoolean()
165
+ def instabugEnvValue = System.getenv('INSTABUG_SOURCEMAPS_UPLOAD_DISABLE')?.toBoolean()
166
+ def defaultValue = true
167
+
168
+ def envValue = luciqEnvValue ?: instabugEnvValue
169
+ return (envValue != null) ? !envValue : defaultValue
170
+ }
171
+
172
+ String resolveVar(String name, String envKey, String defaultValue) {
173
+ def env = System.getenv()
174
+
175
+ // First try LUCIQ environment variable
176
+ def luciqEnvKey = envKey.replace('LUCIQ_', 'LUCIQ_')
177
+ def luciqEnvValue = env.get(luciqEnvKey)
178
+
179
+ // Then try INSTABUG environment variable as fallback
180
+ def instabugEnvKey = envKey.replace('LUCIQ_', 'INSTABUG_')
181
+ def instabugEnvValue = env.get(instabugEnvKey)
182
+
183
+ // Use LUCIQ value if available, otherwise use INSTABUG value, otherwise use default
184
+ def envValue = luciqEnvValue ?: instabugEnvValue
185
+
186
+ if (envValue != null && defaultValue !=null && envValue != defaultValue) {
187
+ project.logger.warn "Environment variable `${envKey}` might have incorrect value, " +
188
+ "make sure this was intentional:\n" +
189
+ " Environment Value: ${envValue}\n" +
190
+ " Default Value: ${defaultValue}"
191
+ }
192
+
193
+ def value = envValue ?: defaultValue
194
+
195
+ if (value == null) {
196
+ throw new InvalidUserDataException("Unable to find ${name}! " +
197
+ "Set the environment variable `${envKey}` or `${instabugEnvKey}` and try again.")
198
+ }
199
+
200
+ return value
201
+ }
202
+
203
+ static String executeNodeScript(File script, File workingDir) {
204
+ if (!script.exists()) {
205
+ println "Script not found: ${script.absolutePath}"
206
+ return null
207
+ }
208
+
209
+ def output = new StringBuffer()
210
+ def error = new StringBuffer()
211
+
212
+ try {
213
+ def process = ['node', script.getAbsolutePath()].execute(null, workingDir)
214
+ process.waitForProcessOutput(output, error)
215
+
216
+ if (process.exitValue() != 0) {
217
+ println "Script failed with exit code ${process.exitValue()}"
218
+ println "Standard Error:\n${error.toString().trim()}"
219
+ println "Standard Output:\n${output.toString().trim()}"
220
+ return null
221
+ }
222
+
223
+ return output.toString().trim()
224
+
225
+ } catch (Exception e) {
226
+ println "Exception while executing Node.js script: ${e.message}"
227
+ e.printStackTrace()
228
+ return null
229
+ }
230
+ }
231
+
232
+ static String executeShellScript(File script, File workingDir) {
233
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
234
+ return null
235
+ }
236
+
237
+ if (!script.canExecute()) {
238
+ // Try to set executable permission
239
+ script.setExecutable(true)
240
+ }
241
+
242
+ def output = new StringBuffer()
243
+ def error = new StringBuffer()
244
+
245
+ // Using 'sh' instead of './' to avoid needing exec permission, but keeping chmod above just in case
246
+ def process = ['sh', script.getAbsolutePath()].execute(null, workingDir)
247
+ process?.waitForProcessOutput(output, error)
248
+
249
+ if (process.exitValue() != 0) {
250
+ println "Error running script: ${error.toString().trim()}"
251
+ return null
252
+ }
253
+
254
+ return output.toString().trim()
255
+ }
@@ -0,0 +1,4 @@
1
+ <manifest
2
+ xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+ </manifest>