Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(release): pulling release/1.20.1 into master #340

Merged
merged 5 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.20.1](https://github.com/rudderlabs/rudder-sdk-android/compare/v1.20.0...v1.20.1) (2023-10-16)


### Bug Fixes

* typo in sample-kotlin build.gradle ([4097ea4](https://github.com/rudderlabs/rudder-sdk-android/commit/4097ea40f9c39966bed2ecad501a78defd93e2c1))
* work manager not getting initialised if ([#330](https://github.com/rudderlabs/rudder-sdk-android/issues/330)) ([d10fc24](https://github.com/rudderlabs/rudder-sdk-android/commit/d10fc244e105fe885628105dc8c22344a2d2e549))

## [1.20.0](https://github.com/rudderlabs/rudder-sdk-android/compare/v1.19.1...v1.20.0) (2023-10-03)


Expand Down
6 changes: 3 additions & 3 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 33
compileSdk 33
defaultConfig {
minSdkVersion 19
targetSdkVersion 33
Expand Down Expand Up @@ -44,10 +44,10 @@ dependencies {
implementation 'androidx.annotation:annotation:1.6.0'


implementation ('com.rudderstack.android.sdk:rudderreporter:0.3.0')
implementation ('com.rudderstack.android.sdk:rudderreporter:0.3.+')
// implementation(project(path: ':rudderreporter'))
// implementation(project(path: ':gsonrudderadapter'))
implementation 'com.rudderstack.kotlin.sdk:gsonrudderadapter:0.2.0'
implementation 'com.rudderstack.kotlin.sdk:gsonrudderadapter:0.2.+'

// required for new life cycle methods
compileOnly 'androidx.lifecycle:lifecycle-process:2.6.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@

public class ApplicationLifeCycleManager {
private final RudderConfig config;
private final RudderFlushWorkManager rudderFlushWorkManager;
private final EventRepository repository;
public static final String VERSION = "version";
private static final AtomicBoolean isFirstLaunch = new AtomicBoolean(true);
private final RudderPreferenceManager preferenceManager;
private final AppVersion appVersion;

public ApplicationLifeCycleManager(RudderConfig config, AppVersion appVersion,
RudderFlushWorkManager rudderFlushWorkManager,
EventRepository repository,
RudderPreferenceManager preferenceManager) {
this.config = config;
this.rudderFlushWorkManager = rudderFlushWorkManager;
this.repository = repository;
this.preferenceManager = preferenceManager;
this.appVersion = appVersion;
Expand All @@ -43,7 +40,6 @@ void trackApplicationUpdateStatus() {
if (this.appVersion.isApplicationInstalled()) {
// application was not installed previously, now triggering Application Installed event
sendApplicationInstalled(appVersion.currentBuild, appVersion.currentVersion);
rudderFlushWorkManager.registerPeriodicFlushWorker();
} else if (this.appVersion.isApplicationUpdated()) {
sendApplicationUpdated(appVersion.previousBuild, appVersion.currentBuild, appVersion.previousVersion, appVersion.currentVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,11 @@ public void handleMessage(Message msg) {
// initiate ApplicationLifeCycleManager
RudderLogger.logDebug("EventRepository: constructor: Initiating ApplicationLifeCycleManager");
AppVersion appVersion = new AppVersion(application);
this.applicationLifeCycleManager = new ApplicationLifeCycleManager(config, appVersion, rudderFlushWorkManager, this, preferenceManager);
this.applicationLifeCycleManager = new ApplicationLifeCycleManager(config, appVersion, this, preferenceManager);
this.applicationLifeCycleManager.trackApplicationUpdateStatus();

rudderFlushWorkManager.registerPeriodicFlushWorker();

initializeLifecycleTracking(applicationLifeCycleManager);

initiateRudderReporterFromPrefetchedConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ public FlushEventsWorker(
@NonNull WorkerParameters params) {
super(context, params);
persistenceProviderFactoryClassName = params.getInputData().getString(PERSISTENCE_PROVIDER_FACTORY_CLASS_NAME_KEY);
ReportManager.incrementWorkManagerInitCounter(1);
}

private void addWorkerMetrics() {
ReportManager.incrementWorkManagerInitializationCounter(1);
ReportManager.incrementWorkManagerCallCounter(1);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ private ReportManager() {
private static LongCounter sourceConfigDownloadAbortCounter = null;
private static LongCounter dbEncryptionCounter = null;

private static LongCounter workManagerSuccessInitializationCounter = null;
private static LongCounter workManagerCallCounter = null;
private static LongCounter workManagerInitCounter = null;


private static final String EVENTS_SUBMITTED_COUNTER_TAG = "submitted_events";
Expand All @@ -95,7 +96,8 @@ private ReportManager() {
private static final String SOURCE_CONFIG_DOWNLOAD_RETRY_COUNTER_TAG = "sc_attempt_retry";

private static final String SOURCE_CONFIG_DOWNLOAD_ABORT_COUNTER_TAG = "sc_attempt_abort";
private static final String FLUSH_WORKER_INIT_COUNTER_TAG = "flush_worker_call";
private static final String FLUSH_WORKER_CALL_COUNTER_TAG = "flush_worker_call";
private static final String FLUSH_WORKER_INIT_COUNTER_TAG = "flush_worker_init";
private static final String ENCRYPTED_DB_COUNTER_TAG = "db_encrypt";

private static final String METRICS_URL_DEV = "https://sdk-metrics.dev-rudder.rudderlabs.com/";
Expand Down Expand Up @@ -139,7 +141,8 @@ private static void createCounters(@NonNull Metrics metrics) {
dmtEventRetryCounter = metrics.getLongCounter(DMT_RETRY_COUNTER_TAG);
dmtEventAbortCounter = metrics.getLongCounter(DMT_DISCARD_COUNTER_TAG);

workManagerSuccessInitializationCounter = metrics.getLongCounter(FLUSH_WORKER_INIT_COUNTER_TAG);
workManagerCallCounter = metrics.getLongCounter(FLUSH_WORKER_CALL_COUNTER_TAG);
workManagerInitCounter = metrics.getLongCounter(FLUSH_WORKER_INIT_COUNTER_TAG);
}

private static void incrementCounter(LongCounter counter, int value, Map<String, String> attributes) {
Expand Down Expand Up @@ -320,8 +323,11 @@ public static void incrementDbEncryptionCounter(int value, Map<String, String> a
incrementCounter(dbEncryptionCounter, value, attributes);
}

static void incrementWorkManagerInitializationCounter(int value) {
incrementCounter(workManagerSuccessInitializationCounter, value);
static void incrementWorkManagerCallCounter(int value) {
incrementCounter(workManagerCallCounter, value);
}
static void incrementWorkManagerInitCounter(int value) {
incrementCounter(workManagerInitCounter, value);
}

public static void reportError(Throwable throwable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ private static void collectDissentedMetrics(List<RudderServerDestination> destin
List<RudderServerDestination> destinationsCopy = new ArrayList<>(destinations);
destinationsCopy.removeAll(consentedDestinations);
for (RudderServerDestination destination : destinationsCopy) {
reportDiscardedDestinationWithType(destination, ReportManager.LABEL_TYPE_DESTINATION_DISSENTED);
reportDiscardedDestinationWithType(destination.getDestinationDefinition().displayName, ReportManager.LABEL_TYPE_DESTINATION_DISSENTED);
}

}
private static void reportDiscardedDestinationWithType(RudderServerDestination destination, String type) {
private static void reportDiscardedDestinationWithType(String destinationName, String type) {
Map<String,String> labelsMap = new HashMap<>();
labelsMap.put(ReportManager.LABEL_TYPE, type);
labelsMap.put(ReportManager.LABEL_INTEGRATION, destination.getDestinationDefinition().displayName);
labelsMap.put(ReportManager.LABEL_INTEGRATION, destinationName);
ReportManager.incrementDeviceModeDiscardedCounter(1, labelsMap);
}

Expand Down Expand Up @@ -202,7 +202,8 @@ private void initiateFactories(List<RudderServerDestination> destinations) {
integrationOperationsMap.put(key, nativeOp);
handleCallBacks(key, nativeOp);
} else {
reportDiscardedDestinationWithType(destination, ReportManager.LABEL_TYPE_DESTINATION_DISABLED);
reportDiscardedDestinationWithType(destination == null? key : destination.destinationDefinition.displayName
, ReportManager.LABEL_TYPE_DESTINATION_DISABLED);
RudderLogger.logDebug(String.format(Locale.US, "EventRepository: initiateFactories: destination was null or not enabled for %s", key));
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class RudderFlushWorkManager {
static final String RUDDER_FLUSH_CONFIG_FILE_NAME = "RudderFlushConfig";
static final String PERSISTENCE_PROVIDER_FACTORY_CLASS_NAME_KEY = "persistenceProviderFactory";

private static final String UNIQUE_FLUSH_WORK_NAME = "flushEvents";
RudderFlushWorkManager(Context context, RudderConfig config, RudderPreferenceManager preferenceManager) {
this.context = context;
this.config = config;
Expand Down Expand Up @@ -77,14 +78,11 @@ void registerPeriodicFlushWorker() {
.build();

WorkManager.getInstance(context).enqueueUniquePeriodicWork(
"flushEvents",
UNIQUE_FLUSH_WORK_NAME,
ExistingPeriodicWorkPolicy.KEEP,
flushPendingEvents);

String periodicWorkRequestId = flushPendingEvents.getId().toString();
preferenceManager.savePeriodicWorkRequestId(periodicWorkRequestId);

RudderLogger.logDebug("EventRepository: registerPeriodicFlushWorker: Registered PeriodicWorkRequest with ID " + periodicWorkRequestId);
RudderLogger.logDebug("EventRepository: registerPeriodicFlushWorker: Registered PeriodicWorkRequest with name " + UNIQUE_FLUSH_WORK_NAME);
}
}

Expand All @@ -97,12 +95,7 @@ void cancelPeriodicFlushWorker() {
RudderLogger.logWarn("EventRepository: cancelPeriodicFlushWorker: WorkManager dependency not found, please add it to your build.gradle");
return;
}
String periodicWorkRequestId = preferenceManager.getPeriodicWorkRequestId();
if (periodicWorkRequestId == null) {
RudderLogger.logWarn("EventRepository: cancelPeriodicFlushWorker: Couldn't find PeriodicWorkRequest Id, cannot cancel PeriodicWorkRequest");
return;
}
WorkManager.getInstance(context).cancelWorkById(UUID.fromString(periodicWorkRequestId));
RudderLogger.logDebug("EventRepository: cancelPeriodicFlushWorker: Successfully cancelled PeriodicWorkRequest With ID " + periodicWorkRequestId);
WorkManager.getInstance(context).cancelUniqueWork(UNIQUE_FLUSH_WORK_NAME);
RudderLogger.logDebug("EventRepository: cancelPeriodicFlushWorker: Successfully cancelled PeriodicWorkRequest With name " + UNIQUE_FLUSH_WORK_NAME);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,6 @@ long getOptOutTime() {
return preferences.getLong(RUDDER_OPT_OUT_TIME_KEY, -1);
}

void savePeriodicWorkRequestId(String periodicWorkRequestId) {
preferences.edit().putString(RUDDER_PERIODIC_WORK_REQUEST_ID_KEY, periodicWorkRequestId).apply();
}

String getPeriodicWorkRequestId() {
return preferences.getString(RUDDER_PERIODIC_WORK_REQUEST_ID_KEY, null);
}

void saveLastEventTimeStamp(Long time) {
preferences.edit().putLong(RUDDER_LAST_EVENT_TIMESTAMP_KEY, time).apply();
}
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android.enableJetifier=true
android.enableR8.fullMode=true
kotlin.code.style=official
GROUP=com.rudderstack.android.sdk
VERSION_CODE=19
VERSION_NAME=1.20.0
VERSION_CODE=20
VERSION_NAME=1.20.1
POM_NAME=Rudderstack SDK for android
POM_DESCRIPTION=Rudderstack SDK for android
POM_ARTIFACT_ID=core
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.20.0",
"version": "1.20.1",
"dependencies": {
"properties-reader": "^2.2.0"
}
Expand Down
4 changes: 3 additions & 1 deletion sample-kotlin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ android {
versionCode 4
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField("String", "DATA_PLANE_URL", properties.getProperty('dataplaneUrl', 'https://api.rudderstack.com'))
buildConfigField("String", "DATA_PLANE_URL", properties.getProperty('dataplaneUrl', "\"https://api.rudderstack.com\""))
buildConfigField("String", "CONTROL_PLANE_URL", properties.getProperty('controlplaneUrl', "\"https://api.rudderstack.com\""))
buildConfigField("String", "WRITE_KEY", properties.getProperty('writeKey', "\"\""))
}
Expand Down Expand Up @@ -88,6 +88,8 @@ dependencies {
implementation 'com.rudderstack.android.integration:braze:1.0.6'
implementation "com.appboy:android-sdk-ui:21.0.0"

//work-manager
implementation 'androidx.work:work-runtime:2.8.1'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.rudderstack.android.integrations.amplitude.AmplitudeIntegrationFactor
import com.rudderstack.android.sdk.core.RudderClient
import com.rudderstack.android.sdk.core.RudderConfig
import com.rudderstack.android.sdk.core.RudderLogger
import java.util.concurrent.TimeUnit

class MainApplication : Application(), Configuration.Provider {
companion object {
Expand All @@ -27,6 +28,7 @@ class MainApplication : Application(), Configuration.Provider {
.withDataPlaneUrl(DATA_PLANE_URL)
.withControlPlaneUrl(BuildConfig.CONTROL_PLANE_URL)
.withLogLevel(RudderLogger.RudderLogLevel.NONE)
.withFlushPeriodically(20,TimeUnit.MINUTES)
.withCollectDeviceId(false)
.withFactory(BrazeIntegrationFactory.FACTORY)
.withFactory(AmplitudeIntegrationFactory.FACTORY)
Expand Down
Loading