@segment/analytics-browser-actions-tiktok-pixel 1.94.1-staging-1f6aa0a59.0 → 1.95.1-staging-ce1986724.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants.d.ts +2 -0
- package/dist/cjs/constants.js +6 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/fields/common_fields.d.ts +2 -0
- package/dist/cjs/{common_fields.js → fields/common_fields.js} +2 -113
- package/dist/cjs/fields/common_fields.js.map +1 -0
- package/dist/cjs/identify/generated-types.d.ts +0 -17
- package/dist/cjs/identify/index.js +10 -20
- package/dist/cjs/identify/index.js.map +1 -1
- package/dist/cjs/reportWebEvent/fields.d.ts +2 -0
- package/dist/cjs/reportWebEvent/fields.js +161 -0
- package/dist/cjs/reportWebEvent/fields.js.map +1 -0
- package/dist/cjs/reportWebEvent/generated-types.d.ts +62 -11
- package/dist/cjs/reportWebEvent/index.js +12 -24
- package/dist/cjs/reportWebEvent/index.js.map +1 -1
- package/dist/cjs/reportWebEvent/travel_fields.d.ts +2 -0
- package/dist/cjs/reportWebEvent/travel_fields.js +210 -0
- package/dist/cjs/reportWebEvent/travel_fields.js.map +1 -0
- package/dist/cjs/reportWebEvent/utils.d.ts +3 -0
- package/dist/cjs/reportWebEvent/utils.js +101 -0
- package/dist/cjs/reportWebEvent/utils.js.map +1 -0
- package/dist/cjs/reportWebEvent/vehicle_fields.d.ts +2 -0
- package/dist/cjs/reportWebEvent/vehicle_fields.js +255 -0
- package/dist/cjs/reportWebEvent/vehicle_fields.js.map +1 -0
- package/dist/cjs/types.d.ts +85 -29
- package/dist/cjs/utils.d.ts +4 -0
- package/dist/cjs/utils.js +18 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/constants.d.ts +2 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/fields/common_fields.d.ts +2 -0
- package/dist/esm/{common_fields.js → fields/common_fields.js} +1 -112
- package/dist/esm/fields/common_fields.js.map +1 -0
- package/dist/esm/identify/generated-types.d.ts +0 -17
- package/dist/esm/identify/index.js +10 -20
- package/dist/esm/identify/index.js.map +1 -1
- package/dist/esm/reportWebEvent/fields.d.ts +2 -0
- package/dist/esm/reportWebEvent/fields.js +158 -0
- package/dist/esm/reportWebEvent/fields.js.map +1 -0
- package/dist/esm/reportWebEvent/generated-types.d.ts +62 -11
- package/dist/esm/reportWebEvent/index.js +12 -24
- package/dist/esm/reportWebEvent/index.js.map +1 -1
- package/dist/esm/reportWebEvent/travel_fields.d.ts +2 -0
- package/dist/esm/reportWebEvent/travel_fields.js +207 -0
- package/dist/esm/reportWebEvent/travel_fields.js.map +1 -0
- package/dist/esm/reportWebEvent/utils.d.ts +3 -0
- package/dist/esm/reportWebEvent/utils.js +98 -0
- package/dist/esm/reportWebEvent/utils.js.map +1 -0
- package/dist/esm/reportWebEvent/vehicle_fields.d.ts +2 -0
- package/dist/esm/reportWebEvent/vehicle_fields.js +252 -0
- package/dist/esm/reportWebEvent/vehicle_fields.js.map +1 -0
- package/dist/esm/types.d.ts +85 -29
- package/dist/esm/utils.d.ts +4 -0
- package/dist/esm/utils.js +15 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/constants.ts +2 -0
- package/src/{common_fields.ts → fields/common_fields.ts} +1 -114
- package/src/identify/generated-types.ts +0 -65
- package/src/identify/index.ts +10 -20
- package/src/reportWebEvent/__tests__/index.test.ts +521 -23
- package/src/reportWebEvent/fields.ts +162 -0
- package/src/reportWebEvent/generated-types.ts +239 -41
- package/src/reportWebEvent/index.ts +14 -26
- package/src/reportWebEvent/travel_fields.ts +216 -0
- package/src/reportWebEvent/utils.ts +167 -0
- package/src/reportWebEvent/vehicle_fields.ts +255 -0
- package/src/types.ts +89 -54
- package/src/utils.ts +18 -0
- package/dist/cjs/common_fields.d.ts +0 -2
- package/dist/cjs/common_fields.js.map +0 -1
- package/dist/esm/common_fields.d.ts +0 -2
- package/dist/esm/common_fields.js.map +0 -1
|
@@ -2,6 +2,7 @@ import { Analytics, Context } from '@segment/analytics-next'
|
|
|
2
2
|
import { Subscription } from '@segment/browser-destination-runtime'
|
|
3
3
|
import TikTokDestination, { destination } from '../../index'
|
|
4
4
|
import { TikTokPixel } from '../../types'
|
|
5
|
+
import { TRAVEL_FIELDS, VEHICLE_FIELDS } from '../../constants'
|
|
5
6
|
|
|
6
7
|
describe('TikTokPixel.reportWebEvent', () => {
|
|
7
8
|
const settings = {
|
|
@@ -68,14 +69,8 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
68
69
|
expect(mockTtp.track).toHaveBeenCalledWith(
|
|
69
70
|
'Pageview',
|
|
70
71
|
{
|
|
71
|
-
content_type: undefined,
|
|
72
72
|
contents: [],
|
|
73
|
-
currency: 'USD'
|
|
74
|
-
description: undefined,
|
|
75
|
-
order_id: undefined,
|
|
76
|
-
query: undefined,
|
|
77
|
-
shop_id: undefined,
|
|
78
|
-
value: undefined
|
|
73
|
+
currency: 'USD'
|
|
79
74
|
},
|
|
80
75
|
{
|
|
81
76
|
event_id: ''
|
|
@@ -137,7 +132,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
137
132
|
quantity: {
|
|
138
133
|
'@path': '$.quantity'
|
|
139
134
|
},
|
|
140
|
-
|
|
135
|
+
content_category: {
|
|
141
136
|
'@path': '$.category'
|
|
142
137
|
},
|
|
143
138
|
content_id: {
|
|
@@ -183,13 +178,13 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
183
178
|
products: [
|
|
184
179
|
{
|
|
185
180
|
product_id: '123',
|
|
186
|
-
category: '
|
|
181
|
+
category: 'category1',
|
|
187
182
|
quantity: 1,
|
|
188
183
|
price: 1
|
|
189
184
|
},
|
|
190
185
|
{
|
|
191
186
|
product_id: '456',
|
|
192
|
-
category: '
|
|
187
|
+
category: 'category1',
|
|
193
188
|
quantity: 2,
|
|
194
189
|
price: 2
|
|
195
190
|
}
|
|
@@ -227,8 +222,8 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
227
222
|
'PlaceAnOrder',
|
|
228
223
|
{
|
|
229
224
|
contents: [
|
|
230
|
-
{ content_id: '123',
|
|
231
|
-
{ content_id: '456',
|
|
225
|
+
{ content_id: '123', content_category: 'category1', price: 1, quantity: 1 },
|
|
226
|
+
{ content_id: '456', content_category: 'category1', price: 2, quantity: 2 }
|
|
232
227
|
],
|
|
233
228
|
currency: 'USD',
|
|
234
229
|
description: 'test-description',
|
|
@@ -293,7 +288,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
293
288
|
quantity: {
|
|
294
289
|
'@path': '$.quantity'
|
|
295
290
|
},
|
|
296
|
-
|
|
291
|
+
content_category: {
|
|
297
292
|
'@path': '$.category'
|
|
298
293
|
},
|
|
299
294
|
content_id: {
|
|
@@ -337,7 +332,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
337
332
|
},
|
|
338
333
|
properties: {
|
|
339
334
|
product_id: '123',
|
|
340
|
-
category: '
|
|
335
|
+
category: 'category1',
|
|
341
336
|
quantity: 1,
|
|
342
337
|
price: 1,
|
|
343
338
|
query: 'test-query',
|
|
@@ -372,7 +367,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
372
367
|
expect(mockTtp.track).toHaveBeenCalledWith(
|
|
373
368
|
'AddToCart',
|
|
374
369
|
{
|
|
375
|
-
contents: [{ content_id: '123',
|
|
370
|
+
contents: [{ content_id: '123', content_category: 'category1', price: 1, quantity: 1 }],
|
|
376
371
|
currency: 'USD',
|
|
377
372
|
description: 'test-description',
|
|
378
373
|
query: 'test-query',
|
|
@@ -436,7 +431,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
436
431
|
quantity: {
|
|
437
432
|
'@path': '$.quantity'
|
|
438
433
|
},
|
|
439
|
-
|
|
434
|
+
content_category: {
|
|
440
435
|
'@path': '$.category'
|
|
441
436
|
},
|
|
442
437
|
content_id: {
|
|
@@ -479,7 +474,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
479
474
|
},
|
|
480
475
|
properties: {
|
|
481
476
|
product_id: '123',
|
|
482
|
-
category: '
|
|
477
|
+
category: 'category1',
|
|
483
478
|
quantity: 1,
|
|
484
479
|
price: 1,
|
|
485
480
|
query: 'test-query',
|
|
@@ -514,7 +509,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
514
509
|
expect(mockTtp.track).toHaveBeenCalledWith(
|
|
515
510
|
'ViewContent',
|
|
516
511
|
{
|
|
517
|
-
contents: [{ content_id: '123',
|
|
512
|
+
contents: [{ content_id: '123', content_category: 'category1', price: 1, quantity: 1 }],
|
|
518
513
|
currency: 'USD',
|
|
519
514
|
description: 'test-description',
|
|
520
515
|
query: 'test-query',
|
|
@@ -578,7 +573,7 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
578
573
|
quantity: {
|
|
579
574
|
'@path': '$.quantity'
|
|
580
575
|
},
|
|
581
|
-
|
|
576
|
+
content_category: {
|
|
582
577
|
'@path': '$.category'
|
|
583
578
|
},
|
|
584
579
|
content_id: {
|
|
@@ -624,13 +619,13 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
624
619
|
products: [
|
|
625
620
|
{
|
|
626
621
|
product_id: '123',
|
|
627
|
-
category: '
|
|
622
|
+
category: 'category1',
|
|
628
623
|
quantity: 1,
|
|
629
624
|
price: 1
|
|
630
625
|
},
|
|
631
626
|
{
|
|
632
627
|
product_id: '456',
|
|
633
|
-
category: '
|
|
628
|
+
category: 'category1',
|
|
634
629
|
quantity: 2,
|
|
635
630
|
price: 2
|
|
636
631
|
}
|
|
@@ -668,8 +663,8 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
668
663
|
'PlaceAnOrder',
|
|
669
664
|
{
|
|
670
665
|
contents: [
|
|
671
|
-
{ content_id: '123',
|
|
672
|
-
{ content_id: '456',
|
|
666
|
+
{ content_id: '123', content_category: 'category1', price: 1, quantity: 1 },
|
|
667
|
+
{ content_id: '456', content_category: 'category1', price: 2, quantity: 2 }
|
|
673
668
|
],
|
|
674
669
|
currency: 'USD',
|
|
675
670
|
description: 'test-description',
|
|
@@ -679,4 +674,507 @@ describe('TikTokPixel.reportWebEvent', () => {
|
|
|
679
674
|
{ event_id: 'ajs-71f386523ee5dfa90c7d0fda28b6b5c6' }
|
|
680
675
|
)
|
|
681
676
|
})
|
|
677
|
+
|
|
678
|
+
test('maps properties correctly for "ViewContent" event for travel parameters', async () => {
|
|
679
|
+
const subscriptions: Subscription[] = [
|
|
680
|
+
{
|
|
681
|
+
partnerAction: 'reportWebEvent',
|
|
682
|
+
name: 'View Content',
|
|
683
|
+
enabled: true,
|
|
684
|
+
subscribe: 'type="page"',
|
|
685
|
+
mapping: {
|
|
686
|
+
event_spec_type: TRAVEL_FIELDS,
|
|
687
|
+
event_id: {
|
|
688
|
+
'@path': '$.messageId'
|
|
689
|
+
},
|
|
690
|
+
anonymousId: {
|
|
691
|
+
'@path': '$.anonymousId'
|
|
692
|
+
},
|
|
693
|
+
external_id: {
|
|
694
|
+
'@path': '$.userId'
|
|
695
|
+
},
|
|
696
|
+
phone_number: {
|
|
697
|
+
'@path': '$.properties.phone'
|
|
698
|
+
},
|
|
699
|
+
email: {
|
|
700
|
+
'@path': '$.properties.email'
|
|
701
|
+
},
|
|
702
|
+
last_name: {
|
|
703
|
+
'@path': '$.context.traits.last_name'
|
|
704
|
+
},
|
|
705
|
+
first_name: {
|
|
706
|
+
'@path': '$.context.traits.first_name'
|
|
707
|
+
},
|
|
708
|
+
address: {
|
|
709
|
+
city: {
|
|
710
|
+
'@path': '$.context.traits.address.city'
|
|
711
|
+
},
|
|
712
|
+
state: {
|
|
713
|
+
'@path': '$.context.traits.address.state'
|
|
714
|
+
},
|
|
715
|
+
country: {
|
|
716
|
+
'@path': '$.context.traits.address.country'
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
groupId: {
|
|
720
|
+
'@path': '$.groupId'
|
|
721
|
+
},
|
|
722
|
+
event: 'ViewContent',
|
|
723
|
+
contents: {
|
|
724
|
+
'@arrayPath': [
|
|
725
|
+
'$.properties',
|
|
726
|
+
{
|
|
727
|
+
price: {
|
|
728
|
+
'@path': '$.price'
|
|
729
|
+
},
|
|
730
|
+
quantity: {
|
|
731
|
+
'@path': '$.quantity'
|
|
732
|
+
},
|
|
733
|
+
content_category: {
|
|
734
|
+
'@path': '$.category'
|
|
735
|
+
},
|
|
736
|
+
content_id: {
|
|
737
|
+
'@path': '$.product_id'
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
]
|
|
741
|
+
},
|
|
742
|
+
currency: {
|
|
743
|
+
'@path': '$.properties.currency'
|
|
744
|
+
},
|
|
745
|
+
value: {
|
|
746
|
+
'@path': '$.properties.value'
|
|
747
|
+
},
|
|
748
|
+
query: {
|
|
749
|
+
'@path': '$.properties.query'
|
|
750
|
+
},
|
|
751
|
+
description: {
|
|
752
|
+
'@path': '$.properties.description'
|
|
753
|
+
},
|
|
754
|
+
travel_fields: {
|
|
755
|
+
city: {
|
|
756
|
+
'@path': '$.properties.city'
|
|
757
|
+
},
|
|
758
|
+
region: {
|
|
759
|
+
'@path': '$.properties.region'
|
|
760
|
+
},
|
|
761
|
+
country: {
|
|
762
|
+
'@path': '$.properties.country'
|
|
763
|
+
},
|
|
764
|
+
checkin_date: {
|
|
765
|
+
'@path': '$.properties.checkin_date'
|
|
766
|
+
},
|
|
767
|
+
checkout_date: {
|
|
768
|
+
'@path': '$.properties.checkout_date'
|
|
769
|
+
},
|
|
770
|
+
num_adults: {
|
|
771
|
+
'@path': '$.properties.num_adults'
|
|
772
|
+
},
|
|
773
|
+
num_children: {
|
|
774
|
+
'@path': '$.properties.num_children'
|
|
775
|
+
},
|
|
776
|
+
num_infants: {
|
|
777
|
+
'@path': '$.properties.num_infants'
|
|
778
|
+
},
|
|
779
|
+
suggested_hotels: {
|
|
780
|
+
'@path': '$.properties.suggested_hotels' // Confirmed this can be a single string or an array of strings
|
|
781
|
+
},
|
|
782
|
+
departing_departure_date: {
|
|
783
|
+
'@path': '$.properties.departing_departure_date'
|
|
784
|
+
},
|
|
785
|
+
returning_departure_date: {
|
|
786
|
+
'@path': '$.properties.returning_departure_date'
|
|
787
|
+
},
|
|
788
|
+
origin_airport: {
|
|
789
|
+
'@path': '$.properties.origin_airport'
|
|
790
|
+
},
|
|
791
|
+
destination_airport: {
|
|
792
|
+
'@path': '$.properties.destination_airport'
|
|
793
|
+
},
|
|
794
|
+
destination_ids: {
|
|
795
|
+
'@path': '$.properties.destination_ids' // Confirmed this can be a single string or an array of strings
|
|
796
|
+
},
|
|
797
|
+
departing_arrival_date: {
|
|
798
|
+
'@path': '$.properties.departing_arrival_date'
|
|
799
|
+
},
|
|
800
|
+
returning_arrival_date: {
|
|
801
|
+
'@path': '$.properties.returning_arrival_date'
|
|
802
|
+
},
|
|
803
|
+
travel_class: {
|
|
804
|
+
'@path': '$.properties.travel_class'
|
|
805
|
+
},
|
|
806
|
+
user_score: {
|
|
807
|
+
'@path': '$.properties.user_score'
|
|
808
|
+
},
|
|
809
|
+
preferred_num_stops: {
|
|
810
|
+
'@path': '$.properties.preferred_num_stops'
|
|
811
|
+
},
|
|
812
|
+
travel_start: {
|
|
813
|
+
'@path': '$.properties.travel_start'
|
|
814
|
+
},
|
|
815
|
+
travel_end: {
|
|
816
|
+
'@path': '$.properties.travel_end'
|
|
817
|
+
},
|
|
818
|
+
suggested_destinations: {
|
|
819
|
+
'@path': '$.properties.suggested_destinations' // Confirmed this can be a single string or an array of strings
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
]
|
|
825
|
+
|
|
826
|
+
const context = new Context({
|
|
827
|
+
messageId: 'ajs-71f386523ee5dfa90c7d0fda28b6b5c6',
|
|
828
|
+
type: 'page',
|
|
829
|
+
anonymousId: 'anonymousId',
|
|
830
|
+
userId: 'userId',
|
|
831
|
+
context: {
|
|
832
|
+
traits: {
|
|
833
|
+
last_name: 'lastName',
|
|
834
|
+
first_name: 'firstName',
|
|
835
|
+
address: {
|
|
836
|
+
city: 'city',
|
|
837
|
+
state: 'state',
|
|
838
|
+
country: 'country'
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
},
|
|
842
|
+
properties: {
|
|
843
|
+
product_id: '123',
|
|
844
|
+
category: 'category1',
|
|
845
|
+
quantity: 1,
|
|
846
|
+
price: 1,
|
|
847
|
+
query: 'test-query',
|
|
848
|
+
value: 10,
|
|
849
|
+
currency: 'USD',
|
|
850
|
+
phone: ['+12345678900'],
|
|
851
|
+
email: ['aaa@aaa.com'],
|
|
852
|
+
description: 'test-description',
|
|
853
|
+
city: 'test_city',
|
|
854
|
+
region: 'test_region',
|
|
855
|
+
country: 'test_country',
|
|
856
|
+
checkin_date: 'test_checkin_date',
|
|
857
|
+
checkout_date: 'test_checkout_date',
|
|
858
|
+
num_adults: 1,
|
|
859
|
+
num_children: 1,
|
|
860
|
+
num_infants: 1,
|
|
861
|
+
suggested_hotels: ['test_suggested_hotels_1', 'test_suggested_hotels_2'],
|
|
862
|
+
departing_departure_date: '20250901',
|
|
863
|
+
returning_departure_date: '20250901',
|
|
864
|
+
origin_airport: 'test_origin_airport',
|
|
865
|
+
destination_airport: 'test_destination_airport',
|
|
866
|
+
destination_ids: ['destination_ids_1', 'destination_ids_2'],
|
|
867
|
+
departing_arrival_date: '20250901',
|
|
868
|
+
returning_arrival_date: '20250901',
|
|
869
|
+
travel_class: 'eco',
|
|
870
|
+
user_score: 1,
|
|
871
|
+
preferred_num_stops: 0,
|
|
872
|
+
travel_start: '20250901',
|
|
873
|
+
travel_end: '20250901',
|
|
874
|
+
suggested_destinations: ['suggested_destinations_1', 'suggested_destinations_2']
|
|
875
|
+
}
|
|
876
|
+
})
|
|
877
|
+
|
|
878
|
+
const [webEvent] = await TikTokDestination({
|
|
879
|
+
...settings,
|
|
880
|
+
subscriptions
|
|
881
|
+
})
|
|
882
|
+
reportWebEvent = webEvent
|
|
883
|
+
|
|
884
|
+
await reportWebEvent.load(Context.system(), {} as Analytics)
|
|
885
|
+
await reportWebEvent.track?.(context)
|
|
886
|
+
|
|
887
|
+
expect(mockTtp.identify).toHaveBeenCalledWith({
|
|
888
|
+
city: 'city',
|
|
889
|
+
country: 'country',
|
|
890
|
+
email: 'aaa@aaa.com',
|
|
891
|
+
phone_number: '+12345678900',
|
|
892
|
+
external_id: 'userId',
|
|
893
|
+
first_name: 'firstname',
|
|
894
|
+
last_name: 'lastname',
|
|
895
|
+
state: 'state',
|
|
896
|
+
zip_code: ''
|
|
897
|
+
})
|
|
898
|
+
expect(mockTtp.track).toHaveBeenCalledWith(
|
|
899
|
+
'ViewContent',
|
|
900
|
+
{
|
|
901
|
+
contents: [{ content_id: '123', content_category: 'category1', price: 1, quantity: 1 }],
|
|
902
|
+
country: "test_country",
|
|
903
|
+
currency: 'USD',
|
|
904
|
+
departing_arrival_date: "20250901",
|
|
905
|
+
departing_departure_date: "20250901",
|
|
906
|
+
description: 'test-description',
|
|
907
|
+
destination_airport: "test_destination_airport",
|
|
908
|
+
destination_ids: [
|
|
909
|
+
"destination_ids_1",
|
|
910
|
+
"destination_ids_2"
|
|
911
|
+
],
|
|
912
|
+
num_adults: 1,
|
|
913
|
+
num_children: 1,
|
|
914
|
+
num_infants:1,
|
|
915
|
+
origin_airport: "test_origin_airport",
|
|
916
|
+
preferred_num_stops: 0,
|
|
917
|
+
region: 'test_region',
|
|
918
|
+
returning_arrival_date: '20250901',
|
|
919
|
+
returning_departure_date: '20250901',
|
|
920
|
+
suggested_destinations: ['suggested_destinations_1', 'suggested_destinations_2'],
|
|
921
|
+
suggested_hotels: ['test_suggested_hotels_1', 'test_suggested_hotels_2'],
|
|
922
|
+
travel_class: 'eco',
|
|
923
|
+
travel_start: '20250901',
|
|
924
|
+
travel_end: '20250901',
|
|
925
|
+
user_score: 1,
|
|
926
|
+
query: 'test-query',
|
|
927
|
+
value: 10,
|
|
928
|
+
city: 'test_city',
|
|
929
|
+
checkin_date: 'test_checkin_date',
|
|
930
|
+
checkout_date: 'test_checkout_date'
|
|
931
|
+
},
|
|
932
|
+
{ event_id: 'ajs-71f386523ee5dfa90c7d0fda28b6b5c6' }
|
|
933
|
+
)
|
|
934
|
+
})
|
|
935
|
+
|
|
936
|
+
test('maps properties correctly for "ViewContent" event with auto parameters', async () => {
|
|
937
|
+
const subscriptions: Subscription[] = [
|
|
938
|
+
{
|
|
939
|
+
partnerAction: 'reportWebEvent',
|
|
940
|
+
name: 'View Content',
|
|
941
|
+
enabled: true,
|
|
942
|
+
subscribe: 'type="page"',
|
|
943
|
+
mapping: {
|
|
944
|
+
event_spec_type: VEHICLE_FIELDS,
|
|
945
|
+
event_id: {
|
|
946
|
+
'@path': '$.messageId'
|
|
947
|
+
},
|
|
948
|
+
anonymousId: {
|
|
949
|
+
'@path': '$.anonymousId'
|
|
950
|
+
},
|
|
951
|
+
external_id: {
|
|
952
|
+
'@path': '$.userId'
|
|
953
|
+
},
|
|
954
|
+
phone_number: {
|
|
955
|
+
'@path': '$.properties.phone'
|
|
956
|
+
},
|
|
957
|
+
email: {
|
|
958
|
+
'@path': '$.properties.email'
|
|
959
|
+
},
|
|
960
|
+
last_name: {
|
|
961
|
+
'@path': '$.context.traits.last_name'
|
|
962
|
+
},
|
|
963
|
+
first_name: {
|
|
964
|
+
'@path': '$.context.traits.first_name'
|
|
965
|
+
},
|
|
966
|
+
address: {
|
|
967
|
+
city: {
|
|
968
|
+
'@path': '$.context.traits.address.city'
|
|
969
|
+
},
|
|
970
|
+
state: {
|
|
971
|
+
'@path': '$.context.traits.address.state'
|
|
972
|
+
},
|
|
973
|
+
country: {
|
|
974
|
+
'@path': '$.context.traits.address.country'
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
groupId: {
|
|
978
|
+
'@path': '$.groupId'
|
|
979
|
+
},
|
|
980
|
+
event: 'ViewContent',
|
|
981
|
+
contents: {
|
|
982
|
+
'@arrayPath': [
|
|
983
|
+
'$.properties',
|
|
984
|
+
{
|
|
985
|
+
price: {
|
|
986
|
+
'@path': '$.price'
|
|
987
|
+
},
|
|
988
|
+
quantity: {
|
|
989
|
+
'@path': '$.quantity'
|
|
990
|
+
},
|
|
991
|
+
content_category: {
|
|
992
|
+
'@path': '$.category'
|
|
993
|
+
},
|
|
994
|
+
content_id: {
|
|
995
|
+
'@path': '$.product_id'
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
]
|
|
999
|
+
},
|
|
1000
|
+
currency: {
|
|
1001
|
+
'@path': '$.properties.currency'
|
|
1002
|
+
},
|
|
1003
|
+
value: {
|
|
1004
|
+
'@path': '$.properties.value'
|
|
1005
|
+
},
|
|
1006
|
+
query: {
|
|
1007
|
+
'@path': '$.properties.query'
|
|
1008
|
+
},
|
|
1009
|
+
description: {
|
|
1010
|
+
'@path': '$.properties.description'
|
|
1011
|
+
},
|
|
1012
|
+
postal_code: {
|
|
1013
|
+
'@path': '$.properties.postal_code'
|
|
1014
|
+
},
|
|
1015
|
+
vehicle_fields: {
|
|
1016
|
+
postal_code: {
|
|
1017
|
+
'@path': '$.properties.postal_code'
|
|
1018
|
+
},
|
|
1019
|
+
make: {
|
|
1020
|
+
'@path': '$.properties.make'
|
|
1021
|
+
},
|
|
1022
|
+
model: {
|
|
1023
|
+
'@path': '$.properties.model'
|
|
1024
|
+
},
|
|
1025
|
+
year: {
|
|
1026
|
+
'@path': '$.properties.year'
|
|
1027
|
+
},
|
|
1028
|
+
state_of_vehicle: {
|
|
1029
|
+
'@path': '$.properties.state_of_vehicle'
|
|
1030
|
+
},
|
|
1031
|
+
mileage_value: {
|
|
1032
|
+
'@path': '$.properties.mileage_value'
|
|
1033
|
+
},
|
|
1034
|
+
mileage_unit: {
|
|
1035
|
+
'@path': '$.properties.mileage_unit'
|
|
1036
|
+
},
|
|
1037
|
+
exterior_color: {
|
|
1038
|
+
'@path': '$.properties.exterior_color'
|
|
1039
|
+
},
|
|
1040
|
+
transmission: {
|
|
1041
|
+
'@path': '$.properties.transmission'
|
|
1042
|
+
},
|
|
1043
|
+
body_style: {
|
|
1044
|
+
'@path': '$.properties.body_style'
|
|
1045
|
+
},
|
|
1046
|
+
fuel_type: {
|
|
1047
|
+
'@path': '$.properties.fuel_type'
|
|
1048
|
+
},
|
|
1049
|
+
drivetrain: {
|
|
1050
|
+
'@path': '$.properties.drive_train'
|
|
1051
|
+
},
|
|
1052
|
+
preferred_price_range_min: {
|
|
1053
|
+
'@path': '$.properties.preferred_price_range_min'
|
|
1054
|
+
},
|
|
1055
|
+
preferred_price_range_max: {
|
|
1056
|
+
'@path': '$.properties.preferred_price_range_max'
|
|
1057
|
+
},
|
|
1058
|
+
trim: {
|
|
1059
|
+
'@path': '$.properties.trim'
|
|
1060
|
+
},
|
|
1061
|
+
vin: {
|
|
1062
|
+
'@path': '$.properties.vin'
|
|
1063
|
+
},
|
|
1064
|
+
interior_color: {
|
|
1065
|
+
'@path': '$.properties.interior_color'
|
|
1066
|
+
},
|
|
1067
|
+
condition_of_vehicle: {
|
|
1068
|
+
'@path': '$.properties.condition_of_vehicle'
|
|
1069
|
+
},
|
|
1070
|
+
viewcontent_type: {
|
|
1071
|
+
'@path': '$.properties.viewcontent_type'
|
|
1072
|
+
},
|
|
1073
|
+
search_type: {
|
|
1074
|
+
'@path': '$.properties.search_type'
|
|
1075
|
+
},
|
|
1076
|
+
registration_type: {
|
|
1077
|
+
'@path': '$.properties.registration_type'
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
]
|
|
1083
|
+
|
|
1084
|
+
const context = new Context({
|
|
1085
|
+
messageId: 'ajs-71f386523ee5dfa90c7d0fda28b6b5c6',
|
|
1086
|
+
type: 'page',
|
|
1087
|
+
anonymousId: 'anonymousId',
|
|
1088
|
+
userId: 'userId',
|
|
1089
|
+
context: {
|
|
1090
|
+
traits: {
|
|
1091
|
+
last_name: 'lastName',
|
|
1092
|
+
first_name: 'firstName',
|
|
1093
|
+
address: {
|
|
1094
|
+
city: 'city',
|
|
1095
|
+
state: 'state',
|
|
1096
|
+
country: 'country'
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
},
|
|
1100
|
+
properties: {
|
|
1101
|
+
product_id: '123',
|
|
1102
|
+
category: 'category1',
|
|
1103
|
+
quantity: 1,
|
|
1104
|
+
price: 1,
|
|
1105
|
+
query: 'test-query',
|
|
1106
|
+
value: 10,
|
|
1107
|
+
currency: 'USD',
|
|
1108
|
+
phone: ['+12345678900'],
|
|
1109
|
+
email: ['aaa@aaa.com'],
|
|
1110
|
+
description: 'test-description',
|
|
1111
|
+
postal_code: 'test_postal_code',
|
|
1112
|
+
make: 'test_make',
|
|
1113
|
+
model: 'test_model',
|
|
1114
|
+
year: 2020,
|
|
1115
|
+
state_of_vehicle: 'New',
|
|
1116
|
+
mileage_value: 12345,
|
|
1117
|
+
mileage_unit: 'MI',
|
|
1118
|
+
exterior_color: 'test_exterior_color',
|
|
1119
|
+
transmission: 'Automatic',
|
|
1120
|
+
body_style: 'Coupe',
|
|
1121
|
+
fuel_type: 'Diesel',
|
|
1122
|
+
drive_train: 'AWD',
|
|
1123
|
+
preferred_price_range_min: 1000,
|
|
1124
|
+
preferred_price_range_max: 2000,
|
|
1125
|
+
trim: 'test_trim',
|
|
1126
|
+
vin: 'test_vin',
|
|
1127
|
+
interior_color: 'test_interior_color',
|
|
1128
|
+
condition_of_vehicle: 'Good'
|
|
1129
|
+
}
|
|
1130
|
+
})
|
|
1131
|
+
|
|
1132
|
+
const [webEvent] = await TikTokDestination({
|
|
1133
|
+
...settings,
|
|
1134
|
+
subscriptions
|
|
1135
|
+
})
|
|
1136
|
+
reportWebEvent = webEvent
|
|
1137
|
+
|
|
1138
|
+
await reportWebEvent.load(Context.system(), {} as Analytics)
|
|
1139
|
+
await reportWebEvent.track?.(context)
|
|
1140
|
+
|
|
1141
|
+
expect(mockTtp.identify).toHaveBeenCalledWith({
|
|
1142
|
+
city: 'city',
|
|
1143
|
+
country: 'country',
|
|
1144
|
+
email: 'aaa@aaa.com',
|
|
1145
|
+
phone_number: '+12345678900',
|
|
1146
|
+
external_id: 'userId',
|
|
1147
|
+
first_name: 'firstname',
|
|
1148
|
+
last_name: 'lastname',
|
|
1149
|
+
state: 'state',
|
|
1150
|
+
zip_code: ''
|
|
1151
|
+
})
|
|
1152
|
+
expect(mockTtp.track).toHaveBeenCalledWith(
|
|
1153
|
+
'ViewContent',
|
|
1154
|
+
{
|
|
1155
|
+
contents: [{ content_id: '123', content_category: 'category1', price: 1, quantity: 1 }],
|
|
1156
|
+
currency: 'USD',
|
|
1157
|
+
description: 'test-description',
|
|
1158
|
+
query: 'test-query',
|
|
1159
|
+
value: 10,
|
|
1160
|
+
postal_code: 'test_postal_code',
|
|
1161
|
+
make: 'test_make',
|
|
1162
|
+
model: 'test_model',
|
|
1163
|
+
year: 2020,
|
|
1164
|
+
state_of_vehicle: 'New',
|
|
1165
|
+
mileage: { unit: 'MI', value: 12345 },
|
|
1166
|
+
exterior_color: 'test_exterior_color',
|
|
1167
|
+
transmission: 'Automatic',
|
|
1168
|
+
body_style: 'Coupe',
|
|
1169
|
+
fuel_type: 'Diesel',
|
|
1170
|
+
drivetrain: 'AWD',
|
|
1171
|
+
preferred_price_range: [1000, 2000],
|
|
1172
|
+
trim: 'test_trim',
|
|
1173
|
+
vin: 'test_vin',
|
|
1174
|
+
interior_color: 'test_interior_color',
|
|
1175
|
+
condition_of_vehicle: 'Good'
|
|
1176
|
+
},
|
|
1177
|
+
{ event_id: 'ajs-71f386523ee5dfa90c7d0fda28b6b5c6' }
|
|
1178
|
+
)
|
|
1179
|
+
})
|
|
682
1180
|
})
|