Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
fix(bridge): fix duplicated analytics client improving errors (segmen…
Browse files Browse the repository at this point in the history
…tio#162)

Co-authored-by: Rafael Lopez <rflpz@Rafaels-MacBook-Pro.local>
  • Loading branch information
rlopezapplaudo and Rafael Lopez authored Apr 13, 2020
1 parent 43c4fa1 commit 28a981d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@ class RNAnalyticsModule(context: ReactApplicationContext): ReactContextBaseJavaM
return promise.resolve(null)
}
else {
return promise.reject("E_SEGMENT_RECONFIGURED", "Duplicate Analytics client")
if (BuildConfig.DEBUG) {
return pomise.resolve(this)
}
else {
return promise.reject("E_SEGMENT_RECONFIGURED", "Segment Analytics Client was allocated multiple times, please check your environment.")
}

}
}

Expand Down
10 changes: 7 additions & 3 deletions packages/core/ios/RNAnalytics/RNAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ +(void)initialize {
return resolver(nil);
}
else {
return rejecter(@"E_SEGMENT_RECONFIGURED", @"Duplicate Analytics client", nil);
#if DEBUG
return resolver(self);
#else
return rejecter(@"E_SEGMENT_RECONFIGURED", @"Segment Analytics Client was allocated multiple times, please check your environment.", nil);
#endif
}
}

Expand All @@ -67,7 +71,7 @@ +(void)initialize {
@try {
[SEGAnalytics setupWithConfiguration:config];
}
@catch(NSException* error) {
@catch(NSError* error) {
return rejecter(@"E_SEGMENT_ERROR", @"Unexpected native Analtyics error", error);
}

Expand All @@ -85,7 +89,7 @@ +(void)initialize {
}

singletonJsonConfig = json;
resolver(nil);
return resolver(nil);
}

- (NSDictionary*)withContextAndIntegrations :(NSDictionary*)context :(NSDictionary*)integrations {
Expand Down

0 comments on commit 28a981d

Please sign in to comment.