How to use the @shopify/network.Header.UserAgent function in @shopify/network

To help you get started, we’ve selected a few @shopify/network examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / quilt / packages / sewing-kit-koa / src / middleware.ts View on Github external
async function sewingKitMiddleware(ctx: Context, next: () => Promise) {
    const assets = new Assets({
      assetPrefix,
      userAgent: ctx.get(Header.UserAgent),
      manifestPath,
    });

    setAssets(ctx, assets);

    await next();
  }
github Shopify / quilt / packages / koa-performance / src / middleware.ts View on Github external
const {body} = ctx.request as any;
      if (!isClientMetricsBody(body)) {
        ctx.status = StatusCode.UnprocessableEntity;
        return;
      }

      const statsd = new StatsDClient({
        host: statsdHost,
        port: statsdPort,
        logger: statsLogger,
        snakeCase: true,
        prefix,
      });

      const userAgent = ctx.get(Header.UserAgent);
      const {connection, events, navigations} = body;

      const metrics: {
        name: string;
        value: any;
        tags: {[key: string]: string | undefined | null};
      }[] = [];

      const additionalTags = getAdditionalTags
        ? getAdditionalTags(body, userAgent)
        : {};

      const tags = {
        browserConnectionType: connection.effectiveType,
        ...additionalTags,
      };