Skip to content

Commit f9eea1f

Browse files
sergeymitrmatticbot
authored andcommitted
Google Analytics: extract API into the package (#37358)
* Move Google Analytics API code from Jetpack into the package. * Add the `is_active` flag to indicate whether GA is active (currently module activation status is used). * Modify the Status package to check activation status of an unavailable module to ease transition to settings when GA module gets removed from Jetpack. Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/9587984604 Upstream-Ref: Automattic/jetpack@25eb8fa
1 parent 8e7d436 commit f9eea1f

File tree

3 files changed

+84
-76
lines changed

3 files changed

+84
-76
lines changed

vendor/automattic/jetpack-status/src/class-modules.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,16 @@ class Modules {
2222
* Check whether or not a Jetpack module is active.
2323
*
2424
* @param string $module The slug of a Jetpack module.
25+
* @param bool $available_only Whether to only check among available modules.
26+
*
2527
* @return bool
2628
*/
27-
public function is_active( $module ) {
29+
public function is_active( $module, $available_only = true ) {
2830
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
2931
return true;
3032
}
3133

32-
return in_array( $module, self::get_active(), true );
34+
return in_array( $module, self::get_active( $available_only ), true );
3335
}
3436

3537
/**
@@ -184,8 +186,12 @@ public function get_file_data( $file, $headers ) {
184186

185187
/**
186188
* Get a list of activated modules as an array of module slugs.
189+
*
190+
* @param bool $available_only Filter out the unavailable (deleted) modules.
191+
*
192+
* @return array
187193
*/
188-
public function get_active() {
194+
public function get_active( $available_only = true ) {
189195
$active = \Jetpack_Options::get_option( 'active_modules' );
190196

191197
if ( ! is_array( $active ) ) {
@@ -206,9 +212,11 @@ public function get_active() {
206212
$active[] = 'protect';
207213
}
208214

209-
// If it's not available, it shouldn't be active.
210-
// We don't delete it from the options though, as it will be active again when a plugin gets reactivated.
211-
$active = array_intersect( $active, $this->get_available() );
215+
if ( $available_only ) {
216+
// If it's not available, it shouldn't be active.
217+
// We don't delete it from the options though, as it will be active again when a plugin gets reactivated.
218+
$active = array_intersect( $active, $this->get_available() );
219+
}
212220

213221
/**
214222
* Allow filtering of the active modules.

vendor/composer/installed.json

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
"dist": {
7878
"type": "path",
7979
"url": "/tmp/jetpack-build/Automattic/jetpack-a8c-mc-stats",
80-
"reference": "57565ecf1d1e928ae6e6b45173a02c79d3544fa4"
80+
"reference": "1166eb6d60bf9041fc24e92183e2be2eba4eaa50"
8181
},
8282
"require": {
8383
"php": ">=7.0"
@@ -130,7 +130,7 @@
130130
"dist": {
131131
"type": "path",
132132
"url": "/tmp/jetpack-build/Automattic/jetpack-admin-ui",
133-
"reference": "e6e28ab1194657afde81db84f7ec8bb489d45d6e"
133+
"reference": "69bbda0b31283c2f68c1a24d0689392693ca3661"
134134
},
135135
"require": {
136136
"php": ">=7.0"
@@ -195,7 +195,7 @@
195195
"dist": {
196196
"type": "path",
197197
"url": "/tmp/jetpack-build/Automattic/jetpack-assets",
198-
"reference": "9169418943668ede23103835ed81b770fe1e48e7"
198+
"reference": "d8252891c9aa01cb986e443c11a808d10de64d5b"
199199
},
200200
"require": {
201201
"automattic/jetpack-constants": "^2.0.3",
@@ -264,15 +264,15 @@
264264
"dist": {
265265
"type": "path",
266266
"url": "/tmp/jetpack-build/Automattic/jetpack-blaze",
267-
"reference": "d94683157c6445c8b53e5d93fc81cbf3bb4440df"
267+
"reference": "d8d9b0e1b554c1a245bc77f5b29bfb21170d43ae"
268268
},
269269
"require": {
270270
"automattic/jetpack-assets": "^2.1.12",
271271
"automattic/jetpack-connection": "^2.10.1",
272272
"automattic/jetpack-constants": "^2.0.3",
273273
"automattic/jetpack-plans": "^0.4.7",
274274
"automattic/jetpack-redirect": "^2.0.2",
275-
"automattic/jetpack-status": "^3.3.0",
275+
"automattic/jetpack-status": "^3.3.1-alpha",
276276
"automattic/jetpack-sync": "^3.1.1",
277277
"php": ">=7.0"
278278
},
@@ -345,7 +345,7 @@
345345
"dist": {
346346
"type": "path",
347347
"url": "/tmp/jetpack-build/Automattic/jetpack-blocks",
348-
"reference": "277b19aecce93e43e384f44848c701c9efdc7f6f"
348+
"reference": "4c99d69e4d14da0db4cf4944c4bb74ccf5a7fc85"
349349
},
350350
"require": {
351351
"automattic/jetpack-constants": "^2.0.3",
@@ -407,11 +407,11 @@
407407
"dist": {
408408
"type": "path",
409409
"url": "/tmp/jetpack-build/Automattic/jetpack-calypsoify",
410-
"reference": "de8ce1cb21fa8e4c365edbe04d85ee28367ac1a6"
410+
"reference": "6649937f0c8fafc4ad47c2810b250eb331ba4a63"
411411
},
412412
"require": {
413413
"automattic/jetpack-assets": "^2.1.12",
414-
"automattic/jetpack-status": "^3.3.0",
414+
"automattic/jetpack-status": "^3.3.1-alpha",
415415
"php": ">=7.0"
416416
},
417417
"require-dev": {
@@ -472,7 +472,7 @@
472472
"dist": {
473473
"type": "path",
474474
"url": "/tmp/jetpack-build/Automattic/jetpack-classic-theme-helper",
475-
"reference": "9951a9d682ccdbef3df7bc6767c6a94dbb81b253"
475+
"reference": "5e251a2c2f383be9fd2ec288c82c3fad4f0fdaa9"
476476
},
477477
"require": {
478478
"automattic/jetpack-assets": "^2.1.12",
@@ -543,7 +543,7 @@
543543
"dist": {
544544
"type": "path",
545545
"url": "/tmp/jetpack-build/Automattic/jetpack-compat",
546-
"reference": "aa75a7a512adb17534becd6614597ab1586613ed"
546+
"reference": "1ec3fe0827a306c694747c129ced86958fcadee8"
547547
},
548548
"require": {
549549
"php": ">=7.0"
@@ -583,7 +583,7 @@
583583
"dist": {
584584
"type": "path",
585585
"url": "/tmp/jetpack-build/Automattic/jetpack-config",
586-
"reference": "13d8bd509274e41d851368349b58bc15f99283f0"
586+
"reference": "b0481b8a446ee51e840bfa6c44ad3a385ed8cc56"
587587
},
588588
"require": {
589589
"php": ">=7.0"
@@ -659,7 +659,7 @@
659659
"dist": {
660660
"type": "path",
661661
"url": "/tmp/jetpack-build/Automattic/jetpack-connection",
662-
"reference": "cbf449d136b31d6a11dcc63a435188855ceb9a0f"
662+
"reference": "707db26d28c1b2522d2c90f72e36b1ad79822af2"
663663
},
664664
"require": {
665665
"automattic/jetpack-a8c-mc-stats": "^2.0.1",
@@ -668,7 +668,7 @@
668668
"automattic/jetpack-constants": "^2.0.3",
669669
"automattic/jetpack-redirect": "^2.0.2",
670670
"automattic/jetpack-roles": "^2.0.2",
671-
"automattic/jetpack-status": "^3.3.0",
671+
"automattic/jetpack-status": "^3.3.1-alpha",
672672
"php": ">=7.0"
673673
},
674674
"require-dev": {
@@ -746,7 +746,7 @@
746746
"dist": {
747747
"type": "path",
748748
"url": "/tmp/jetpack-build/Automattic/jetpack-constants",
749-
"reference": "d9a997a419fd9f40998601bb51c5f0877cc0f63d"
749+
"reference": "12996819eaf48f0791b2b2f5d63db6ec12d3e21a"
750750
},
751751
"require": {
752752
"php": ">=7.0"
@@ -800,7 +800,7 @@
800800
"dist": {
801801
"type": "path",
802802
"url": "/tmp/jetpack-build/Automattic/jetpack-device-detection",
803-
"reference": "587428020b82718ffe7528d8be479c4457471cc5"
803+
"reference": "f33a299c4e99cfc7ee61736ea9a6c124f83d3d63"
804804
},
805805
"require": {
806806
"php": ">=7.0"
@@ -853,7 +853,7 @@
853853
"dist": {
854854
"type": "path",
855855
"url": "/tmp/jetpack-build/Automattic/jetpack-ip",
856-
"reference": "e8814dcc6fdb38909c2dfae3d94099fc62bb8bec"
856+
"reference": "ce996844bf1504dc40ae12c404a156933ebffff1"
857857
},
858858
"require": {
859859
"php": ">=7.0"
@@ -911,7 +911,7 @@
911911
"dist": {
912912
"type": "path",
913913
"url": "/tmp/jetpack-build/Automattic/jetpack-jitm",
914-
"reference": "dc979d8435dbc57c18f29de6bc1c4f066a8a8e13"
914+
"reference": "796e7c1fb8baf47f3f95d09b3184050cccee3dd5"
915915
},
916916
"require": {
917917
"automattic/jetpack-a8c-mc-stats": "^2.0.1",
@@ -920,7 +920,7 @@
920920
"automattic/jetpack-device-detection": "^2.1.3",
921921
"automattic/jetpack-logo": "^2.0.3",
922922
"automattic/jetpack-redirect": "^2.0.2",
923-
"automattic/jetpack-status": "^3.3.0",
923+
"automattic/jetpack-status": "^3.3.1-alpha",
924924
"php": ">=7.0"
925925
},
926926
"require-dev": {
@@ -986,7 +986,7 @@
986986
"dist": {
987987
"type": "path",
988988
"url": "/tmp/jetpack-build/Automattic/jetpack-logo",
989-
"reference": "0f646dbed21d406adaa3667848ff43c99be0fb72"
989+
"reference": "eda60aae7371e9b619b2c3ff9a91a814f1bf00ee"
990990
},
991991
"require": {
992992
"php": ">=7.0"
@@ -1039,7 +1039,7 @@
10391039
"dist": {
10401040
"type": "path",
10411041
"url": "/tmp/jetpack-build/Automattic/jetpack-masterbar",
1042-
"reference": "aebcec39863a3fe3964aefb9708207fddf36613f"
1042+
"reference": "b048e661d1126f983134bc2daf9142932ec25c8e"
10431043
},
10441044
"require": {
10451045
"automattic/jetpack-assets": "^2.1.12",
@@ -1050,7 +1050,7 @@
10501050
"automattic/jetpack-jitm": "^3.1.12",
10511051
"automattic/jetpack-logo": "^2.0.3",
10521052
"automattic/jetpack-plans": "^0.4.7",
1053-
"automattic/jetpack-status": "^3.3.0",
1053+
"automattic/jetpack-status": "^3.3.1-alpha",
10541054
"php": ">=7.0"
10551055
},
10561056
"require-dev": {
@@ -1121,7 +1121,7 @@
11211121
"dist": {
11221122
"type": "path",
11231123
"url": "/tmp/jetpack-build/Automattic/jetpack-mu-wpcom",
1124-
"reference": "81348ddc66129a11db50ecbbf96e40b5f85a8a3d"
1124+
"reference": "b0562a9b98fe9bed190d099bf0137573453cefec"
11251125
},
11261126
"require": {
11271127
"automattic/jetpack-assets": "^2.1.12",
@@ -1133,7 +1133,7 @@
11331133
"automattic/jetpack-masterbar": "^0.2.0-alpha",
11341134
"automattic/jetpack-redirect": "^2.0.2",
11351135
"automattic/jetpack-stats-admin": "^0.20.0",
1136-
"automattic/jetpack-status": "^3.3.0",
1136+
"automattic/jetpack-status": "^3.3.1-alpha",
11371137
"automattic/scheduled-updates": "^0.13.0",
11381138
"php": ">=7.0"
11391139
},
@@ -1202,7 +1202,7 @@
12021202
"dist": {
12031203
"type": "path",
12041204
"url": "/tmp/jetpack-build/Automattic/jetpack-password-checker",
1205-
"reference": "721eff51d4405493dff08ce86da9219529f18e04"
1205+
"reference": "3ca08362782e8a37d7990412181d53d11afc67ee"
12061206
},
12071207
"require": {
12081208
"php": ">=7.0"
@@ -1263,15 +1263,15 @@
12631263
"dist": {
12641264
"type": "path",
12651265
"url": "/tmp/jetpack-build/Automattic/jetpack-plans",
1266-
"reference": "bb6ca9c1fd1c22345cc32033494ed0e151d25ba6"
1266+
"reference": "9542ca5932548665d098df6f6ee3473082756de5"
12671267
},
12681268
"require": {
12691269
"automattic/jetpack-connection": "^2.10.1",
12701270
"php": ">=7.0"
12711271
},
12721272
"require-dev": {
12731273
"automattic/jetpack-changelogger": "^4.2.4",
1274-
"automattic/jetpack-status": "^3.3.0",
1274+
"automattic/jetpack-status": "^3.3.1-alpha",
12751275
"automattic/wordbless": "@dev",
12761276
"yoast/phpunit-polyfills": "1.1.0"
12771277
},
@@ -1331,7 +1331,7 @@
13311331
"dist": {
13321332
"type": "path",
13331333
"url": "/tmp/jetpack-build/Automattic/jetpack-post-list",
1334-
"reference": "85be4fe77fe0b01534e44d8467bc7292dd0e464d"
1334+
"reference": "7f068bd15114177ca32a10c427ceacd4377277bb"
13351335
},
13361336
"require": {
13371337
"automattic/jetpack-assets": "^2.1.12",
@@ -1396,10 +1396,10 @@
13961396
"dist": {
13971397
"type": "path",
13981398
"url": "/tmp/jetpack-build/Automattic/jetpack-redirect",
1399-
"reference": "013015425b75dc6473d5ee11a84bfcc316486756"
1399+
"reference": "cff347b983332351797c8223983cbe343034dfec"
14001400
},
14011401
"require": {
1402-
"automattic/jetpack-status": "^3.3.0",
1402+
"automattic/jetpack-status": "^3.3.1-alpha",
14031403
"php": ">=7.0"
14041404
},
14051405
"require-dev": {
@@ -1451,7 +1451,7 @@
14511451
"dist": {
14521452
"type": "path",
14531453
"url": "/tmp/jetpack-build/Automattic/jetpack-roles",
1454-
"reference": "513122ccb9cc1b8fd8f75f83c287493d54a63402"
1454+
"reference": "f2752f49a1414d6dd149118ae1389fe09e0dbb43"
14551455
},
14561456
"require": {
14571457
"php": ">=7.0"
@@ -1505,12 +1505,12 @@
15051505
"dist": {
15061506
"type": "path",
15071507
"url": "/tmp/jetpack-build/Automattic/jetpack-stats",
1508-
"reference": "da0716c8c8bac6d1ed3aa6324e20eb1527bafafb"
1508+
"reference": "677d014e793fa570578babbfacfb43b75e75d86b"
15091509
},
15101510
"require": {
15111511
"automattic/jetpack-connection": "^2.10.1",
15121512
"automattic/jetpack-constants": "^2.0.3",
1513-
"automattic/jetpack-status": "^3.3.0",
1513+
"automattic/jetpack-status": "^3.3.1-alpha",
15141514
"php": ">=7.0"
15151515
},
15161516
"require-dev": {
@@ -1572,15 +1572,15 @@
15721572
"dist": {
15731573
"type": "path",
15741574
"url": "/tmp/jetpack-build/Automattic/jetpack-stats-admin",
1575-
"reference": "a71d0c49bad3b4406d349f4730264432bfbad947"
1575+
"reference": "bc0a6d9ea3d4f26ace4e275177154e8a7853b03f"
15761576
},
15771577
"require": {
15781578
"automattic/jetpack-connection": "^2.10.1",
15791579
"automattic/jetpack-constants": "^2.0.3",
15801580
"automattic/jetpack-jitm": "^3.1.12",
15811581
"automattic/jetpack-plans": "^0.4.7",
15821582
"automattic/jetpack-stats": "^0.13.0",
1583-
"automattic/jetpack-status": "^3.3.0",
1583+
"automattic/jetpack-status": "^3.3.1-alpha",
15841584
"php": ">=7.0"
15851585
},
15861586
"require-dev": {
@@ -1640,12 +1640,12 @@
16401640
},
16411641
{
16421642
"name": "automattic/jetpack-status",
1643-
"version": "3.3.0",
1644-
"version_normalized": "3.3.0.0",
1643+
"version": "3.3.1-alpha.1718830075",
1644+
"version_normalized": "3.3.1.0-alpha1718830075",
16451645
"dist": {
16461646
"type": "path",
16471647
"url": "/tmp/jetpack-build/Automattic/jetpack-status",
1648-
"reference": "96e1f6992308225394cf85d0d1667c5eecea215b"
1648+
"reference": "8a8cb36ecd51f97a62044e19567e214d4fdaa1a8"
16491649
},
16501650
"require": {
16511651
"automattic/jetpack-constants": "^2.0.3",
@@ -1710,15 +1710,15 @@
17101710
"dist": {
17111711
"type": "path",
17121712
"url": "/tmp/jetpack-build/Automattic/jetpack-sync",
1713-
"reference": "340269110220c9713c24f14277fd0e2099b752af"
1713+
"reference": "ef3513d278008060a3337a62d3778390d7da88b0"
17141714
},
17151715
"require": {
17161716
"automattic/jetpack-connection": "^2.10.1",
17171717
"automattic/jetpack-constants": "^2.0.3",
17181718
"automattic/jetpack-ip": "^0.2.2",
17191719
"automattic/jetpack-password-checker": "^0.3.1",
17201720
"automattic/jetpack-roles": "^2.0.2",
1721-
"automattic/jetpack-status": "^3.3.0",
1721+
"automattic/jetpack-status": "^3.3.1-alpha",
17221722
"php": ">=7.0"
17231723
},
17241724
"require-dev": {
@@ -1788,13 +1788,13 @@
17881788
"dist": {
17891789
"type": "path",
17901790
"url": "/tmp/jetpack-build/Automattic/scheduled-updates",
1791-
"reference": "29b2826ab44410f64e75d04e8c9dcd66bd838e0d"
1791+
"reference": "510f4869856d8dee98b1dc0a57f75f816d60de9a"
17921792
},
17931793
"require": {
17941794
"automattic/jetpack-connection": "^2.10.1",
17951795
"automattic/jetpack-constants": "^2.0.3",
17961796
"automattic/jetpack-plans": "^0.4.7",
1797-
"automattic/jetpack-status": "^3.3.0",
1797+
"automattic/jetpack-status": "^3.3.1-alpha",
17981798
"automattic/jetpack-sync": "^3.1.1",
17991799
"php": ">=7.0"
18001800
},

0 commit comments

Comments
 (0)