{"version":3,"file":"configureAutoTrack.mjs","sources":["../../../../../src/providers/pinpoint/apis/configureAutoTrack.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { peekCtxArgs, updateProviderTrackers, validateTrackerConfiguration, } from '../../../utils';\nimport { record } from './record';\n// Configured Tracker instances for Pinpoint\nconst configuredTrackers = {};\nexport function configureAutoTrack(...args) {\n    // Peek the optional leading context WITHOUT falling back to the global\n    // context. The context is only needed when events are emitted; resolving it\n    // eagerly would (a) throw when trackers are configured before\n    // `Amplify.configure()` and (b) pin auto-tracked events to the configuration\n    // snapshot captured at setup time after a later `configure()` call.\n    const { ctx, input } = peekCtxArgs(args);\n    validateTrackerConfiguration(input);\n    // Callback that will emit an appropriate event to Pinpoint when required by the Tracker.\n    // When no explicit context was supplied, `record` resolves the global context\n    // lazily at emit time, so auto-tracked events follow the live configuration\n    // and trackers can be set up before `Amplify.configure()` is called.\n    const emitTrackingEvent = (eventName, attributes) => {\n        const recordInput = {\n            name: eventName,\n            attributes,\n        };\n        if (ctx) {\n            record(ctx, recordInput);\n        }\n        else {\n            record(recordInput);\n        }\n    };\n    // Initialize or update this provider's trackers\n    updateProviderTrackers(input, emitTrackingEvent, configuredTrackers);\n}\n"],"names":[],"mappings":";;;;;;;;;AAAA;AACA;AAGA;AACA,MAAM,kBAAkB,GAAG,EAAE;AACtB,SAAS,kBAAkB,CAAC,GAAG,IAAI,EAAE;AAC5C;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC;AAC5C,IAAI,4BAA4B,CAAC,KAAK,CAAC;AACvC;AACA;AACA;AACA;AACA,IAAI,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE,UAAU,KAAK;AACzD,QAAQ,MAAM,WAAW,GAAG;AAC5B,YAAY,IAAI,EAAE,SAAS;AAC3B,YAAY,UAAU;AACtB,SAAS;AACT,QAAQ,IAAI,GAAG,EAAE;AACjB,YAAY,MAAM,CAAC,GAAG,EAAE,WAAW,CAAC;AACpC,QAAQ;AACR,aAAa;AACb,YAAY,MAAM,CAAC,WAAW,CAAC;AAC/B,QAAQ;AACR,IAAI,CAAC;AACL;AACA,IAAI,sBAAsB,CAAC,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,CAAC;AACxE;;;;"}