Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Example/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
platform :ios, '13.0'

#use_frameworks!

Expand Down
12 changes: 6 additions & 6 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
PODS:
- Analytics (4.1.3)
- Expecta (1.0.6)
- Intercom (9.3.1)
- Intercom (16.0.2)
- OCHamcrest (7.2.0)
- OCMockito (5.1.3):
- OCHamcrest (~> 7.0)
- Segment-Intercom (1.0.1):
- Segment-Intercom (1.0.2):
- Analytics
- Intercom
- Specta (1.0.7)
Expand All @@ -32,12 +32,12 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Analytics: 4c01e3e19d4be86705bad6581a1c2aa5a15a9d22
Expecta: 3b6bd90a64b9a1dcb0b70aa0e10a7f8f631667d5
Intercom: f87679713dab3105d3144880ddbf1f0fa1bd00a1
Intercom: 605585b4c8d59f47269dde4f70c9702fbe0e8612
OCHamcrest: 8097ab14ab9366f44cd66638aa589fea3840d779
OCMockito: 677cbb4a18fd492b5a4fb10144dada4de5ddb877
Segment-Intercom: 6c242e7c0eb6b6972d2db87ec85bdc24e2aa066c
Segment-Intercom: 8dd32f465076ae88aef3780becc254a472ed1000
Specta: 3e1bd89c3517421982dc4d1c992503e48bd5fe66

PODFILE CHECKSUM: 814d22aada40c6f5e3be731b2811ed77a5378fad
PODFILE CHECKSUM: 93e9b54371f0f3d8c37db72a568846114fd24fcb

COCOAPODS: 1.10.1
COCOAPODS: 1.13.0
5 changes: 3 additions & 2 deletions Example/Segment-Intercom.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -441,7 +442,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down Expand Up @@ -475,7 +476,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.3;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
Expand Down
18 changes: 11 additions & 7 deletions Example/Tests/Tests.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
} context:@{}
integrations:@{}];
[integration identify:identifyPayload];
[verify(mockIntercom) registerUserWithUserId:@"3942084234230"];
ICMUserAttributes *attributes = [ICMUserAttributes new];
attributes.userId = @"3942084234230";
[verify(mockIntercom) loginUserWithUserAttributes:attributes success:nil failure:nil];
});

it(@"calls track without properties", ^{
Expand Down Expand Up @@ -100,7 +102,7 @@
ICMUserAttributes *userAttributes = [ICMUserAttributes new];
userAttributes.companies = @[ company ];

[verify(mockIntercom) updateUser:userAttributes];
[verify(mockIntercom) updateUser:userAttributes success:nil failure:nil];
});

it(@"calls track with revenue and total", ^{
Expand Down Expand Up @@ -191,7 +193,7 @@
} context:@{}
integrations:@{}];
[integration identify:identifyPayload];
[verify(mockIntercom) registerUnidentifiedUser];
[verify(mockIntercom) loginUnidentifiedUserWithSuccess:nil failure:nil];
});

it(@"calls track with properties", ^{
Expand Down Expand Up @@ -301,7 +303,7 @@
userAttributes.companies = @[ company ];

[integration identify:identifyPayload];
[verify(mockIntercom) updateUser:userAttributes];
[verify(mockIntercom) updateUser:userAttributes success:nil failure:nil];
});

it(@"identfies a known user with traits", ^{
Expand Down Expand Up @@ -337,19 +339,21 @@
};

[integration identify:identifyPayload];
[verify(mockIntercom) updateUser:userAttributes];
[verify(mockIntercom) updateUser:userAttributes success:nil failure:nil];
});

it(@"identfies a known user without traits", ^{
SEGIdentifyPayload *identifyPayload = [[SEGIdentifyPayload alloc] initWithUserId:@"3942084234230" anonymousId:nil traits:@{} context:@{} integrations:@{}];

[integration identify:identifyPayload];
[verify(mockIntercom) registerUserWithUserId:@"3942084234230"];
ICMUserAttributes *attributes = [ICMUserAttributes new];
attributes.userId = @"3942084234230";
[verify(mockIntercom) loginUserWithUserAttributes:attributes success:nil failure:nil];
});

it(@"resets user", ^{
[integration reset];
[verify(mockIntercom) reset];
[verify(mockIntercom) logout];
});

});
Expand Down
20 changes: 11 additions & 9 deletions Segment-Intercom/Classes/SEGIntercomIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ - (void)identify:(SEGIdentifyPayload *)payload
{
// Intercom allows users to choose to track only known or only unknown users, as well as both. Segment will support the ability to track both by checking for loggedIn users (determined by the userId) and falling back to setting the user as "Unidentified" if this is not present.
if (payload.userId) {
[self.intercom registerUserWithUserId:payload.userId];
SEGLog(@"[Intercom registerUserWithUserId:%@];", payload.userId);
ICMUserAttributes *attributes = [ICMUserAttributes new];
attributes.userId = payload.userId;
[self.intercom loginUserWithUserAttributes:attributes success:nil failure:nil];
SEGLog(@"[Intercom loginUserWithUserAttributes:%@];", payload.userId);
} else if (payload.anonymousId) {
[self.intercom registerUnidentifiedUser];
SEGLog(@"[Intercom registerUnidentifiedUser];");
[self.intercom loginUnidentifiedUserWithSuccess:nil failure:nil];
SEGLog(@"[Intercom loginUnidentifiedUserWithSuccess];");
}

NSDictionary *integration = [payload.integrations valueForKey:@"intercom"];
Expand Down Expand Up @@ -96,7 +98,7 @@ - (void)track:(SEGTrackPayload *)payload
[price setObject:finalAmount forKey:@"amount"];

[output removeObjectForKey:key];
isAmountSet = @YES;
isAmountSet = true;
}

if ([key isEqual:@"currency"]) {
Expand Down Expand Up @@ -130,14 +132,14 @@ - (void)group:(SEGGroupPayload *)payload
ICMUserAttributes *userAttributes = [ICMUserAttributes new];
userAttributes.companies = @[ company ];

[self.intercom updateUser:userAttributes];
[self.intercom updateUser:userAttributes success:nil failure:nil];
SEGLog(@"[Intercom updateUser:%@];", userAttributes);
}

- (void)reset
{
[self.intercom reset];
SEGLog(@" [Intercom reset];");
[self.intercom logout];
SEGLog(@" [Intercom logout];");
}

#pragma mark - Utils
Expand Down Expand Up @@ -204,7 +206,7 @@ - (void)setUserAttributes:(SEGIdentifyPayload *)payload
}

userAttributes.customAttributes = customAttributes;
[self.intercom updateUser:userAttributes];
[self.intercom updateUser:userAttributes success:nil failure:nil];
SEGLog(@"[Intercom updateUser:%@];", userAttributes);
}

Expand Down