Skip to content
Draft
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
23 changes: 18 additions & 5 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,36 @@ rootProject.allprojects {

apply plugin: 'com.android.library'

android {
// Conditional for compatibility with AGP <4.2.
if (project.android.hasProperty("namespace")) {
namespace 'ly.count.dart.countly_flutter'
// ---- SDK VERSION PARSE ----
def properties = new File("${rootDir}/../scripts/config/sdk_versions.txt")

def androidSdkVersion = null

properties.eachLine { line ->
line = line.trim()
if (line.startsWith("android_sdk_version=")) {
androidSdkVersion = line.split("=")[1].trim()
}
}

println("Using Android Countly SDK version: " + androidSdkVersion)
// -------------------------------------

android {
namespace 'ly.count.dart.countly_flutter'
compileSdk 35

defaultConfig {
minSdkVersion 21
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

lintOptions {
disable 'InvalidPackage'
}
}

dependencies {
implementation 'ly.count.android:sdk:25.4.1'
implementation "ly.count.android:sdk:${androidSdkVersion}"
implementation 'com.google.firebase:firebase-messaging:24.0.3'
}
2 changes: 1 addition & 1 deletion lib/src/web/countly_flutter_plugin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class CountlyFlutterPlugin {
final head = querySelector('head');

// try this as module
final scriptTag = _createScriptTag(CountlyFlutterPluginConfig.WEB_SDK_URL);
final scriptTag = _createScriptTag(CountlyFlutterPluginConfig.getWebSDKUrl());
head?.children.add(scriptTag);
await scriptTag.onLoad.first;

Expand Down
21 changes: 20 additions & 1 deletion lib/src/web/plugin_config.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import 'dart:io';

class CountlyFlutterPluginConfig {
static const String SDK_VERSION_STRING = '25.4.1';
static const String SDK_NAME = 'dart-flutterb-web';
static const String WEB_SDK_URL = 'https://cdn.jsdelivr.net/npm/[email protected]/lib/countly.min.js';
static String WEB_SDK_URL = 'https://cdn.jsdelivr.net/npm/countly-sdk-web@{VERSION}/lib/countly.min.js';

static String getWebSDKUrl() {
final config = File('scripts/config/sdk_versions.txt').readAsLinesSync();

String webVersion = '';

for (var line in config) {
line = line.trim();
if (line.startsWith('web_sdk_version=')) {
webVersion = line.split('=')[1].trim();
break;
}
}

final url = WEB_SDK_URL.replaceFirst('{VERSION}', webVersion);
return url;
}
}
3 changes: 3 additions & 0 deletions scripts/config/sdk_versions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
android_sdk_version=25.4.6
ios_sdk_version=25.4.7
web_sdk_version=25.4.1