Coder Social home page Coder Social logo

devtools's People

Contributors

auz avatar bttf avatar camerondowner avatar jdorn avatar mknowlton89 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

devtools's Issues

Port "devtools" into new extension

Given we have a new chrome extension architecture,

When we port the existing devtools code into it,

Then it should work as it did in the previous chrome extension

Current Value override doesn't work with Javascript SDK

I've added the Javascript SDK to our bundle with web pack. The dev tools can read the features and user attributes no problem, but overriding the Current Value in dev tools doesn't seem to change the feature value.

Javascript Setup:

import { GrowthBook } from "@growthbook/growthbook";

const gb = new GrowthBook({
  apiHost: "https://cdn.growthbook.io",
  clientKey: "******************",
  enableDevMode: true,
  subscribeToChanges: true,
  trackingCallback: (experiment, result) => {
    // TODO: Use your real analytics tracking system
    console.log("Viewed Experiment", {
      experimentId: experiment.key,
      variationId: result.key
    });
  }
});
window.gb = gb; // Expose for debugging

...

gb.setAttributes({
  id: cartToken,
  email: window?.userAttributes?.email,
  customerId: window?.userAttributes?.customerId,
  totalSpent: window?.userAttributes?.totalSpent,
  ordersCount: window?.userAttributes?.ordersCount,
  tags: window?.userAttributes?.tags,
  country: Shopify.country,
  locale: Shopify?.locale,
  currency: Shopify?.currency?.active,
  url: window.location.href,
  userAgent: navigator.userAgent,
  screenWidth: window.innerWidth,
  screenSize: screenSize,
  themeId: Shopify.theme.id,
  themeName: Shopify.theme.name,
  themeRole: Shopify.theme.role
});


//===========================
// setup growthbook
//===========================

export const setupGrowthbook = async function(){

    // Wait for features to be available
    await gb.loadFeatures();

    const value = gb.getFeatureValue("google-top-quality-store");
    console.log("google-top-quality-store", value);

}

Heres the devtools screen:
Screenshot 2023-11-16 at 3 26 55 PM

The feature never shows as a force feature value:
Screenshot 2023-11-16 at 3 28 34 PM

I've been digging through to code to try and find the method by which these are getting set. It seems theres something with messages sent to the window so I started logging any related to GB

window.addEventListener("message", function (event) {
  const data = event.data;
  if(data?.type?.startsWith("GB_")){
    console.log(data);
  }
});

but I only get one message:

{
	attributes: {id: '31295c7d037d94ba9af407aee0fb2eba', email: undefined, customerId: undefined, totalSpent: undefined, ordersCount: undefined, …}
	experiments: {}
	features: { 
		google-top-quality-store : {defaultValue: false, rules: Array(1)}
	}
	overrides: {},
	type: "GB_REFRESH"
}

which also appears to have no overrides.

Devtools not connecting in incognito

As the title says, opening the devtools (with the plugin correctly enabled) in chrome's incognito mode the user is presented with the "Trying to connect to page's GrowthBook SDK" message.

This issue seems consistent across Chromium based browsers.

Chromium Engine Version: 121.x/122.x
GrowthBook devtools plugin Version: 0.3.6

GrowthBook DevTools behaves unexpectedly with multiple tabs running the GrowthBook SDK

Problem: Currently, if a user has multiple tabs open with each tab running an instance of the GrowthBook JS SDK, the GrowthBook DevTools extension will behave unexpectedly. This is due to the DevTools extension indiscriminately selecting the first tab it finds to communicate with.

DevTools extension upon opening (syncs with current tab's GrowthBook SDK)
Screenshot 2023-10-13 at 4 31 36 PM

DevTools extension upon opening a 2nd tab with it's own GrowthBook SDK (extension syncs with recently opened tab)

Screenshot 2023-10-13 at 4 32 07 PM

Proposed solution: Ensure messages are contained between tab and content script and background script target the inspected window.

Implementation:

  1. See example solution provided by contributor

Related bug #39

Changing feature values doesn't work when using Chrome devtools in a separate window

Hi,

I'm using the devtools while using Chrome DevTools in a separate window pop out but the feature flag values aren't updating.

I think this is caused by the function sendMessage in controller.ts not being able to find the correct tab, as it's no longer the currentWindow - the DevTools window is.

I've cloned and tested the following solution, and I believe it works as expected. Let me know if you'd prefer me to open a pull request.

Current

function sendMessage(msg: Message) {
  chrome.tabs &&
    chrome.tabs.query(
      {
        active: true,
        currentWindow: true,
      },
      (tabs) => {
        chrome.tabs.sendMessage(tabs[0].id || 0, msg);
      }
    );
}

Suggestion

function sendMessage(msg: Message) {
    if (chrome.tabs && chrome.devtools?.inspectedWindow) {
        const  { tabId } = chrome.devtools.inspectedWindow;
        chrome.tabs.sendMessage(tabId || 0, msg);
    }
}

URL Targeting debugging within Visual Editor

Problem: Users don’t know if URL targets are working when they make edits in the Visual Editor. Only when loading the SDK and experiment do they find out, and it’s hard to debug.

Proposed solution: Add an indicator to the Visual Editor that displays whether or not the URL targeting rules for a given experiment are targeting the current page being edited.

Steps to implement

  1. Ensure the visual editor can load URL targeting rules of an experiment. (Needs to happen in fetchVisualChangeset in src/background.ts ) Might already be included in payload from API but if not, we need to make changes to GB backend to include them.
  2. Leverage GrowthBook JS SDK util isURLTargeted to determine if any of the URLs target the current loaded page URL. (If the GB JS SDK is not installed it is OK to add as a dependency to Visual Editor)
  3. Render UI in the Visual Editor that is minimal but effective in alerting the user when no URL targets target the currently loaded page URL

Add CI/CD workflows

Add CI/CD workflows:

  • build
  • unit tests
  • package and upload as build artifact to the Github Action workflow run

Based on this discussion: #8 (comment)

Create chrome extension w/ new architecture

Our current chrome extension (https://github.com/growthbook/devtools) is built around a single feature - the GrowthBook devtools panel.

It's current architecture is built on create-react-app that is pointed to build the DevTools panel UX.

We need to extend the development and build pipeline to allow for the development of multiple build targets (and not just a single react app).

This task is to forge a new chrome extension with an architecture that cleanly supports multiple features with different build targets.

Example build targets:

  • Devtools panel
  • Popup menu
  • Visual Editor UX
  • Options menu

Add React Storybook

Add support for Storybook in the devtools. Currently we need to build and reload the extension which creates a slow end-to-end workflow. Allow rapid prototyping with Storybook.

GrowthBook DevTools does not represent multiple visual changesets appropriately for visual experiments

Problem: Currently, when inspecting a Visual Experiment, if the Visual Experiment has multiple visual changesets, the DevTools extension will only render one of them.

Example Experiment w/ multiple visual changesets
Screenshot 2023-10-13 at 4 28 11 PM

DevTools rendering only one of them
Screenshot 2023-10-13 at 4 23 50 PM

Proposed solution: Ensure we render all visual changesets for an experiment and highlight the one that currently targets the page URL. (If none target the URL, notify the user via a small alert in the DevTools UI).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.