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: use latest Amplitude Browser 2 SDK (2.11.10) for flutter SDK web #216

Merged
merged 21 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
cd95079
WIP: have updated sdk able to track events, using js_interop_unsafe
chungdaniel Dec 5, 2024
7d28b49
WIP: Add a few methods to handleMethodCall
chungdaniel Dec 9, 2024
2ce053f
WIP: able to initialize amplitude without errors
chungdaniel Dec 18, 2024
4532d58
WIP: have created classes for js_interop for configuration, event
chungdaniel Dec 20, 2024
2e70401
WIP: removed js_interop classes as they were redundant to dart classes
chungdaniel Dec 30, 2024
cbb59aa
chore: Update documentation for running example app for web
chungdaniel Dec 31, 2024
ed6ef00
chore: remove comments, add helper method
chungdaniel Dec 31, 2024
2af5022
chore: update min flutter version in README
chungdaniel Dec 31, 2024
8ee5b8d
Add new configuration members to .toMap and use []= operator
chungdaniel Dec 31, 2024
e52c63e
Group configuration by platform
chungdaniel Jan 1, 2025
d6ea6c7
feat: add optOut for browser SDK
chungdaniel Jan 6, 2025
0b789c4
fix: Address PR comments:
chungdaniel Jan 6, 2025
2d39e15
chore: reword doc for getEvent
chungdaniel Jan 6, 2025
4ca04d8
chore: fix lint issues
chungdaniel Jan 7, 2025
59281d1
chore: add new configuration options to test
chungdaniel Jan 7, 2025
d2cd976
chore: add new config to test
chungdaniel Jan 7, 2025
a6f5c65
Update swift-lint.yml
chungdaniel Jan 7, 2025
8b270bb
Use macos-13
chungdaniel Jan 7, 2025
cbfd0df
Update swift-lint.yml
chungdaniel Jan 7, 2025
1c7a8e7
remove test key
chungdaniel Jan 7, 2025
52c0e96
remove offline config for all platforms
chungdaniel Jan 8, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/swift-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on: [pull_request]

jobs:
lint:
runs-on: macos-12
runs-on: macos-13
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set Xcode 14
- name: Set Xcode 14.1
run: |
sudo xcode-select -switch /Applications/Xcode_14.1.app

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ From Amplitude Flutter v4, we bump up the kotlin version to v1.9.22 to support l

The following matrix lists the minimum support for Amplitude Flutter SDK version.

| Amplitude Flutter | Gradle | Android Gradle Plugin | Kotlin Gradle Plugin |
|-------------------|-------|-----------------------|----------------------|
| `4.+` | `8.2` | `8.2.2` | `1.9.22` |
| Flutter | Amplitude Flutter | Gradle | Android Gradle Plugin | Kotlin Gradle Plugin |
|---------|-------------------|-------|-----------------------|-----------------------|
|`3.3+` | `4.+` | `8.2` | `8.2.2` | `1.9.22` |


