This repository was archived by the owner on Jun 20, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -200,13 +200,7 @@ class AnalyticsImpl implements Analytics {
200
200
}
201
201
202
202
@override
203
- String get clientId => properties['clientId' ];
204
-
205
- void _initClientId () {
206
- if (clientId == null ) {
207
- properties['clientId' ] = new Uuid ().generateV4 ();
208
- }
209
- }
203
+ String get clientId => properties['clientId' ] ?? = new Uuid ().generateV4 ();
210
204
211
205
/**
212
206
* Send raw data to analytics. Callers should generally use one of the typed
@@ -227,8 +221,6 @@ class AnalyticsImpl implements Analytics {
227
221
if (! enabled) return new Future .value ();
228
222
229
223
if (_bucket.removeDrop ()) {
230
- _initClientId ();
231
-
232
224
_variableMap.forEach ((key, value) {
233
225
args[key] = value;
234
226
});
Original file line number Diff line number Diff line change @@ -62,6 +62,28 @@ void defineTests() {
62
62
mock.sendScreenView ('baz' );
63
63
return mock.waitForLastPing (timeout: new Duration (milliseconds: 100 ));
64
64
});
65
+
66
+ group ('clientId' , () {
67
+ test ('is available immediately' , () {
68
+ AnalyticsImplMock mock = createMock ();
69
+ expect (mock.clientId, isNotEmpty);
70
+ });
71
+
72
+ test ('is memoized' , () {
73
+ AnalyticsImplMock mock = createMock ();
74
+ final value1 = mock.clientId;
75
+ final value2 = mock.clientId;
76
+ expect (value1, isNotEmpty);
77
+ expect (value1, value2);
78
+ });
79
+
80
+ test ('is stored in properties' , () {
81
+ AnalyticsImplMock mock = createMock ();
82
+ expect (mock.properties['clientId' ], isNull);
83
+ final value = mock.clientId;
84
+ expect (mock.properties['clientId' ], value);
85
+ });
86
+ });
65
87
});
66
88
67
89
group ('postEncode' , () {
You can’t perform that action at this time.
0 commit comments