MCPcopy
hub / github.com/ampproject/amphtml / constructor

Method constructor

src/extension-analytics.js:64–91  ·  view source on GitHub ↗

* @param {!Element} parent * @param {!JsonObject} config

(parent, config)

Source from the content-addressed store, hash-verified

62 * @param {!JsonObject} config
63 */
64 constructor(parent, config) {
65 devAssert(config['triggers'], 'Config must have triggers defined');
66 /** @private {string} */
67 this.id_ = parent.getResourceId();
68
69 /** @private {!AmpElement} */
70 this.parent_ = parent;
71
72 /** @private {JsonObject} */
73 this.config_ = config;
74
75 for (const event in config['triggers']) {
76 const eventType = config['triggers'][event]['on'];
77 devAssert(
78 eventType,
79 'CustomEventReporter config must specify trigger eventType'
80 );
81 const newEventType = this.getEventTypeInSandbox_(eventType);
82 config['triggers'][event]['on'] = newEventType;
83 }
84
85 this.parent_
86 .signals()
87 .whenSignal(CommonSignals_Enum.LOAD_START)
88 .then(() => {
89 insertAnalyticsElement(this.parent_, config, true);
90 });
91 }
92
93 /**
94 * @param {string} eventType

Callers

nothing calls this directly

Calls 7

devAssertFunction · 0.90
insertAnalyticsElementFunction · 0.85
getResourceIdMethod · 0.80
whenSignalMethod · 0.80
thenMethod · 0.45
signalsMethod · 0.45

Tested by

no test coverage detected