<commit_before>/**
 * Copyright 2015 The AMP HTML Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS-IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {Activity} from './activity-impl';
import {AnalyticsConfig, mergeObjects} from './config';
import {AnalyticsEventType} from './events';
import {ChunkPriority, chunk} from '../../../src/chunk';
import {CookieWriter} from './cookie-writer';
import {Deferred} from '../../../src/utils/promise';
import {
  ExpansionOptions,
  VariableService,
  stringToBool,
  variableServicePromiseForDoc,
} from './variables';
import {
  InstrumentationService,
  instrumentationServicePromiseForDoc,
} from './instrumentation';
import {LayoutPriority} from '../../../src/layout';
import {LinkerManager} from './linker-manager';
import {RequestHandler, expandPostMessage} from './requests';
import {Services} from '../../../src/services';
import {Transport} from './transport';
import {dev, devAssert, rethrowAsync, user} from '../../../src/log';
import {dict, hasOwn} from '../../../src/utils/object';
import {expandTemplate} from '../../../src/string';
import {getMode} from '../../../src/mode';
import {installLinkerReaderService} from './linker-reader';
import {isAnalyticsChunksExperimentOn} from './analytics-group';
import {isArray, isEnumValue} from '../../../src/types';
import {isIframed} from '../../../src/dom';
import {isInFie} from '../../../src/iframe-helper';
import {toggle} from '../../../src/style';

const TAG = 'amp-analytics';

const MAX_REPLACES = 16; // The maximum number of entries in a extraUrlParamsReplaceMap

const ALLOWLIST_EVENT_IN_SANDBOX = [
  AnalyticsEventType.VISIBLE,
  AnalyticsEventType.HIDDEN,
];

export class AmpAnalytics extends AMP.BaseElement {
  /** @param {!AmpElement} element */
  constructor(element) {
    super(element);

    /** @private {!Promise} */
    this.consentPromise_ = Promise.resolve();

    /**
     * The html id of the `amp-user-notification` element.
     * @private {?string}
     */
    this.consentNotificationId_ = null;

    /** @private {boolean} */
    this.isSandbox_ = false;

    /**
     * @private {Object<string, RequestHandler>} A map of request handler with requests
     */
    this.requests_ = {};

    /**
     * @private {!JsonObject}
     */
    this.config_ = dict();<commit_msg>allow ini-load & render-start trigger in inserted analytics component (#29994)<commit_after>/**
 * Copyright 2015 The AMP HTML Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS-IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import {Activity} from './activity-impl';
import {AnalyticsConfig, mergeObjects} from './config';
import {AnalyticsEventType} from './events';
import {ChunkPriority, chunk} from '../../../src/chunk';
import {CookieWriter} from './cookie-writer';
import {Deferred} from '../../../src/utils/promise';
import {
  ExpansionOptions,
  VariableService,
  stringToBool,
  variableServicePromiseForDoc,
} from './variables';
import {
  InstrumentationService,
  instrumentationServicePromiseForDoc,
} from './instrumentation';
import {LayoutPriority} from '../../../src/layout';
import {LinkerManager} from './linker-manager';
import {RequestHandler, expandPostMessage} from './requests';
import {Services} from '../../../src/services';
import {Transport} from './transport';
import {dev, devAssert, rethrowAsync, user} from '../../../src/log';
import {dict, hasOwn} from '../../../src/utils/object';
import {expandTemplate} from '../../../src/string';
import {getMode} from '../../../src/mode';
import {installLinkerReaderService} from './linker-reader';
import {isAnalyticsChunksExperimentOn} from './analytics-group';
import {isArray, isEnumValue} from '../../../src/types';
import {isIframed} from '../../../src/dom';
import {isInFie} from '../../../src/iframe-helper';
import {toggle} from '../../../src/style';

const TAG = 'amp-analytics';

const MAX_REPLACES = 16; // The maximum number of entries in a extraUrlParamsReplaceMap

const ALLOWLIST_EVENT_IN_SANDBOX = [
  AnalyticsEventType.VISIBLE,
  AnalyticsEventType.HIDDEN,
  AnalyticsEventType.INI_LOAD,
  AnalyticsEventType.RENDER_START,
];

export class AmpAnalytics extends AMP.BaseElement {
  /** @param {!AmpElement} element */
  constructor(element) {
    super(element);

    /** @private {!Promise} */
    this.consentPromise_ = Promise.resolve();

    /**
     * The html id of the `amp-user-notification` element.
     * @private {?string}
     */
    this.consentNotificationId_ = null;

    /** @private {boolean} */
    this.isSandbox_ = false;

    /**
     * @private {Object<string, RequestHandler>} A map of request handler with requests
     */
    this.requests_ = {};

    /**
     * @private {!JsonObject}
     */
    this.config_ = dict();
{'fraction_non_alphanumeric': 0.1544361164371623, 'fraction_numerical': 0.004357678229039568, 'mean_word_length': 3.5395569620253164, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5002783', 'n_tokens_mistral': 1653, 'n_tokens_neox': 1628, 'n_words': 515}