snowplow/snowplow-javascript-tracker

View on GitHub

Showing 145 of 325 total issues

Function OptimizelyXPlugin has a Cognitive Complexity of 8 (exceeds 5 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 45 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 addTracker has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

  trackerId: string,
  namespace: string,
  version: string,
  endpoint: string,
  sharedState: SharedState,
Severity: Minor
Found in libraries/browser-tracker-core/src/snowplow.ts - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if (!process.env[environmentVariableName]) {
                            // No, so trim this line
                            lineShouldBeTrimmed = true;
                            break;
                        }
    Severity: Major
    Found in common/scripts/install-run.js - About 45 mins to fix

      Function setValue has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        function setValue(value?: string, ttl?: number, path?: string, domain?: string, samesite?: string, secure?: boolean): boolean {
      Severity: Minor
      Found in libraries/browser-tracker-core/src/tracker/cookie_storage.ts - About 45 mins to fix

        Function constructor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          constructor(pingIntervalSeconds: number | undefined, maxPausedPings: number | undefined, trackPing: () => void) {
            if (maxPausedPings !== undefined) {
              this.maxPausedPings = maxPausedPings;
            }
        
        
        Severity: Minor
        Found in plugins/browser-plugin-media/src/pingInterval.ts - About 45 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 Tracker has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

          trackerId: string,
          namespace: string,
          version: string,
          endpoint: string,
          sharedState: SharedState,
        Severity: Minor
        Found in libraries/browser-tracker-core/src/tracker/index.ts - About 45 mins to fix

          Function matchVendor has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function matchVendor(rule: string, vendor: string): boolean {
            // rule and vendor must have same number of elements
            const vendorParts = vendor.split('.');
            const ruleParts = rule.split('.');
            if (vendorParts && ruleParts) {
          Severity: Minor
          Found in libraries/tracker-core/src/contexts.ts - About 45 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 updateBufferingStats has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            private updateBufferingStats(log: Log) {
              if (log.eventType == MediaEventType.BufferStart) {
                this.bufferingStartedAt = log.time;
                this.bufferingStartTime = log.contentTime;
              } else if (this.bufferingStartedAt !== undefined) {
          Severity: Minor
          Found in plugins/browser-plugin-media/src/sessionStats.ts - About 45 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 getUTF8Length has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          function getUTF8Length(s: string) {
            let len = 0;
            for (let i = 0; i < s.length; i++) {
              const code = s.charCodeAt(i);
              if (code <= 0x7f) {
          Severity: Minor
          Found in libraries/tracker-core/src/emitter/emitter_event.ts - About 45 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 deleteCookie has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

            function deleteCookie(name: string, path?: string, domainName?: string, sameSite?: string, secure?: boolean): void {
          Severity: Minor
          Found in libraries/browser-tracker-core/src/tracker/cookie_storage.ts - About 35 mins to fix

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

            export function deleteCookie(cookieName: string, path?: string, domainName?: string, sameSite?: string, secure?: boolean) {
            Severity: Minor
            Found in libraries/browser-tracker-core/src/helpers/index.ts - About 35 mins to fix

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

              function _installPackage(logger, packageInstallFolder, name, version, command) {
              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

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

                  function getUsefulSchema(sb: PayloadBuilder): string {
                    let eventJson = sb.getJson();
                    for (const json of eventJson) {
                      if (json.keyIfEncoded === 'ue_px' && typeof json.json['data'] === 'object') {
                        const schema = (json.json['data'] as Record<string, unknown>)['schema'];
                  Severity: Minor
                  Found in libraries/tracker-core/src/contexts.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 PerformanceNavigationTimingPlugin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function PerformanceNavigationTimingPlugin(): BrowserPlugin {
                    return {
                      activateBrowserPlugin: () => {
                        /* Setup a PerformanceObserver to allow caching of a completed navigation timing entry. We don't need to query the API after that. */
                        if (typeof PerformanceObserver !== 'undefined') {
                  Severity: Minor
                  Found in plugins/browser-plugin-performance-navigation-timing/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 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 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 newInMemoryEventStore has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function newInMemoryEventStore({
                    maxSize = 1000,
                    events = [],
                  }: EventStoreConfiguration & InMemoryEventStoreConfiguration): EventStore {
                    let store: EventStorePayload[] = [...events];
                  Severity: Minor
                  Found in libraries/tracker-core/src/event_store.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 attachWebVitalsPageListeners has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function attachWebVitalsPageListeners(callback: () => void) {
                    // Safari does not fire "visibilitychange" on the tab close
                    // So we have 2 options: lose Safari data, or lose LCP/CLS that depends on "visibilitychange" logic.
                    // Current solution: if LCP/CLS supported, use `onHidden` otherwise, use `pagehide` to fire the callback in the end.
                    //
                  Severity: Minor
                  Found in plugins/browser-plugin-web-vitals/src/utils.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 constructNavigationTimingContext has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                  Open

                  export function constructNavigationTimingContext(
                    performanceNavigationTimingInstance: PerformanceNavigationTimingContext
                  ) {
                    const performanceNavigationKeys = [
                      'entryType',
                  Severity: Minor
                  Found in plugins/browser-plugin-performance-navigation-timing/src/contexts.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