Skip to content

Commit cc52933

Browse files
authored
Sends extra props on ecommerce events (#55)
1 parent 2b71af9 commit cc52933

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

Example/Tests/Tests.m

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286
it(@"tracks Order Completed with revenue if both total and revenue are present", ^{
287287
integration = [[SEGAmplitudeIntegration alloc] initWithSettings:@{ @"useLogRevenueV2" : @true } andAmplitude:amplitude andAmpRevenue:amprevenue andAmpIdentify:identify];
288288

289-
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:@{
289+
NSDictionary *props = @{
290290
@"checkout_id" : @"9bcf000000000000",
291291
@"order_id" : @"50314b8e",
292292
@"affiliation" : @"App Store",
@@ -304,19 +304,21 @@
304304
@"price" : @"21.99",
305305
@"quantity" : @"1"
306306
}
307-
}
308-
context:@{}
307+
};
308+
309+
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:props context:@{}
309310
integrations:@{}];
310311

311312
[integration track:payload];
312313
[[verify(amprevenue) setPrice:@8] setQuantity:1];
314+
[verify(amprevenue) setEventProperties:props];
313315
[verify(amplitude) logRevenueV2:amprevenue];
314316
});
315317

316318
it(@"tracks Order Completed with total if revenue is not present", ^{
317319
integration = [[SEGAmplitudeIntegration alloc] initWithSettings:@{ @"useLogRevenueV2" : @true } andAmplitude:amplitude andAmpRevenue:amprevenue andAmpIdentify:identify];
318320

319-
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:@{
321+
NSDictionary *props = @{
320322
@"checkout_id" : @"9bcf000000000000",
321323
@"order_id" : @"50314b8e",
322324
@"affiliation" : @"App Store",
@@ -333,19 +335,22 @@
333335
@"price" : @"21.99",
334336
@"quantity" : @"1"
335337
}
336-
}
338+
};
339+
340+
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:props
337341
context:@{}
338342
integrations:@{}];
339343

340344
[integration track:payload];
341345
[[verify(amprevenue) setPrice:@30.45] setQuantity:1];
346+
[verify(amprevenue) setEventProperties:props];
342347
[verify(amplitude) logRevenueV2:amprevenue];
343348
});
344349

345350
it(@"tracks Order Completed with revenue of type String", ^{
346351
integration = [[SEGAmplitudeIntegration alloc] initWithSettings:@{ @"useLogRevenueV2" : @true } andAmplitude:amplitude andAmpRevenue:amprevenue andAmpIdentify:identify];
347352

348-
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:@{
353+
NSDictionary *props = @{
349354
@"checkout_id" : @"9bcf000000000000",
350355
@"order_id" : @"50314b8e",
351356
@"affiliation" : @"App Store",
@@ -363,12 +368,14 @@
363368
@"price" : @"21.99",
364369
@"quantity" : @"1"
365370
}
366-
}
367-
context:@{}
371+
};
372+
373+
SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:@"Order Completed" properties:props context:@{}
368374
integrations:@{}];
369375

370376
[integration track:payload];
371377
[[verify(amprevenue) setPrice:@8] setQuantity:1];
378+
[verify(amprevenue) setEventProperties:props];
372379
[verify(amplitude) logRevenueV2:amprevenue];
373380
});
374381

Pod/Classes/SEGAmplitudeIntegration.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ - (void)trackLogRevenueV2:(NSDictionary *)properties andRevenueOrTotal:(NSNumber
177177
SEGLog(@"[AMPRevenue revenue] setRevenueType:%@];", revenueType);
178178
}
179179

180+
[self.amprevenue setEventProperties:properties];
181+
SEGLog(@"[AMPRevenue revenue] setEventProperties:%@];", properties);
182+
180183
[self.amplitude logRevenueV2:self.amprevenue];
181184
SEGLog(@"[Amplitude logRevenueV2:%@];", self.amprevenue);
182185
}

0 commit comments

Comments
 (0)