Skip to content

Commit 94ef7ea

Browse files
committed
release: SDK 3.2.0
1 parent ad720ce commit 94ef7ea

File tree

93 files changed

+11639
-11209
lines changed

Some content is hidden

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

93 files changed

+11639
-11209
lines changed

Sources/gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[versions]
2-
agp = "8.12.0"
2+
agp = "8.13.1"
33
android = "4.1.1.4"
44
androidCompileSdk = "36"
55
androidMinSdk = "21"
6-
androidLint = "31.12.0"
6+
androidLint = "31.13.1"
77
androidxJunit = "1.2.1"
88
androidXCoreKtx = "1.16.0"
99
androidXLibraryVersion = "1.0.0"
1010
androidXTestCoreKtx = "1.6.1"
1111
androidXTestRunner = "1.6.2"
1212
androidXTestTruth = "1.6.0"
1313
assertjCore = "3.24.2"
14-
batchSdk = "3.1.1"
15-
batchApiLevel = "311"
16-
batchMessagingApiLevel = "31"
14+
batchSdk = "3.2.0"
15+
batchApiLevel = "320"
16+
batchMessagingApiLevel = "32"
1717
batchResourcePrefix = "com_batchsdk_"
1818
batchNamespace = "com.batch.android"
1919
batchTestNamespace = "com.batch.android.test"

