@@ -200,7 +200,9 @@ object ConstructorIo {
200200 groupIdFilter : String? = null,
201201 preFilterExpression : String? = null,
202202 sectionFacets : Map <String , List <Pair <String , List <String >>>>? = null,
203- fmtOptions : Map <String , Any >? = null
203+ fmtOptions : Map <String , Any >? = null,
204+ slCampaignId : String? = null,
205+ slCampaignOwner : String? = null
204206 ): ArrayList <Pair <String , String >> {
205207
206208 val encodedParams: ArrayList <Pair <String , String >> = arrayListOf ()
@@ -263,6 +265,8 @@ object ConstructorIo {
263265 }
264266 }
265267 showHiddenFacets?.let { encodedParams.add(Constants .QueryConstants .FMT_OPTIONS .format(Constants .QueryConstants .SHOW_HIDDEN_FACETS ).urlEncode() to showHiddenFacets.toString().urlEncode()) }
268+ slCampaignId?.let { encodedParams.add(" sl_campaign_id" .urlEncode() to it.urlEncode()) }
269+ slCampaignOwner?.let { encodedParams.add(" sl_campaign_owner" .urlEncode() to it.urlEncode()) }
266270 groupsSortBy?.let { encodedParams.add(Constants .QueryConstants .FMT_OPTIONS .format(Constants .QueryConstants .GROUPS_SORT_BY ).urlEncode() to groupsSortBy.urlEncode()) }
267271 groupsSortOrder?.let { encodedParams.add(Constants .QueryConstants .FMT_OPTIONS .format(Constants .QueryConstants .GROUPS_SORT_ORDER ).urlEncode() to groupsSortOrder.urlEncode()) }
268272 resultId?.let { encodedParams.add(Constants .QueryConstants .RESULT_ID .urlEncode() to it.urlEncode()) }
@@ -1442,6 +1446,7 @@ object ConstructorIo {
14421446 }
14431447
14441448 /* *
1449+ * @deprecated Prefer [trackSearchResultsLoaded] with an array of [TrackingItem] in place of an array of strings for customerIds.
14451450 * Tracks search results loaded (a.k.a. search results viewed) events.
14461451 *
14471452 * Example:
@@ -1454,17 +1459,37 @@ object ConstructorIo {
14541459 * @param analyticsTags Additional analytics tags to pass
14551460 */
14561461 fun trackSearchResultsLoaded (term : String , resultCount : Int , customerIds : Array <String >? = null, analyticsTags : Map <String , String >? = null) {
1457- var completable = trackSearchResultsLoadedInternal(term, resultCount, customerIds, analyticsTags)
1458- disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, {
1459- t -> e(" Search Results Loaded error: ${t.message} " )
1460- }))
1462+ var completable = trackSearchResultsLoadedInternal(term, resultCount, customerIds = customerIds, analyticsTags = analyticsTags)
1463+ disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, { t -> e(" Search Results Loaded error: ${t.message} " ) }))
1464+ }
1465+
1466+ /* *
1467+ * Tracks search results loaded (a.k.a. search results viewed) events.
1468+ *
1469+ * Example:
1470+ * ```
1471+ * ConstructorIo.trackSearchResultsLoaded("tooth", 789, arrayOf(TrackingItem("1234", "2345", "camp1234", "owner-A"))
1472+ * ```
1473+ * @param term the term that results are displayed for, i.e. "Pumpkin"
1474+ * @param resultCount the number of results for that term
1475+ * @param items the list of items shown
1476+ * @param analyticsTags Additional analytics tags to pass
1477+ */
1478+ fun trackSearchResultsLoaded (term : String , resultCount : Int , items : Array <TrackingItem >, analyticsTags : Map <String , String >? = null) {
1479+ var completable = trackSearchResultsLoadedInternal(term, resultCount, items = items, analyticsTags = analyticsTags)
1480+ disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, { t -> e(" Search Results Loaded error: ${t.message} " ) }))
14611481 }
1462- internal fun trackSearchResultsLoadedInternal (term : String , resultCount : Int , customerIds : Array <String >? = null, analyticsTags : Map <String , String >? = null): Completable {
1482+
1483+ internal fun trackSearchResultsLoadedInternal (term : String , resultCount : Int , customerIds : Array <String >? = null, items : Array <TrackingItem >? = null, analyticsTags : Map <String , String >? = null): Completable {
14631484 preferenceHelper.getSessionId(sessionIncrementHandler)
1464- val items = customerIds?.map{ item -> TrackingItem (item, null )}
1485+ val itemsList: List <TrackingItem >? = when {
1486+ items != null -> items.toList()
1487+ customerIds != null -> customerIds.map { id -> TrackingItem (id, null , null , null ) }
1488+ else -> null
1489+ }
14651490 val searchResultLoadRequestBody = SearchResultLoadRequestBody (
14661491 term,
1467- items ,
1492+ itemsList ,
14681493 resultCount,
14691494 " Not Available" ,
14701495 BuildConfig .CLIENT_VERSION ,
@@ -1497,7 +1522,7 @@ object ConstructorIo {
14971522 * @param searchTerm the term that results are displayed for, i.e. "Pumpkin"
14981523 * @param sectionName the section that the results came from, i.e. "Products"
14991524 * @param resultID the result ID of the search response that the click came from
1500- */
1525+ */
15011526 fun trackSearchResultClick (itemName : String , customerId : String , searchTerm : String = Constants .QueryConstants .TERM_UNKNOWN , sectionName : String? = null, resultID : String? = null) {
15021527 var completable = trackSearchResultClickInternal(itemName, customerId, null , searchTerm, sectionName, resultID)
15031528
@@ -1527,9 +1552,9 @@ object ConstructorIo {
15271552 }))
15281553 }
15291554
1530- internal fun trackSearchResultClickInternal (itemName : String , customerId : String , variationId : String? , searchTerm : String = Constants .QueryConstants .TERM_UNKNOWN , sectionName : String? = null, resultID : String? = null): Completable {
1555+ internal fun trackSearchResultClickInternal (itemName : String , customerId : String , variationId : String? , searchTerm : String = Constants .QueryConstants .TERM_UNKNOWN , sectionName : String? = null, resultID : String? = null, slCampaignId : String? = null, slCampaignOwner : String? = null ): Completable {
15311556 preferenceHelper.getSessionId(sessionIncrementHandler)
1532- val encodedParams: ArrayList <Pair <String , String >> = getEncodedParams(resultId = resultID)
1557+ val encodedParams: ArrayList <Pair <String , String >> = getEncodedParams(resultId = resultID, slCampaignId = slCampaignId, slCampaignOwner = slCampaignOwner )
15331558 val sName = sectionName ? : preferenceHelper.defaultItemSection
15341559 return dataManager.trackSearchResultClick(itemName, customerId, variationId, searchTerm, arrayOf(
15351560 Constants .QueryConstants .SECTION to sName
@@ -1622,7 +1647,7 @@ object ConstructorIo {
16221647 * @param revenue the revenue of the purchase event
16231648 * @param orderID the identifier of the order
16241649 * @param analyticsTags Additional analytics tags to pass
1625- */
1650+ */
16261651 fun trackPurchase (customerIds : Array <String >, revenue : Double? , orderID : String , sectionName : String? = null, analyticsTags : Map <String , String >? = null) {
16271652 val items = customerIds.map { item -> PurchaseItem (item) }
16281653 var completable = trackPurchaseInternal(items.toTypedArray(), revenue, orderID, sectionName, analyticsTags)
@@ -1677,6 +1702,7 @@ object ConstructorIo {
16771702 }
16781703
16791704 /* *
1705+ * @deprecated Prefer [trackBrowseResultsLoaded] with an array of [TrackingItem] in place of an array of strings for itemIds.
16801706 * Tracks browse result loaded (a.k.a. browse results viewed) events.
16811707 *
16821708 * Example:
@@ -1690,10 +1716,26 @@ object ConstructorIo {
16901716 * @param analyticsTags Additional analytics tags to pass
16911717 */
16921718 fun trackBrowseResultsLoaded (filterName : String , filterValue : String , itemIds : Array <String >, resultCount : Int , sectionName : String? = null, url : String = "Not Available ", analyticsTags : Map <String , String >? = null) {
1693- var completable = trackBrowseResultsLoadedInternal(filterName, filterValue, itemIds, resultCount, sectionName, url, analyticsTags)
1694- disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, {
1695- t -> e(" Browse Results Loaded error: ${t.message} " )
1696- }))
1719+ var completable = trackBrowseResultsLoadedInternal(filterName, filterValue, itemIds = itemIds, resultCount = resultCount, sectionName = sectionName, url = url, analyticsTags = analyticsTags)
1720+ disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, { t -> e(" Browse Results Loaded error: ${t.message} " ) }))
1721+ }
1722+
1723+ /* *
1724+ * Tracks browse result loaded (a.k.a. browse results viewed) events.
1725+ *
1726+ * Example:
1727+ * ```
1728+ * ConstructorIo.trackBrowseResultsLoaded("Category", "Snacks", arrayOf(TrackingItem("1234", "2345", "camp1234", "owner-A")), 674)
1729+ * ```
1730+ * @param filterName the name of the primary filter, i.e. "Aisle"
1731+ * @param filterValue the value of the primary filter, i.e. "Produce"
1732+ * @param items the list of the displayed items
1733+ * @param resultCount the number of results for that filter name/value pair
1734+ * @param analyticsTags Additional analytics tags to pass
1735+ */
1736+ fun trackBrowseResultsLoaded (filterName : String , filterValue : String , items : Array <TrackingItem >, resultCount : Int , sectionName : String? = null, url : String = "Not Available ", analyticsTags : Map <String , String >? = null) {
1737+ var completable = trackBrowseResultsLoadedInternal(filterName, filterValue, items = items, resultCount = resultCount, sectionName = sectionName, url = url, analyticsTags = analyticsTags)
1738+ disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, { t -> e(" Browse Results Loaded error: ${t.message} " ) }))
16971739 }
16981740
16991741 /* *
@@ -1709,20 +1751,24 @@ object ConstructorIo {
17091751 * @param analyticsTags Additional analytics tags to pass
17101752 */
17111753 fun trackBrowseResultsLoaded (filterName : String , filterValue : String , resultCount : Int , sectionName : String? = null, url : String = "Not Available ", analyticsTags : Map <String , String >? = null) {
1712- var completable = trackBrowseResultsLoadedInternal(filterName, filterValue, null , resultCount, sectionName, url, analyticsTags)
1754+ var completable = trackBrowseResultsLoadedInternal(filterName, filterValue, null , null , resultCount, sectionName, url, analyticsTags)
17131755 disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, {
17141756 t -> e(" Browse Results Loaded error: ${t.message} " )
17151757 }))
17161758 }
17171759
1718- internal fun trackBrowseResultsLoadedInternal (filterName : String , filterValue : String , itemIds : Array <String >? = null, resultCount : Int , sectionName : String? = null, url : String = "Not Available ", analyticsTags : Map <String , String >? = null): Completable {
1760+ internal fun trackBrowseResultsLoadedInternal (filterName : String , filterValue : String , itemIds : Array <String >? = null, items : Array < TrackingItem > ? = null, resultCount : Int , sectionName : String? = null, url : String = "Not Available ", analyticsTags : Map <String , String >? = null): Completable {
17191761 preferenceHelper.getSessionId(sessionIncrementHandler)
17201762 val section = sectionName ? : preferenceHelper.defaultItemSection
1721- val items = itemIds?.map{ item -> TrackingItem (item, null )}
1763+ val itemsList: List <TrackingItem >? = when {
1764+ items != null -> items.toList()
1765+ itemIds != null -> itemIds.map { id -> TrackingItem (id, null , null , null ) }
1766+ else -> null
1767+ }
17221768 val browseResultLoadRequestBody = BrowseResultLoadRequestBody (
17231769 filterName,
17241770 filterValue,
1725- items ,
1771+ itemsList ,
17261772 resultCount,
17271773 url,
17281774 BuildConfig .CLIENT_VERSION ,
@@ -1757,9 +1803,11 @@ object ConstructorIo {
17571803 * @param sectionName the section that the results came from, i.e. "Products"
17581804 * @param resultID the result ID of the browse response that the selection came from
17591805 * @param analyticsTags Additional analytics tags to pass
1806+ * @param slCampaignId The campaign id of the clicked item
1807+ * @param slCampaignOwner The campaign owner of the clicked item
17601808 */
1761- fun trackBrowseResultClick (filterName : String , filterValue : String , customerId : String , resultPositionOnPage : Int , sectionName : String? = null, resultID : String? = null, analyticsTags : Map <String , String >? = null) {
1762- var completable = trackBrowseResultClickInternal(filterName, filterValue, customerId, null , resultPositionOnPage, sectionName, resultID, analyticsTags)
1809+ fun trackBrowseResultClick (filterName : String , filterValue : String , customerId : String , resultPositionOnPage : Int , sectionName : String? = null, resultID : String? = null, analyticsTags : Map <String , String >? = null, slCampaignId : String? = null, slCampaignOwner : String? = null ) {
1810+ var completable = trackBrowseResultClickInternal(filterName, filterValue, customerId, null , resultPositionOnPage, sectionName, resultID, slCampaignId, slCampaignOwner, analyticsTags)
17631811 disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, {
17641812 t -> e(" Browse Result Click error: ${t.message} " )
17651813 }))
@@ -1780,15 +1828,17 @@ object ConstructorIo {
17801828 * @param sectionName the section that the results came from, i.e. "Products"
17811829 * @param resultID the result ID of the browse response that the selection came from
17821830 * @param analyticsTags Additional analytics tags to pass
1831+ * @param slCampaignId The campaign id of the clicked item
1832+ * @param slCampaignOwner The campaign owner of the clicked item
17831833 */
1784- fun trackBrowseResultClick (filterName : String , filterValue : String , customerId : String , variationId : String , resultPositionOnPage : Int , sectionName : String? = null, resultID : String? = null, analyticsTags : Map <String , String >? = null) {
1785- var completable = trackBrowseResultClickInternal(filterName, filterValue, customerId, variationId, resultPositionOnPage, sectionName, resultID, analyticsTags)
1834+ fun trackBrowseResultClick (filterName : String , filterValue : String , customerId : String , variationId : String , resultPositionOnPage : Int , sectionName : String? = null, resultID : String? = null, analyticsTags : Map <String , String >? = null, slCampaignId : String? = null, slCampaignOwner : String? = null ) {
1835+ var completable = trackBrowseResultClickInternal(filterName, filterValue, customerId, variationId, resultPositionOnPage, sectionName, resultID, slCampaignId, slCampaignOwner, analyticsTags)
17861836 disposable.add(completable.subscribeOn(Schedulers .io()).subscribe({}, {
17871837 t -> e(" Browse Result Click error: ${t.message} " )
17881838 }))
17891839 }
17901840
1791- internal fun trackBrowseResultClickInternal (filterName : String , filterValue : String , customerId : String , variationId : String? = null, resultPositionOnPage : Int , sectionName : String? = null, resultID : String? = null, analyticsTags : Map <String , String >? = null): Completable {
1841+ internal fun trackBrowseResultClickInternal (filterName : String , filterValue : String , customerId : String , variationId : String? = null, resultPositionOnPage : Int , sectionName : String? = null, resultID : String? = null, slCampaignId : String? = null, slCampaignOwner : String? = null, analyticsTags : Map <String , String >? = null): Completable {
17921842 preferenceHelper.getSessionId(sessionIncrementHandler)
17931843 val section = sectionName ? : preferenceHelper.defaultItemSection
17941844 val browseResultClickRequestBody = BrowseResultClickRequestBody (
@@ -1808,6 +1858,8 @@ object ConstructorIo {
18081858 section,
18091859 System .currentTimeMillis(),
18101860 resultID,
1861+ slCampaignId,
1862+ slCampaignOwner,
18111863 )
18121864
18131865 return dataManager.trackBrowseResultClick(
@@ -2110,7 +2162,7 @@ object ConstructorIo {
21102162 internal fun trackRecommendationResultsViewInternal (podId : String , itemIds : Array <String >? = null, numResultsViewed : Int , resultPage : Int? = null, resultCount : Int? = null, resultId : String? = null, sectionName : String? = null, url : String = "Not Available ", analyticsTags : Map <String , String >? = null): Completable {
21112163 preferenceHelper.getSessionId(sessionIncrementHandler)
21122164 val section = sectionName ? : preferenceHelper.defaultItemSection
2113- val items = itemIds?.map{ item -> TrackingItem (item, null )}
2165+ val items = itemIds?.map{ item -> TrackingItem (item, null , null , null )}
21142166 val recommendationResultViewRequestBody = RecommendationResultViewRequestBody (
21152167 podId,
21162168 items,
0 commit comments