Skip to content

Commit

Permalink
feature(apikey): adding apikey to session
Browse files Browse the repository at this point in the history
  • Loading branch information
YYChen01988 committed May 31, 2023
2 parents dce60da + ef240c3 commit c98a7e0
Show file tree
Hide file tree
Showing 28 changed files with 249 additions and 105 deletions.
40 changes: 30 additions & 10 deletions .buildkite/pipeline.full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ steps:
download:
- "build/fixture-r19.apk"
- "build/fixture-r19/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -120,7 +122,9 @@ steps:
download:
- "build/fixture-r19.apk"
- "build/fixture-r19/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -204,7 +208,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -232,7 +238,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -260,7 +268,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -288,7 +298,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -320,7 +332,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -348,7 +362,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -376,7 +392,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -404,7 +422,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down
28 changes: 21 additions & 7 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ steps:
download:
- "build/fixture-r19.apk"
- "build/fixture-r19/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -157,7 +159,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand All @@ -184,7 +188,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -212,7 +218,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -244,7 +252,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -273,7 +283,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down Expand Up @@ -301,7 +313,9 @@ steps:
download:
- "build/fixture-r21.apk"
- "build/fixture-r21/*"
upload: "maze_output/failed/**/*"
upload:
- "maze_output/failed/**/*"
- "maze_output/metrics.csv"
docker-compose#v4.7.0:
pull: maze-runner
run: maze-runner
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 5.31.0 (2023-05-31)

### Enhancements

