Skip to content

Commit

Permalink
Merge pull request #10 from Nash0x7E2/offline
Browse files Browse the repository at this point in the history
Stopped sending events while in debug
  • Loading branch information
seenickcode committed Jul 21, 2019
2 parents 7cbaa92 + 3662404 commit 2b7d19f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.0.9] - 7/19/19
* Allowed user to specifiy whether to show debug logs
* Disabled sending events (by default) to Mixpanel during debugging.

## [1.0.8] - 7/04/19
* Updated Dart SDK constraints in pubspec
* Updated all dependencies
Expand Down
16 changes: 12 additions & 4 deletions lib/pure_mixpanel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ class Mixpanel {
final String token;
final bool debug;
final bool trackIp;
final bool showDebugLog;

Mixpanel({@required this.token, this.debug: false, this.trackIp: false});
Mixpanel({
@required this.token,
this.debug: false,
this.trackIp: false,
this.showDebugLog = true,
});

Future<http.Response> track(String eventName,
{String distinctID, Map<String, String> properties}) async {
Expand All @@ -28,11 +34,13 @@ class Mixpanel {
final uri = MixpanelUri.create(path: '/track', queryParameters: {
'data': payload,
'verbose': (this.debug ? '1' : '0'),
'ip': (this.trackIp ? '1': '0'),
'ip': (this.trackIp ? '1' : '0'),
});
if (debug) {
print(
'mixpanel req\n\tproperties: $properties\n\turi: ${uri.toString()}');
if (showDebugLog)
print(
'IN DEBUG NOT SENDING TO MIXPANEL: \n req\n\tproperties: $properties\n\turi: ${uri.toString()}');
return null;
}
return http.get(uri.toString());
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: pure_mixpanel
description: A new pure Dart library for Mixpanel analytics.
version: 1.0.8
version: 1.0.9
author: Nicholas Manning <puremixpanel@gmail.com>
homepage: https://github.com/seenickcode/pure_mixpanel

Expand Down

0 comments on commit 2b7d19f

Please sign in to comment.