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

don't mutate properties or options #66

Closed
Changes from all commits
Commits
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
don't mutate properties or options
  • Loading branch information
lukepighetti committed Dec 28, 2023
commit 9cc0b0b81d6b5fe46ee84a3a3838b4a2b76d8a1f
13 changes: 8 additions & 5 deletions lib/src/posthog.dart
Original file line number Diff line number Diff line change
@@ -33,15 +33,18 @@ class Posthog {
Map<String, dynamic>? properties,
Map<String, dynamic>? options,
}) {
if (properties != null &&
!properties.containsKey('\$screen_name') &&
final _properties = properties == null ? null : {...properties};
final _options = options == null ? null : {...options};

if (_properties != null &&
!_properties.containsKey('\$screen_name') &&
this.currentScreen != null) {
properties['\$screen_name'] = this.currentScreen;
_properties['\$screen_name'] = this.currentScreen;
}
return _posthog.capture(
eventName: eventName,
properties: properties,
options: options,
properties: _properties,
options: _options,
);
}

Loading