{"size": 1861, "ext": "js", "max_stars_repo_path": "kanui/src/errors/DeprecatedApiError.js", "max_stars_repo_name": "vitorCamargo/architecture-patterns", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "kanui/src/errors/DeprecatedApiError.js", "max_issues_repo_name": "vitorCamargo/architecture-patterns", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "kanui/src/errors/DeprecatedApiError.js", "max_forks_repo_name": "vitorCamargo/architecture-patterns", "max_forks_repo_forks_event_min_datetime": "2020-10-26T17:04:29.000Z", "max_forks_repo_forks_event_max_datetime": "2020-10-27T13:06:52.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 54.7352941176, "max_line_length": 151, "alphanum_fraction": 0.693175712}
import OneSignalError from './OneSignalError';
import { ApiUsageMetricEvent, ApiUsageMetricKind } from '../managers/MetricsManager';
export var DeprecatedApiReason;
(function (DeprecatedApiReason) {
    DeprecatedApiReason[DeprecatedApiReason["HttpPermissionRequest"] = 0] = "HttpPermissionRequest";
    DeprecatedApiReason[DeprecatedApiReason["SyncHashedEmail"] = 1] = "SyncHashedEmail";
})(DeprecatedApiReason || (DeprecatedApiReason = {}));
export class DeprecatedApiError extends OneSignalError {
    constructor(reason) {
        switch (reason) {
            case DeprecatedApiReason.HttpPermissionRequest:
                super('The HTTP permission request has been deprecated. Please remove any custom popups from your code.');
                this.reportUsage(ApiUsageMetricKind.HttpPermissionRequest);
                break;
            case DeprecatedApiReason.SyncHashedEmail:
                super('API syncHashedEmail() has been deprecated and will be removed in a future SDK release.' +
                    ' Please remove any usages from your code.');
                this.reportUsage(ApiUsageMetricKind.SyncHashedEmail);
                break;
        }
        /**
         * Important! Required to make sure the correct error type is detected during instanceof checks.
         * Same applies to all derived classes.
         * https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md#extending-built-ins-like-error-array-and-map-may-no-longer-work
         */
        Object.setPrototypeOf(this, DeprecatedApiError.prototype);
    }
    reportUsage(apiKind) {
        if (typeof OneSignal !== 'undefined' && OneSignal.context && OneSignal.context.metricsManager) {
            OneSignal.context.metricsManager.reportEvent(new ApiUsageMetricEvent(apiKind));
        }
    }
}
//# sourceMappingURL=DeprecatedApiError.js.map