apollographql / embeddable-explorer

MIT License
35 stars 12 forks source link

runTelemetry: false does not disable calls to m.stripe.com and others #285

Closed aclarknexient closed 1 year ago

aclarknexient commented 1 year ago

Issue Description

When running an apollo non-prod landing page, disabling telemetry does not seem to work.

Steps to Reproduce

  1. Follow the TypeScript steps in https://www.apollographql.com/docs/apollo-server/getting-started up to the end of step 6.
  2. Don't run the server yet.
  3. Add the embed option to the ApolloServer plugins list
  4. Add runTelemetry: false to the embed options. (Example is below)
  5. Run npm start and open the server landing page at http://localhost:4000/
  6. Open your browser's devtools network monitor and reload the landing page.
  7. Observe calls to hosts outside the local network.

Expected Behaviour

There should be no calls to external hosts:

Actual Behaviour

Calls are made to the following hosts:

import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { ApolloServerPluginLandingPageLocalDefault, ApolloServerPluginLandingPageProductionDefault } from '@apollo/server/plugin/landingPage/default';

// A schema is a collection of type definitions (hence "typeDefs")
// that together define the "shape" of queries that are executed against
// your data.
const typeDefs = `#graphql
  # Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

  # This "Book" type defines the queryable fields for every book in our data source.
  type Book {
    title: String
    author: String
  }

  # The "Query" type is special: it lists all of the available queries that
  # clients can execute, along with the return type for each. In this
  # case, the "books" query returns an array of zero or more Books (defined above).
  type Query {
    books: [Book]
  }
`;

const books = [
  {
    title: 'The Awakening',
    author: 'Kate Chopin',
  },
  {
    title: 'City of Glass',
    author: 'Paul Auster',
  },
];

// Resolvers define how to fetch the types defined in your schema.
// This resolver retrieves books from the "books" array above.
const resolvers = {
  Query: {
    books: () => books,
  },
};

// The ApolloServer constructor requires two parameters: your schema
// definition and your set of resolvers.
const server = new ApolloServer({
  typeDefs,
  resolvers,
  plugins: [
    // Install a landing page plugin based on NODE_ENV
    process.env.NODE_ENV === 'production'
      ? ApolloServerPluginLandingPageProductionDefault({
          graphRef: 'my-graph-id@my-graph-variant',
          footer: false,
        })
      : ApolloServerPluginLandingPageLocalDefault({ 
        footer: false,
        embed: {
          runTelemetry: false,
        }
      }),
  ],
});

// Passing an ApolloServer instance to the `startStandaloneServer` function:
//  1. creates an Express app
//  2. installs your ApolloServer instance as middleware
//  3. prepares your app to handle incoming requests
const { url } = await startStandaloneServer(server, {
  listen: { port: 4000 },
});

console.log(`🚀  Server ready at: ${url}`);
mayakoneval commented 1 year ago

Hello! Thanks for the report.

The embedded Sandbox / Explorer is an iframe to our hosted site studio.apollographql.com. If you would like to use a non-hosted GraphiQL or a custom landing page, we have options for plugins in Apollo Server.

While we do not send any telemetry for folks with runTelemetry: false in the config, the team is working on minimizing the amount of network calls you listed here. Note that most of these network requests are not for telemetry: Stripe & Recurly are for billing, LaunchDarkly is our feature flag service, all the apollographql.com calls are to our cdn which hosts the favicon or the bundle you are seeing, for example. The Google telemetry calls you do see are script tags that we don't use if you have run runTelemetry: false, but we are working on not making the set up calls to begin with.

I'll update when any changes have been shipped, thanks!

mayakoneval commented 1 year ago

Hi! We shipped a fix so you shouldn't see telemetry initial calls at all now with the runTelemetry: false config option. Thanks!