@@ -102,7 +102,10 @@ Analytics.prototype.addIntegration = function(Integration) {
102
102
* @return {Analytics }
103
103
*/
104
104
105
- Analytics . prototype . init = Analytics . prototype . initialize = function ( settings , options ) {
105
+ Analytics . prototype . init = Analytics . prototype . initialize = function (
106
+ settings ,
107
+ options
108
+ ) {
106
109
settings = settings || { } ;
107
110
options = options || { } ;
108
111
@@ -121,8 +124,8 @@ Analytics.prototype.init = Analytics.prototype.initialize = function(settings, o
121
124
// Don't load disabled integrations
122
125
if ( options . integrations ) {
123
126
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 ] )
126
129
) {
127
130
return ;
128
131
}
@@ -158,7 +161,10 @@ Analytics.prototype.init = Analytics.prototype.initialize = function(settings, o
158
161
// create a list of any integrations that did not initialize - this will be passed with all events for replay support:
159
162
this . failedInitializations = [ ] ;
160
163
each ( function ( integration ) {
161
- if ( options . initialPageview && integration . options . initialPageview === false ) {
164
+ if (
165
+ options . initialPageview &&
166
+ integration . options . initialPageview === false
167
+ ) {
162
168
integration . page = after ( 2 , integration . page ) ;
163
169
}
164
170
@@ -226,9 +232,9 @@ Analytics.prototype.add = function(integration) {
226
232
Analytics . prototype . identify = function ( id , traits , options , fn ) {
227
233
// Argument reshuffling.
228
234
/* 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 ( ) ) ;
232
238
/* eslint-enable no-unused-expressions, no-sequences */
233
239
234
240
// clone traits before we manipulate so we don't do anything uncouth, and take
@@ -278,12 +284,11 @@ Analytics.prototype.user = function() {
278
284
Analytics . prototype . group = function ( id , traits , options , fn ) {
279
285
/* eslint-disable no-unused-expressions, no-sequences */
280
286
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 ( ) ) ;
284
290
/* eslint-enable no-unused-expressions, no-sequences */
285
291
286
-
287
292
// grab from group again to make sure we're taking from the source
288
293
group . identify ( id , traits ) ;
289
294
@@ -318,8 +323,9 @@ Analytics.prototype.group = function(id, traits, options, fn) {
318
323
Analytics . prototype . track = function ( event , properties , options , fn ) {
319
324
// Argument reshuffling.
320
325
/* 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 ) ;
323
329
/* eslint-enable no-unused-expressions, no-sequences */
324
330
325
331
// figure out if the event is archived.
@@ -353,7 +359,10 @@ Analytics.prototype.track = function(event, properties, options, fn) {
353
359
}
354
360
355
361
// 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
+ ) ;
357
366
358
367
this . _invoke ( 'track' , new Track ( msg ) ) ;
359
368
@@ -374,7 +383,11 @@ Analytics.prototype.track = function(event, properties, options, fn) {
374
383
* @return {Analytics }
375
384
*/
376
385
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
+ ) {
378
391
if ( ! links ) return this ;
379
392
// always arrays, handles jquery
380
393
if ( type ( links ) === 'element' ) links = [ links ] ;
@@ -387,9 +400,10 @@ Analytics.prototype.trackClick = Analytics.prototype.trackLink = function(links,
387
400
on ( el , 'click' , function ( e ) {
388
401
var ev = is . fn ( event ) ? event ( el ) : event ;
389
402
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' ) ;
393
407
394
408
self . track ( ev , props ) ;
395
409
@@ -417,14 +431,19 @@ Analytics.prototype.trackClick = Analytics.prototype.trackLink = function(links,
417
431
* @return {Analytics }
418
432
*/
419
433
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
+ ) {
421
439
if ( ! forms ) return this ;
422
440
// always arrays, handles jquery
423
441
if ( type ( forms ) === 'element' ) forms = [ forms ] ;
424
442
425
443
var self = this ;
426
444
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`.' ) ;
428
447
function handler ( e ) {
429
448
prevent ( e ) ;
430
449
@@ -465,12 +484,15 @@ Analytics.prototype.trackSubmit = Analytics.prototype.trackForm = function(forms
465
484
Analytics . prototype . page = function ( category , name , properties , options , fn ) {
466
485
// Argument reshuffling.
467
486
/* 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 ) ;
474
496
/* eslint-enable no-unused-expressions, no-sequences */
475
497
476
498
properties = clone ( properties ) || { } ;
@@ -539,9 +561,9 @@ Analytics.prototype.pageview = function(url) {
539
561
Analytics . prototype . alias = function ( to , from , options , fn ) {
540
562
// Argument reshuffling.
541
563
/* 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 ) ;
545
567
/* eslint-enable no-unused-expressions, no-sequences */
546
568
547
569
var msg = this . normalize ( {
@@ -660,7 +682,11 @@ Analytics.prototype._invoke = function(method, facade) {
660
682
// Check if an integration failed to initialize.
661
683
// If so, do not process the message as the integration is in an unstable state.
662
684
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
+ ) ;
664
690
} else {
665
691
try {
666
692
metrics . increment ( 'analytics_js.integration.invoke' , {
@@ -673,7 +699,12 @@ Analytics.prototype._invoke = function(method, facade) {
673
699
method : method ,
674
700
integration_name : integration . name
675
701
} ) ;
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
+ ) ;
677
708
}
678
709
}
679
710
} , this . _integrations ) ;
@@ -738,13 +769,17 @@ Analytics.prototype._parseQuery = function(query) {
738
769
function pickPrefix ( prefix , object ) {
739
770
var length = prefix . length ;
740
771
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
+ ) ;
748
783
}
749
784
} ;
750
785
@@ -772,7 +807,9 @@ Analytics.prototype.normalize = function(msg) {
772
807
* @param {Object } planIntegrations Tracking plan integrations.
773
808
* @return {Object } The merged integrations.
774
809
*/
775
- Analytics . prototype . _mergeInitializeAndPlanIntegrations = function ( planIntegrations ) {
810
+ Analytics . prototype . _mergeInitializeAndPlanIntegrations = function (
811
+ planIntegrations
812
+ ) {
776
813
// Do nothing if there are no initialization integrations
777
814
if ( ! this . options . integrations ) {
778
815
return planIntegrations ;
0 commit comments