Skip to content

Commit 94d1824

Browse files
committed
Initial flutter lite commit
0 parents  commit 94d1824

55 files changed

Lines changed: 10887 additions & 0 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
coverage/
13+
doc/
14+
tool/
15+
pubspec.lock
16+
17+
# IntelliJ related
18+
*.iml
19+
*.ipr
20+
*.iws
21+
.idea/
22+
23+
# The .vscode folder contains launch configuration and tasks you configure in
24+
# VS Code which you may wish to be included in version control, so this line
25+
# is commented out by default.
26+
.vscode/
27+
28+
# Flutter/Dart/Pub related
29+
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
30+
/pubspec.lock
31+
**/doc/api/
32+
.dart_tool/
33+
.flutter-plugins
34+
.flutter-plugins-dependencies
35+
build/
36+
example/flutter_example/.dart_tool/
37+
example/flutter_example/.idea/
38+
example/flutter_example/flutter_*.iml
39+
example/flutter_example/build/
40+
example/flutter_example/.flutter-plugins
41+
example/flutter_example/.flutter-plugins-dependencies
42+
example/flutter_example/pubspec.lock
43+
example/flutter_example/android
44+
example/flutter_example/ios
45+
android/.gradle/

CHANGELOG.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
## 26.1.0-rc.1
2+
3+
* Initial SDK release with the following functionalities:
4+
5+
* Initialization:
6+
* `Countly.init(config)` - Initialize the SDK with configuration
7+
* `Countly.defaultInstance` - Access the default SDK instance
8+
* `Countly.instance(key)` - Access a specific SDK instance by key
9+
* `Countly.disposeInstance(key)` - Dispose a specific SDK instance
10+
* `Countly.disposeAll()` - Dispose all SDK instances
11+
* Multi-instance support with unique instance keys
12+
13+
* Configuration Options (CountlyConfig)
14+
* `appKey` (required) - Application key
15+
* `serverUrl` (required) - Server URL (http:// or https://)
16+
* `deviceId` - Custom device ID (auto-generated if not provided)
17+
* `userProperties` - Initial user properties to set
18+
* `storageMode` - Storage mode (persistent or memory)
19+
* `storageMethods` - Custom storage implementation
20+
* `startWithUnknownConsent` - Start in unknown consent mode
21+
* `giveConsent` - Grant consent at initialization
22+
* `logLevel` - Logging verbosity level (error, warning, info, debug, verbose)
23+
* `logger` - Custom logger implementation (SdkLogger interface)
24+
* `enableSDKLogs` - Enable SDK internal logging
25+
* `enableVisualWarnings` - Show visual warnings (toasts) for SDK errors/warnings
26+
* `customRequestHeaders` - Custom HTTP headers for requests
27+
* `deviceMetricOverrides` - Override collected device metrics
28+
* `sbs` - Initial SDK Behavior Settings
29+
* `disableOldDataMigration` - Disable migration from legacy native SDKs
30+
31+
* Events Module (sdk.events)
32+
* `record(key, count, sum, dur, segmentation)` - Record custom events with optional parameters
33+
* `recordMetrics(metricOverride)` - Record device metrics with optional overrides
34+
* Segmentation support for strings, numbers, booleans, and lists
35+
36+
* Views Module (sdk.views)
37+
* `startAutoStoppedView(viewName, {segmentation})` - Start an auto-stopped view
38+
* `endActiveView({segmentation})` - End the currently active view
39+
* Automatic view duration tracking with heartbeat mechanism
40+
* View state recovery after app restart
41+
42+
* Users Module (sdk.users)
43+
* `setProperties(props)` - Set user properties (named and custom)
44+
* `pushToArray(key, values)` - Add values to array property (allows duplicates)
45+
* `addToSet(key, values)` - Add unique values to array property
46+
* `pullFromArray(key, values)` - Remove values from array property
47+
* Named properties: name, username, email, organization, phone, picture, gender, byear
48+
49+
* Consents Module (sdk.consents)
50+
* `giveConsent()` - Grant consent for data collection
51+
* `revokeConsent()` - Revoke consent and clear data
52+
* Unknown consent state support
53+
54+
* Device ID Module (sdk.id)
55+
* `changeWithMerge(newDeviceId)` - Change device ID with server-side merge
56+
* `changeWithoutMerge(newDeviceId)` - Change device ID without merge (new user)
57+
* `deviceId` - Read-only access to current device ID
58+
* `deviceIdType` - Read-only access to device ID type (provided/generated)
59+
60+
* SDK Behavior Settings (SBS)
61+
* Server-side configuration support
62+
* Automatic SBS fetching and caching
63+
* Queue size limits (event/request queues)
64+
* Key/value length limits
65+
* Tracking control (global, events, views)
66+
* Event blacklist/whitelist filtering
67+
* User properties blacklist/whitelist filtering
68+
* Segmentation blacklist/whitelist filtering
69+
* Event-specific segmentation filtering
70+
71+
* Storage
72+
* Persistent storage support (SharedPreferences)
73+
* Memory-only storage mode
74+
* Custom storage methods override
75+
* Legacy native SDK data migration (Android/iOS)
76+
77+
* Networking
78+
* Automatic request queuing and retry
79+
* Request backoff mechanism
80+
* Custom HTTP headers support
81+
* Health check reporting
82+
83+
* Logging
84+
* Configurable log levels
85+
* Custom logger implementation support
86+
* Visual warnings (toasts) on Flutter
87+

README.md

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
# Countly Flutter Lite SDK
2+
3+
This repository contains the non-bridged and lightweight Flutter Lite SDK which can be integrated into mobile application. The Countly Flutter Lite SDK is intended to be used with [Countly Lite](https://countly.com/lite), [Countly Flex](https://countly.com/flex), [Countly Enterprise](https://countly.com/enterprise).
4+
5+
## What is Countly?
6+
7+
[Countly](https://countly.com) is a product analytics solution and innovation enabler that helps teams track product performance and customer journey and behavior across [mobile](https://countly.com/mobile-analytics), [web](https://countly.com/web-analytics), and [desktop](https://countly.com/desktop-analytics) applications.
8+
9+
Track, measure, and take action - all without leaving Countly.
10+
11+
* **Questions or feature requests?** [Join the Countly Community on Discord](https://discord.gg/countly)
12+
* **Looking for the Countly Server?** [Countly Server repository](https://github.com/Countly/countly-server)
13+
14+
## Integrating Countly SDK in your projects
15+
16+
For a detailed description on how to use this SDK [check out our documentation](https://support.count.ly/hc/en-us/articles/).
17+
18+
For an example integration of this SDK, see the [Flutter example app in this repository](https://github.com/Countly/countly-sdk-dart/tree/main/example/flutter_example).
19+
20+
This SDK supports the following features:
21+
22+
* Analytics
23+
* User Profiles
24+
* Views
25+
* Consent management
26+
* Device ID management
27+
28+
## Installation
29+
30+
In the `dependencies:` section of your `pubspec.yaml`, add the following line:
31+
32+
```yaml
33+
dependencies:
34+
countly_flutter_lite: <latest_version>
35+
```
36+
37+
## Usage
38+
39+
### Initialization
40+
41+
```dart
42+
import 'package:countly_flutter_lite/countly.dart';
43+
import 'package:flutter/widgets.dart';
44+
45+
void main() async {
46+
WidgetsFlutterBinding.ensureInitialized();
47+
48+
final config = CountlyConfig(
49+
appKey: 'YOUR_APP_KEY',
50+
serverUrl: 'https://your.server.com',
51+
giveConsent: true,
52+
enableSDKLogs: true,
53+
);
54+
55+
await Countly.init(config);
56+
runApp(const MyApp());
57+
}
58+
```
59+
60+
### Configuration Options
61+
62+
```dart
63+
final config = CountlyConfig(
64+
appKey: 'YOUR_APP_KEY', // Required: Your Countly app key
65+
serverUrl: 'https://server.com', // Required: Your Countly server URL
66+
deviceId: 'custom-device-id', // Optional: Custom device ID
67+
giveConsent: true, // Optional: Grant consent at init
68+
startWithUnknownConsent: false, // Optional: Start with unknown consent
69+
enableSDKLogs: true, // Optional: Enable logging
70+
logLevel: LogLevel.verbose, // Optional: Log verbosity
71+
enableVisualWarnings: false, // Optional: Show visual warnings
72+
customRequestHeaders: { // Optional: Custom HTTP headers
73+
'X-Custom-Header': 'value',
74+
},
75+
deviceMetricOverrides: { // Optional: Override device metrics
76+
'_os': 'CustomOS',
77+
},
78+
userProperties: { // Optional: Initial user properties
79+
'name': 'John Doe',
80+
'tier': 'premium',
81+
},
82+
disableOldDataMigration: false, // Optional: Disable legacy migration
83+
);
84+
85+
// storageMode is optional:
86+
// - if omitted, Flutter Lite uses persistent storage
87+
// - if set (e.g. StorageMode.memory), your explicit value is respected
88+
89+
```
90+
91+
### Recording Events
92+
93+
```dart
94+
final sdk = Countly.defaultInstance!;
95+
96+
await sdk.events.record(key: 'button_click');
97+
await sdk.events.record(key: 'item_purchased', count: 3);
98+
await sdk.events.record(key: 'purchase', sum: 29.99);
99+
await sdk.events.record(key: 'video_watched', dur: 120.5);
100+
101+
await sdk.events.record(
102+
key: 'purchase',
103+
count: 1,
104+
sum: 99.99,
105+
dur: 5.0,
106+
segmentation: {
107+
'product_id': 'SKU123',
108+
'category': 'electronics',
109+
'tags': ['featured', 'sale'],
110+
},
111+
);
112+
```
113+
114+
### Recording Views
115+
116+
```dart
117+
final sdk = Countly.defaultInstance!;
118+
119+
await sdk.views.startAutoStoppedView('HomePage');
120+
await sdk.views.startAutoStoppedView('ProductPage', segmentation: {
121+
'category': 'electronics',
122+
});
123+
await sdk.views.endActiveView(segmentation: {
124+
'exit': 'back_button',
125+
});
126+
```
127+
128+
### User Profiles
129+
130+
```dart
131+
final sdk = Countly.defaultInstance!;
132+
133+
await sdk.users.setProperties({
134+
'name': 'John Doe',
135+
'email': 'john@example.com',
136+
'username': 'johndoe',
137+
'phone': '+1234567890',
138+
'gender': 'M',
139+
'byear': 1990,
140+
});
141+
142+
await sdk.users.pushToArray('viewed_products', ['SKU123', 'SKU456']);
143+
await sdk.users.addToSet('categories', ['electronics', 'books']);
144+
await sdk.users.pullFromArray('interests', ['outdated']);
145+
```
146+
147+
### Consent Management
148+
149+
```dart
150+
final sdk = Countly.defaultInstance!;
151+
152+
await sdk.consents.giveConsent();
153+
await sdk.consents.revokeConsent();
154+
```
155+
156+
### Device ID Management
157+
158+
```dart
159+
final sdk = Countly.defaultInstance!;
160+
161+
final deviceId = sdk.deviceId;
162+
await sdk.id.changeWithMerge('user_123456');
163+
await sdk.id.changeWithoutMerge('new_anonymous_id');
164+
await sdk.consents.giveConsent();
165+
```
166+
167+
### Multi-Instance Support
168+
169+
```dart
170+
final primary = await Countly.init(config);
171+
final secondary = await Countly.init(config2, instanceKey: 'secondary');
172+
173+
final primaryInstance = Countly.defaultInstance;
174+
final secondaryInstance = Countly.instance('secondary');
175+
176+
await Countly.disposeInstance('secondary');
177+
await Countly.disposeAll();
178+
```
179+
180+
### Custom Logger
181+
182+
```dart
183+
class MyLogger implements SdkLogger {
184+
@override
185+
bool isEnabled(LogLevel level) => level.index <= LogLevel.info.index;
186+
187+
@override
188+
void log(LogLevel level, String message, {Object? error, StackTrace? stack}) {
189+
print('[${level.name}] $message');
190+
}
191+
}
192+
193+
final config = CountlyConfig(
194+
appKey: 'YOUR_APP_KEY',
195+
serverUrl: 'https://your.server.com',
196+
logger: MyLogger(),
197+
enableSDKLogs: true,
198+
);
199+
```
200+
201+
## Security
202+
203+
Security is very important to us. If you discover any issue regarding security, please disclose the information responsibly by sending an email to <security@countly.com> and **not by creating a GitHub issue**.
204+
205+
## Badges
206+
207+
If you like Countly, [why not use one of our badges](https://countly.com/brand-assets) and give a link back to us so others know about this wonderful platform?
208+
209+
<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/dark.svg?v2" alt="Countly - Product Analytics" /></a>
210+
211+
```JS
212+
<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/dark.svg" alt="Countly - Product Analytics" /></a>
213+
```
214+
215+
<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/light.svg?v2" alt="Countly - Product Analytics" /></a>
216+
217+
```JS
218+
<a href="https://count.ly/f/badge" rel="nofollow"><img style="width:145px;height:60px" src="https://countly.com/badges/light.svg" alt="Countly - Product Analytics" /></a>
219+
```
220+
221+
## How can I help you with your efforts?
222+
223+
Glad you asked! For community support, feature requests, and engaging with the Countly Community, please join us at [our Discord Server](https://discord.gg/countly). We're excited to have you there!
224+
225+
Also, we are on [Twitter](https://twitter.com/gocountly) and [LinkedIn](https://www.linkedin.com/company/countly) if you would like to keep up with Countly related updates.

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include: package:flutter_lints/flutter.yaml

android/build.gradle

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
plugins {
2+
id 'com.android.library'
3+
id 'org.jetbrains.kotlin.android'
4+
}
5+
6+
android {
7+
namespace 'ly.count.dart.countly_flutter_lite'
8+
compileSdkVersion 34
9+
10+
defaultConfig {
11+
minSdkVersion 21
12+
}
13+
14+
compileOptions {
15+
sourceCompatibility JavaVersion.VERSION_1_8
16+
targetCompatibility JavaVersion.VERSION_1_8
17+
}
18+
19+
kotlinOptions {
20+
jvmTarget = '1.8'
21+
}
22+
}
23+
24+
dependencies {
25+
implementation 'androidx.annotation:annotation:1.8.0'
26+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<manifest package="ly.count.dart.countly_flutter_lite" />

0 commit comments

Comments
 (0)