Learn more about the Android [Gradle Plugin compatibility](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle), [Gradle compatibility](https://docs.gradle.org/current/userguide/compatibility.html#kotlin), and [Kotlin compatibility](https://kotlinlang.org/docs/whatsnew17.html#bumping-minimum-supported-versions).
Expand Down
11 changes: 8 additions & 3 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ A few resources to get you started if this is your first Flutter project:
- [Lab: Write your first Flutter app](https://flutter.io/docs/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://flutter.io/docs/cookbook)

For help getting started with Flutter, view our
[online documentation](https://flutter.io/docs), which offers tutorials,
For help getting started with Flutter, view our
[online documentation](https://flutter.io/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.


## Run the example
Assuming you have Flutter setup on your machine.
Assuming you have Flutter setup on your machine.

Update your Amplitude API key in `lib/main.dart`.

Expand All @@ -31,3 +31,8 @@ flutter run
```shell
flutter run -d chrome
```
In some cases (e.g. Chrome with forced sign-in), above command may not work well.
Use the below command to start the server, then follow the printed link in console.
```shell
flutter run -d web-server --web-port=5000 --web-enable-expression-evaluation
```
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.amplitude_flutter_example"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>9.0</string>
<string>12.0</string>
</dict>
</plist>
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ SPEC CHECKSUMS:
amplitude_flutter: aed4ad5d2da06894245fde7e8c56fed39ac6dca8
AmplitudeSwift: cc22038404dc5581e2dea5dc2501302959dd3c90
AnalyticsConnector: a53214d38ae22734c6266106c0492b37832633a9
Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7

PODFILE CHECKSUM: cc1f88378b4bfcf93a6ce00d2c587857c6008d3b

COCOAPODS: 1.15.2
COCOAPODS: 1.16.2
13 changes: 8 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -164,7 +164,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0910;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "The Chromium Authors";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -232,10 +232,12 @@
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
Expand All @@ -246,6 +248,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
Expand Down Expand Up @@ -349,7 +352,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -427,7 +430,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -474,7 +477,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
4 changes: 4 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>CADisableMinimumFrameDurationOnPhone</key>
<true/>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
1 change: 1 addition & 0 deletions example/lib/app_state.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: depend_on_referenced_packages
import 'package:amplitude_flutter/amplitude.dart';
import 'package:flutter/material.dart';

Expand Down
7 changes: 4 additions & 3 deletions example/lib/device_id_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import 'app_state.dart';

class DeviceIdForm extends StatefulWidget {
@override
_DeviceIdFormState createState() => _DeviceIdFormState();
// ignore: library_private_types_in_public_api
State<DeviceIdForm> createState() => _DeviceIdFormState();
}

class _DeviceIdFormState extends State<DeviceIdForm> {
Expand All @@ -12,7 +13,7 @@ class _DeviceIdFormState extends State<DeviceIdForm> {
AppState
.of(context)
.analytics
..setDeviceId(deviceId);
.setDeviceId(deviceId);
};
}

Expand All @@ -23,7 +24,7 @@ class _DeviceIdFormState extends State<DeviceIdForm> {
children: <Widget>[
Text('Device Id', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
new TextField(
TextField(
autocorrect: false,
decoration: InputDecoration(labelText: 'Device Id'),
onChanged: makeHandler(context),
Expand Down
4 changes: 3 additions & 1 deletion example/lib/event_form.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import 'package:flutter/material.dart';

// ignore_for_file: depend_on_referenced_packages
import 'package:amplitude_flutter/events/base_event.dart';

import 'app_state.dart';

class EventForm extends StatefulWidget {
@override
_EventFormState createState() => _EventFormState();
State<EventForm> createState() => _EventFormState();
}

class _EventFormState extends State<EventForm> {
Expand Down
6 changes: 3 additions & 3 deletions example/lib/flush_thresholds_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'app_state.dart';

class FlushThresholdForm extends StatefulWidget {
@override
_FlushThresholdFormState createState() => _FlushThresholdFormState();
State<FlushThresholdForm> createState() => _FlushThresholdFormState();
}

class _FlushThresholdFormState extends State<FlushThresholdForm> {
Expand All @@ -20,7 +20,7 @@ class _FlushThresholdFormState extends State<FlushThresholdForm> {
if (eventUploadThresholdInput.text.isNotEmpty && value != null) {
AppState.of(context)
// ..analytics.setEventUploadThreshold(value)
..setMessage('Event upload threshold set.');
.setMessage('Event upload threshold set.');
}
}

Expand All @@ -30,7 +30,7 @@ class _FlushThresholdFormState extends State<FlushThresholdForm> {
if (eventUploadPeriodMillisInput.text.isNotEmpty && value != null) {
AppState.of(context)
// ..analytics.setEventUploadPeriodMillis(value)
..setMessage('Event upload period millis set.');
.setMessage('Event upload period millis set.');
}
}

Expand Down
2 changes: 1 addition & 1 deletion example/lib/group_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'app_state.dart';

class GroupForm extends StatefulWidget {
@override
_GroupFormState createState() => _GroupFormState();
State<GroupForm> createState() => _GroupFormState();
}

class _GroupFormState extends State<GroupForm> {
Expand Down
3 changes: 2 additions & 1 deletion example/lib/group_identify_form.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// ignore_for_file: depend_on_referenced_packages
import 'package:amplitude_flutter/events/identify.dart';
import 'package:flutter/material.dart';

import 'app_state.dart';

class GroupIdentifyForm extends StatefulWidget {
@override
_GroupIdentifyFormState createState() => _GroupIdentifyFormState();
State<GroupIdentifyForm> createState() => _GroupIdentifyFormState();
}

class _GroupIdentifyFormState extends State<GroupIdentifyForm> {
Expand Down
3 changes: 2 additions & 1 deletion example/lib/identify_form.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// ignore_for_file: depend_on_referenced_packages
import 'package:amplitude_flutter/events/identify.dart';
import 'package:flutter/material.dart';

import 'app_state.dart';

class IdentifyForm extends StatefulWidget {
@override
_IdentifyFormState createState() => _IdentifyFormState();
State<IdentifyForm> createState() => _IdentifyFormState();
}

class _IdentifyFormState extends State<IdentifyForm> {
Expand Down
3 changes: 2 additions & 1 deletion example/lib/my_app.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';

// ignore_for_file: depend_on_referenced_packages
import 'package:amplitude_flutter/amplitude.dart';
import 'package:amplitude_flutter/configuration.dart';
import 'package:amplitude_flutter/constants.dart';
Expand All @@ -22,7 +23,7 @@ class MyApp extends StatefulWidget {
final String apiKey;

@override
_MyAppState createState() => _MyAppState();
State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
Expand Down
2 changes: 1 addition & 1 deletion example/lib/reset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'app_state.dart';

class ResetForm extends StatefulWidget {
@override
_DeviceState createState() => _DeviceState();
State<ResetForm> createState() => _DeviceState();
}

class _DeviceState extends State<ResetForm> {
Expand Down
3 changes: 2 additions & 1 deletion example/lib/revenue_form.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// ignore_for_file: depend_on_referenced_packages
import 'package:amplitude_flutter/events/revenue.dart';

import 'app_state.dart';

class RevenueForm extends StatefulWidget {
@override
_RevenueFormState createState() => _RevenueFormState();
State<RevenueForm> createState() => _RevenueFormState();
}

class _RevenueFormState extends State<RevenueForm> {
Expand Down
18 changes: 6 additions & 12 deletions example/lib/user_id_form.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import 'package:flutter/material.dart';

import 'app_state.dart';

class UserIdForm extends StatefulWidget {
@override
_UserIdFormState createState() => _UserIdFormState();
State<UserIdForm> createState() => _UserIdFormState();
}

class _UserIdFormState extends State<UserIdForm> {
void Function(String) makeHandler(BuildContext context) {
return (String userId) {
AppState.of(context).analytics..setUserId(userId.isEmpty ? null : userId);
AppState
.of(context)
.analytics
.setUserId(userId.isEmpty ? null : userId);
};
}

Expand All @@ -19,17 +21,9 @@ class _UserIdFormState extends State<UserIdForm> {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
// Text('Current User Id', style: Theme.of(context).textTheme.headlineSmall),
// FutureBuilder(
// // future: AppState.of(context).analytics.getUserId(),
// builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
// return Text(snapshot.data.toString());
// },
// ),
// const SizedBox(height: 10),
Text('User Id', style: Theme.of(context).textTheme.headlineSmall),
const SizedBox(height: 10),
new TextField(
TextField(
autocorrect: false,
decoration: InputDecoration(labelText: 'User Id'),
onChanged: makeHandler(context)),
Expand Down
Loading
Loading