Skip to content

Commit 30a71f7

Browse files
authored
Merge pull request #61 from middleware-labs/sourcemap-plugin
❇️ added sourcemap plugin
2 parents 71a0b7d + 3e81bce commit 30a71f7

17 files changed

Lines changed: 781 additions & 2 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: release-sourcemap-plugin
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
versionName:
6+
description: 'Version Name'
7+
required: true
8+
9+
jobs:
10+
publish:
11+
name: Publish
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4.1.1
16+
- name: Set up Java 17 for running Gradle
17+
uses: actions/setup-java@v3.13.0
18+
with:
19+
distribution: temurin
20+
java-version: 17
21+
22+
- name: Grant Permission to Execute Gradle
23+
run: chmod +x gradlew
24+
25+
- name: Build with Gradle
26+
uses: gradle/gradle-build-action@v2
27+
with:
28+
arguments: build
29+
30+
- name: Publish Sourcemap Plugin
31+
run: |
32+
echo "Publishing plugin ${{ github.event.inputs.versionName }}🚀🚀"
33+
./gradlew :sourcemap-plugin:publish --no-daemon
34+
echo "Published✅"
35+
env:
36+
ORG_GRADLE_PROJECT_VERSION_NAME: ${{ github.event.inputs.versionName }}
37+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
38+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
39+
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.GPG_SECRET }}
40+
ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.GPG_ID }}
41+
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
.cxx
1515
local.properties
1616
.idea
17+
build

app/proguard-rules.pro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,8 @@
1919
# If you keep the line number information, uncomment this to
2020
# hide the original source file name.
2121
#-renamesourcefileattribute SourceFile
22+
-dontwarn io.opentelemetry.contrib.disk.buffering.**
23+
# Ensure R8 renames as much as possible for testing
24+
-repackageclasses ''
25+
-allowaccessmodification
26+
-overloadaggressively
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.middleware.android.sample;
2+
3+
public class CrashHelper {
4+
public void executeRiskOperation() {
5+
// Nested call to ensure a deeper obfuscated stacktrace
6+
performDeepNestedTask();
7+
}
8+
9+
private void performDeepNestedTask() {
10+
throw new RuntimeException("Middleware Test Crash: " + System.currentTimeMillis());
11+
}
12+
}

app/src/main/java/io/middleware/android/sample/MainActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ protected void onCreate(Bundle savedInstanceState) {
114114
}
115115
}
116116
});
117+
118+
findViewById(R.id.btn_trigger_crash).setOnClickListener(view -> {
119+
new CrashHelper().executeRiskOperation();
120+
});
117121
}
118122

119123
private void createSession() {

app/src/main/res/layout/activity_main.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,23 @@
7373
app:tint="#ff0000" />
7474

7575
<Button
76-
android:id="@+id/force_new_session"
76+
android:id="@+id/btn_trigger_crash"
7777
android:layout_width="wrap_content"
7878
android:layout_height="wrap_content"
79+
android:text="@string/trigger_obfuscated_crash"
7980
android:layout_below="@id/anr_button"
8081
android:layout_centerHorizontal="true"
8182
android:layout_marginTop="16dp"
83+
app:tint="#ff0000"
84+
/>
85+
86+
<Button
87+
android:id="@+id/force_new_session"
88+
android:layout_width="wrap_content"
89+
android:layout_height="wrap_content"
90+
android:layout_below="@id/btn_trigger_crash"
91+
android:layout_centerHorizontal="true"
92+
android:layout_marginTop="16dp"
8293
android:text="@string/force_new_session"
8394
app:tint="#ff0000" />
8495

app/src/main/res/values/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
<string name="custom_rum_event">CUSTOM RUM EVENT</string>
88
<string name="application_not_responding">APPLICATION NOT RESPONDING</string>
99
<string name="force_new_session">FORCE NEW SESSION</string>
10-
</resources>
10+
<string name="trigger_obfuscated_crash">Trigger Obfuscated Crash</string>
11+
</resources>

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ dependencyResolutionManagement {
2222
rootProject.name = "Sample"
2323
include ':app'
2424
include ':sdk'
25+
include ':sourcemap-plugin'

sourcemap-plugin/bin/main/META-INF/gradle-plugins/io.middleware.sourcemap.properties

Whitespace-only changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.middleware.sourcemap
2+
3+
/**
4+
* DSL extension exposed to the build script as `middlewareSourcemap { ... }`.
5+
*/
6+
class MiddlewareSourcemapExtension {
7+
8+
/** Middleware API key. Falls back to the MW_API_KEY environment variable. */
9+
String apiKey
10+
11+
/**
12+
* The version string attached to the uploaded mapping.
13+
* Defaults to the variant's versionName.
14+
*/
15+
String appVersion
16+
17+
/**
18+
* Backend URL for obtaining a pre-signed upload URL.
19+
* Defaults to the Middleware hosted endpoint.
20+
*/
21+
String backendUrl = "https://app.middleware.io/api/v1/android/getSasUrl"
22+
23+
/**
24+
* When true, deletes the local mapping.txt after a successful upload.
25+
* Useful in CI to avoid accidentally shipping mapping files.
26+
*/
27+
boolean deleteAfterUpload = false
28+
}

0 commit comments

Comments
 (0)