* Added ApiKey to session and it can be reset in session callback .
[#1855](https://github.com/bugsnag/bugsnag-android/pull/1855)
*
## 5.30.0 (2023-05-11)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source "https://rubygems.org"
#gem 'bugsnag-maze-runner', path: '../maze-runner'

# Or a specific release:
gem 'bugsnag-maze-runner', '~>7.0'
gem 'bugsnag-maze-runner', '~>7.30.2'

# Or follow master:
#gem 'bugsnag-maze-runner', git: 'https://github.com/bugsnag/maze-runner'
Expand Down
20 changes: 11 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ GEM
selenium-webdriver (~> 4.2, < 4.6)
bugsnag (6.25.2)
concurrent-ruby (~> 1.0)
bugsnag-maze-runner (7.23.0)
bugsnag-maze-runner (7.30.2)
appium_lib (~> 12.0.0)
appium_lib_core (~> 5.4.0)
bugsnag (~> 6.24)
cucumber (~> 7.1)
cucumber-expressions (~> 6.0.0)
curb (~> 0.9.6)
dogstatsd-ruby (~> 5.5.0)
json_schemer (~> 0.2.24)
optimist (~> 3.0.1)
os (~> 1.0.0)
Expand Down Expand Up @@ -62,10 +63,11 @@ GEM
cucumber-cucumber-expressions (~> 14.0, >= 14.0.0)
curb (0.9.11)
diff-lcs (1.5.0)
dogstatsd-ruby (5.5.0)
ecma-re-validator (0.4.0)
regexp_parser (~> 2.2)
eventmachine (1.2.7)
faye-websocket (0.11.1)
faye-websocket (0.11.2)
eventmachine (>= 0.12.0)
websocket-driver (>= 0.5.1)
ffi (1.15.5)
Expand All @@ -86,27 +88,27 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1)
multi_test (0.1.2)
nokogiri (1.14.2-arm64-darwin)
nokogiri (1.15.1-arm64-darwin)
racc (~> 1.4)
nokogiri (1.14.2-x86_64-darwin)
nokogiri (1.15.1-x86_64-darwin)
racc (~> 1.4)
optimist (3.0.1)
os (1.0.1)
power_assert (2.0.3)
racc (1.6.2)
rack (2.2.6.4)
rack (2.2.7)
rake (12.3.3)
regexp_parser (2.7.0)
regexp_parser (2.8.0)
rexml (3.2.5)
rubyzip (2.3.2)
selenium-webdriver (4.5.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sys-uname (1.2.2)
sys-uname (1.2.3)
ffi (~> 1.1)
test-unit (3.5.7)
test-unit (3.5.8)
power_assert
thor (1.0.1)
tomlrb (2.0.3)
Expand All @@ -125,7 +127,7 @@ PLATFORMS
x86_64-darwin-20

DEPENDENCIES
bugsnag-maze-runner (~> 7.0)
bugsnag-maze-runner (~> 7.30.2)
license_finder (~> 6.13)

BUNDLED WITH
Expand Down
2 changes: 2 additions & 0 deletions bugsnag-android-core/api/bugsnag-android-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -573,11 +573,13 @@ public abstract interface class com/bugsnag/android/Plugin {
}

public final class com/bugsnag/android/Session : com/bugsnag/android/JsonStream$Streamable, com/bugsnag/android/UserAware {
public fun getApiKey ()Ljava/lang/String;
public fun getApp ()Lcom/bugsnag/android/App;
public fun getDevice ()Lcom/bugsnag/android/Device;
public fun getId ()Ljava/lang/String;
public fun getStartedAt ()Ljava/util/Date;
public fun getUser ()Lcom/bugsnag/android/User;
public fun setApiKey (Ljava/lang/String;)V
public fun setId (Ljava/lang/String;)V
public fun setStartedAt (Ljava/util/Date;)V
public fun setUser (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@ public void testSessionFromFile() throws Exception {

@Test
public void testAutoCapturedOverride() throws Exception {
session = new Session("id", new Date(), null, false, new Notifier(), NoopLogger.INSTANCE, "TEST APIKEY");
session = new Session(
"id",
new Date(),
null,
false,
new Notifier(),
NoopLogger.INSTANCE,
"TEST APIKEY"
);
assertFalse(session.isAutoCaptured());
session.setAutoCaptured(true);
assertTrue(session.isAutoCaptured());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ internal data class SessionFilenameInfo(

@JvmStatic
fun findTimestampInFilename(file: File): Long {
return file.name.substringAfter("_").drop(uuidLength)
return file.name.split("_")[1].drop(uuidLength)
.toLongOrNull() ?: -1
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public int compare(File lhs, File rhs) {
SESSION_COMPARATOR,
logger,
delegate);
this.config =config;
this.config = config;
}

@NonNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ Session startNewSession(@NonNull Date date, @Nullable User user,
return null;
}
String id = UUID.randomUUID().toString();
Session session = new Session(id, date, user, autoCaptured, client.getNotifier(), logger, configuration.getApiKey());
Session session = new Session(
id, date, user, autoCaptured,
client.getNotifier(), logger, configuration.getApiKey()
);
if (trackSessionIfNeeded(session)) {
return session;
} else {
Expand Down Expand Up @@ -256,7 +259,9 @@ void flushStoredSessions() {

void flushStoredSession(File storedFile) {
logger.d("SessionTracker#flushStoredSession() - attempting delivery");
Session payload = new Session(storedFile, client.getNotifier(), logger, configuration.getApiKey());
Session payload = new Session(
storedFile, client.getNotifier(), logger, configuration.getApiKey()
);

if (!payload.isV2Payload()) { // collect data here
payload.setApp(client.getAppDataCollector().generateApp());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ public class SessionFacadeTest {
private Session session;
private InterceptingLogger logger;

/**
* Captures session logs
*/
@Before
public void setUp() {
logger = new InterceptingLogger();
session = new Session("123", new Date(0), new User(), true, new Notifier(), logger, "BUGSNAG_API_KEY");
session = new Session(
"123", new Date(0), new User(),
true, new Notifier(), logger, "BUGSNAG_API_KEY"
);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ class SessionFilenameTest {
1504255147933,
"my-uuid-uuuuuuuuuuuuuuuuuuuuuuuuuuuu"
).encode()
assertEquals("TEST APIKEY_my-uuid-uuuuuuuuuuuuuuuuuuuuuuuuuuuu1504255147933_v2.json", fileName)
assertEquals(
"TEST APIKEY_my-uuid-uuuuuuuuuuuuuuuuuuuuuuuuuuuu1504255147933_v2.json",
fileName
)
}

@Test
Expand Down

0 comments on commit c98a7e0

Please sign in to comment.