snowplow/snowplow-javascript-tracker

View on GitHub

Showing 353 of 353 total issues

Function parseIdCookie has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function parseIdCookie(
  id: string | undefined,
  domainUserId: string,
  memorizedSessionId: string,
  memorizedVisitCount: number
Severity: Major
Found in libraries/browser-tracker-core/src/tracker/id_cookie.ts - About 2 hrs to fix

    Consider simplifying this complex logical expression.
    Open

      if (isExtendedFormat) {
        /* Index is used by Enrich, so it should not be changed. */
        crossDomainParameterValue = [
          domainUserId,
          timestamp,
    Severity: Critical
    Found in libraries/browser-tracker-core/src/helpers/cross_domain.ts - About 2 hrs to fix

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

      export function trackMediaSeekEnd(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track({ mediaEvent: { type: MediaEventType.SeekEnd } }, args, trackers);
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 4 other locations - About 2 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 123..128
      plugins/browser-plugin-media/src/api.ts on lines 208..213
      plugins/browser-plugin-media/src/api.ts on lines 597..602
      plugins/browser-plugin-media/src/api.ts on lines 611..616

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

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

      export function trackMediaReady(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track({ mediaEvent: { type: MediaEventType.Ready } }, args, trackers);
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 4 other locations - About 2 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 208..213
      plugins/browser-plugin-media/src/api.ts on lines 221..226
      plugins/browser-plugin-media/src/api.ts on lines 597..602
      plugins/browser-plugin-media/src/api.ts on lines 611..616

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

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

      export function trackMediaSeekStart(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track({ mediaEvent: { type: MediaEventType.SeekStart } }, args, trackers);
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 4 other locations - About 2 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 123..128
      plugins/browser-plugin-media/src/api.ts on lines 221..226
      plugins/browser-plugin-media/src/api.ts on lines 597..602
      plugins/browser-plugin-media/src/api.ts on lines 611..616

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

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

      export function trackMediaBufferEnd(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track({ mediaEvent: { type: MediaEventType.BufferEnd } }, args, trackers);
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 4 other locations - About 2 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 123..128
      plugins/browser-plugin-media/src/api.ts on lines 208..213
      plugins/browser-plugin-media/src/api.ts on lines 221..226
      plugins/browser-plugin-media/src/api.ts on lines 597..602

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

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

      export function trackMediaBufferStart(
        args: MediaTrackArguments & CommonMediaEventProperties,
        trackers: Array<string> = Object.keys(_trackers)
      ) {
        track({ mediaEvent: { type: MediaEventType.BufferStart } }, args, trackers);
      Severity: Major
      Found in plugins/browser-plugin-media/src/api.ts and 4 other locations - About 2 hrs to fix
      plugins/browser-plugin-media/src/api.ts on lines 123..128
      plugins/browser-plugin-media/src/api.ts on lines 208..213
      plugins/browser-plugin-media/src/api.ts on lines 221..226
      plugins/browser-plugin-media/src/api.ts on lines 611..616

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

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

      export function PerformanceTimingPlugin(): BrowserPlugin {
        /**
         * Creates a context from the window.performance.timing object
         *
         * @returns object PerformanceTiming context
      Severity: Minor
      Found in plugins/browser-plugin-performance-timing/src/index.ts - About 1 hr to fix

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

            case InternalVimeoEvent.INTERACTIVEOVERLAYPANELCLICKED:
              trackMediaSelfDescribingEvent({
                id,
                player,
                event: {
        plugins/browser-plugin-vimeo-tracking/src/mediaPluginBinding.ts on lines 153..163

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

        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

            case InternalVimeoEvent.INTERACTIVEHOTSPOTCLICKED:
              trackMediaSelfDescribingEvent({
                id,
                player,
                event: {
        plugins/browser-plugin-vimeo-tracking/src/mediaPluginBinding.ts on lines 165..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 74.

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

        export function tracker(
          emitters: Emitter | Array<Emitter>,
          namespace: string,
          appId: string,
          encodeBase64: boolean
        Severity: Minor
        Found in trackers/node-tracker/src/tracker.ts - About 1 hr to fix

          Function matchSchemaAgainstRuleSet has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          export function matchSchemaAgainstRuleSet(ruleSet: RuleSet, schema: string): boolean {
            let rejectCount = 0;
            let acceptCount = 0;
            const acceptRules = ruleSet['accept'];
            if (Array.isArray(acceptRules)) {
          Severity: Minor
          Found in libraries/tracker-core/src/contexts.ts - About 1 hr 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 3 locations. Consider refactoring.
          Open

          export function asVimeoPlayerCuePointData(eventData: EventData | unknown): VimeoPlayerCuePointData {
            const data = eventData as VimeoCuePoint;
            return {
              cuePointTime: data.time,
              data: data.data,
          Severity: Major
          Found in plugins/browser-plugin-vimeo-tracking/src/types.ts and 2 other locations - About 1 hr to fix
          plugins/browser-plugin-vimeo-tracking/src/types.ts on lines 72..79
          plugins/browser-plugin-vimeo-tracking/src/types.ts on lines 91..98

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

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

          export function asTextTrackData(eventData: EventData | unknown): TextTrackData {
            const data = eventData as TextTrackData;
            return {
              language: data.language,
              kind: data.kind,
          Severity: Major
          Found in plugins/browser-plugin-vimeo-tracking/src/types.ts and 2 other locations - About 1 hr to fix
          plugins/browser-plugin-vimeo-tracking/src/types.ts on lines 53..60
          plugins/browser-plugin-vimeo-tracking/src/types.ts on lines 72..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 73.

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

          export function asTimeUpdateData(eventData: EventData | unknown): TimeUpdateData {
            const data = eventData as TimeUpdateData;
            return {
              duration: data.duration,
              percent: data.percent,
          Severity: Major
          Found in plugins/browser-plugin-vimeo-tracking/src/types.ts and 2 other locations - About 1 hr to fix
          plugins/browser-plugin-vimeo-tracking/src/types.ts on lines 53..60
          plugins/browser-plugin-vimeo-tracking/src/types.ts on lines 91..98

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

          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 removeGlobalContexts(
            contexts: Array<ConditionalContextProvider | ContextPrimitive>,
            trackers?: Array<string>
          ) {
            dispatchToTrackers(trackers, (t) => {
          Severity: Major
          Found in trackers/browser-tracker/src/api.ts and 1 other location - About 1 hr to fix
          trackers/browser-tracker/src/api.ts on lines 413..420

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

          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 addGlobalContexts(
            contexts: Array<ConditionalContextProvider | ContextPrimitive>,
            trackers?: Array<string>
          ) {
            dispatchToTrackers(trackers, (t) => {
          Severity: Major
          Found in trackers/browser-tracker/src/api.ts and 1 other location - About 1 hr to fix
          trackers/browser-tracker/src/api.ts on lines 428..435

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

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

          export function OptimizelyXPlugin(): BrowserPlugin {
            /**
             * Check that *both* optimizely and optimizely.get exist
             *
             * @param property - optimizely data property
          Severity: Minor
          Found in plugins/browser-plugin-optimizely-x/src/index.ts - About 1 hr to fix

            Function base64decode has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function base64decode(encodedData: string): string {
              //  discuss at: http://locutus.io/php/base64_decode/
              // original by: Tyler Akins (http://rumkin.com)
              // improved by: Thunder.m
              // improved by: Kevin van Zonneveld (http://kvz.io)
            Severity: Minor
            Found in libraries/tracker-core/src/base64.ts - About 1 hr to fix

              Function getPerformanceTimingContext has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                function getPerformanceTimingContext() {
                  var windowAlias = window,
                    performanceAlias =
                      windowAlias.performance ||
                      windowAlias.mozPerformance ||
              Severity: Minor
              Found in plugins/browser-plugin-performance-timing/src/index.ts - About 1 hr to fix
                Severity
                Category
                Status
                Source
                Language