snowplow/snowplow-javascript-tracker

View on GitHub

Showing 352 of 352 total issues

Consider simplifying this complex logical expression.
Open

      if (event_type === 'change_form' || (type !== 'checkbox' && type !== 'radio')) {
        tracker.core.track(
          buildFormFocusOrChange({
            schema: event_type,
            formId: getParentFormIdentifier(elt) ?? '',
Severity: Major
Found in plugins/browser-plugin-form-tracking/src/helpers.ts - About 40 mins to fix

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

    export function parseAndValidateInt(obj: unknown) {
      var result = parseInt(obj as string);
      return isNaN(result) ? undefined : result;
    }
    Severity: Minor
    Found in libraries/browser-tracker-core/src/helpers/index.ts and 1 other location - About 40 mins to fix
    libraries/browser-tracker-core/src/helpers/index.ts on lines 358..361

    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 48.

    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

      if (plugins.performanceTiming && performanceTiming) {
        const { PerformanceTimingPlugin, ...apiMethods } = PerformanceTiming;
        activatedPlugins.push([PerformanceTimingPlugin(), apiMethods]);
      }
    Severity: Minor
    Found in trackers/javascript-tracker/src/features.ts and 1 other location - About 40 mins to fix
    trackers/javascript-tracker/src/features.ts on lines 81..84

    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 48.

    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 parseAndValidateFloat(obj: unknown) {
      var result = parseFloat(obj as string);
      return isNaN(result) ? undefined : result;
    }
    Severity: Minor
    Found in libraries/browser-tracker-core/src/helpers/index.ts and 1 other location - About 40 mins to fix
    libraries/browser-tracker-core/src/helpers/index.ts on lines 346..349

    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 48.

    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

      if (plugins.optimizelyX && optimizelyXSummary) {
        const { OptimizelyXPlugin, ...apiMethods } = OptimizelyX;
        activatedPlugins.push([OptimizelyXPlugin(), apiMethods]);
      }
    Severity: Minor
    Found in trackers/javascript-tracker/src/features.ts and 1 other location - About 40 mins to fix
    trackers/javascript-tracker/src/features.ts on lines 76..79

    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 48.

    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 installAndRun has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs) {
    Severity: Minor
    Found in common/scripts/install-run.js - About 35 mins to fix

      Function runMediaPluginFunction has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        player: MediaPlayer,
        trackedPlayer: TrackedPlayer,
        eventType: EventType,
        eventData: EventData | unknown = {},
        trackError: (error: VimeoError) => void
      Severity: Minor
      Found in plugins/browser-plugin-vimeo-tracking/src/mediaPluginBinding.ts - About 35 mins to fix

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

        export function isConditionalContextProvider(input: unknown): input is ConditionalContextProvider {
          return isFilterProvider(input) || isRuleSetProvider(input);
        }
        Severity: Minor
        Found in libraries/tracker-core/src/contexts.ts and 1 other location - About 35 mins to fix
        libraries/tracker-core/src/contexts.ts on lines 434..436

        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 47.

        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

          function debug(message: string, ...extraParams: unknown[]) {
            if (logLevel >= LOG_LEVEL.debug && typeof console !== 'undefined') {
              console.debug(label + message, ...extraParams);
            }
          }
        Severity: Minor
        Found in libraries/tracker-core/src/logger.ts and 1 other location - About 35 mins to fix
        libraries/tracker-core/src/logger.ts on lines 100..104

        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 47.

        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

          dispatchToTrackersInCollection(trackers, _trackers, (t) => {
            t.core.track(buildEcommerceActionEvent({ type: 'list_view', name }), context, timestamp);
          });
        Severity: Minor
        Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 35 mins to fix
        plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 100..102

        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 47.

        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

          function info(message: string, ...extraParams: unknown[]) {
            if (logLevel >= LOG_LEVEL.info && typeof console !== 'undefined') {
              console.info(label + message, ...extraParams);
            }
          }
        Severity: Minor
        Found in libraries/tracker-core/src/logger.ts and 1 other location - About 35 mins to fix
        libraries/tracker-core/src/logger.ts on lines 91..95

        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 47.

        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 isContextPrimitive(input: unknown): input is ContextPrimitive {
          return isContextCallbackFunction(input) || isSelfDescribingJson(input);
        }
        Severity: Minor
        Found in libraries/tracker-core/src/contexts.ts and 1 other location - About 35 mins to fix
        libraries/tracker-core/src/contexts.ts on lines 472..474

        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 47.

        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 const YTError: Record<number, string> = {
          2: 'INVALID_PARAMETER',
          5: 'HTML5_PLAYER_ERROR',
          100: 'NOT_FOUND',
          101: 'EMBED_DISALLOWED',
        Severity: Minor
        Found in plugins/browser-plugin-youtube-tracking/src/constants.ts and 1 other location - About 35 mins to fix
        plugins/browser-plugin-media-tracking/src/constants.ts on lines 4..10

        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 47.

        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 const READY_STATE: Record<number, string> = {
          0: 'HAVE_NOTHING',
          1: 'HAVE_METADATA',
          2: 'HAVE_CURRENT_DATA',
          3: 'HAVE_FUTURE_DATA',
        Severity: Minor
        Found in plugins/browser-plugin-media-tracking/src/constants.ts and 1 other location - About 35 mins to fix
        plugins/browser-plugin-youtube-tracking/src/constants.ts on lines 43..49

        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 47.

        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

          dispatchToTrackersInCollection(trackers, _trackers, (t) => {
            t.core.track(buildEcommerceActionEvent({ type: 'list_click', name }), context, timestamp);
          });
        Severity: Minor
        Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 35 mins to fix
        plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 82..84

        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 47.

        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 startVimeoTracking has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function startVimeoTracking(args: VimeoTrackingConfiguration): void {
          const { video, ...config } = args;
          if (video === undefined) {
            LOG.error("Property 'video' is undefined");
          } else if (video instanceof HTMLIFrameElement && video.nodeName !== 'IFRAME') {
        Severity: Minor
        Found in plugins/browser-plugin-vimeo-tracking/src/initialization.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function __createBinding has a Cognitive Complexity of 7 (exceeds 5 allowed). 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: Minor
        Found in common/scripts/install-run-rush.js - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function attachListeners has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        function attachListeners(player: YT.Player, conf: TrackingOptions) {
          const builtInEvents: Record<string, Function> = {
            [YTPlayerEvent.ONSTATECHANGE]: (e: YT.OnStateChangeEvent) => {
              const stateEventInCaptureEvents = conf.captureEvents.indexOf(YTStateEvent[e.data.toString()]) !== -1;
              // If the user is tracking 'percentprogress' events, we need to pass these state changes to `progressHandler`,
        Severity: Minor
        Found in plugins/browser-plugin-youtube-tracking/src/index.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function GaCookiesPlugin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function GaCookiesPlugin(pluginOptions: GACookiesPluginOptions = defaultPluginOptions): BrowserPlugin {
          return {
            contexts: () => {
              const contexts: SelfDescribingJson<Record<string, unknown>>[] = [];
              const { ga4, ga4MeasurementId, ua, cookiePrefix } = { ...defaultPluginOptions, ...pluginOptions };
        Severity: Minor
        Found in plugins/browser-plugin-ga-cookies/src/index.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Function enableYouTubeTracking has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        export function enableYouTubeTracking(args: { id: string | YT.Player; options?: MediaTrackingOptions }) {
          if (!Object.keys(_trackers).length) {
            LOG.error('Check YoutubeTrackingPlugin is initialized in tracker config');
            return;
          }
        Severity: Minor
        Found in plugins/browser-plugin-youtube-tracking/src/index.ts - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        Severity
        Category
        Status
        Source
        Language