snowplow/snowplow-javascript-tracker

View on GitHub

Showing 352 of 352 total issues

Function InQueueManager has 200 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function InQueueManager(functionName: string, asyncQueue: Array<unknown>): Queue {
  const windowAlias = window,
    documentAlias = document,
    sharedState: SharedState = createSharedState(),
    availableTrackerIds: Array<string> = [],
Severity: Major
Found in trackers/javascript-tracker/src/in_queue.ts - About 1 day to fix

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
        if (k2 === undefined) k2 = k;
        var desc = Object.getOwnPropertyDescriptor(m, k);
        if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
          desc = { enumerable: true, get: function() { return m[k]; } };
    Severity: Major
    Found in common/scripts/install-run.js and 1 other location - About 1 day to fix
    common/scripts/install-run-rush.js on lines 4..14

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 195.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Identical blocks of code found in 2 locations. Consider refactoring.
    Open

    var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
        if (k2 === undefined) k2 = k;
        var desc = Object.getOwnPropertyDescriptor(m, k);
        if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
          desc = { enumerable: true, get: function() { return m[k]; } };
    Severity: Major
    Found in common/scripts/install-run-rush.js and 1 other location - About 1 day to fix
    common/scripts/install-run.js on lines 4..14

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 195.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export function trackRemoveFromCart(
      cart: Cart & CommonEcommerceEventProperties,
      trackers: Array<string> = Object.keys(_trackers)
    ) {
      const { context = [], timestamp, products = [], ...cartAttributes } = cart;
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 7 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 165..176

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 192.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    export function trackAddToCart(
      cart: Cart & CommonEcommerceEventProperties,
      trackers: Array<string> = Object.keys(_trackers)
    ) {
      const { context = [], timestamp, products = [], ...cartAttributes } = cart;
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 7 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 184..195

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 192.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    File api.ts has 474 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { BrowserPlugin, BrowserTracker, dispatchToTrackersInCollection } from '@snowplow/browser-tracker-core';
    import { buildSelfDescribingEvent, LOG, SelfDescribingJson } from '@snowplow/tracker-core';
    import { MediaTracking } from './mediaTracking';
    import { MediaPingInterval } from './pingInterval';
    import { MediaSessionTracking } from './sessionTracking';
    Severity: Minor
    Found in plugins/browser-plugin-media/src/api.ts - About 7 hrs to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export interface MediaPlayerUpdate {
        /** The current playback time position within the media in seconds */
        currentTime?: number;
        /** A double-precision floating-point value indicating the duration of the media in seconds */
        duration?: number | null;
      Severity: Major
      Found in plugins/browser-plugin-media/src/types.ts and 1 other location - About 6 hrs to fix
      plugins/browser-plugin-media/src/types.ts on lines 227..258

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 171.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export interface MediaPlayer extends Record<string, unknown> {
        /** The current playback time position within the media in seconds */
        currentTime: number;
        /** A double-precision floating-point value indicating the duration of the media in seconds */
        duration?: number | null;
      Severity: Major
      Found in plugins/browser-plugin-media/src/types.ts and 1 other location - About 6 hrs to fix
      plugins/browser-plugin-media/src/types.ts on lines 261..292

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 171.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      File out_queue.ts has 445 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { attemptWriteLocalStorage, isString } from '../helpers';
      import { SharedState } from '../state';
      import { localStorageAccessible } from '../detectors';
      import { LOG, Payload } from '@snowplow/tracker-core';
      import { PAYLOAD_DATA_SCHEMA } from './schemata';
      Severity: Minor
      Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 6 hrs to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export function buildAdConversion(event: AdConversionEvent): PayloadBuilder {
          const { conversionId, costModel, cost, category, action, property, initialValue, advertiserId, campaignId } = event;
          const eventJson = {
            schema: 'iglu:com.snowplowanalytics.snowplow/ad_conversion/jsonschema/1-0-0',
            data: removeEmptyProperties({
        Severity: Major
        Found in libraries/tracker-core/src/core.ts and 1 other location - About 6 hrs to fix
        libraries/tracker-core/src/core.ts on lines 947..965

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 162.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        export function buildAdClick(event: AdClickEvent): PayloadBuilder {
          const { targetUrl, clickId, costModel, cost, bannerId, zoneId, impressionId, advertiserId, campaignId } = event;
          const eventJson = {
            schema: 'iglu:com.snowplowanalytics.snowplow/ad_click/jsonschema/1-0-0',
            data: removeEmptyProperties({
        Severity: Major
        Found in libraries/tracker-core/src/core.ts and 1 other location - About 6 hrs to fix
        libraries/tracker-core/src/core.ts on lines 1005..1023

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 162.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        File contexts.ts has 429 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * Copyright (c) 2022 Snowplow Analytics Ltd, 2010 Anthon Pang
         * All rights reserved.
         *
         * Redistribution and use in source and binary forms, with or without
        Severity: Minor
        Found in libraries/tracker-core/src/contexts.ts - About 6 hrs to fix

          Function trackerCore has 156 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function trackerCore(configuration: CoreConfiguration = {}): TrackerCore {
            function newCore(base64: boolean, corePlugins: Array<CorePlugin>, callback?: (PayloadData: PayloadBuilder) => void) {
              const pluginContextsHelper: PluginContexts = pluginContexts(corePlugins),
                globalContextsHelper: GlobalContexts = globalContexts();
          
          
          Severity: Major
          Found in libraries/tracker-core/src/core.ts - About 6 hrs to fix

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            export function setPageType(context: PageContext, trackers: Array<string> = Object.keys(_trackers)) {
              const { type, language, locale } = context;
              trackers.forEach((trackerId) => {
                if (_context[trackerId]) {
                  _context[trackerId] = removeContext(_context[trackerId], PAGE_SCHEMA);
            Severity: Major
            Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 6 hrs to fix
            plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 297..313

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 158.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            export function setEcommerceUser(context: UserContext, trackers: Array<string> = Object.keys(_trackers)) {
              const { id, is_guest, email } = context;
              trackers.forEach((trackerId) => {
                if (_context[trackerId]) {
                  _context[trackerId] = removeContext(_context[trackerId], USER_SCHEMA);
            Severity: Major
            Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 6 hrs to fix
            plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 273..289

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 158.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            export function trackMediaVolumeChange(
              args: MediaTrackArguments & MediaTrackVolumeChangeArguments & CommonMediaEventProperties,
              trackers: Array<string> = Object.keys(_trackers)
            ) {
              const { previousVolume, newVolume } = args;
            Severity: Major
            Found in plugins/browser-plugin-media/src/api.ts and 1 other location - About 5 hrs to fix
            plugins/browser-plugin-media/src/api.ts on lines 236..257

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 154.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

            export function trackMediaPlaybackRateChange(
              args: MediaTrackArguments & MediaTrackPlaybackRateChangeArguments & CommonMediaEventProperties,
              trackers: Array<string> = Object.keys(_trackers)
            ) {
              const { previousRate, newRate } = args;
            Severity: Major
            Found in plugins/browser-plugin-media/src/api.ts and 1 other location - About 5 hrs to fix
            plugins/browser-plugin-media/src/api.ts on lines 267..288

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 154.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Function Plugins has 140 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function Plugins(configuration: JavaScriptTrackerConfiguration) {
              const {
                performanceTiming,
                gaCookies,
                geolocation,
            Severity: Major
            Found in trackers/javascript-tracker/src/features.ts - About 5 hrs to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              export function buildConsentWithdrawn(event: ConsentWithdrawnEvent) {
                const { all, id, version, name, description } = event;
                const documentJson = {
                  schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0',
                  data: removeEmptyProperties({ id, version, name, description }),
              Severity: Major
              Found in libraries/tracker-core/src/core.ts and 1 other location - About 5 hrs to fix
              libraries/tracker-core/src/core.ts on lines 1342..1360

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 145.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              export function buildConsentGranted(event: ConsentGrantedEvent) {
                const { expiry, id, version, name, description } = event;
                const documentJson = {
                  schema: 'iglu:com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0',
                  data: removeEmptyProperties({ id, version, name, description }),
              Severity: Major
              Found in libraries/tracker-core/src/core.ts and 1 other location - About 5 hrs to fix
              libraries/tracker-core/src/core.ts on lines 1298..1316

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 145.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language