-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from mzanoni/master
Added promo measurements
- Loading branch information
Showing
7 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
src/AnalyticsTracker.Tests/Messages/EnhancedEcommerce/PromoClickMeasurementTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using NUnit.Framework; | ||
using Vertica.AnalyticsTracker.Commands.EnhancedEcommerce.FieldObjects; | ||
using Vertica.AnalyticsTracker.Messages.EnhancedEcommerce; | ||
|
||
namespace AnalyticsTracker.Tests.Messages.EnhancedEcommerce | ||
{ | ||
[TestFixture] | ||
public class PromoClickMeasurementTester | ||
{ | ||
[Test] | ||
public void RenderMessage_AddsPromoView() | ||
{ | ||
var subj = new PromoClickMeasurement(new[] { new PromoFieldObject("JUNE_PROMO13", "June Sale") }); | ||
var renderedMessage = subj.RenderMessage(); | ||
Assert.That(renderedMessage, Is.StringContaining("{'event': 'promotionClick','ecommerce': {'promoClick': {'promotions': [{'id': 'JUNE_PROMO13','name': 'June Sale'}]}}}")); | ||
} | ||
|
||
[Test] | ||
public void RenderMessage_AddsPromoViewWithOptional() | ||
{ | ||
var subj = new PromoClickMeasurement(new[] { new PromoFieldObject("JUNE_PROMO13", "June Sale", creative: "banner1", position: "slot1") }); | ||
var renderedMessage = subj.RenderMessage(); | ||
Assert.That(renderedMessage, Is.StringContaining("{'event': 'promotionClick','ecommerce': {'promoClick': {'promotions': [{'id': 'JUNE_PROMO13','name': 'June Sale','creative': 'banner1','position': 'slot1'}]}}}")); | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/AnalyticsTracker.Tests/Messages/EnhancedEcommerce/PromoViewMeasurementTester.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using NUnit.Framework; | ||
using Vertica.AnalyticsTracker.Commands.EnhancedEcommerce.FieldObjects; | ||
using Vertica.AnalyticsTracker.Messages.EnhancedEcommerce; | ||
|
||
namespace AnalyticsTracker.Tests.Messages.EnhancedEcommerce | ||
{ | ||
[TestFixture] | ||
public class PromoViewMeasurementTester | ||
{ | ||
[Test] | ||
public void RenderMessage_AddsPromoView() | ||
{ | ||
var subj = new PromoViewMeasurement(new[] { new PromoFieldObject("JUNE_PROMO13", "June Sale") }); | ||
var renderedMessage = subj.RenderMessage(); | ||
Assert.That(renderedMessage, Is.StringContaining("{'ecommerce': {'promoView': {'promotions': [{'id': 'JUNE_PROMO13','name': 'June Sale'}]}}}")); | ||
} | ||
|
||
[Test] | ||
public void RenderMessage_AddsPromoViewWithOptional() | ||
{ | ||
var subj = new PromoViewMeasurement(new[] { new PromoFieldObject("JUNE_PROMO13", "June Sale", creative: "banner1", position: "slot1") }); | ||
var renderedMessage = subj.RenderMessage(); | ||
Assert.That(renderedMessage, Is.StringContaining("{'ecommerce': {'promoView': {'promotions': [{'id': 'JUNE_PROMO13','name': 'June Sale','creative': 'banner1','position': 'slot1'}]}}}")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/AnalyticsTracker/Commands/EnhancedEcommerce/FieldObjects/PromoFieldObject.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Vertica.AnalyticsTracker.Commands.EnhancedEcommerce.FieldObjects | ||
{ | ||
public class PromoFieldObject | ||
{ | ||
private readonly Dictionary<string, object> _info = new Dictionary<string, object>(); | ||
|
||
public PromoFieldObject(string id, string name, string creative = null, string position = null) | ||
{ | ||
_info["id"] = id; | ||
_info["name"] = name; | ||
_info["creative"] = creative; | ||
_info["position"] = position; | ||
} | ||
|
||
public Dictionary<string, object> Info => _info; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/AnalyticsTracker/Messages/EnhancedEcommerce/PromoClickMeasurement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Vertica.AnalyticsTracker.Commands.EnhancedEcommerce.FieldObjects; | ||
|
||
namespace Vertica.AnalyticsTracker.Messages.EnhancedEcommerce | ||
{ | ||
public class PromoClickMeasurement : EnhancedEcommerceMeasurementBase | ||
{ | ||
private readonly PromoFieldObject[] _promoFieldObjects; | ||
|
||
public PromoClickMeasurement(PromoFieldObject[] promoFieldObjects) : base("promotionClick") | ||
{ | ||
_promoFieldObjects = promoFieldObjects; | ||
} | ||
|
||
public override Dictionary<string, object> CreateMeasurement() | ||
{ | ||
var promotions = | ||
new Dictionary<string, object> { { "promotions", _promoFieldObjects.Select(i => i.Info).ToArray() } }; | ||
|
||
return new Dictionary<string, object> | ||
{ | ||
{ "promoClick", promotions } | ||
}; | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/AnalyticsTracker/Messages/EnhancedEcommerce/PromoViewMeasurement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Vertica.AnalyticsTracker.Commands.EnhancedEcommerce.FieldObjects; | ||
|
||
namespace Vertica.AnalyticsTracker.Messages.EnhancedEcommerce | ||
{ | ||
public class PromoViewMeasurement : EnhancedEcommerceMeasurementBase | ||
{ | ||
private readonly PromoFieldObject[] _promoFieldObjects; | ||
|
||
public PromoViewMeasurement(PromoFieldObject[] promoFieldObjects) | ||
{ | ||
_promoFieldObjects = promoFieldObjects; | ||
} | ||
|
||
public override Dictionary<string, object> CreateMeasurement() | ||
{ | ||
var promotions = | ||
new Dictionary<string, object> { { "promotions", _promoFieldObjects.Select(i => i.Info).ToArray() } }; | ||
|
||
return new Dictionary<string, object> | ||
{ | ||
{ "promoView", promotions } | ||
}; | ||
} | ||
} | ||
} |