From 37504dbe0139c1d4975a9abdb1d7fdd06981c28a Mon Sep 17 00:00:00 2001 From: James Nylen Date: Thu, 3 Aug 2017 19:15:41 -0400 Subject: [PATCH] Track stats for automatically converted blocks --- blocks/api/parser.js | 6 ++++++ test/setup-globals.js | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/blocks/api/parser.js b/blocks/api/parser.js index 5a7b871719fb5..a02a75e7b80a9 100644 --- a/blocks/api/parser.js +++ b/blocks/api/parser.js @@ -4,6 +4,11 @@ import { parse as hpqParse } from 'hpq'; import { pickBy } from 'lodash'; +/** + * WordPress dependencies + */ +import { bumpStat } from '@wordpress/utils'; + /** * Internal dependencies */ @@ -75,6 +80,7 @@ export function createBlockWithFallback( name, rawContent, attributes ) { // Convert 'core/text' blocks in existing content to the new // 'core/paragraph'. if ( name === 'core/text' ) { + bumpStat( 'block_auto_convert', 'core-text-to-paragraph' ); name = 'core/paragraph'; } diff --git a/test/setup-globals.js b/test/setup-globals.js index 931f6e146d798..d5a8ed265c789 100644 --- a/test/setup-globals.js +++ b/test/setup-globals.js @@ -51,3 +51,14 @@ global.wp = global.wp || {}; global.wp.a11y = { speak: () => {}, }; + +global.window.getUserSetting = settingName => { + switch ( settingName ) { + case 'gutenberg_tracking': + return 'on'; + default: + throw new Error( + 'Unrecognized user setting requested: ' + settingName + ); + } +};