summaryrefslogtreecommitdiffstats
path: root/browser/extensions/webcompat/shims/eluminate.js
blob: 3fa65c048c211db21e48131cca198736e3bc9a29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/**
 * Bug 1606448 - Shim CoreMetrics Eluminate analytics
 *
 * Sites may rely on eluminate.js tracking in ways which cause breakage,
 * which has been seen on shopping sites such as Vans.com, where the
 * search filtering UX is broken. This shim mitigates such breakage.
 */

if (!window.CM_DDX) {
  window.CM_DDX = {
    domReadyFired: false,
    headScripts: true,
    dispatcherLoadRequested: false,
    firstPassFunctionBinding: false,
    BAD_PAGE_ID_ELAPSED_TIMEOUT: 5000,
    version: -1,
    standalone: false,
    test: {
      syndicate: true,
      testCounter: "",
      doTest: false,
      newWin: false,
      process: () => {},
    },
    partner: {},
    invokeFunctionWhenAvailable: a => {
      a();
    },
    gup: d => "",
    privacy: {
      isDoNotTrackEnabled: () => false,
      setDoNotTrack: () => {},
      getDoNotTrack: () => false,
    },
    setSubCookie: () => {},
  };
  const noopfn = () => {};
  const w = window;
  w.cmAddShared = noopfn;
  w.cmCalcSKUString = noopfn;
  w.cmCreateManualImpressionTag = noopfn;
  w.cmCreateManualLinkClickTag = noopfn;
  w.cmCreateManualPageviewTag = noopfn;
  w.cmCreateOrderTag = noopfn;
  w.cmCreatePageviewTag = noopfn;
  w.cmExecuteTagQueue = noopfn;
  w.cmRetrieveUserID = noopfn;
  w.cmSetClientID = noopfn;
  w.cmSetCurrencyCode = noopfn;
  w.cmSetFirstPartyIDs = noopfn;
  w.cmSetSubCookie = noopfn;
  w.cmSetupCookieMigration = noopfn;
  w.cmSetupNormalization = noopfn;
  w.cmSetupOther = noopfn;
  w.cmStartTagSet = noopfn;
  w.cmCreateConversionEventTag = noopfn;
  w.cmCreateDefaultPageviewTag = noopfn;
  w.cmCreateElementTag = noopfn;
  w.cmCreateManualImpressionTag = noopfn;
  w.cmCreateManualLinkClickTag = noopfn;
  w.cmCreateManualPageviewTag = noopfn;
  w.cmCreatePageElementTag = noopfn;
  w.cmCreatePageviewTag = noopfn;
  w.cmCreateProductElementTag = noopfn;
  w.cmCreateProductviewTag = noopfn;
  w.cmCreateTechPropsTag = noopfn;
  w.cmLoadIOConfig = noopfn;
  w.cmSetClientID = noopfn;
  w.cmSetCurrencyCode = noopfn;
  w.cmSetFirstPartyIDs = noopfn;
  w.cmSetupCookieMigration = noopfn;
  w.cmSetupNormalization = noopfn;

  w.cmSetupOther = b => {
    for (const a in b) {
      window[a] = b[a];
    }
  };

  const techProps = {};

  w.coremetrics = {
    cmLastReferencedPageID: "",
    cmLoad: noopfn,
    cmUpdateConfig: noopfn,
    getTechProps: () => techProps,
    isDef: c => typeof c !== "undefined" && c,
  };
}