-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add preset traffic source attributes (#10)
Co-authored-by: zhu-xiaowei <[email protected]>
- Loading branch information
1 parent
2996028
commit 8e0891d
Showing
8 changed files
with
230 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.4.0 | ||
|
||
* feat: add preset traffic source attributes | ||
|
||
## 0.3.0 | ||
|
||
* feat: add record screen view api | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import 'mock_method_channel.dart'; | ||
|
||
void main() { | ||
TestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
MockMethodChannel platform = MockMethodChannel(); | ||
|
||
test('init method for UnimplementedError', () async { | ||
Map<String, Object?> initConfig = { | ||
'appId': 'testApp', | ||
'endpoint': "", | ||
}; | ||
expect(() async { | ||
await platform.init(initConfig); | ||
}, throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('record method for UnimplementedError', () async { | ||
Map<String, Object?> attributes = { | ||
"category": "shoes", | ||
"currency": "CNY", | ||
"value": 279.9 | ||
}; | ||
expect(platform.record(attributes), | ||
throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('setUserId method for UnimplementedError', () async { | ||
Map<String, Object?> attributes = { | ||
"userId": "1234", | ||
}; | ||
expect(platform.setUserId(attributes), | ||
throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('setUserAttributes method for UnimplementedError', () async { | ||
Map<String, Object?> attributes = {"_user_age": 21, "_user_name": "carl"}; | ||
expect(platform.setUserAttributes(attributes), | ||
throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('addGlobalAttributes method for UnimplementedError', () async { | ||
Map<String, Object?> attributes = { | ||
"channel": "Play Store", | ||
"level": 5.1, | ||
"class": 6 | ||
}; | ||
expect(platform.addGlobalAttributes(attributes), | ||
throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('deleteGlobalAttributes method for UnimplementedError', () async { | ||
Map<String, Object?> attributes = { | ||
"attributes": ["attr1", "attr2"], | ||
}; | ||
expect(platform.deleteGlobalAttributes(attributes), | ||
throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('updateConfigure method for UnimplementedError', () async { | ||
Map<String, Object?> attributes = { | ||
"appId": "newAppId", | ||
"endpoint": "https://example.com/collect", | ||
}; | ||
expect(platform.updateConfigure(attributes), | ||
throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('flushEvents method for UnimplementedError', () async { | ||
expect(platform.flushEvents(), throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('disable method for UnimplementedError', () async { | ||
expect(platform.disable(), throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
|
||
test('enable method for UnimplementedError', () async { | ||
expect(platform.enable(), throwsA(isInstanceOf<UnimplementedError>())); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:clickstream_analytics/clickstream_analytics_platform_interface.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/services.dart'; | ||
|
||
/// An implementation of [ClickstreamFlutterPlatform] that uses method channels. | ||
class MockMethodChannel extends ClickstreamInterface { | ||
/// The method channel used to interact with the native platform. | ||
@visibleForTesting | ||
final methodChannel = const MethodChannel('clickstream_flutter'); | ||
|
||
@override | ||
Future<bool> init(Map<String, Object?> configure) async { | ||
return super.init(configure); | ||
} | ||
|
||
@override | ||
Future<void> record(Map<String, Object?> attributes) async { | ||
return super.record(attributes); | ||
} | ||
|
||
@override | ||
Future<void> setUserId(Map<String, Object?> userId) async { | ||
return super.setUserId(userId); | ||
} | ||
|
||
@override | ||
Future<void> setUserAttributes(Map<String, Object?> attributes) async { | ||
return super.setUserAttributes(attributes); | ||
} | ||
|
||
@override | ||
Future<void> addGlobalAttributes(Map<String, Object?> attributes) async { | ||
return super.addGlobalAttributes(attributes); | ||
} | ||
|
||
@override | ||
Future<void> deleteGlobalAttributes(Map<String, Object?> attributes) async { | ||
return super.deleteGlobalAttributes(attributes); | ||
} | ||
|
||
@override | ||
Future<void> updateConfigure(Map<String, Object?> configure) async { | ||
return super.updateConfigure(configure); | ||
} | ||
|
||
@override | ||
Future<void> flushEvents() async { | ||
return super.flushEvents(); | ||
} | ||
|
||
@override | ||
Future<void> disable() async { | ||
return super.disable(); | ||
} | ||
|
||
@override | ||
Future<void> enable() async { | ||
return super.enable(); | ||
} | ||
} |