@@ -6,13 +6,14 @@ import {
66 SegmentAnalytics ,
77 SegmentOpts ,
88 SegmentIntegration ,
9- PageDefaults , Message
9+ PageDefaults
1010} from './types' ;
1111
1212import { pageDefaults } from './pageDefaults' ;
1313
1414import cloneDeep from 'lodash.clonedeep'
1515import pick from 'lodash.pick'
16+ import url from 'component-url'
1617
1718var _analytics = global . analytics ;
1819
@@ -37,7 +38,6 @@ var extend = require('extend');
3738var cookie = require ( './cookie' ) ;
3839var metrics = require ( './metrics' ) ;
3940var debug = require ( 'debug' ) ;
40- var defaults = require ( '@ndhoule/defaults' ) ;
4141var group = require ( './group' ) ;
4242var is = require ( 'is' ) ;
4343var isMeta = require ( '@segment/is-meta' ) ;
@@ -46,7 +46,6 @@ var nextTick = require('next-tick');
4646var normalize = require ( './normalize' ) ;
4747var on = require ( 'component-event' ) . bind ;
4848var prevent = require ( '@segment/prevent-default' ) ;
49- var querystring = require ( 'component-querystring' ) ;
5049var store = require ( './store' ) ;
5150var user = require ( './user' ) ;
5251var type = require ( 'component-type' ) ;
@@ -69,7 +68,6 @@ function Analytics() {
6968 this . log = debug ( 'analytics.js' ) ;
7069 bindAll ( this ) ;
7170
72-
7371 const self = this ;
7472 this . on ( 'initialize' , function ( _ , options ) {
7573 if ( options . initialPageview ) self . page ( ) ;
@@ -960,9 +958,22 @@ Analytics.prototype.reset = function() {
960958 * @api private
961959 */
962960
961+ interface QueryStringParams {
962+ [ key : string ] : string | null ;
963+ }
964+
963965Analytics . prototype . _parseQuery = function ( query : string ) : SegmentAnalytics {
964966 // 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+
966977 // Create traits and properties objects, populate from querysting params
967978 var traits = pickPrefix ( 'ajs_trait_' , q ) ;
968979 var props = pickPrefix ( 'ajs_prop_' , q ) ;
0 commit comments