Skip to content

Commit a6accbf

Browse files
authored
Prepare 2.3.0 release (#127)
* Fix Retrieve Existing request ID behavior for PROCESSING state (#95) * Fix Retrieve Existing request ID behavior for PENDING state * Add distinction between Pending & Processing * Code cleanup (and research on proguard rules being handed to consumers) (#98) * Add proguard rules to project for automatic client consumption * Fix constant name after renaming class * Concrete R8 rules are actually not needed * Add enum for GrantType (#99) * Update Robolectric dependency (#102) * Update changelog * Use Epoch usec for Analytics timestamp (#107) * Add UT for Analytics (#108) * Refresh Auth Token for Customer Request (#109) * Initial support for Unauthorized Customer Request refresh * Add useful docs about token refresh window * Improve logging for CashAppCashAppPayImpl * Use Duration instead of Long for better time handling * Remove not needed call to interrupt * Schedule auth token refresh on `startWithExistingCustomerRequest` when status is "pending" * Support deferred auth token refresh upon authorize call * Better thread safety and handling * Update comment * Add new Refreshing state (#110) * Add Refreshing state * Use better explicit tag for logging * Abstract thread managment away from main class (#113) * Redact PII for logs and metrics (#112) * Redact PII for logs and metrics * Add UTs for PiiString * Swap redact with unredacted defaults * Redact more fields; move redaction step to encoding * Simplify internal class names (#115) * Modify CashAppPayButton to allow for dynamic styles (#116) * Modify CashAppPayButton to allow for dynamic styles * Update CHANGELOG * Update testing frameworks and link baseline * Add PR template (#120) * Logging abstraction (#119) * Create new module for logging * CashPayLogger implementation, and apply it to Analytics module * Add CAP logger to Core module * Create lint baseline file for logging module * Fix tests * Change Analytics implementation to log only Warn level or above * Add support to observe logging changes * Add some UT for logging module * Add UTs for CashAppLoggerImpl * Add some useful documentation to tests * Set default PR template (#121) * Make Initializer open to modification (#123) * Update Spotless Plugin and Ktlint version (#124) * Add minify rules (#125) * Add consumer-rules for minify * Bump release version; update release notes * Add more minify rules * Update Core dependency on OkHttp (#126) * Add consumer-rules for minify * Bump release version; update release notes * Add more minify rules * Update Core dependency on OkHttp * Update changelog for release * Update CHANGELOG * Release version 2.3.0
1 parent b62ee84 commit a6accbf

File tree

51 files changed

+840
-392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+840
-392
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## Jira Ticket
2+
[Jira Ticket]()
3+
4+
## What are you trying to accomplish?
5+
6+
## How did you accomplish this?
7+
8+
## Steps to manually test this change:
9+
<!--- Test Case: [what is this testing]
10+
1.
11+
-->
12+
13+
## Visual:

.github/pull_request_template.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Jira Ticket
2+
[Jira Ticket]()
3+
4+
## What are you trying to accomplish?
5+
6+
## How did you accomplish this?
7+
8+
## Steps to manually test this change:
9+
<!--- Test Case: [what is this testing]
10+
1.
11+
-->
12+
13+
## Visual:
14+
15+
| Before | After |
16+
|--------|-------|
17+
| | |

CHANGELOG.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
# 2.3.0
2+
3+
- The class `CashAppPayInitializer` was made open, so that androidx.startup can be manually overridden.
4+
- This version bundles fixes for minify enabled builds.
5+
- Updated internal dependency on `OkHttp` to version `4.11.0`.
6+
7+
## Breaking Changes
8+
9+
- Renamed class `CashAppCashAppPayApiNetworkException` to `CashAppPayApiNetworkException`
10+
- Renamed class `CashAppCashAppPayApiNetworkException` to `CashAppPayApiNetworkException`
11+
- This version contains a change to the bundled Cash App Pay button.
12+
Previously, `light` and `dark` variants of the button were made possible by using 2 different
13+
views, respectively `CashAppPayButtonLight` an `CashAppPayButtonDark`. As of this version, the
14+
there will only be a single `CashAppPayButton` view, which has been updated to support both variants.
15+
To obtain different variants, developers should use the XML `style` attribute to specify the variant they want, as follows:
16+
17+
18+
Light Variant:
19+
```xml
20+
<app.cash.paykit.core.ui.CashAppPayButton
21+
style="@style/CAPButtonStyle.Light"
22+
android:layout_height="54dp"
23+
android:layout_width="match_parent"/>
24+
```
25+
26+
Dark Variant:
27+
```xml
28+
<app.cash.paykit.core.ui.CashAppPayButton
29+
style="@style/CAPButtonStyle.Dark"
30+
android:layout_height="54dp"
31+
android:layout_width="match_parent"/>
32+
```
33+
34+
This change makes it possible for developer to use the button in a more flexible way, such as using
35+
a style that changes accordingly to the OS theme.
36+
37+
You should migrate any instances of `CashAppPayButtonLight` and `CashAppPayButtonDark` to `CashAppPayButton`.
38+
139
# 2.2.1
240

341
Here's what has changed on this release:

analytics-core/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ dependencies {
4646
testImplementation "junit:junit:$junit_version"
4747
testImplementation "io.mockk:mockk:$mockk_version"
4848

49+
implementation project(':logging')
50+
4951
// Robolectric environment.
5052
testImplementation "org.robolectric:robolectric:$robolectric_version"
5153
}

analytics-core/src/main/java/app/cash/paykit/analytics/AnalyticsLogger.kt

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,43 +16,27 @@
1616
package app.cash.paykit.analytics
1717

1818
import android.util.Log
19+
import app.cash.paykit.logging.CashAppLogger
1920

2021
class AnalyticsLogger(
2122
private val options: AnalyticsOptions,
23+
private val cashAppLogger: CashAppLogger,
2224
) {
2325
fun v(tag: String, msg: String) {
2426
if (options.logLevel <= Log.VERBOSE) {
25-
log(Log.VERBOSE, tag, msg)
26-
}
27-
}
28-
29-
fun d(tag: String, msg: String) {
30-
if (options.logLevel <= Log.DEBUG) {
31-
log(Log.DEBUG, tag, msg)
32-
}
33-
}
34-
35-
fun i(tag: String, msg: String) {
36-
if (options.logLevel <= Log.INFO) {
37-
log(Log.INFO, tag, msg)
27+
cashAppLogger.logVerbose(tag, msg)
3828
}
3929
}
4030

4131
fun w(tag: String, msg: String) {
4232
if (options.logLevel <= Log.WARN) {
43-
log(Log.WARN, tag, msg)
33+
cashAppLogger.logWarning(tag, msg)
4434
}
4535
}
4636

47-
fun e(tag: String, msg: String) {
37+
fun e(tag: String, msg: String, throwable: Throwable? = null) {
4838
if (options.logLevel <= Log.ERROR) {
49-
log(Log.ERROR, tag, msg)
50-
}
51-
}
52-
53-
private fun log(priority: Int, tag: String, msg: String) {
54-
if (!options.isLoggerDisabled) {
55-
Log.println(priority, tag, msg)
39+
cashAppLogger.logError(tag, msg, throwable)
5640
}
5741
}
5842
}

analytics-core/src/main/java/app/cash/paykit/analytics/PayKitAnalytics.kt

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import app.cash.paykit.analytics.core.DeliveryWorker
2222
import app.cash.paykit.analytics.persistence.EntriesDataSource
2323
import app.cash.paykit.analytics.persistence.sqlite.AnalyticsSQLiteDataSource
2424
import app.cash.paykit.analytics.persistence.sqlite.AnalyticsSqLiteHelper
25+
import app.cash.paykit.logging.CashAppLogger
2526
import java.util.*
2627
import java.util.concurrent.ExecutionException
2728
import java.util.concurrent.ExecutorService
@@ -34,18 +35,22 @@ import java.util.concurrent.atomic.AtomicBoolean
3435
class PayKitAnalytics constructor(
3536
private val context: Context,
3637
private val options: AnalyticsOptions,
38+
private val cashAppLogger: CashAppLogger,
3739
private val sqLiteHelper: AnalyticsSqLiteHelper = AnalyticsSqLiteHelper(
3840
context = context,
3941
options = options,
4042
),
4143
val entriesDataSource: EntriesDataSource = AnalyticsSQLiteDataSource(
4244
sqLiteHelper = sqLiteHelper,
4345
options = options,
46+
cashAppLogger = cashAppLogger,
4447
),
45-
private val logger: AnalyticsLogger = AnalyticsLogger(options = options),
48+
private val logger: AnalyticsLogger = AnalyticsLogger(options = options, cashAppLogger = cashAppLogger),
4649
vararg initialDeliveryHandlers: DeliveryHandler,
4750
) {
48-
private val TAG = "PayKitAnalytics"
51+
companion object {
52+
private const val TAG = "PayKitAnalytics"
53+
}
4954

5055
/** Collection of FutureTasks that perform the delivery work. */
5156
private var deliveryTasks = mutableListOf<FutureTask<Unit>>()
@@ -71,7 +76,7 @@ class PayKitAnalytics constructor(
7176
entriesDataSource.resetEntries()
7277
ensureExecutorIsUpAndRunning()
7378
ensureSchedulerIsUpAndRunning()
74-
logger.i(TAG, "Initialization completed.")
79+
logger.v(TAG, "Initialization completed.")
7580
}
7681

7782
/**
@@ -87,7 +92,7 @@ class PayKitAnalytics constructor(
8792
initializeScheduledExecutorService()
8893
}
8994
} ?: run {
90-
logger.d(TAG, "Creating scheduler service.")
95+
logger.v(TAG, "Creating scheduler service.")
9196
initializeScheduledExecutorService()
9297
}
9398
}
@@ -105,7 +110,7 @@ class PayKitAnalytics constructor(
105110
executor = Executors.newSingleThreadExecutor()
106111
}
107112
} ?: run {
108-
logger.d(TAG, "Creating executor service.")
113+
logger.v(TAG, "Creating executor service.")
109114
executor = Executors.newSingleThreadExecutor()
110115
}
111116
}
@@ -117,7 +122,7 @@ class PayKitAnalytics constructor(
117122
private fun initializeScheduledExecutorService() {
118123
shouldShutdown.set(false)
119124
scheduler = Executors.newSingleThreadScheduledExecutor().also {
120-
logger.d(
125+
logger.v(
121126
TAG,
122127
"Initializing scheduled executor service | delay:%ds, interval:%ds".format(
123128
Locale.US,
@@ -143,7 +148,7 @@ class PayKitAnalytics constructor(
143148
while (itr.hasNext()) {
144149
itr.next().run {
145150
if (isCancelled || isDone) {
146-
logger.d(
151+
logger.v(
147152
TAG,
148153
"Removing task from queue: ${toString()} (canceled=$isCancelled, done=$isDone)",
149154
)
@@ -187,25 +192,25 @@ class PayKitAnalytics constructor(
187192

188193
fun scheduleShutdown() {
189194
shouldShutdown.set(true)
190-
logger.i(TAG, "Scheduled shutdown.")
195+
logger.v(TAG, "Scheduled shutdown.")
191196
}
192197

193198
private fun shutdown() {
194199
executor?.run {
195200
shutdown()
196-
logger.i(TAG, "Executor service shutdown.")
201+
logger.v(TAG, "Executor service shutdown.")
197202
}
198203
scheduler?.run {
199204
shutdown()
200-
logger.i(TAG, "Scheduled executor service shutdown.")
205+
logger.v(TAG, "Scheduled executor service shutdown.")
201206
}
202207
if (deliveryTasks.isNotEmpty()) {
203208
deliveryTasks.clear()
204-
logger.i(TAG, "FutureTask list cleared.")
209+
logger.v(TAG, "FutureTask list cleared.")
205210
}
206211

207212
sqLiteHelper.close()
208-
logger.i(TAG, "Shutdown completed.")
213+
logger.v(TAG, "Shutdown completed.")
209214
}
210215

211216
@Synchronized
@@ -214,7 +219,7 @@ class PayKitAnalytics constructor(
214219
if (existingHandler == null) {
215220
handler.setDependencies(entriesDataSource, logger)
216221
deliveryHandlers.add(handler)
217-
logger.i(
222+
logger.v(
218223
TAG,
219224
"Registering %s as delivery handler for %s".format(
220225
Locale.US,
@@ -237,7 +242,7 @@ class PayKitAnalytics constructor(
237242
@Synchronized
238243
fun unregisterDeliveryHandler(handler: DeliveryHandler) {
239244
deliveryHandlers.remove(handler)
240-
logger.i(
245+
logger.v(
241246
TAG,
242247
"Unregistering %s as delivery handler for %s".format(
243248
Locale.US,
@@ -273,7 +278,7 @@ class PayKitAnalytics constructor(
273278
ensureExecutorIsUpAndRunning()
274279
val handler: DeliveryHandler? = getDeliveryHandler(type)
275280
return if (handler != null && handler.deliverableType.equals(type, ignoreCase = true)) {
276-
logger.i(TAG, "Scheduling $type for delivery --- $content")
281+
logger.v(TAG, "Scheduling $type for delivery --- $content")
277282
ScheduleDeliverableTask(type, content, metaData).also {
278283
executor!!.execute(it)
279284
}
@@ -294,7 +299,7 @@ class PayKitAnalytics constructor(
294299
if (type != null && content != null) {
295300
val entryId: Long = entriesDataSource.insertEntry(type, content, metaData)
296301
if (entryId > 0) {
297-
logger.d(
302+
logger.v(
298303
TAG,
299304
String.format("%s scheduled for delivery. id: %d", type, entryId),
300305
)

analytics-core/src/main/java/app/cash/paykit/analytics/core/DeliveryHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ abstract class DeliveryHandler {
3232

3333
private val listener = object : DeliveryListener {
3434
override fun onSuccess(entries: List<AnalyticEntry>) {
35-
logger?.d(
35+
logger?.v(
3636
TAG,
3737
"successful delivery, deleting $deliverableType[" + entries.toCommaSeparatedListIds() + "]",
3838
)
3939
dataSource?.deleteEntry(entries)
4040
}
4141

4242
override fun onError(entries: List<AnalyticEntry>) {
43-
logger?.d(
43+
logger?.v(
4444
TAG,
4545
"DELIVERY_FAILED for $deliverableType[" + entries.toCommaSeparatedListIds() + "]",
4646
)

analytics-core/src/main/java/app/cash/paykit/analytics/core/DeliveryWorker.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,39 +28,39 @@ internal class DeliveryWorker(
2828
private val logger: AnalyticsLogger,
2929
) : Callable<Unit> {
3030
init {
31-
logger.d(TAG, "DeliveryWorker initialized.")
31+
logger.v(TAG, "DeliveryWorker initialized.")
3232
}
3333

3434
@Throws(Exception::class)
3535
override fun call() {
36-
logger.d(TAG, "Starting delivery [$this]")
36+
logger.v(TAG, "Starting delivery [$this]")
3737
for (deliveryHandler in handlers) {
3838
val entryType = deliveryHandler.deliverableType
3939
val processId: String = dataSource.generateProcessId(entryType)
4040
var entries: List<AnalyticEntry> =
4141
dataSource.getEntriesForDelivery(processId, entryType)
4242
if (entries.isNotEmpty()) {
43-
logger.d(
43+
logger.v(
4444
TAG,
4545
"Processing %s[%d] | processId=%s".format(Locale.US, entries, entries.size, processId),
4646
)
4747
}
4848
while (entries.isNotEmpty()) {
49-
logger.d(TAG, "DELIVERY_IN_PROGRESS for ids[" + entries.toCommaSeparatedListIds() + "]")
49+
logger.v(TAG, "DELIVERY_IN_PROGRESS for ids[" + entries.toCommaSeparatedListIds() + "]")
5050
dataSource.updateStatuses(entries, AnalyticEntry.STATE_DELIVERY_IN_PROGRESS)
5151
deliveryHandler.deliver(entries, deliveryHandler.deliveryListener)
5252

5353
// get the next batch of events to send
5454
entries = dataSource.getEntriesForDelivery(processId, entryType)
5555
if (entries.isNotEmpty()) {
56-
logger.d(
56+
logger.v(
5757
TAG,
5858
"Processing %s[%d] | processId=%s".format(Locale.US, entries, entries.size, processId),
5959
)
6060
}
6161
}
6262
}
63-
logger.d(TAG, "Delivery finished. [$this]")
63+
logger.v(TAG, "Delivery finished. [$this]")
6464
}
6565

6666
companion object {

0 commit comments

Comments
 (0)