UNPKG

@aws-amplify/analytics

Version:

Analytics category of aws-amplify

33 lines (30 loc) • 1.36 kB
import { isAmplifyContext } from '@aws-amplify/core'; // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 /** * Non-destructively inspects a public-API arguments array and separates the * optional leading {@link AmplifyContext} from the API input. * * Unlike core's `resolveCtxArgs`, this helper deliberately does NOT fall back * to the global context — `ctx` stays `undefined` when no explicit context was * supplied. Callers (e.g. `configureAutoTrack`) that only need the context at * emit time use this so the global context is resolved lazily: resolving it * eagerly would (a) throw when trackers are configured before * `Amplify.configure()` and (b) pin auto-tracked events to the configuration * snapshot captured at setup time after a later `configure()` call. * * @param args The raw arguments array of an overloaded public API. * * @returns `{ ctx?, input }` — `ctx` is set only when the first argument is a * branded `AmplifyContext`; `input` is the argument that follows it (or the * first argument when no context was passed). * * @internal */ function peekCtxArgs(args) { return isAmplifyContext(args[0]) ? { ctx: args[0], input: args[1] } : { ctx: undefined, input: args[0] }; } export { peekCtxArgs }; //# sourceMappingURL=peekCtxArgs.mjs.map