@@ -102,7 +102,10 @@ Analytics.prototype.addIntegration = function(Integration) {
102102 * @return {Analytics }
103103 */
104104
105- Analytics . prototype . init = Analytics . prototype . initialize = function ( settings , options ) {
105+ Analytics . prototype . init = Analytics . prototype . initialize = function (
106+ settings ,
107+ options
108+ ) {
106109 settings = settings || { } ;
107110 options = options || { } ;
108111
@@ -121,8 +124,8 @@ Analytics.prototype.init = Analytics.prototype.initialize = function(settings, o
121124 // Don't load disabled integrations
122125 if ( options . integrations ) {
123126 if (
124- options . integrations [ name ] === false
125- || options . integrations . All === false && ! options . integrations [ name ]
127+ options . integrations [ name ] === false ||
128+ ( options . integrations . All === false && ! options . integrations [ name ] )
126129 ) {
127130 return ;
128131 }
@@ -158,7 +161,10 @@ Analytics.prototype.init = Analytics.prototype.initialize = function(settings, o
158161 // create a list of any integrations that did not initialize - this will be passed with all events for replay support:
159162 this . failedInitializations = [ ] ;
160163 each ( function ( integration ) {
161- if ( options . initialPageview && integration . options . initialPageview === false ) {
164+ if (
165+ options . initialPageview &&
166+ integration . options . initialPageview === false
167+ ) {
162168 integration . page = after ( 2 , integration . page ) ;
163169 }
164170
@@ -226,9 +232,9 @@ Analytics.prototype.add = function(integration) {
226232Analytics . prototype . identify = function ( id , traits , options , fn ) {
227233 // Argument reshuffling.
228234 /* eslint-disable no-unused-expressions, no-sequences */
229- if ( is . fn ( options ) ) fn = options , options = null ;
230- if ( is . fn ( traits ) ) fn = traits , options = null , traits = null ;
231- if ( is . object ( id ) ) options = traits , traits = id , id = user . id ( ) ;
235+ if ( is . fn ( options ) ) ( fn = options ) , ( options = null ) ;
236+ if ( is . fn ( traits ) ) ( fn = traits ) , ( options = null ) , ( traits = null ) ;
237+ if ( is . object ( id ) ) ( options = traits ) , ( traits = id ) , ( id = user . id ( ) ) ;
232238 /* eslint-enable no-unused-expressions, no-sequences */
233239
234240 // clone traits before we manipulate so we don't do anything uncouth, and take
@@ -278,12 +284,11 @@ Analytics.prototype.user = function() {
278284Analytics . prototype . group = function ( id , traits , options , fn ) {
279285 /* eslint-disable no-unused-expressions, no-sequences */
280286 if ( ! arguments . length ) return group ;
281- if ( is . fn ( options ) ) fn = options , options = null ;
282- if ( is . fn ( traits ) ) fn = traits , options = null , traits = null ;
283- if ( is . object ( id ) ) options = traits , traits = id , id = group . id ( ) ;
287+ if ( is . fn ( options ) ) ( fn = options ) , ( options = null ) ;
288+ if ( is . fn ( traits ) ) ( fn = traits ) , ( options = null ) , ( traits = null ) ;
289+ if ( is . object ( id ) ) ( options = traits ) , ( traits = id ) , ( id = group . id ( ) ) ;
284290 /* eslint-enable no-unused-expressions, no-sequences */
285291
286-
287292 // grab from group again to make sure we're taking from the source
288293 group . identify ( id , traits ) ;
289294
@@ -318,8 +323,9 @@ Analytics.prototype.group = function(id, traits, options, fn) {
318323Analytics . prototype . track = function ( event , properties , options , fn ) {
319324 // Argument reshuffling.
320325 /* eslint-disable no-unused-expressions, no-sequences */
321- if ( is . fn ( options ) ) fn = options , options = null ;
322- if ( is . fn ( properties ) ) fn = properties , options = null , properties = null ;
326+ if ( is . fn ( options ) ) ( fn = options ) , ( options = null ) ;
327+ if ( is . fn ( properties ) )
328+ ( fn = properties ) , ( options = null ) , ( properties = null ) ;
323329 /* eslint-enable no-unused-expressions, no-sequences */
324330
325331 // figure out if the event is archived.
@@ -353,7 +359,10 @@ Analytics.prototype.track = function(event, properties, options, fn) {
353359 }
354360
355361 // Add the initialize integrations so the server-side ones can be disabled too
356- defaults ( msg . integrations , this . _mergeInitializeAndPlanIntegrations ( planIntegrationOptions ) ) ;
362+ defaults (
363+ msg . integrations ,
364+ this . _mergeInitializeAndPlanIntegrations ( planIntegrationOptions )
365+ ) ;
357366
358367 this . _invoke ( 'track' , new Track ( msg ) ) ;
359368
@@ -374,7 +383,11 @@ Analytics.prototype.track = function(event, properties, options, fn) {
374383 * @return {Analytics }
375384 */
376385
377- Analytics . prototype . trackClick = Analytics . prototype . trackLink = function ( links , event , properties ) {
386+ Analytics . prototype . trackClick = Analytics . prototype . trackLink = function (
387+ links ,
388+ event ,
389+ properties
390+ ) {
378391 if ( ! links ) return this ;
379392 // always arrays, handles jquery
380393 if ( type ( links ) === 'element' ) links = [ links ] ;
@@ -387,9 +400,10 @@ Analytics.prototype.trackClick = Analytics.prototype.trackLink = function(links,
387400 on ( el , 'click' , function ( e ) {
388401 var ev = is . fn ( event ) ? event ( el ) : event ;
389402 var props = is . fn ( properties ) ? properties ( el ) : properties ;
390- var href = el . getAttribute ( 'href' )
391- || el . getAttributeNS ( 'http://www.w3.org/1999/xlink' , 'href' )
392- || el . getAttribute ( 'xlink:href' ) ;
403+ var href =
404+ el . getAttribute ( 'href' ) ||
405+ el . getAttributeNS ( 'http://www.w3.org/1999/xlink' , 'href' ) ||
406+ el . getAttribute ( 'xlink:href' ) ;
393407
394408 self . track ( ev , props ) ;
395409
@@ -417,14 +431,19 @@ Analytics.prototype.trackClick = Analytics.prototype.trackLink = function(links,
417431 * @return {Analytics }
418432 */
419433
420- Analytics . prototype . trackSubmit = Analytics . prototype . trackForm = function ( forms , event , properties ) {
434+ Analytics . prototype . trackSubmit = Analytics . prototype . trackForm = function (
435+ forms ,
436+ event ,
437+ properties
438+ ) {
421439 if ( ! forms ) return this ;
422440 // always arrays, handles jquery
423441 if ( type ( forms ) === 'element' ) forms = [ forms ] ;
424442
425443 var self = this ;
426444 each ( function ( el ) {
427- if ( type ( el ) !== 'element' ) throw new TypeError ( 'Must pass HTMLElement to `analytics.trackForm`.' ) ;
445+ if ( type ( el ) !== 'element' )
446+ throw new TypeError ( 'Must pass HTMLElement to `analytics.trackForm`.' ) ;
428447 function handler ( e ) {
429448 prevent ( e ) ;
430449
@@ -465,12 +484,15 @@ Analytics.prototype.trackSubmit = Analytics.prototype.trackForm = function(forms
465484Analytics . prototype . page = function ( category , name , properties , options , fn ) {
466485 // Argument reshuffling.
467486 /* eslint-disable no-unused-expressions, no-sequences */
468- if ( is . fn ( options ) ) fn = options , options = null ;
469- if ( is . fn ( properties ) ) fn = properties , options = properties = null ;
470- if ( is . fn ( name ) ) fn = name , options = properties = name = null ;
471- if ( type ( category ) === 'object' ) options = name , properties = category , name = category = null ;
472- if ( type ( name ) === 'object' ) options = properties , properties = name , name = null ;
473- if ( type ( category ) === 'string' && type ( name ) !== 'string' ) name = category , category = null ;
487+ if ( is . fn ( options ) ) ( fn = options ) , ( options = null ) ;
488+ if ( is . fn ( properties ) ) ( fn = properties ) , ( options = properties = null ) ;
489+ if ( is . fn ( name ) ) ( fn = name ) , ( options = properties = name = null ) ;
490+ if ( type ( category ) === 'object' )
491+ ( options = name ) , ( properties = category ) , ( name = category = null ) ;
492+ if ( type ( name ) === 'object' )
493+ ( options = properties ) , ( properties = name ) , ( name = null ) ;
494+ if ( type ( category ) === 'string' && type ( name ) !== 'string' )
495+ ( name = category ) , ( category = null ) ;
474496 /* eslint-enable no-unused-expressions, no-sequences */
475497
476498 properties = clone ( properties ) || { } ;
@@ -539,9 +561,9 @@ Analytics.prototype.pageview = function(url) {
539561Analytics . prototype . alias = function ( to , from , options , fn ) {
540562 // Argument reshuffling.
541563 /* eslint-disable no-unused-expressions, no-sequences */
542- if ( is . fn ( options ) ) fn = options , options = null ;
543- if ( is . fn ( from ) ) fn = from , options = null , from = null ;
544- if ( is . object ( from ) ) options = from , from = null ;
564+ if ( is . fn ( options ) ) ( fn = options ) , ( options = null ) ;
565+ if ( is . fn ( from ) ) ( fn = from ) , ( options = null ) , ( from = null ) ;
566+ if ( is . object ( from ) ) ( options = from ) , ( from = null ) ;
545567 /* eslint-enable no-unused-expressions, no-sequences */
546568
547569 var msg = this . normalize ( {
@@ -660,7 +682,11 @@ Analytics.prototype._invoke = function(method, facade) {
660682 // Check if an integration failed to initialize.
661683 // If so, do not process the message as the integration is in an unstable state.
662684 if ( failedInitializations . indexOf ( name ) >= 0 ) {
663- self . log ( 'Skipping invokation of .%s method of %s integration. Integation failed to initialize properly.' , method , name ) ;
685+ self . log (
686+ 'Skipping invokation of .%s method of %s integration. Integation failed to initialize properly.' ,
687+ method ,
688+ name
689+ ) ;
664690 } else {
665691 try {
666692 metrics . increment ( 'analytics_js.integration.invoke' , {
@@ -673,7 +699,12 @@ Analytics.prototype._invoke = function(method, facade) {
673699 method : method ,
674700 integration_name : integration . name
675701 } ) ;
676- self . log ( 'Error invoking .%s method of %s integration: %o' , method , name , e ) ;
702+ self . log (
703+ 'Error invoking .%s method of %s integration: %o' ,
704+ method ,
705+ name ,
706+ e
707+ ) ;
677708 }
678709 }
679710 } , this . _integrations ) ;
@@ -738,13 +769,17 @@ Analytics.prototype._parseQuery = function(query) {
738769 function pickPrefix ( prefix , object ) {
739770 var length = prefix . length ;
740771 var sub ;
741- return foldl ( function ( acc , val , key ) {
742- if ( key . substr ( 0 , length ) === prefix ) {
743- sub = key . substr ( length ) ;
744- acc [ sub ] = val ;
745- }
746- return acc ;
747- } , { } , object ) ;
772+ return foldl (
773+ function ( acc , val , key ) {
774+ if ( key . substr ( 0 , length ) === prefix ) {
775+ sub = key . substr ( length ) ;
776+ acc [ sub ] = val ;
777+ }
778+ return acc ;
779+ } ,
780+ { } ,
781+ object
782+ ) ;
748783 }
749784} ;
750785
@@ -772,7 +807,9 @@ Analytics.prototype.normalize = function(msg) {
772807 * @param {Object } planIntegrations Tracking plan integrations.
773808 * @return {Object } The merged integrations.
774809 */
775- Analytics . prototype . _mergeInitializeAndPlanIntegrations = function ( planIntegrations ) {
810+ Analytics . prototype . _mergeInitializeAndPlanIntegrations = function (
811+ planIntegrations
812+ ) {
776813 // Do nothing if there are no initialization integrations
777814 if ( ! this . options . integrations ) {
778815 return planIntegrations ;
0 commit comments