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

Fall back to using Segment integration when we cannot get settings #636

Merged
merged 4 commits into from
Nov 23, 2016

Conversation

tonyxiao
Copy link
Contributor

@tonyxiao tonyxiao commented Nov 23, 2016

cc @f2prateek @ladanazita

To repro the original buggy behavior

  1. Put device in airplane mode and open app
  2. Send an event Application Launched 1
  3. Force kill the app via task switcher
  4. Disable airplane mode and regain internet access
  5. Launch the app again, send another event Application Launched 2
  6. Observe that Application Launched 2 will hit tracking API, while Application Launched 1 will be missing.

Basically what happens is that during step 2, if the settings request were to fail, no integrations would be initialized (segment included). This hotfix falls back to segment integration in those cases and we'll have a more comprehensive set of fixes to address this from a design level in development branch.

@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Analytics"
s.version = "3.5.3"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should stay as is.

@@ -562,8 +562,16 @@ - (void)refreshSettings
self.settingsRequest = [self.httpClient settingsForWriteKey:self.configuration.writeKey completionHandler:^(BOOL success, NSDictionary *settings) {
if (success) {
[self setCachedSettings:settings];
} else {
// Hotfix: If settings request fail, fall back to using just Segment integration
Copy link
Contributor

Choose a reason for hiding this comment

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

Hotfix seems like a weird comment to leave in. I'd rather put in something like "todo: we need to fix this behaviour"

@@ -583,7 +591,7 @@ + (void)debug:(BOOL)showDebugLogs

+ (NSString *)version
{
return @"3.5.3";
Copy link
Contributor

Choose a reason for hiding this comment

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

Should stay as (same as above) and updated as part of the release process.

@tonyxiao
Copy link
Contributor Author

@f2prateek updated

@f2prateek
Copy link
Contributor

@tonyxiao nice, Let's do a quick manual test to verify the offline behaviour and get this out (adding one more comment but shouldn't block the change)

// Won't catch situation where this callback never gets called - that will get addressed separately in regular dev
[self setCachedSettings:@{
@"integrations": @{
@"Segment.io": @{ @"apiKey": self.configuration.writeKey },
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually instead of doing setCachedSettings we should do updateIntegrationWithSettings (can't do this yet because the code references self.cachedSettings directly in a few places)>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Wanted to change as few lines as possible since this is a hotfix. It'll become a lot more clear in dev.

@tonyxiao
Copy link
Contributor Author

@f2prateek Yea I did a manual test and verified that it behaves as expected. Merging.

@tonyxiao tonyxiao merged commit 7d4cecb into master Nov 23, 2016
@tonyxiao tonyxiao deleted the release-3.5.4 branch November 23, 2016 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants