@aws-amplify/analytics
Version:
Analytics category of aws-amplify
38 lines (36 loc) • 1.58 kB
JavaScript
;
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.deprecatePinpoint = void 0;
const core_1 = require("@aws-amplify/core");
const logger = new core_1.ConsoleLogger('Analytics');
const DEPRECATION_MESSAGE = 'The default (Amazon Pinpoint) export of `aws-amplify/analytics` is deprecated. ' +
'AWS will end support for Amazon Pinpoint on October 30, 2026. ' +
'Migrate to a supported provider by importing from its sub-path export instead: ' +
'Kinesis (`aws-amplify/analytics/kinesis`), ' +
'Kinesis Data Firehose (`aws-amplify/analytics/kinesis-firehose`), or ' +
'Personalize Event (`aws-amplify/analytics/personalize`).';
/**
* Wraps a Pinpoint (default-export) Analytics API so that invoking it emits a
* one-time runtime deprecation warning before delegating to the underlying
* implementation. The returned function is a transparent proxy — it preserves
* the exact parameters, return value, and `this` binding of the wrapped API.
*
* The warning is emitted at most once per wrapped API for the lifetime of the
* module, so repeated calls do not spam the console.
*
* @internal
*/
const deprecatePinpoint = (fn) => {
let warned = false;
return (...args) => {
if (!warned) {
warned = true;
logger.warn(DEPRECATION_MESSAGE);
}
return fn(...args);
};
};
exports.deprecatePinpoint = deprecatePinpoint;
//# sourceMappingURL=deprecatePinpoint.js.map