snowplow/snowplow-javascript-tracker

View on GitHub

Showing 352 of 352 total issues

Function executeQueue has 105 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  function executeQueue(sync: boolean = false) {
    // Failsafe in case there is some way for a bad value like "null" to end up in the outQueue
    while (outQueue.length && typeof outQueue[0] !== 'string' && typeof outQueue[0] !== 'object') {
      outQueue.shift();
    }
Severity: Major
Found in libraries/browser-tracker-core/src/tracker/out_queue.ts - About 4 hrs to fix

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

    var __importStar = (this && this.__importStar) || function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
        __setModuleDefault(result, mod);
    Severity: Major
    Found in common/scripts/install-run.js and 1 other location - About 4 hrs to fix
    common/scripts/install-run-rush.js on lines 20..26

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

    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 __importStar = (this && this.__importStar) || function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
        __setModuleDefault(result, mod);
    Severity: Major
    Found in common/scripts/install-run-rush.js and 1 other location - About 4 hrs to fix
    common/scripts/install-run.js on lines 20..26

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

    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 trackerCore has a Cognitive Complexity of 27 (exceeds 5 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: Minor
    Found in libraries/tracker-core/src/core.ts - About 3 hrs 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

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

    function removeEmptyProperties(event: Record<string, unknown>): Record<string, unknown> {
      const ret: Record<string, unknown> = {};
      for (const k in event) {
        if (event[k] !== null && typeof event[k] !== 'undefined') {
          ret[k] = event[k];
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/core.ts and 1 other location - About 3 hrs to fix
    plugins/browser-plugin-enhanced-consent/src/core.ts on lines 44..52

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

    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 removeEmptyProperties(event: Record<string, unknown>): Record<string, unknown> {
      const ret: Record<string, unknown> = {};
      for (const k in event) {
        if (event[k] !== null && typeof event[k] !== 'undefined') {
          ret[k] = event[k];
    Severity: Major
    Found in plugins/browser-plugin-enhanced-consent/src/core.ts and 1 other location - About 3 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/core.ts on lines 28..36

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

    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 trackEnhancedEcommerceRemoveFromCart(
      ecommerce: UAEnhancedEcommerceObject & RemoveFromCartEvent,
      opts: Options & { finalCartValue: number }
    ) {
      const currency = (ecommerce.currencyCode || opts.currency)!;
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/ua/api.ts and 1 other location - About 3 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/ua/api.ts on lines 47..54

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

    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 trackEnhancedEcommerceAddToCart(
      ecommerce: UAEnhancedEcommerceObject & AddToCartEvent,
      opts: Options & { finalCartValue: number }
    ) {
      const currency = (ecommerce.currencyCode || opts.currency)!;
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/ua/api.ts and 1 other location - About 3 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/ua/api.ts on lines 56..63

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

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

    export function gotEmitter(
      endpoint: string,
      protocol: HttpProtocol = HttpProtocol.HTTPS,
      port?: number,
      method?: HttpMethod,
    Severity: Minor
    Found in trackers/node-tracker/src/got_emitter.ts - About 3 hrs 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

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

    export function trackGA4RemoveFromCart(
      ecommerce: GA4EcommerceObject & Currency,
      opts: Options & { finalCartValue: number }
    ) {
      const currency = (ecommerce.currency || opts.currency)!;
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/ga4/api.ts and 1 other location - About 3 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/ga4/api.ts on lines 35..42

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

    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 trackGA4AddToCart(
      ecommerce: GA4EcommerceObject & Currency,
      opts: Options & { finalCartValue: number }
    ) {
      const currency = (ecommerce.currency || opts.currency)!;
    Severity: Major
    Found in plugins/browser-plugin-snowplow-ecommerce/src/ga4/api.ts and 1 other location - About 3 hrs to fix
    plugins/browser-plugin-snowplow-ecommerce/src/ga4/api.ts on lines 44..51

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

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

    export function BrowserFeaturesPlugin(): BrowserPlugin {
      return {
        activateBrowserPlugin: (tracker: BrowserTracker) => {
          const navigatorAlias = navigator;
          // General plugin detection
    Severity: Minor
    Found in plugins/browser-plugin-browser-features/src/index.ts - About 3 hrs 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 DebuggerPlugin has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function DebuggerPlugin(logLevel: LOG_LEVEL = LOG_LEVEL.debug): BrowserPlugin {
      let LOG: Logger;
      let tracker: BrowserTracker;
      let eventColour: string;
    
    
    Severity: Major
    Found in plugins/browser-plugin-debugger/src/index.ts - About 3 hrs to fix

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

      export function trackMediaPause(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track(
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 1 other location - About 3 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 137..152

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

      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 trackMediaPlay(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track(
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 1 other location - About 3 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 160..175

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

      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 addPlugin has 76 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        function addPlugin(parameterArray: Array<unknown>, trackerIdentifiers: Array<string>) {
          function postScriptHandler(scriptSrc: string) {
            if (Object.prototype.hasOwnProperty.call(pendingPlugins, scriptSrc)) {
              windowAlias.clearTimeout(pendingPlugins[scriptSrc].timeout);
              delete pendingPlugins[scriptSrc];
      Severity: Major
      Found in trackers/javascript-tracker/src/in_queue.ts - About 3 hrs to fix

        Function gotEmitter has 76 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function gotEmitter(
          endpoint: string,
          protocol: HttpProtocol = HttpProtocol.HTTPS,
          port?: number,
          method?: HttpMethod,
        Severity: Major
        Found in trackers/node-tracker/src/got_emitter.ts - About 3 hrs to fix

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

          export function SnowplowMediaPlugin(): BrowserPlugin {
            let trackerId: string;
            return {
              activateBrowserPlugin: (tracker) => {
                trackerId = tracker.id;
          Severity: Major
          Found in plugins/browser-plugin-media/src/api.ts and 1 other location - About 3 hrs to fix
          plugins/browser-plugin-snowplow-ecommerce/src/api.ts on lines 37..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 95.

          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 SnowplowEcommercePlugin(): BrowserPlugin {
            let trackerId: string;
            return {
              activateBrowserPlugin: (tracker) => {
                trackerId = tracker.id;
          Severity: Major
          Found in plugins/browser-plugin-snowplow-ecommerce/src/api.ts and 1 other location - About 3 hrs to fix
          plugins/browser-plugin-media/src/api.ts on lines 34..46

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

          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 7 locations. Consider refactoring.
          Open

          export function trackLinkClick(
            event: LinkClickEvent & CommonEventProperties,
            trackers: Array<string> = Object.keys(_trackers)
          ) {
            dispatchToTrackersInCollection(trackers, _trackers, (t) => {
          Severity: Major
          Found in plugins/browser-plugin-link-click-tracking/src/index.ts and 6 other locations - About 2 hrs to fix
          plugins/browser-plugin-ad-tracking/src/index.ts on lines 63..70
          plugins/browser-plugin-ad-tracking/src/index.ts on lines 78..85
          plugins/browser-plugin-button-click-tracking/src/api.ts on lines 34..41
          plugins/browser-plugin-ecommerce/src/index.ts on lines 133..140
          plugins/browser-plugin-site-tracking/src/index.ts on lines 59..66
          plugins/browser-plugin-site-tracking/src/index.ts on lines 74..81

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

          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