Skip to content

Commit 0d217bb

Browse files
racingDeveloperdavide-scalzo
authored andcommitted
Disable IP address Geolocalizaiton for GDPR related issues on iOS (davide-scalzo#145)
* Added method to disalbe ip address geolocalization on iOS * Exporting the method * Fixed typo
1 parent 1f5837f commit 0d217bb

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

RNMixpanel/Mixpanel.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@
9393
*/
9494
@property (atomic) NSUInteger flushInterval;
9595

96+
/*!
97+
@property
98+
99+
@abstract
100+
Controls whether to automatically send the client IP Address as part of
101+
event tracking. With an IP address, geo-location is possible down to neighborhoods
102+
within a city, although the Mixpanel Dashboard will just show you city level location
103+
specificity. For privacy reasons, you may be in a situation where you need to forego
104+
effectively having access to such granular location information via the IP Address.
105+
106+
@discussion
107+
Defaults to YES.
108+
*/
109+
@property (atomic) BOOL useIPAddressForGeoLocation;
110+
96111
/*!
97112
@property
98113

RNMixpanel/RNMixpanel.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,14 @@ -(Mixpanel*) getInstance: (NSString *)name {
8686
resolve(nil);
8787
}
8888

89+
// disable ip address geolocalization
90+
RCT_EXPORT_METHOD(disableIpAddressGeolocalization:(NSString *)apiToken
91+
resolve:(RCTPromiseResolveBlock)resolve
92+
reject:(RCTPromiseRejectBlock)reject) {
93+
[self getInstance:apiToken].useIPAddressForGeoLocation = NO;
94+
resolve(nil);
95+
}
96+
8997
// track with properties
9098
RCT_EXPORT_METHOD(trackWithProperties:(NSString *)event
9199
properties:(NSDictionary *)properties

index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ export class MixpanelInstance {
7171
return RNMixpanel.flush(this.apiToken)
7272
}
7373

74+
disableIpAddressGeolocalization(): Promise<void> {
75+
if (!this.initialized) throw new Error(uninitializedError('disableIpAddressGeolocalization'))
76+
return RNMixpanel.disableIpAddressGeolocalization(this.apiToken)
77+
}
78+
7479
alias(alias: string): Promise<void> {
7580
if (!this.initialized) throw new Error(uninitializedError('createAlias'))
7681

@@ -241,6 +246,12 @@ export default {
241246
defaultInstance.flush()
242247
},
243248

249+
disableIpAddressGeolocalization() {
250+
if (!defaultInstance) throw new Error(NO_INSTANCE_ERROR)
251+
252+
defaultInstance.disableIpAddressGeolocalization()
253+
},
254+
244255
createAlias(alias: string) {
245256
if (!defaultInstance) throw new Error(NO_INSTANCE_ERROR)
246257

0 commit comments

Comments
 (0)