Sources/sdk/src/main/java/com/batch/android/BatchEventAttributes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public String getLabel() {
7979
* Add a string attribute for the specified key
8080
*
8181
* @param key Attribute key. Should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
82-
* @param value String value to add. Can't be longer than 64 characters, and can't be empty or null. For better results, you should trim/lowercase your strings, and use slugs when possible.
82+
* @param value String value to add. Can't be longer than 300 characters, and can't be empty or null. For better results, you should trim/lowercase your strings, and use slugs when possible.
8383
* @return Same BatchEventAttributes instance, for chaining
8484
*/
8585
public BatchEventAttributes put(@NonNull String key, @NonNull String value) {

Sources/sdk/src/main/java/com/batch/android/BatchProfileAttributeEditor.java

Lines changed: 12 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -275,24 +275,14 @@ public BatchProfileAttributeEditor setAttribute(final @NonNull String key, @NonN
275275
* Set a custom profile attribute for a key.
276276
*
277277
* @param key Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
278-
* @param value Attribute value, can't be null or empty. Must be a string not longer than 64 characters. For better results, you should make them upper/lowercase and trim the whitespaces.
278+
* @param value Attribute value, can't be null or empty. Must be a string not longer than 300 characters. For better results, you should make them upper/lowercase and trim the whitespaces.
279279
* @return This object instance, for method chaining
280280
*/
281281
public BatchProfileAttributeEditor setAttribute(final @NonNull String key, final @NonNull String value) {
282282
try {
283283
ProfileDataHelper.assertNotNull(value);
284284
String normalizedKey = ProfileDataHelper.normalizeAttributeKey(key);
285-
if (ProfileDataHelper.isNotValidStringValue(value)) {
286-
Logger.error(
287-
TAG,
288-
"String attributes can't be null or longer than " +
289-
ProfileDataHelper.ATTR_STRING_MAX_LENGTH +
290-
" characters. Ignoring attribute '" +
291-
key +
292-
"'"
293-
);
294-
return this;
295-
}
285+
ProfileDataHelper.validateCEPStringValue(value);
296286
this.profileUpdateOperation.addAttribute(normalizedKey, new UserAttribute(value, AttributeType.STRING));
297287
} catch (AttributeValidationException e) {
298288
e.printErrorMessage(TAG, key);
@@ -349,21 +339,13 @@ public BatchProfileAttributeEditor setAttribute(final @NonNull String key, final
349339
* Set a custom profile attribute for a key.
350340
*
351341
* @param key Attribute key, can't be null. It should be made of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
352-
* @param value Attribute value, can't be null or empty. Must be a valid List not longer than X items.
342+
* @param value Attribute value, can't be null or empty. Must be a valid List not longer than 25 items.
353343
* @return This object instance, for method chaining
354344
*/
355345
public BatchProfileAttributeEditor setAttribute(final @NonNull String key, final @NonNull List<String> value) {
356346
try {
357347
String normalizedKey = ProfileDataHelper.normalizeAttributeKey(key);
358-
if (ProfileDataHelper.isNotValidStringArray(value)) {
359-
Logger.error(
360-
TAG,
361-
"Array of string attributes must not be longer than 25 items, only values of type String and must respect the string attribute limitations. Ignoring attribute '" +
362-
key +
363-
"'"
364-
);
365-
return this;
366-
}
348+
ProfileDataHelper.validateStringArray(value);
367349
this.profileUpdateOperation.addAttribute(
368350
normalizedKey,
369351
new UserAttribute(new ArrayList<>(value), AttributeType.STRING_ARRAY)
@@ -406,23 +388,12 @@ public BatchProfileAttributeEditor removeAttribute(@NonNull String key) {
406388
* Add a string value in the specified array attribute. If empty, the collection will automatically be created.
407389
*
408390
* @param key The array attribute to add the value to. Cannot be null. Must be a string of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
409-
* @param value The value to add. Cannot be null or empty. Must be a string no longer than 64 characters.
391+
* @param value The value to add. Cannot be null or empty. Must be a string no longer than 300 characters.
410392
* @return This object instance, for method chaining
411393
*/
412394
public BatchProfileAttributeEditor addToArray(final @NonNull String key, final @NonNull String value) {
413395
try {
414396
String normalizedKey = ProfileDataHelper.normalizeAttributeKey(key);
415-
if (ProfileDataHelper.isNotValidStringValue(value)) {
416-
Logger.error(
417-
TAG,
418-
"Strings in Array attributes can't be null or longer than " +
419-
ProfileDataHelper.ATTR_STRING_MAX_LENGTH +
420-
" characters. Ignoring attribute '" +
421-
key +
422-
"'"
423-
);
424-
return this;
425-
}
426397
this.profileUpdateOperation.addToList(normalizedKey, new ArrayList<>(Collections.singletonList(value)));
427398
} catch (AttributeValidationException e) {
428399
e.printErrorMessage(TAG, key);
@@ -436,21 +407,12 @@ public BatchProfileAttributeEditor addToArray(final @NonNull String key, final @
436407
* Add a list of strings in the specified array attribute. If empty, the collection will automatically be created.
437408
*
438409
* @param key The array attribute to add the value to. Cannot be null. Must be a string of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
439-
* @param values The strings to add. Cannot be null or empty. Must be strings no longer than 64 characters and max 25 items
410+
* @param values The strings to add. Cannot be null or empty. Must be strings no longer than 300 characters and max 25 items
440411
* @return This object instance, for method chaining
441412
*/
442413
public BatchProfileAttributeEditor addToArray(final @NonNull String key, final @NonNull List<String> values) {
443414
try {
444415
String normalizedKey = ProfileDataHelper.normalizeAttributeKey(key);
445-
if (ProfileDataHelper.isNotValidStringArray(values)) {
446-
Logger.error(
447-
TAG,
448-
"Array of string attributes must not be longer than 25 items, only values of type String and must respect the string attribute limitations. Ignoring attribute '" +
449-
key +
450-
"'"
451-
);
452-
return this;
453-
}
454416
this.profileUpdateOperation.addToList(normalizedKey, new ArrayList<>(values));
455417
} catch (AttributeValidationException e) {
456418
e.printErrorMessage(TAG, key);
@@ -464,26 +426,15 @@ public BatchProfileAttributeEditor addToArray(final @NonNull String key, final @
464426

465427
/**
466428
* Removes a string from an array attribute.
467-
* Does nothing if the tag does not exist.
429+
* Does nothing if the value does not exist.
468430
*
469-
* @param key Array attribute name
470-
* @param value The value to remove
431+
* @param key The array attribute to remove the value to. Cannot be null. Must be a string of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
432+
* @param value The value to remove. Cannot be null or empty. Must be a string no longer than 300 characters.
471433
* @return This object instance, for method chaining
472434
*/
473435
public BatchProfileAttributeEditor removeFromArray(final @NonNull String key, final @NonNull String value) {
474436
try {
475437
String normalizedKey = ProfileDataHelper.normalizeAttributeKey(key);
476-
if (ProfileDataHelper.isNotValidStringValue(value)) {
477-
Logger.error(
478-
TAG,
479-
"Strings in Array attributes can't be null or longer than " +
480-
ProfileDataHelper.ATTR_STRING_MAX_LENGTH +
481-
" characters. Ignoring attribute '" +
482-
key +
483-
"'"
484-
);
485-
return this;
486-
}
487438
this.profileUpdateOperation.removeFromList(
488439
normalizedKey,
489440
new ArrayList<>(Collections.singletonList(value))
@@ -498,24 +449,15 @@ public BatchProfileAttributeEditor removeFromArray(final @NonNull String key, fi
498449

499450
/**
500451
* Removes a list of strings from an array attribute.
501-
* Does nothing if the tag does not exist.
452+
* Does nothing if an item does not exist.
502453
*
503-
* @param key Array attribute name
504-
* @param values The values to remove
454+
* @param key The array attribute to remove the value from. Cannot be null. Must be a string of letters, numbers or underscores ([a-z0-9_]) and can't be longer than 30 characters.
455+
* @param values The strings to remove. Cannot be null or empty. Must be strings no longer than 300 characters and max 25 items
505456
* @return This object instance, for method chaining
506457
*/
507458
public BatchProfileAttributeEditor removeFromArray(final @NonNull String key, final @NonNull List<String> values) {
508459
try {
509460
String normalizedKey = ProfileDataHelper.normalizeAttributeKey(key);
510-
if (ProfileDataHelper.isNotValidStringArray(values)) {
511-
Logger.error(
512-
TAG,
513-
"Array of string attributes must not be longer than 25 items, only values of type String and must respect the string attribute limitations. Ignoring attribute '" +
514-
key +
515-
"'"
516-
);
517-
return this;
518-
}
519461
this.profileUpdateOperation.removeFromList(normalizedKey, new ArrayList<>(values));
520462
} catch (AttributeValidationException e) {
521463
e.printErrorMessage(TAG, key);

Sources/sdk/src/main/java/com/batch/android/MetricWebservice.java

Lines changed: 61 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,50 @@
22

33
import android.content.Context;
44
import com.batch.android.core.Logger;
5-
import com.batch.android.core.MessagePackWebservice;
65
import com.batch.android.core.ParameterKeys;
6+
import com.batch.android.core.Parameters;
77
import com.batch.android.core.TaskRunnable;
8+
import com.batch.android.core.Webservice;
89
import com.batch.android.core.domain.DomainURLBuilder;
910
import com.batch.android.post.MetricPostDataProvider;
1011
import com.batch.android.webservice.listener.MetricWebserviceListener;
1112
import java.net.MalformedURLException;
13+
import java.util.HashMap;
14+
import java.util.Map;
1215

13-
class MetricWebservice extends MessagePackWebservice implements TaskRunnable {
16+
class MetricWebservice extends Webservice implements TaskRunnable {
1417

1518
private static final String TAG = "MetricWebservice";
1619

1720
private final MetricWebserviceListener listener;
21+
private final MetricPostDataProvider dataProvider;
1822

1923
protected MetricWebservice(
2024
Context context,
2125
MetricWebserviceListener listener,
2226
MetricPostDataProvider dataProvider,
2327
String... parameters
2428
) throws MalformedURLException {
25-
super(context, dataProvider, DomainURLBuilder.METRIC_WS_URL, parameters);
29+
super(context, RequestType.POST, DomainURLBuilder.METRIC_WS_URL, parameters);
2630
if (listener == null) {
2731
throw new NullPointerException("Listener is null");
2832
}
33+
if (dataProvider == null || dataProvider.isEmpty()) {
34+
throw new NullPointerException("Provider is empty");
35+
}
36+
2937
this.listener = listener;
38+
this.dataProvider = dataProvider;
3039
}
3140

3241
@Override
3342
public void run() {
3443
Logger.internal(TAG, "Webservice started");
3544
try {
3645
executeRequest();
37-
this.listener.onSuccess();
46+
listener.onSuccess();
3847
} catch (WebserviceError error) {
39-
this.listener.onFailure(error);
48+
listener.onFailure(error);
4049
}
4150
}
4251

@@ -45,6 +54,53 @@ public String getTaskIdentifier() {
4554
return "Batch/metricsws";
4655
}
4756

57+
@Override
58+
protected MetricPostDataProvider getPostDataProvider() {
59+
return dataProvider;
60+
}
61+
62+
@Override
63+
protected Map<String, String> getHeaders() {
64+
Map<String, String> headers = new HashMap<>();
65+
headers.put("x-batch-sdk-version", Parameters.SDK_VERSION);
66+
return headers;
67+
}
68+
69+
@Override
70+
protected String getURLSorterPatternParameterKey() {
71+
return ParameterKeys.METRIC_WS_URLSORTER_PATTERN_KEY;
72+
}
73+
74+
@Override
75+
protected String getCryptorTypeParameterKey() {
76+
return ParameterKeys.METRIC_WS_CRYPTORTYPE_KEY;
77+
}
78+
79+
@Override
80+
protected String getCryptorModeParameterKey() {
81+
return ParameterKeys.METRIC_WS_CRYPTORMODE_KEY;
82+
}
83+
84+
@Override
85+
protected String getPostCryptorTypeParameterKey() {
86+
return ParameterKeys.METRIC_WS_POST_CRYPTORTYPE_KEY;
87+
}
88+
89+
@Override
90+
protected String getReadCryptorTypeParameterKey() {
91+
return ParameterKeys.METRIC_WS_READ_CRYPTORTYPE_KEY;
92+
}
93+
94+
@Override
95+
protected String getSpecificConnectTimeoutKey() {
96+
return ParameterKeys.METRIC_WS_CONNECT_TIMEOUT_KEY;
97+
}
98+
99+
@Override
100+
protected String getSpecificReadTimeoutKey() {
101+
return ParameterKeys.METRIC_WS_READ_TIMEOUT_KEY;
102+
}
103+
48104
@Override
49105
protected String getSpecificRetryCountKey() {
50106
return ParameterKeys.METRIC_WS_RETRYCOUNT_KEY;

Sources/sdk/src/main/java/com/batch/android/core/MessagePackWebservice.java

Lines changed: 0 additions & 80 deletions
This file was deleted.

0 commit comments

Comments
 (0)