@@ -788,7 +788,9 @@ describe('Amplitude', () => {
788
788
expect ( responses . length ) . toBe ( 1 )
789
789
expect ( responses [ 0 ] . status ) . toBe ( 200 )
790
790
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
791
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
791
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
792
+ `"api_key=undefined&mapping=%5B%7B%22user_id%22%3A%22some-previous-user-id%22%2C%22global_user_id%22%3A%22some-user-id%22%7D%5D"`
793
+ )
792
794
} )
793
795
794
796
it ( 'should send data to the EU endpoint' , async ( ) => {
@@ -812,7 +814,9 @@ describe('Amplitude', () => {
812
814
expect ( responses . length ) . toBe ( 1 )
813
815
expect ( responses [ 0 ] . status ) . toBe ( 200 )
814
816
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
815
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
817
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
818
+ `"api_key=&mapping=%5B%7B%22user_id%22%3A%22some-previous-user-id%22%2C%22global_user_id%22%3A%22some-user-id%22%7D%5D"`
819
+ )
816
820
} )
817
821
} )
818
822
@@ -1979,7 +1983,9 @@ describe('Amplitude', () => {
1979
1983
expect ( responses . length ) . toBe ( 1 )
1980
1984
expect ( responses [ 0 ] . status ) . toBe ( 200 )
1981
1985
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
1982
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
1986
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
1987
+ `"api_key=undefined&identification=%7B%22os_name%22%3A%22iOS%22%2C%22os_version%22%3A%229%22%2C%22device_manufacturer%22%3A%22Apple%22%2C%22device_model%22%3A%22iPhone%22%2C%22device_type%22%3A%22mobile%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22country%22%3A%22United+States%22%2C%22city%22%3A%22San+Francisco%22%2C%22language%22%3A%22en-US%22%2C%22platform%22%3A%22Web%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
1988
+ )
1983
1989
} )
1984
1990
1985
1991
it ( 'should support referrer and utm user_properties' , async ( ) => {
@@ -2010,7 +2016,9 @@ describe('Amplitude', () => {
2010
2016
expect ( responses . length ) . toBe ( 1 )
2011
2017
expect ( responses [ 0 ] . status ) . toBe ( 200 )
2012
2018
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
2013
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2019
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2020
+ `"api_key=undefined&identification=%7B%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%2C%22%24set%22%3A%7B%22utm_source%22%3A%22Newsletter%22%2C%22utm_medium%22%3A%22email%22%2C%22utm_campaign%22%3A%22TPS+Innovation+Newsletter%22%2C%22utm_term%22%3A%22tps+reports%22%2C%22utm_content%22%3A%22image+link%22%2C%22referrer%22%3A%22some-referrer%22%7D%2C%22%24setOnce%22%3A%7B%22initial_utm_source%22%3A%22Newsletter%22%2C%22initial_utm_medium%22%3A%22email%22%2C%22initial_utm_campaign%22%3A%22TPS+Innovation+Newsletter%22%2C%22initial_utm_term%22%3A%22tps+reports%22%2C%22initial_utm_content%22%3A%22image+link%22%2C%22initial_referrer%22%3A%22some-referrer%22%7D%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2021
+ )
2014
2022
} )
2015
2023
2016
2024
it ( 'shouldnt append $ keys to user_properties if referrer/utm are not specified' , async ( ) => {
@@ -2029,7 +2037,9 @@ describe('Amplitude', () => {
2029
2037
expect ( responses . length ) . toBe ( 1 )
2030
2038
expect ( responses [ 0 ] . status ) . toBe ( 200 )
2031
2039
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
2032
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2040
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2041
+ `"api_key=undefined&identification=%7B%22os_name%22%3A%22iOS%22%2C%22os_version%22%3A%229%22%2C%22device_manufacturer%22%3A%22Apple%22%2C%22device_model%22%3A%22iPhone%22%2C%22device_type%22%3A%22mobile%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22country%22%3A%22United+States%22%2C%22city%22%3A%22San+Francisco%22%2C%22language%22%3A%22en-US%22%2C%22platform%22%3A%22Web%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2042
+ )
2033
2043
} )
2034
2044
2035
2045
it ( 'should support parsing userAgent when the setting is true' , async ( ) => {
@@ -2060,7 +2070,9 @@ describe('Amplitude', () => {
2060
2070
expect ( responses . length ) . toBe ( 1 )
2061
2071
expect ( responses [ 0 ] . status ) . toBe ( 200 )
2062
2072
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
2063
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2073
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2074
+ `"api_key=undefined&identification=%7B%22os_name%22%3A%22Mac+OS%22%2C%22os_version%22%3A%2253%22%2C%22device_model%22%3A%22Mac+OS%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2075
+ )
2064
2076
} )
2065
2077
2066
2078
it ( 'should not send parsed user agent properties when setting is false' , async ( ) => {
@@ -2091,7 +2103,9 @@ describe('Amplitude', () => {
2091
2103
expect ( responses . length ) . toBe ( 1 )
2092
2104
expect ( responses [ 0 ] . status ) . toBe ( 200 )
2093
2105
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
2094
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2106
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2107
+ `"api_key=undefined&identification=%7B%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2108
+ )
2095
2109
} )
2096
2110
2097
2111
it ( 'should change casing for device type when value is android' , async ( ) => {
@@ -2110,7 +2124,9 @@ describe('Amplitude', () => {
2110
2124
2111
2125
nock ( 'https://api2.amplitude.com' ) . post ( '/identify' ) . reply ( 200 , { } )
2112
2126
const responses = await testDestination . testAction ( 'identifyUser' , { event, mapping, useDefaultMappings : true } )
2113
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2127
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2128
+ `"api_key=undefined&identification=%7B%22user_id%22%3A%22user1234%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%7D%2C%22platform%22%3A%22Android%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2129
+ )
2114
2130
} )
2115
2131
2116
2132
it ( 'should change casing for device type when value is ios' , async ( ) => {
@@ -2129,7 +2145,9 @@ describe('Amplitude', () => {
2129
2145
2130
2146
nock ( 'https://api2.amplitude.com' ) . post ( '/identify' ) . reply ( 200 , { } )
2131
2147
const responses = await testDestination . testAction ( 'identifyUser' , { event, mapping, useDefaultMappings : true } )
2132
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2148
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2149
+ `"api_key=undefined&identification=%7B%22user_id%22%3A%22user1234%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%7D%2C%22platform%22%3A%22iOS%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2150
+ )
2133
2151
} )
2134
2152
2135
2153
it ( 'should send data to the EU endpoint' , async ( ) => {
@@ -2156,7 +2174,9 @@ describe('Amplitude', () => {
2156
2174
expect ( responses . length ) . toBe ( 1 )
2157
2175
expect ( responses [ 0 ] . status ) . toBe ( 200 )
2158
2176
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
2159
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2177
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2178
+ `"api_key=&identification=%7B%22os_name%22%3A%22iOS%22%2C%22os_version%22%3A%229%22%2C%22device_manufacturer%22%3A%22Apple%22%2C%22device_model%22%3A%22iPhone%22%2C%22device_type%22%3A%22mobile%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22some-anonymous-id%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22country%22%3A%22United+States%22%2C%22city%22%3A%22San+Francisco%22%2C%22language%22%3A%22en-US%22%2C%22platform%22%3A%22Web%22%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2179
+ )
2160
2180
} )
2161
2181
2162
2182
it ( 'should give precedence to OS properties over userAgent properties' , async ( ) => {
@@ -2191,7 +2211,9 @@ describe('Amplitude', () => {
2191
2211
expect ( responses . length ) . toBe ( 1 )
2192
2212
expect ( responses [ 0 ] . status ) . toBe ( 200 )
2193
2213
expect ( responses [ 0 ] . data ) . toMatchObject ( { } )
2194
- expect ( responses [ 0 ] . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2214
+ expect ( responses [ 0 ] . options . body . toString ( ) ) . toMatchInlineSnapshot (
2215
+ `"api_key=undefined&identification=%7B%22os_name%22%3A%22iPhone+OS%22%2C%22os_version%22%3A%228.1.3%22%2C%22device_model%22%3A%22Mac+OS%22%2C%22user_id%22%3A%22some-user-id%22%2C%22device_id%22%3A%22foo%22%2C%22user_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22library%22%3A%22segment%22%7D&options=undefined"`
2216
+ )
2195
2217
} )
2196
2218
} )
2197
2219
@@ -2224,7 +2246,9 @@ describe('Amplitude', () => {
2224
2246
2225
2247
expect ( response . status ) . toBe ( 200 )
2226
2248
expect ( response . data ) . toMatchObject ( { } )
2227
- expect ( response . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2249
+ expect ( response . options . body . toString ( ) ) . toMatchInlineSnapshot (
2250
+ `"api_key=undefined&identification=%5B%7B%22device_id%22%3A%22some-anonymous-id%22%2C%22groups%22%3A%7B%22some-type%22%3A%22some-value%22%7D%2C%22insert_id%22%3A%22some-insert-id%22%2C%22library%22%3A%22segment%22%2C%22time%22%3A1618245157710%2C%22user_id%22%3A%22some-user-id%22%2C%22user_properties%22%3A%7B%22some-type%22%3A%22some-value%22%7D%7D%5D&options=undefined"`
2251
+ )
2228
2252
} )
2229
2253
2230
2254
it ( 'should fire groupidentify call to Amplitude' , async ( ) => {
@@ -2239,7 +2263,9 @@ describe('Amplitude', () => {
2239
2263
2240
2264
expect ( response . status ) . toBe ( 200 )
2241
2265
expect ( response . data ) . toMatchObject ( { } )
2242
- expect ( response . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2266
+ expect ( response . options . body . toString ( ) ) . toMatchInlineSnapshot (
2267
+ `"api_key=undefined&identification=%5B%7B%22group_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22group_value%22%3A%22some-value%22%2C%22group_type%22%3A%22some-type%22%2C%22library%22%3A%22segment%22%7D%5D&options=undefined"`
2268
+ )
2243
2269
} )
2244
2270
2245
2271
it ( 'should fire identify call to Amplitude EU endpoint' , async ( ) => {
@@ -2259,7 +2285,9 @@ describe('Amplitude', () => {
2259
2285
2260
2286
expect ( response . status ) . toBe ( 200 )
2261
2287
expect ( response . data ) . toMatchObject ( { } )
2262
- expect ( response . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2288
+ expect ( response . options . body . toString ( ) ) . toMatchInlineSnapshot (
2289
+ `"api_key=&identification=%5B%7B%22device_id%22%3A%22some-anonymous-id%22%2C%22groups%22%3A%7B%22some-type%22%3A%22some-value%22%7D%2C%22insert_id%22%3A%22some-insert-id%22%2C%22library%22%3A%22segment%22%2C%22time%22%3A1618245157710%2C%22user_id%22%3A%22some-user-id%22%2C%22user_properties%22%3A%7B%22some-type%22%3A%22some-value%22%7D%7D%5D&options=undefined"`
2290
+ )
2263
2291
} )
2264
2292
2265
2293
it ( 'should fire groupidentify call to Amplitude EU endpoint' , async ( ) => {
@@ -2279,7 +2307,9 @@ describe('Amplitude', () => {
2279
2307
2280
2308
expect ( response . status ) . toBe ( 200 )
2281
2309
expect ( response . data ) . toMatchObject ( { } )
2282
- expect ( response . options . body ) . toMatchInlineSnapshot ( `URLSearchParams {}` )
2310
+ expect ( response . options . body . toString ( ) ) . toMatchInlineSnapshot (
2311
+ `"api_key=&identification=%5B%7B%22group_properties%22%3A%7B%22some-trait-key%22%3A%22some-trait-value%22%7D%2C%22group_value%22%3A%22some-value%22%2C%22group_type%22%3A%22some-type%22%2C%22library%22%3A%22segment%22%7D%5D&options=undefined"`
2312
+ )
2283
2313
} )
2284
2314
} )
2285
2315
0 commit comments