Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercy811 committed Apr 4, 2024
1 parent 5b612af commit 47aa273
Show file tree
Hide file tree
Showing 21 changed files with 333 additions and 313 deletions.
9 changes: 9 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
include: package:lints/recommended.yaml

analyzer:
exclude: [lib/amplitude_web.dart, lib/web/amplitude_js.dart] # Uncomment when web is supported

linter:
rules:
- prefer_single_quotes
- prefer_relative_imports
6 changes: 3 additions & 3 deletions lib/amplitude.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Amplitude {
/// await amplitude.isBuilt;
/// ```
Amplitude(this.configuration, [MethodChannel? methodChannel]) {
_channel = methodChannel ?? this._channel;
_channel = methodChannel ?? _channel;
isBuilt = _init();
}

Expand Down Expand Up @@ -116,7 +116,7 @@ class Amplitude {
String groupType, String groupName, Identify identify,
[EventOptions? options]) async {
final event = GroupIdentifyEvent();
final group = Map<String, dynamic>();
final group = <String, dynamic>{};
group[groupType] = groupName;
event.groups = group;
event.groupProperties = identify.properties;
Expand All @@ -142,7 +142,7 @@ class Amplitude {
/// Note: This will also set groupType: groupName as a user property.
Future<void> setGroup(String groupType, dynamic groupName,
[EventOptions? options]) async {
if (!(groupName is String) && !(groupName is List<String>)) {
if (groupName is! String && groupName is! List<String>) {
// TODO(xinyi): log warn that groupName should be either a string or an array of string.
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class Configuration {
'appVersion': appVersion,
// This field doesn't belong to Configuration
// Pass it for FlutterLibraryPlugin
'library': "${Constants.packageName}/${Constants.packageVersion}"
'library': '${Constants.packageName}/${Constants.packageVersion}'
};
}
}
6 changes: 3 additions & 3 deletions lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
class Constants {
static const packageName = 'amplitude-flutter';
static const packageVersion = '4.0.0-beta.2';
static const identify_event = '\$identify';
static const group_identify_event = '\$groupidentify';
static const revenue_event = 'revenue_amount';
static const identifyEvent = '\$identify';
static const groupIdentifyEvent = '\$groupidentify';
static const revenueEvent = 'revenue_amount';

static const flushQueueSize = 30;
static const flushIntervalMillis = 30 * 1000; // 30 seconds
Expand Down
2 changes: 1 addition & 1 deletion lib/events/group_identify_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import '../constants.dart';
import 'base_event.dart';

class GroupIdentifyEvent extends BaseEvent {
GroupIdentifyEvent() : super(eventType: Constants.group_identify_event);
GroupIdentifyEvent() : super(eventType: Constants.groupIdentifyEvent);
}
1 change: 1 addition & 0 deletions lib/events/identify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ class Identify {
propertySet.add(property);
}

// ignore: constant_identifier_names
static const UNSET_VALUE = '-';
}
2 changes: 1 addition & 1 deletion lib/events/identify_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import '../constants.dart';
import 'base_event.dart';

class IdentifyEvent extends BaseEvent {
IdentifyEvent() : super(eventType: Constants.identify_event);
IdentifyEvent() : super(eventType: Constants.identifyEvent);
}
14 changes: 7 additions & 7 deletions lib/events/revenue.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import 'revenue_event.dart';

class RevenueConstants {
static const String revenueProductId = "\$productId";
static const String revenueQuantity = "\$quantity";
static const String revenuePrice = "\$price";
static const String revenueType = "\$revenueType";
static const String revenueReceipt = "\$receipt";
static const String revenueReceiptSig = "\$receiptSig";
static const String revenue = "\$revenue";
static const String revenueProductId = '\$productId';
static const String revenueQuantity = '\$quantity';
static const String revenuePrice = '\$price';
static const String revenueType = '\$revenueType';
static const String revenueReceipt = '\$receipt';
static const String revenueReceiptSig = '\$receiptSig';
static const String revenue = '\$revenue';
}

class Revenue {
Expand Down
2 changes: 1 addition & 1 deletion lib/events/revenue_event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import '../constants.dart';
import 'base_event.dart';

class RevenueEvent extends BaseEvent {
RevenueEvent() : super(eventType: Constants.revenue_event);
RevenueEvent() : super(eventType: Constants.revenueEvent);
}
10 changes: 10 additions & 0 deletions lib/identify.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,25 @@ import 'package:flutter/foundation.dart';
class Identify {
Identify() : payload = <String, dynamic>{};

// ignore: constant_identifier_names
static const String OP_SET = r'$set';
// ignore: constant_identifier_names
static const String OP_SET_ONCE = r'$setOnce';
// ignore: constant_identifier_names
static const String OP_ADD = r'$add';
// ignore: constant_identifier_names
static const String OP_APPEND = r'$append';
// ignore: constant_identifier_names
static const String OP_UNSET = r'$unset';
// ignore: constant_identifier_names
static const String OP_PREPEND = r'$prepend';
// ignore: constant_identifier_names
static const String OP_PREINSERT = r'$preInsert';
// ignore: constant_identifier_names
static const String OP_POSTINSERT = r'$postInsert';
// ignore: constant_identifier_names
static const String OP_REMOVE = r'$remove';
// ignore: constant_identifier_names
static const String OP_CLEAR_ALL = r'$clearAll';

final Map<String, dynamic> payload;
Expand Down
38 changes: 19 additions & 19 deletions lib/tracking_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,25 @@ class TrackingOptions {

Map<String, bool> toMap() {
return {
"ipAddress": ipAddress,
"language": language,
"platform": platform,
"region": region,
"dma": dma,
"country": country,
"city": city,
"carrier": carrier,
"deviceModel": deviceModel,
"deviceManufacturer": deviceManufacturer,
"osVersion": osVersion,
"osName": osName,
"versionName": versionName,
"adid": adid,
"appSetId": appSetId,
"deviceBrand": deviceBrand,
"latLag": latLag,
"apiLevel": apiLevel,
"idfv": idfv,
'ipAddress': ipAddress,
'language': language,
'platform': platform,
'region': region,
'dma': dma,
'country': country,
'city': city,
'carrier': carrier,
'deviceModel': deviceModel,
'deviceManufacturer': deviceManufacturer,
'osVersion': osVersion,
'osName': osName,
'versionName': versionName,
'adid': adid,
'appSetId': appSetId,
'deviceBrand': deviceBrand,
'latLag': latLag,
'apiLevel': apiLevel,
'idfv': idfv,
};
}
}
Expand Down
Loading

0 comments on commit 47aa273

Please sign in to comment.