@@ -6,13 +6,14 @@ import {
6
6
SegmentAnalytics ,
7
7
SegmentOpts ,
8
8
SegmentIntegration ,
9
- PageDefaults , Message
9
+ PageDefaults
10
10
} from './types' ;
11
11
12
12
import { pageDefaults } from './pageDefaults' ;
13
13
14
14
import cloneDeep from 'lodash.clonedeep'
15
15
import pick from 'lodash.pick'
16
+ import url from 'component-url'
16
17
17
18
var _analytics = global . analytics ;
18
19
@@ -37,7 +38,6 @@ var extend = require('extend');
37
38
var cookie = require ( './cookie' ) ;
38
39
var metrics = require ( './metrics' ) ;
39
40
var debug = require ( 'debug' ) ;
40
- var defaults = require ( '@ndhoule/defaults' ) ;
41
41
var group = require ( './group' ) ;
42
42
var is = require ( 'is' ) ;
43
43
var isMeta = require ( '@segment/is-meta' ) ;
@@ -46,7 +46,6 @@ var nextTick = require('next-tick');
46
46
var normalize = require ( './normalize' ) ;
47
47
var on = require ( 'component-event' ) . bind ;
48
48
var prevent = require ( '@segment/prevent-default' ) ;
49
- var querystring = require ( 'component-querystring' ) ;
50
49
var store = require ( './store' ) ;
51
50
var user = require ( './user' ) ;
52
51
var type = require ( 'component-type' ) ;
@@ -69,7 +68,6 @@ function Analytics() {
69
68
this . log = debug ( 'analytics.js' ) ;
70
69
bindAll ( this ) ;
71
70
72
-
73
71
const self = this ;
74
72
this . on ( 'initialize' , function ( _ , options ) {
75
73
if ( options . initialPageview ) self . page ( ) ;
@@ -960,9 +958,22 @@ Analytics.prototype.reset = function() {
960
958
* @api private
961
959
*/
962
960
961
+ interface QueryStringParams {
962
+ [ key : string ] : string | null ;
963
+ }
964
+
963
965
Analytics . prototype . _parseQuery = function ( query : string ) : SegmentAnalytics {
964
966
// Parse querystring to an object
965
- var q = querystring . parse ( query ) ;
967
+ const parsed = url . parse ( query ) ;
968
+
969
+ const q = parsed . query
970
+ . split ( '&' )
971
+ . reduce ( ( acc : QueryStringParams , str : string ) => {
972
+ const [ k , v ] = str . split ( '=' ) ;
973
+ acc [ k ] = decodeURI ( v ) . replace ( '+' , ' ' ) ;
974
+ return acc ;
975
+ } , { } ) ;
976
+
966
977
// Create traits and properties objects, populate from querysting params
967
978
var traits = pickPrefix ( 'ajs_trait_' , q ) ;
968
979
var props = pickPrefix ( 'ajs_prop_' , q ) ;
0 commit comments