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

Fix empty string for CLIENT_ID from being sent when user decides to opt in #144

Merged
merged 13 commits into from
Aug 10, 2023

Conversation

eliasyishak
Copy link
Contributor

Fixes:

This update will now ensure that an opted out user who decides to opt back in will have their newly generated CLIENT_ID string being sent to the event that is emitted on opt in/out


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

Copy link
Contributor

@andrewkolos andrewkolos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with mild concern

Comment on lines 587 to 589
_clientIdFile.writeAsStringSync('');

_clientId = _clientIdFile.readAsStringSync();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if _clientId should be behind an abstraction that prevents it becoming out-of-sync with the file contents, but I am afraid I don't have time to read the entire code base.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wouldn't be a bad idea actually. Creating a getter that just reads the contents of the file should suffice on the AnalyticsImpl instance.

Does that help with the mild concern?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect some construct that exposes a getter and setter. The getter would read the file (or return a cached value if we are confident or don't care that it has not changed). The setter would write the file and update the cached file. These two methods would be the only things that 1) interact with the file and 2) store the current/cached value.

If AnalyticsImpl were the only context we are interacting with the client ID file, then you could use a class property with a getter/setter. However, Initializer also interacts with the file, so you would need another construct (or rework Initializer into something else that's more general purpose (e.g. User or UserConfig). To reiterate, I have not read the whole codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see what you mean. I'll keep that in mind if we are altering the client id anywhere else within the instance but at the moment it is only being read in the AnalyticsImpl constructor and only gets reassigned within the setTelemetry method

@eliasyishak eliasyishak merged commit 295ff92 into dart-lang:main Aug 10, 2023
6 checks passed
@eliasyishak eliasyishak deleted the 143-fix-empty-client-id-string branch August 10, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants