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

feat: add option to configure dataPlaneUrl as the metrics url #471

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: 3 additions & 5 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ dependencies {
implementation 'androidx.annotation:annotation:1.6.0'


implementation 'com.rudderstack.android.sdk:rudderreporter:[0.4.0, 0.6.0)'
// implementation(project(path: ':rudderreporter'))
// implementation(project(path: ':gsonrudderadapter'))
implementation 'com.rudderstack.kotlin.sdk:gsonrudderadapter:[0.2.0, 0.3.0)'
implementation 'com.rudderstack.android.sdk:rudderreporter:0.6.0'
implementation 'com.rudderstack.kotlin.sdk:gsonrudderadapter:0.2.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


// required for new life cycle methods
compileOnly 'androidx.lifecycle:lifecycle-process:2.6.1'
Expand Down Expand Up @@ -89,4 +87,4 @@ tasks.withType(JavaExec) {
//apply from: "${rootProject.projectDir}/scripts/publish-module.gradle"

apply from: rootProject.file('gradle/mvn-publish.gradle')
apply from: rootProject.file('gradle/codecov.gradle')
apply from: rootProject.file('gradle/codecov.gradle')
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ private void initiateRudderReporterFromPrefetchedConfig() {
if (serverConfig != null && serverConfig.source != null
&& serverConfig.source.sourceConfiguration != null) {
RudderLogger.logDebug("EventRepository: constructor: Prefetched source serverConfig is available");
enableStatsCollection(application, writeKey, serverConfig.source.sourceConfiguration.getStatsCollection());
enableStatsCollection(application, writeKey, serverConfig.source.sourceConfiguration.getStatsCollection(), dataResidencyManager.getDataPlaneUrl());
} else {
RudderLogger.logDebug("EventRepository: constructor: Prefetched source serverConfig is not available");
}
Expand Down Expand Up @@ -271,8 +271,6 @@ private void initiateSDK(@Nullable RudderConsentFilter consentFilter) {
if (serverConfig != null) {
isSDKEnabled = serverConfig.source.isSourceEnabled;
if (isSDKEnabled) {
if (serverConfig.source.sourceConfiguration != null)
enableStatsCollection(application, writeKey, serverConfig.source.sourceConfiguration.getStatsCollection());
dataResidencyManager.setDataResidencyUrls(serverConfig);
dataPlaneUrl = dataResidencyManager.getDataPlaneUrl();
if (dataPlaneUrl == null) {
Expand All @@ -281,6 +279,8 @@ private void initiateSDK(@Nullable RudderConsentFilter consentFilter) {
Collections.singletonMap(LABEL_TYPE, LABEL_TYPE_DATA_PLANE_URL_INVALID));
return;
}
if (serverConfig.source.sourceConfiguration != null)
enableStatsCollection(application, writeKey, serverConfig.source.sourceConfiguration.getStatsCollection(), dataPlaneUrl);
if (consentFilter != null)
this.consentFilterHandler = new ConsentFilterHandler(serverConfig.source, consentFilter);
cloudModeManager.startCloudModeProcessor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ private ReportManager() {
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/";
private static final String METRICS_URL_PROD = "https://sdk-metrics.rudderstack.com/";
private static Metrics metrics = null;
private static ErrorClient errorStatsClient = null;

Expand Down Expand Up @@ -161,15 +159,15 @@ private static void incrementCounter(LongCounter counter, int value) {

@SuppressWarnings("ConstantConditions")
static void enableStatsCollection(Application application, String writeKey,
@NonNull SourceConfiguration.StatsCollection statsCollection) {
@NonNull SourceConfiguration.StatsCollection statsCollection, String dataPlaneUrl) {
if (!isStatsReporterAvailable()) {
if (!(statsCollection.getMetrics().isEnabled() || statsCollection.getErrors().isEnabled())) {
RudderLogger.logDebug("EventRepository: Stats collection is not enabled");
return;
}
RudderLogger.logDebug("EventRepository: Creating Stats Reporter");
initiateRudderReporter(application, writeKey, statsCollection.getMetrics().isEnabled(),
statsCollection.getErrors().isEnabled());
statsCollection.getErrors().isEnabled(), dataPlaneUrl);
RudderLogger.logDebug("EventRepository: Metrics collection is not initialized");
return;
}
Expand Down Expand Up @@ -211,10 +209,10 @@ private static void checkAndUpdateErrorsCollection(boolean isErrorsEnabled) {
}

private static void initiateRudderReporter(Context context, @Nullable String writeKey,
boolean isMetricsEnabled, boolean isErrorsEnabled) {
boolean isMetricsEnabled, boolean isErrorsEnabled, String dataPlaneUrl) {
RudderLogger.logDebug("EventRepository: Creating RudderReporter isMetricsEnabled: " + isMetricsEnabled + " isErrorsEnabled: " + isErrorsEnabled);
if (rudderReporter == null) {
rudderReporter = new DefaultRudderReporter(context, METRICS_URL_PROD,
rudderReporter = new DefaultRudderReporter(context, dataPlaneUrl,
getStatsConfig(writeKey), new GsonAdapter(), isMetricsEnabled, isErrorsEnabled);
rudderReporter.getSyncer().startScheduledSyncs(METRICS_UPLOAD_INTERVAL,
true, METRICS_FLUSH_COUNT);
Expand Down
Loading