@amplitude/analytics-core 2.35.1-pnpm-migration.0 → 2.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/lib/cjs/index.d.ts +2 -2
  2. package/lib/cjs/index.d.ts.map +1 -1
  3. package/lib/cjs/index.js +4 -2
  4. package/lib/cjs/index.js.map +1 -1
  5. package/lib/cjs/storage/browser-storage.d.ts.map +1 -1
  6. package/lib/cjs/storage/browser-storage.js +2 -1
  7. package/lib/cjs/storage/browser-storage.js.map +1 -1
  8. package/lib/cjs/storage/cookie.d.ts +14 -2
  9. package/lib/cjs/storage/cookie.d.ts.map +1 -1
  10. package/lib/cjs/storage/cookie.js +106 -17
  11. package/lib/cjs/storage/cookie.js.map +1 -1
  12. package/lib/cjs/types/storage.d.ts +13 -0
  13. package/lib/cjs/types/storage.d.ts.map +1 -1
  14. package/lib/cjs/types/storage.js.map +1 -1
  15. package/lib/cjs/types/user-session.d.ts +1 -0
  16. package/lib/cjs/types/user-session.d.ts.map +1 -1
  17. package/lib/cjs/types/user-session.js.map +1 -1
  18. package/lib/esm/index.d.ts +2 -2
  19. package/lib/esm/index.d.ts.map +1 -1
  20. package/lib/esm/index.js +1 -1
  21. package/lib/esm/index.js.map +1 -1
  22. package/lib/esm/storage/browser-storage.d.ts.map +1 -1
  23. package/lib/esm/storage/browser-storage.js +2 -1
  24. package/lib/esm/storage/browser-storage.js.map +1 -1
  25. package/lib/esm/storage/cookie.d.ts +14 -2
  26. package/lib/esm/storage/cookie.d.ts.map +1 -1
  27. package/lib/esm/storage/cookie.js +104 -17
  28. package/lib/esm/storage/cookie.js.map +1 -1
  29. package/lib/esm/types/storage.d.ts +13 -0
  30. package/lib/esm/types/storage.d.ts.map +1 -1
  31. package/lib/esm/types/storage.js.map +1 -1
  32. package/lib/esm/types/user-session.d.ts +1 -0
  33. package/lib/esm/types/user-session.d.ts.map +1 -1
  34. package/lib/esm/types/user-session.js.map +1 -1
  35. package/package.json +1 -1
@@ -22,7 +22,7 @@ export { createIdentifyEvent } from './utils/event-builder';
22
22
  export { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';
23
23
  export { generateHashCode, isTimestampInSample } from './utils/sampling';
24
24
  export { MemoryStorage } from './storage/memory';
25
- export { CookieStorage } from './storage/cookie';
25
+ export { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';
26
26
  export { getStorageKey } from './storage/helpers';
27
27
  export { BrowserStorage } from './storage/browser-storage';
28
28
  export { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';
@@ -32,7 +32,7 @@ export { FetchTransport } from './transports/fetch';
32
32
  export { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';
33
33
  export { LogLevel } from './types/loglevel';
34
34
  export { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';
35
- export { Storage, IdentityStorageType } from './types/storage';
35
+ export { Storage, IdentityStorageType, CookieStorageConfig } from './types/storage';
36
36
  export { Event, IdentifyOperation, SpecialEventType, IdentifyEvent, GroupIdentifyEvent, IdentifyUserProperties, } from './types/event/event';
37
37
  export { EventOptions, BaseEvent } from './types/event/base-event';
38
38
  export { IngestionMetadata } from './types/event/ingestion-metadata';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D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BAA4B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAGrE,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,kBAAkB,EAClB,6BAA6B,GAC9B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
package/lib/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_RAGE_CLICK_THRESHOLD = exports.DEFAULT_RAGE_CLICK_ALLOWLIST = exports.DEFAULT_DEAD_CLICK_ALLOWLIST = exports.DEFAULT_ACTION_CLICK_ALLOWLIST = exports.DEFAULT_DATA_ATTRIBUTE_PREFIX = exports.DEFAULT_CSS_SELECTOR_ALLOWLIST = exports.OfflineDisabled = exports.ServerZone = exports.SpecialEventType = exports.IdentifyOperation = exports.STORAGE_PREFIX = exports.AMPLITUDE_PREFIX = exports.LogLevel = exports.RemoteConfigClient = exports.FetchTransport = exports.BaseTransport = exports.registerSdkLoaderMetadata = exports.DiagnosticsClient = exports.BrowserStorage = exports.getStorageKey = exports.CookieStorage = exports.MemoryStorage = exports.isTimestampInSample = exports.generateHashCode = exports.getDecodeURI = exports.isUrlMatchAllowlist = exports.createIdentifyEvent = exports.UUID = exports.getClientStates = exports.getClientLogConfig = exports.debugWrapper = exports.returnWrapper = exports.getQueryParams = exports.getLanguage = exports.getOldCookieName = exports.getCookieName = exports.isNewSession = exports.setConnectorUserId = exports.setConnectorDeviceId = exports.getAnalyticsConnector = exports.getGlobalScope = exports.Logger = exports.RequestMetadata = exports.Config = exports.IdentityEventSender = exports.Destination = exports.RevenueProperty = exports.Revenue = exports.Identify = exports.AmplitudeCore = void 0;
4
- exports.multicast = exports.merge = exports.asyncMap = exports.Observable = exports.EMAIL_REGEX = exports.SSN_REGEX = exports.CC_REGEX = exports.replaceSensitiveString = exports.MASKED_TEXT_VALUE = exports.TEXT_MASK_ATTRIBUTE = exports.getPageTitle = exports.CampaignParser = exports.MKTG = exports.BASE_CAMPAIGN = exports.EMPTY_VALUE = exports.FORBIDDEN_HEADERS = exports.SAFE_HEADERS = exports.NetworkRequestEvent = exports.networkObserver = exports.NetworkEventCallback = exports.Status = exports.DEFAULT_DEAD_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD = exports.DEFAULT_RAGE_CLICK_WINDOW_MS = void 0;
3
+ exports.DEFAULT_DEAD_CLICK_ALLOWLIST = exports.DEFAULT_ACTION_CLICK_ALLOWLIST = exports.DEFAULT_DATA_ATTRIBUTE_PREFIX = exports.DEFAULT_CSS_SELECTOR_ALLOWLIST = exports.OfflineDisabled = exports.ServerZone = exports.SpecialEventType = exports.IdentifyOperation = exports.STORAGE_PREFIX = exports.AMPLITUDE_PREFIX = exports.LogLevel = exports.RemoteConfigClient = exports.FetchTransport = exports.BaseTransport = exports.registerSdkLoaderMetadata = exports.DiagnosticsClient = exports.BrowserStorage = exports.getStorageKey = exports.decodeCookieValue = exports.isDomainEqual = exports.CookieStorage = exports.MemoryStorage = exports.isTimestampInSample = exports.generateHashCode = exports.getDecodeURI = exports.isUrlMatchAllowlist = exports.createIdentifyEvent = exports.UUID = exports.getClientStates = exports.getClientLogConfig = exports.debugWrapper = exports.returnWrapper = exports.getQueryParams = exports.getLanguage = exports.getOldCookieName = exports.getCookieName = exports.isNewSession = exports.setConnectorUserId = exports.setConnectorDeviceId = exports.getAnalyticsConnector = exports.getGlobalScope = exports.Logger = exports.RequestMetadata = exports.Config = exports.IdentityEventSender = exports.Destination = exports.RevenueProperty = exports.Revenue = exports.Identify = exports.AmplitudeCore = void 0;
4
+ exports.multicast = exports.merge = exports.asyncMap = exports.Observable = exports.EMAIL_REGEX = exports.SSN_REGEX = exports.CC_REGEX = exports.replaceSensitiveString = exports.MASKED_TEXT_VALUE = exports.TEXT_MASK_ATTRIBUTE = exports.getPageTitle = exports.CampaignParser = exports.MKTG = exports.BASE_CAMPAIGN = exports.EMPTY_VALUE = exports.FORBIDDEN_HEADERS = exports.SAFE_HEADERS = exports.NetworkRequestEvent = exports.networkObserver = exports.NetworkEventCallback = exports.Status = exports.DEFAULT_DEAD_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD = exports.DEFAULT_RAGE_CLICK_WINDOW_MS = exports.DEFAULT_RAGE_CLICK_THRESHOLD = exports.DEFAULT_RAGE_CLICK_ALLOWLIST = void 0;
5
5
  var core_client_1 = require("./core-client");
6
6
  Object.defineProperty(exports, "AmplitudeCore", { enumerable: true, get: function () { return core_client_1.AmplitudeCore; } });
7
7
  var identify_1 = require("./identify");
@@ -53,6 +53,8 @@ var memory_1 = require("./storage/memory");
53
53
  Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function () { return memory_1.MemoryStorage; } });
54
54
  var cookie_1 = require("./storage/cookie");
55
55
  Object.defineProperty(exports, "CookieStorage", { enumerable: true, get: function () { return cookie_1.CookieStorage; } });
56
+ Object.defineProperty(exports, "isDomainEqual", { enumerable: true, get: function () { return cookie_1.isDomainEqual; } });
57
+ Object.defineProperty(exports, "decodeCookieValue", { enumerable: true, get: function () { return cookie_1.decodeCookieValue; } });
56
58
  var helpers_1 = require("./storage/helpers");
57
59
  Object.defineProperty(exports, "getStorageKey", { enumerable: true, get: function () { return helpers_1.getStorageKey; } });
58
60
  var browser_storage_1 = require("./storage/browser-storage");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AAItB,uCAAiD;AAAxC,oGAAA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Bb,iDAA4F;AAAnF,wGAAA,UAAU,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,uGAAA,SAAS,OAAA","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { CoreClient, PluginHost } from './types/client/core-client';\nexport { AnalyticsClient } from './types/client/analytics-client';\nexport { AmplitudeContext } from './types/amplitude-context';\nexport { Identify, IIdentify } from './identify';\nexport { Revenue, IRevenue, RevenueProperty } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { Config, RequestMetadata } from './config';\nexport { IConfig } from './types/config/core-config';\nexport { Logger, ILogger, LogConfig } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\nexport { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';\nexport { generateHashCode, isTimestampInSample } from './utils/sampling';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BrowserStorage } from './storage/browser-storage';\n\nexport { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';\nexport { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType } from './types/storage';\nexport {\n Event,\n IdentifyOperation,\n SpecialEventType,\n IdentifyEvent,\n GroupIdentifyEvent,\n IdentifyUserProperties,\n} from './types/event/event';\nexport { EventOptions, BaseEvent } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType, ServerZone } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport, TransportOptions, TransportTypeOrOptions } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport {\n Plugin,\n BeforePlugin,\n DestinationPlugin,\n EnrichmentPlugin,\n PluginType,\n AnalyticsIdentity,\n} from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n LabeledEvent,\n Trigger,\n DataSource,\n} from './types/element-interactions';\n\nexport {\n FrustrationInteractionsOptions,\n DEFAULT_DEAD_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_THRESHOLD,\n DEFAULT_RAGE_CLICK_WINDOW_MS,\n DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD,\n DEFAULT_DEAD_CLICK_WINDOW_MS,\n} from './types/frustration-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { Status } from './types/status';\n\nexport { NetworkEventCallback, networkObserver } from './network-observer';\nexport { NetworkRequestEvent, IRequestWrapper, JsonObject, JsonValue, JsonArray } from './network-request-event';\nexport { NetworkTrackingOptions, NetworkCaptureRule } from './types/network-tracking';\nexport { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';\n\nexport { PageUrlEnrichmentOptions } from './types/page-url-enrichment';\n\n// Campaign\nexport { Campaign, UTMParameters, ReferrerParameters, ClickIdParameters, ICampaignParser } from './types/campaign';\nexport { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';\nexport { CampaignParser } from './campaign/campaign-parser';\nexport {\n getPageTitle,\n TEXT_MASK_ATTRIBUTE,\n MASKED_TEXT_VALUE,\n replaceSensitiveString,\n CC_REGEX,\n SSN_REGEX,\n EMAIL_REGEX,\n} from './plugins/helpers';\n\n// Browser\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n RemoteConfigOptions,\n} from './types/config/browser-config';\nexport { BrowserClient } from './types/client/browser-client';\n\n// Node\nexport { NodeClient } from './types/client/node-client';\nexport { NodeConfig, NodeOptions } from './types/config/node-config';\n\n// React Native\nexport {\n ReactNativeConfig,\n ReactNativeTrackingOptions,\n ReactNativeOptions,\n ReactNativeAttributionOptions,\n} from './types/config/react-native-config';\nexport { ReactNativeClient } from './types/client/react-native-client';\n\nexport { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';\n\nexport { InstanceProxy } from './types/proxy';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,6CAA8C;AAArC,4GAAA,aAAa,OAAA;AAItB,uCAAiD;AAAxC,oGAAA,QAAQ,OAAA;AACjB,qCAA+D;AAAtD,kGAAA,OAAO,OAAA;AAAY,0GAAA,eAAe,OAAA;AAC3C,qDAAoD;AAA3C,0GAAA,WAAW,OAAA;AACpB,+CAAyD;AAAhD,+GAAA,mBAAmB,OAAA;AAC5B,mCAAmD;AAA1C,gGAAA,MAAM,OAAA;AAAE,yGAAA,eAAe,OAAA;AAEhC,mCAAsD;AAA7C,gGAAA,MAAM,OAAA;AACf,+CAAgD;AAAvC,8GAAA,cAAc,OAAA;AACvB,6DAAwG;AAA/F,4HAAA,qBAAqB,OAAA;AAAE,2H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AAAxC,yGAAA,UAAU,OAAA;AACnC,2CAAkD;AAAzC,0GAAA,eAAe,OAAA;AAexB,qEAUsC;AANpC,sIAAA,8BAA8B,OAAA;AAC9B,qIAAA,6BAA6B,OAAA;AAC7B,sIAAA,8BAA8B,OAAA;AAMhC,6EAQ0C;AANxC,wIAAA,4BAA4B,OAAA;AAC5B,wIAAA,4BAA4B,OAAA;AAC5B,wIAAA,4BAA4B,OAAA;AAC5B,wIAAA,4BAA4B,OAAA;AAC5B,sJAAA,0CAA0C,OAAA;AAC1C,wIAAA,4BAA4B,OAAA;AAG9B,yCAAwC;AAA/B,gGAAA,MAAM,OAAA;AAEf,uDAA2E;AAAlE,wHAAA,oBAAoB,OAAA;AAAE,mHAAA,eAAe,OAAA;AAC9C,iEAAiH;AAAxG,4HAAA,mBAAmB,OAAA;AAE5B,+CAAoE;AAA3D,yGAAA,YAAY,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAMxC,+CAAqE;AAA5D,wGAAA,WAAW,OAAA;AAAE,0GAAA,aAAa,OAAA;AAAE,iGAAA,IAAI,OAAA;AACzC,8DAA4D;AAAnD,iHAAA,cAAc,OAAA;AACvB,6CAQ2B;AAPzB,uGAAA,YAAY,OAAA;AACZ,8GAAA,mBAAmB,OAAA;AACnB,4GAAA,iBAAiB,OAAA;AACjB,iHAAA,sBAAsB,OAAA;AACtB,mGAAA,QAAQ,OAAA;AACR,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AA6Bb,iDAA4F;AAAnF,wGAAA,UAAU,OAAA;AAAE,sGAAA,QAAQ,OAAA;AAAE,mGAAA,KAAK,OAAA;AAAE,uGAAA,SAAS,OAAA","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { CoreClient, PluginHost } from './types/client/core-client';\nexport { AnalyticsClient } from './types/client/analytics-client';\nexport { AmplitudeContext } from './types/amplitude-context';\nexport { Identify, IIdentify } from './identify';\nexport { Revenue, IRevenue, RevenueProperty } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { Config, RequestMetadata } from './config';\nexport { IConfig } from './types/config/core-config';\nexport { Logger, ILogger, LogConfig } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\nexport { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';\nexport { generateHashCode, isTimestampInSample } from './utils/sampling';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BrowserStorage } from './storage/browser-storage';\n\nexport { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';\nexport { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType, CookieStorageConfig } from './types/storage';\nexport {\n Event,\n IdentifyOperation,\n SpecialEventType,\n IdentifyEvent,\n GroupIdentifyEvent,\n IdentifyUserProperties,\n} from './types/event/event';\nexport { EventOptions, BaseEvent } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType, ServerZone } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport, TransportOptions, TransportTypeOrOptions } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport {\n Plugin,\n BeforePlugin,\n DestinationPlugin,\n EnrichmentPlugin,\n PluginType,\n AnalyticsIdentity,\n} from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n LabeledEvent,\n Trigger,\n DataSource,\n} from './types/element-interactions';\n\nexport {\n FrustrationInteractionsOptions,\n DEFAULT_DEAD_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_THRESHOLD,\n DEFAULT_RAGE_CLICK_WINDOW_MS,\n DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD,\n DEFAULT_DEAD_CLICK_WINDOW_MS,\n} from './types/frustration-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { Status } from './types/status';\n\nexport { NetworkEventCallback, networkObserver } from './network-observer';\nexport { NetworkRequestEvent, IRequestWrapper, JsonObject, JsonValue, JsonArray } from './network-request-event';\nexport { NetworkTrackingOptions, NetworkCaptureRule } from './types/network-tracking';\nexport { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';\n\nexport { PageUrlEnrichmentOptions } from './types/page-url-enrichment';\n\n// Campaign\nexport { Campaign, UTMParameters, ReferrerParameters, ClickIdParameters, ICampaignParser } from './types/campaign';\nexport { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';\nexport { CampaignParser } from './campaign/campaign-parser';\nexport {\n getPageTitle,\n TEXT_MASK_ATTRIBUTE,\n MASKED_TEXT_VALUE,\n replaceSensitiveString,\n CC_REGEX,\n SSN_REGEX,\n EMAIL_REGEX,\n} from './plugins/helpers';\n\n// Browser\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n RemoteConfigOptions,\n} from './types/config/browser-config';\nexport { BrowserClient } from './types/client/browser-client';\n\n// Node\nexport { NodeClient } from './types/client/node-client';\nexport { NodeConfig, NodeOptions } from './types/config/node-config';\n\n// React Native\nexport {\n ReactNativeConfig,\n ReactNativeTrackingOptions,\n ReactNativeOptions,\n ReactNativeAttributionOptions,\n} from './types/config/react-native-config';\nexport { ReactNativeClient } from './types/client/react-native-client';\n\nexport { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';\n\nexport { InstanceProxy } from './types/proxy';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"browser-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,OAAO,CAAC;gBAAR,OAAO,CAAC,qBAAS;IAE/B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAcxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
1
+ {"version":3,"file":"browser-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,OAAO,CAAC;gBAAR,OAAO,CAAC,qBAAS;IAE/B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAcxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BrowserStorage = void 0;
4
4
  var tslib_1 = require("tslib");
5
+ var uuid_1 = require("../utils/uuid");
5
6
  var BrowserStorage = /** @class */ (function () {
6
7
  function BrowserStorage(storage) {
7
8
  this.storage = storage;
@@ -18,7 +19,7 @@ var BrowserStorage = /** @class */ (function () {
18
19
  }
19
20
  random = String(Date.now());
20
21
  testStorage = new BrowserStorage(this.storage);
21
- testKey = 'AMP_TEST';
22
+ testKey = "AMP_TEST_".concat((0, uuid_1.UUID)().substring(0, 8));
22
23
  _b.label = 1;
23
24
  case 1:
24
25
  _b.trys.push([1, 4, 5, 7]);
@@ -1 +1 @@
1
- {"version":3,"file":"browser-storage.js","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":";;;;AAEA;IACE,wBAAoB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAEnC,kCAAS,GAAf;;;;;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,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;iBACnD;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,UAAU,CAAC,GAAG,CAAC,CAAC;iBAC/B;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,8BAAK,GAAX;;;;gBACE,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;iBACvB;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IACH,qBAAC;AAAD,CAAC,AAjED,IAiEC;AAjEY,wCAAc","sourcesContent":["import { Storage as AmplitudeStorage } from '../types/storage';\n\nexport class BrowserStorage<T> implements AmplitudeStorage<T> {\n constructor(private storage?: Storage) {}\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!this.storage) {\n return false;\n }\n\n const random = String(Date.now());\n const testStorage = new BrowserStorage<string>(this.storage);\n const testKey = 'AMP_TEST';\n try {\n await testStorage.set(testKey, random);\n const value = await testStorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n try {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n console.error(`[Amplitude] Error: Could not get value from storage`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n return this.storage?.getItem(key) || undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n try {\n this.storage?.setItem(key, JSON.stringify(value));\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n try {\n this.storage?.removeItem(key);\n } catch {\n //\n }\n }\n\n async reset(): Promise<void> {\n try {\n this.storage?.clear();\n } catch {\n //\n }\n }\n}\n"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;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,sBAAO,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,GAAG,CAAC,KAAI,SAAS,EAAC;;;KAChD;IAEK,4BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;;gBAC7B,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;iBACnD;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,UAAU,CAAC,GAAG,CAAC,CAAC;iBAC/B;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,8BAAK,GAAX;;;;gBACE,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;iBACvB;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IACH,qBAAC;AAAD,CAAC,AAjED,IAiEC;AAjEY,wCAAc","sourcesContent":["import { UUID } from '../utils/uuid';\nimport { Storage as AmplitudeStorage } from '../types/storage';\n\nexport class BrowserStorage<T> implements AmplitudeStorage<T> {\n constructor(private storage?: Storage) {}\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!this.storage) {\n return false;\n }\n\n const random = String(Date.now());\n const testStorage = new BrowserStorage<string>(this.storage);\n const testKey = `AMP_TEST_${UUID().substring(0, 8)}`;\n try {\n await testStorage.set(testKey, random);\n const value = await testStorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n try {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n console.error(`[Amplitude] Error: Could not get value from storage`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n return this.storage?.getItem(key) || undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n try {\n this.storage?.setItem(key, JSON.stringify(value));\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n try {\n this.storage?.removeItem(key);\n } catch {\n //\n }\n }\n\n async reset(): Promise<void> {\n try {\n this.storage?.clear();\n } catch {\n //\n }\n }\n}\n"]}
@@ -1,8 +1,9 @@
1
- import { Storage, CookieStorageOptions } from '../types/storage';
1
+ import { Storage, CookieStorageOptions, CookieStorageConfig } from '../types/storage';
2
2
  export declare class CookieStorage<T> implements Storage<T> {
3
3
  options: CookieStorageOptions;
4
+ config: CookieStorageConfig;
4
5
  private static testValue;
5
- constructor(options?: CookieStorageOptions);
6
+ constructor(options?: CookieStorageOptions, config?: CookieStorageConfig);
6
7
  isEnabled(): Promise<boolean>;
7
8
  get(key: string): Promise<T | undefined>;
8
9
  getRaw(key: string): Promise<string | undefined>;
@@ -10,4 +11,15 @@ export declare class CookieStorage<T> implements Storage<T> {
10
11
  remove(key: string): Promise<void>;
11
12
  reset(): Promise<void>;
12
13
  }
14
+ /**
15
+ * Decodes a cookie value that was encoded with btoa(encodeURIComponent(...)).
16
+ * Handles both standard encoding and double URL encoding (used by Ruby Rails v7+).
17
+ */
18
+ export declare const decodeCookieValue: (value: string) => string | undefined;
19
+ /**
20
+ * Compares two domain strings for equality, ignoring leading dots.
21
+ * This is useful for comparing cookie domains since ".example.com" and "example.com"
22
+ * are effectively equivalent for cookie scoping.
23
+ */
24
+ export declare const isDomainEqual: (domain1: string | undefined, domain2: string | undefined) => boolean;
13
25
  //# sourceMappingURL=cookie.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAk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,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAoBD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,KAAG,MAAM,GAAG,SAE1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,YAAa,MAAM,GAAG,SAAS,WAAW,MAAM,GAAG,SAAS,KAAG,OAOxF,CAAC"}
@@ -1,11 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CookieStorage = void 0;
3
+ exports.isDomainEqual = exports.decodeCookieValue = exports.CookieStorage = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var global_scope_1 = require("../global-scope");
6
6
  var CookieStorage = /** @class */ (function () {
7
- function CookieStorage(options) {
7
+ function CookieStorage(options, config) {
8
+ if (config === void 0) { config = {}; }
8
9
  this.options = tslib_1.__assign({}, options);
10
+ this.config = config;
9
11
  }
10
12
  CookieStorage.prototype.isEnabled = function () {
11
13
  return tslib_1.__awaiter(this, void 0, void 0, function () {
@@ -44,19 +46,18 @@ var CookieStorage = /** @class */ (function () {
44
46
  });
45
47
  };
46
48
  CookieStorage.prototype.get = function (key) {
47
- var _a;
48
49
  return tslib_1.__awaiter(this, void 0, void 0, function () {
49
50
  var value, decodedValue;
50
- return tslib_1.__generator(this, function (_b) {
51
- switch (_b.label) {
51
+ return tslib_1.__generator(this, function (_a) {
52
+ switch (_a.label) {
52
53
  case 0: return [4 /*yield*/, this.getRaw(key)];
53
54
  case 1:
54
- value = _b.sent();
55
+ value = _a.sent();
55
56
  if (!value) {
56
57
  return [2 /*return*/, undefined];
57
58
  }
58
59
  try {
59
- decodedValue = (_a = decodeCookiesAsDefault(value)) !== null && _a !== void 0 ? _a : decodeCookiesWithDoubleUrlEncoding(value);
60
+ decodedValue = (0, exports.decodeCookieValue)(value);
60
61
  if (decodedValue === undefined) {
61
62
  console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(key, ", value: ").concat(value));
62
63
  return [2 /*return*/, undefined];
@@ -64,7 +65,7 @@ var CookieStorage = /** @class */ (function () {
64
65
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
65
66
  return [2 /*return*/, JSON.parse(decodedValue)];
66
67
  }
67
- catch (_c) {
68
+ catch (_b) {
68
69
  console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(key, ", value: ").concat(value));
69
70
  return [2 /*return*/, undefined];
70
71
  }
@@ -74,17 +75,82 @@ var CookieStorage = /** @class */ (function () {
74
75
  });
75
76
  };
76
77
  CookieStorage.prototype.getRaw = function (key) {
77
- var _a, _b;
78
+ var _a, _b, _c, _d;
78
79
  return tslib_1.__awaiter(this, void 0, void 0, function () {
79
- var globalScope, cookie, match;
80
- return tslib_1.__generator(this, function (_c) {
81
- globalScope = (0, global_scope_1.getGlobalScope)();
82
- cookie = (_b = (_a = globalScope === null || globalScope === void 0 ? void 0 : globalScope.document) === null || _a === void 0 ? void 0 : _a.cookie.split('; ')) !== null && _b !== void 0 ? _b : [];
83
- match = cookie.find(function (c) { return c.indexOf(key + '=') === 0; });
84
- if (!match) {
85
- return [2 /*return*/, undefined];
80
+ var globalScope, globalScopeWithCookiesStore, cookieStore, cookies_2, cookies_1, cookies_1_1, cookie, ignoreError_1, cookies, match, duplicateResolverFn;
81
+ var e_1, _e;
82
+ var _this = this;
83
+ return tslib_1.__generator(this, function (_f) {
84
+ switch (_f.label) {
85
+ case 0:
86
+ globalScope = (0, global_scope_1.getGlobalScope)();
87
+ globalScopeWithCookiesStore = globalScope;
88
+ _f.label = 1;
89
+ case 1:
90
+ _f.trys.push([1, 4, , 5]);
91
+ cookieStore = globalScopeWithCookiesStore === null || globalScopeWithCookiesStore === void 0 ? void 0 : globalScopeWithCookiesStore.cookieStore;
92
+ if (!cookieStore) return [3 /*break*/, 3];
93
+ return [4 /*yield*/, cookieStore.getAll(key)];
94
+ case 2:
95
+ cookies_2 = _f.sent();
96
+ if (cookies_2) {
97
+ /* istanbul ignore if */
98
+ if (cookies_2.length > 1) {
99
+ (_a = this.config.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.recordEvent('cookies.duplicate', {
100
+ cookies: cookies_2.map(function (cookie) { return cookie.domain; }),
101
+ });
102
+ (_b = this.config.diagnosticsClient) === null || _b === void 0 ? void 0 : _b.increment('cookies.duplicate.occurrence.cookieStore');
103
+ }
104
+ try {
105
+ for (cookies_1 = tslib_1.__values(cookies_2), cookies_1_1 = cookies_1.next(); !cookies_1_1.done; cookies_1_1 = cookies_1.next()) {
106
+ cookie = cookies_1_1.value;
107
+ if ((0, exports.isDomainEqual)(cookie.domain, this.options.domain)) {
108
+ return [2 /*return*/, cookie.value];
109
+ }
110
+ }
111
+ }
112
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
113
+ finally {
114
+ try {
115
+ if (cookies_1_1 && !cookies_1_1.done && (_e = cookies_1.return)) _e.call(cookies_1);
116
+ }
117
+ finally { if (e_1) throw e_1.error; }
118
+ }
119
+ }
120
+ _f.label = 3;
121
+ case 3: return [3 /*break*/, 5];
122
+ case 4:
123
+ ignoreError_1 = _f.sent();
124
+ return [3 /*break*/, 5];
125
+ case 5:
126
+ cookies = ((_d = (_c = globalScope === null || globalScope === void 0 ? void 0 : globalScope.document) === null || _c === void 0 ? void 0 : _c.cookie.split('; ')) !== null && _d !== void 0 ? _d : []).filter(function (c) { return c.indexOf(key + '=') === 0; });
127
+ match = undefined;
128
+ duplicateResolverFn = this.config.duplicateResolverFn;
129
+ if (typeof duplicateResolverFn === 'function' && cookies.length > 1) {
130
+ match = cookies.find(function (c) {
131
+ var _a;
132
+ try {
133
+ var res = duplicateResolverFn(c.substring(key.length + 1));
134
+ if (!res) {
135
+ (_a = _this.config.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.increment('cookies.duplicate.occurrence.document.cookie');
136
+ }
137
+ return res;
138
+ }
139
+ catch (ignoreError) {
140
+ /* istanbul ignore next */
141
+ return false;
142
+ }
143
+ });
144
+ }
145
+ // if match was not found, just get the first one that matches the key
146
+ if (!match) {
147
+ match = cookies[0];
148
+ }
149
+ if (!match) {
150
+ return [2 /*return*/, undefined];
151
+ }
152
+ return [2 /*return*/, match.substring(key.length + 1)];
86
153
  }
87
- return [2 /*return*/, match.substring(key.length + 1)];
88
154
  });
89
155
  });
90
156
  };
@@ -169,4 +235,27 @@ var decodeCookiesWithDoubleUrlEncoding = function (value) {
169
235
  return undefined;
170
236
  }
171
237
  };
238
+ /**
239
+ * Decodes a cookie value that was encoded with btoa(encodeURIComponent(...)).
240
+ * Handles both standard encoding and double URL encoding (used by Ruby Rails v7+).
241
+ */
242
+ var decodeCookieValue = function (value) {
243
+ var _a;
244
+ return (_a = decodeCookiesAsDefault(value)) !== null && _a !== void 0 ? _a : decodeCookiesWithDoubleUrlEncoding(value);
245
+ };
246
+ exports.decodeCookieValue = decodeCookieValue;
247
+ /**
248
+ * Compares two domain strings for equality, ignoring leading dots.
249
+ * This is useful for comparing cookie domains since ".example.com" and "example.com"
250
+ * are effectively equivalent for cookie scoping.
251
+ */
252
+ var isDomainEqual = function (domain1, domain2) {
253
+ if (!domain1 || !domain2) {
254
+ return false;
255
+ }
256
+ var normalized1 = domain1.startsWith('.') ? domain1.substring(1) : domain1;
257
+ var normalized2 = domain2.startsWith('.') ? domain2.substring(1) : domain2;
258
+ return normalized1.toLowerCase() === normalized2.toLowerCase();
259
+ };
260
+ exports.isDomainEqual = isDomainEqual;
172
261
  //# sourceMappingURL=cookie.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":";;;;AACA,gDAAiD;AAEjD;IAIE,uBAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,wBAA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C,CAAC;KACxC;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC;AAEF,IAAM,kCAAkC,GAAG,UAAC,KAAa;IACvD,uEAAuE;IACvE,kEAAkE;IAClE,IAAI;QACF,OAAO,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC5D;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC","sourcesContent":["import { Storage, CookieStorageOptions } from '../types/storage';\nimport { getGlobalScope } from '../global-scope';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n private static testValue: undefined | string;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!getGlobalScope()) {\n return false;\n }\n\n CookieStorage.testValue = String(Date.now());\n const testStorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStorage.set(testKey, CookieStorage.testValue);\n const value = await testStorage.get(testKey);\n return value === CookieStorage.testValue;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n const decodedValue = decodeCookiesAsDefault(value) ?? decodeCookiesWithDoubleUrlEncoding(value);\n if (decodedValue === undefined) {\n console.error(`Amplitude Logger [Error]: Failed to decode cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(decodedValue);\n } catch {\n console.error(`Amplitude Logger [Error]: Failed to parse cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const globalScope = getGlobalScope();\n const cookie = globalScope?.document?.cookie.split('; ') ?? [];\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n const globalScope = getGlobalScope();\n if (globalScope) {\n globalScope.document.cookie = str;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Amplitude Logger [Error]: Failed to set cookie for key: ${key}. Error: ${errorMessage}`);\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n\nconst decodeCookiesAsDefault = (value: string): string | undefined => {\n try {\n return decodeURIComponent(atob(value));\n } catch {\n return undefined;\n }\n};\n\nconst decodeCookiesWithDoubleUrlEncoding = (value: string): string | undefined => {\n // Modern Ruby (v7+) automatically encodes cookies with URL encoding by\n // https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html\n try {\n return decodeURIComponent(atob(decodeURIComponent(value)));\n } catch {\n return undefined;\n }\n};\n"]}
1
+ {"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":";;;;AACA,gDAAiD;AAoBjD;IAKE,uBAAY,OAA8B,EAAE,MAAgC;QAAhC,uBAAA,EAAA,WAAgC;QAC1E,IAAI,CAAC,OAAO,wBAAQ,OAAO,CAAE,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEK,iCAAS,GAAf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;AAPW,QAAA,aAAa,iBAOxB","sourcesContent":["import { Storage, CookieStorageOptions, CookieStorageConfig } from '../types/storage';\nimport { getGlobalScope } from '../global-scope';\n\n// CookieStore is a Web API not included in standard TypeScript lib types\n// https://developer.mozilla.org/en-US/docs/Web/API/CookieStore\ninterface CookieStoreSetOptions {\n name: string;\n value: string;\n expires?: number;\n domain?: string;\n sameSite?: 'strict' | 'lax' | 'none';\n}\n\ninterface CookieStore {\n getAll(key: string): Promise<CookieStoreSetOptions[] | undefined>;\n}\n\ntype GlobalScopeWithCookieStore = {\n cookieStore?: CookieStore;\n} & typeof global;\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n config: CookieStorageConfig;\n private static testValue: undefined | string;\n\n constructor(options?: CookieStorageOptions, config: CookieStorageConfig = {}) {\n this.options = { ...options };\n this.config = config;\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!getGlobalScope()) {\n return false;\n }\n\n CookieStorage.testValue = String(Date.now());\n const testStorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStorage.set(testKey, CookieStorage.testValue);\n const value = await testStorage.get(testKey);\n return value === CookieStorage.testValue;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n const decodedValue = decodeCookieValue(value);\n if (decodedValue === undefined) {\n console.error(`Amplitude Logger [Error]: Failed to decode cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(decodedValue);\n } catch {\n console.error(`Amplitude Logger [Error]: Failed to parse cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const globalScope = getGlobalScope();\n\n // use CookieStore if available and enabled\n const globalScopeWithCookiesStore = globalScope as GlobalScopeWithCookieStore;\n try {\n const cookieStore = globalScopeWithCookiesStore?.cookieStore;\n if (cookieStore) {\n const cookies = await cookieStore.getAll(key);\n if (cookies) {\n /* istanbul ignore if */\n if (cookies.length > 1) {\n this.config.diagnosticsClient?.recordEvent('cookies.duplicate', {\n cookies: cookies.map((cookie) => cookie.domain),\n });\n this.config.diagnosticsClient?.increment('cookies.duplicate.occurrence.cookieStore');\n }\n\n for (const cookie of cookies) {\n if (isDomainEqual(cookie.domain, this.options.domain)) {\n return cookie.value;\n }\n }\n }\n }\n } catch (ignoreError) {\n /* istanbul ignore next */\n // if cookieStore had a surprise failure, fallback to document.cookie\n }\n\n const cookies = (globalScope?.document?.cookie.split('; ') ?? []).filter((c) => c.indexOf(key + '=') === 0);\n let match: string | undefined = undefined;\n\n // if matcher function is provided, use it to de-duplicate when there's more than one cookie\n /* istanbul ignore if */\n const duplicateResolverFn = this.config.duplicateResolverFn;\n if (typeof duplicateResolverFn === 'function' && cookies.length > 1) {\n match = cookies.find((c) => {\n try {\n const res = duplicateResolverFn(c.substring(key.length + 1));\n if (!res) {\n this.config.diagnosticsClient?.increment('cookies.duplicate.occurrence.document.cookie');\n }\n return res;\n } catch (ignoreError) {\n /* istanbul ignore next */\n return false;\n }\n });\n }\n\n // if match was not found, just get the first one that matches the key\n if (!match) {\n match = cookies[0];\n }\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n const globalScope = getGlobalScope();\n if (globalScope) {\n globalScope.document.cookie = str;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Amplitude Logger [Error]: Failed to set cookie for key: ${key}. Error: ${errorMessage}`);\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n\nconst decodeCookiesAsDefault = (value: string): string | undefined => {\n try {\n return decodeURIComponent(atob(value));\n } catch {\n return undefined;\n }\n};\n\nconst decodeCookiesWithDoubleUrlEncoding = (value: string): string | undefined => {\n // Modern Ruby (v7+) automatically encodes cookies with URL encoding by\n // https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html\n try {\n return decodeURIComponent(atob(decodeURIComponent(value)));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Decodes a cookie value that was encoded with btoa(encodeURIComponent(...)).\n * Handles both standard encoding and double URL encoding (used by Ruby Rails v7+).\n */\nexport const decodeCookieValue = (value: string): string | undefined => {\n return decodeCookiesAsDefault(value) ?? decodeCookiesWithDoubleUrlEncoding(value);\n};\n\n/**\n * Compares two domain strings for equality, ignoring leading dots.\n * This is useful for comparing cookie domains since \".example.com\" and \"example.com\"\n * are effectively equivalent for cookie scoping.\n */\nexport const isDomainEqual = (domain1: string | undefined, domain2: string | undefined): boolean => {\n if (!domain1 || !domain2) {\n return false;\n }\n const normalized1 = domain1.startsWith('.') ? domain1.substring(1) : domain1;\n const normalized2 = domain2.startsWith('.') ? domain2.substring(1) : domain2;\n return normalized1.toLowerCase() === normalized2.toLowerCase();\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { IDiagnosticsClient } from '../diagnostics/diagnostics-client';
1
2
  export interface Storage<T> {
2
3
  isEnabled(): Promise<boolean>;
3
4
  get(key: string): Promise<T | undefined>;
@@ -12,5 +13,17 @@ export interface CookieStorageOptions {
12
13
  sameSite?: string;
13
14
  secure?: boolean;
14
15
  }
16
+ /**
17
+ * Configuration for CookieStorage behavior.
18
+ * Separated from options to keep storage-specific config distinct from cookie attributes.
19
+ */
20
+ export interface CookieStorageConfig {
21
+ /**
22
+ * Function to resolve duplicate cookies when multiple cookies with the same key exist.
23
+ * Returns true if the cookie value should be used, false otherwise.
24
+ */
25
+ duplicateResolverFn?: (value: string) => boolean;
26
+ diagnosticsClient?: IDiagnosticsClient;
27
+ }
15
28
  export type IdentityStorageType = 'cookie' | 'localStorage' | 'sessionStorage' | 'none';
16
29
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,cAAc,GAAG,gBAAgB,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;CACxC;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,cAAc,GAAG,gBAAgB,GAAG,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"","sourcesContent":["export interface Storage<T> {\n isEnabled(): Promise<boolean>;\n get(key: string): Promise<T | undefined>;\n getRaw(key: string): Promise<string | undefined>;\n set(key: string, value: T): Promise<void>;\n remove(key: string): Promise<void>;\n reset(): Promise<void>;\n}\n\nexport interface CookieStorageOptions {\n domain?: string;\n expirationDays?: number;\n sameSite?: string;\n secure?: boolean;\n}\n\nexport type IdentityStorageType = 'cookie' | 'localStorage' | 'sessionStorage' | 'none';\n"]}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"","sourcesContent":["import { IDiagnosticsClient } from '../diagnostics/diagnostics-client';\n\nexport interface Storage<T> {\n isEnabled(): Promise<boolean>;\n get(key: string): Promise<T | undefined>;\n getRaw(key: string): Promise<string | undefined>;\n set(key: string, value: T): Promise<void>;\n remove(key: string): Promise<void>;\n reset(): Promise<void>;\n}\n\nexport interface CookieStorageOptions {\n domain?: string;\n expirationDays?: number;\n sameSite?: string;\n secure?: boolean;\n}\n\n/**\n * Configuration for CookieStorage behavior.\n * Separated from options to keep storage-specific config distinct from cookie attributes.\n */\nexport interface CookieStorageConfig {\n /**\n * Function to resolve duplicate cookies when multiple cookies with the same key exist.\n * Returns true if the cookie value should be used, false otherwise.\n */\n duplicateResolverFn?: (value: string) => boolean;\n diagnosticsClient?: IDiagnosticsClient;\n}\n\nexport type IdentityStorageType = 'cookie' | 'localStorage' | 'sessionStorage' | 'none';\n"]}
@@ -7,5 +7,6 @@ export interface UserSession {
7
7
  lastEventId?: number;
8
8
  pageCounter?: number;
9
9
  debugLogsEnabled?: boolean;
10
+ cookieDomain?: string;
10
11
  }
11
12
  //# sourceMappingURL=user-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
1
+ {"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"user-session.js","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"","sourcesContent":["export interface UserSession {\n userId?: string;\n deviceId?: string;\n sessionId?: number;\n lastEventTime?: number;\n optOut: boolean;\n lastEventId?: number;\n pageCounter?: number;\n debugLogsEnabled?: boolean;\n}\n"]}
1
+ {"version":3,"file":"user-session.js","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"","sourcesContent":["export interface UserSession {\n userId?: string;\n deviceId?: string;\n sessionId?: number;\n lastEventTime?: number;\n optOut: boolean;\n lastEventId?: number;\n pageCounter?: number;\n debugLogsEnabled?: boolean;\n cookieDomain?: string;\n}\n"]}
@@ -22,7 +22,7 @@ export { createIdentifyEvent } from './utils/event-builder';
22
22
  export { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';
23
23
  export { generateHashCode, isTimestampInSample } from './utils/sampling';
24
24
  export { MemoryStorage } from './storage/memory';
25
- export { CookieStorage } from './storage/cookie';
25
+ export { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';
26
26
  export { getStorageKey } from './storage/helpers';
27
27
  export { BrowserStorage } from './storage/browser-storage';
28
28
  export { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';
@@ -32,7 +32,7 @@ export { FetchTransport } from './transports/fetch';
32
32
  export { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';
33
33
  export { LogLevel } from './types/loglevel';
34
34
  export { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';
35
- export { Storage, IdentityStorageType } from './types/storage';
35
+ export { Storage, IdentityStorageType, CookieStorageConfig } from './types/storage';
36
36
  export { Event, IdentifyOperation, SpecialEventType, IdentifyEvent, GroupIdentifyEvent, IdentifyUserProperties, } from './types/event/event';
37
37
  export { EventOptions, BaseEvent } from './types/event/base-event';
38
38
  export { IngestionMetadata } from './types/event/ingestion-metadata';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,g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AoB,CAAC;AAE5F,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
package/lib/esm/index.js CHANGED
@@ -18,7 +18,7 @@ export { createIdentifyEvent } from './utils/event-builder';
18
18
  export { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';
19
19
  export { generateHashCode, isTimestampInSample } from './utils/sampling';
20
20
  export { MemoryStorage } from './storage/memory';
21
- export { CookieStorage } from './storage/cookie';
21
+ export { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';
22
22
  export { getStorageKey } from './storage/helpers';
23
23
  export { BrowserStorage } from './storage/browser-storage';
24
24
  export { DiagnosticsClient } from './diagnostics/diagnostics-client';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAY,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAsB,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE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,EAC5B,4BAA4B,EAC5B,4BAA4B,EAC5B,0CAA0C,EAC1C,4BAA4B,GAC7B,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAqD,MAAM,yBAAyB,CAAC;AAEjH,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAMpE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,QAAQ,EACR,SAAS,EACT,WAAW,GACZ,MAAM,mBAAmB,CAAC;AA4B3B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { CoreClient, PluginHost } from './types/client/core-client';\nexport { AnalyticsClient } from './types/client/analytics-client';\nexport { AmplitudeContext } from './types/amplitude-context';\nexport { Identify, IIdentify } from './identify';\nexport { Revenue, IRevenue, RevenueProperty } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { Config, RequestMetadata } from './config';\nexport { IConfig } from './types/config/core-config';\nexport { Logger, ILogger, LogConfig } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\nexport { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';\nexport { generateHashCode, isTimestampInSample } from './utils/sampling';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BrowserStorage } from './storage/browser-storage';\n\nexport { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';\nexport { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType } from './types/storage';\nexport {\n Event,\n IdentifyOperation,\n SpecialEventType,\n IdentifyEvent,\n GroupIdentifyEvent,\n IdentifyUserProperties,\n} from './types/event/event';\nexport { EventOptions, BaseEvent } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType, ServerZone } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport, TransportOptions, TransportTypeOrOptions } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport {\n Plugin,\n BeforePlugin,\n DestinationPlugin,\n EnrichmentPlugin,\n PluginType,\n AnalyticsIdentity,\n} from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n LabeledEvent,\n Trigger,\n DataSource,\n} from './types/element-interactions';\n\nexport {\n FrustrationInteractionsOptions,\n DEFAULT_DEAD_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_THRESHOLD,\n DEFAULT_RAGE_CLICK_WINDOW_MS,\n DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD,\n DEFAULT_DEAD_CLICK_WINDOW_MS,\n} from './types/frustration-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { Status } from './types/status';\n\nexport { NetworkEventCallback, networkObserver } from './network-observer';\nexport { NetworkRequestEvent, IRequestWrapper, JsonObject, JsonValue, JsonArray } from './network-request-event';\nexport { NetworkTrackingOptions, NetworkCaptureRule } from './types/network-tracking';\nexport { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';\n\nexport { PageUrlEnrichmentOptions } from './types/page-url-enrichment';\n\n// Campaign\nexport { Campaign, UTMParameters, ReferrerParameters, ClickIdParameters, ICampaignParser } from './types/campaign';\nexport { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';\nexport { CampaignParser } from './campaign/campaign-parser';\nexport {\n getPageTitle,\n TEXT_MASK_ATTRIBUTE,\n MASKED_TEXT_VALUE,\n replaceSensitiveString,\n CC_REGEX,\n SSN_REGEX,\n EMAIL_REGEX,\n} from './plugins/helpers';\n\n// Browser\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n RemoteConfigOptions,\n} from './types/config/browser-config';\nexport { BrowserClient } from './types/client/browser-client';\n\n// Node\nexport { NodeClient } from './types/client/node-client';\nexport { NodeConfig, NodeOptions } from './types/config/node-config';\n\n// React Native\nexport {\n ReactNativeConfig,\n ReactNativeTrackingOptions,\n ReactNativeOptions,\n ReactNativeAttributionOptions,\n} from './types/config/react-native-config';\nexport { ReactNativeClient } from './types/client/react-native-client';\n\nexport { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';\n\nexport { InstanceProxy } from './types/proxy';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI9C,OAAO,EAAE,QAAQ,EAAa,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAY,eAAe,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAsB,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAmB,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAClF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,M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AAW,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,QAAQ,EACR,SAAS,EACT,WAAW,GACZ,MAAM,mBAAmB,CAAC;AA4B3B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAkB,MAAM,oBAAoB,CAAC","sourcesContent":["export { AmplitudeCore } from './core-client';\nexport { CoreClient, PluginHost } from './types/client/core-client';\nexport { AnalyticsClient } from './types/client/analytics-client';\nexport { AmplitudeContext } from './types/amplitude-context';\nexport { Identify, IIdentify } from './identify';\nexport { Revenue, IRevenue, RevenueProperty } from './revenue';\nexport { Destination } from './plugins/destination';\nexport { IdentityEventSender } from './plugins/identity';\nexport { Config, RequestMetadata } from './config';\nexport { IConfig } from './types/config/core-config';\nexport { Logger, ILogger, LogConfig } from './logger';\nexport { getGlobalScope } from './global-scope';\nexport { getAnalyticsConnector, setConnectorDeviceId, setConnectorUserId } from './analytics-connector';\nexport { isNewSession } from './session';\nexport { getCookieName, getOldCookieName } from './cookie-name';\nexport { getLanguage } from './language';\nexport { getQueryParams } from './query-params';\n\nexport { returnWrapper, AmplitudeReturn } from './utils/return-wrapper';\nexport { debugWrapper, getClientLogConfig, getClientStates } from './utils/debug';\nexport { UUID } from './utils/uuid';\nexport { createIdentifyEvent } from './utils/event-builder';\nexport { isUrlMatchAllowlist, getDecodeURI } from './utils/url-utils';\nexport { generateHashCode, isTimestampInSample } from './utils/sampling';\n\nexport { MemoryStorage } from './storage/memory';\nexport { CookieStorage, isDomainEqual, decodeCookieValue } from './storage/cookie';\nexport { getStorageKey } from './storage/helpers';\n\nexport { BrowserStorage } from './storage/browser-storage';\n\nexport { DiagnosticsClient, IDiagnosticsClient } from './diagnostics/diagnostics-client';\nexport { registerSdkLoaderMetadata } from './diagnostics/uncaught-sdk-errors';\n\nexport { BaseTransport } from './transports/base';\nexport { FetchTransport } from './transports/fetch';\n\nexport { RemoteConfigClient, IRemoteConfigClient, RemoteConfig, Source } from './remote-config/remote-config';\n\nexport { LogLevel } from './types/loglevel';\nexport { AMPLITUDE_PREFIX, STORAGE_PREFIX } from './types/constants';\nexport { Storage, IdentityStorageType, CookieStorageConfig } from './types/storage';\nexport {\n Event,\n IdentifyOperation,\n SpecialEventType,\n IdentifyEvent,\n GroupIdentifyEvent,\n IdentifyUserProperties,\n} from './types/event/event';\nexport { EventOptions, BaseEvent } from './types/event/base-event';\nexport { IngestionMetadata } from './types/event/ingestion-metadata';\nexport { ServerZoneType, ServerZone } from './types/server-zone';\nexport { OfflineDisabled } from './types/offline';\nexport { Plan } from './types/event/plan';\nexport { TransportType, Transport, TransportOptions, TransportTypeOrOptions } from './types/transport';\nexport { Payload } from './types/payload';\nexport { Response } from './types/response';\nexport { UserSession } from './types/user-session';\nexport {\n Plugin,\n BeforePlugin,\n DestinationPlugin,\n EnrichmentPlugin,\n PluginType,\n AnalyticsIdentity,\n} from './types/plugin';\nexport { Result } from './types/result';\nexport {\n ElementInteractionsOptions,\n Messenger,\n ActionType,\n DEFAULT_CSS_SELECTOR_ALLOWLIST,\n DEFAULT_DATA_ATTRIBUTE_PREFIX,\n DEFAULT_ACTION_CLICK_ALLOWLIST,\n LabeledEvent,\n Trigger,\n DataSource,\n} from './types/element-interactions';\n\nexport {\n FrustrationInteractionsOptions,\n DEFAULT_DEAD_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_ALLOWLIST,\n DEFAULT_RAGE_CLICK_THRESHOLD,\n DEFAULT_RAGE_CLICK_WINDOW_MS,\n DEFAULT_RAGE_CLICK_OUT_OF_BOUNDS_THRESHOLD,\n DEFAULT_DEAD_CLICK_WINDOW_MS,\n} from './types/frustration-interactions';\nexport { PageTrackingOptions, PageTrackingTrackOn, PageTrackingHistoryChanges } from './types/page-view-tracking';\nexport { Status } from './types/status';\n\nexport { NetworkEventCallback, networkObserver } from './network-observer';\nexport { NetworkRequestEvent, IRequestWrapper, JsonObject, JsonValue, JsonArray } from './network-request-event';\nexport { NetworkTrackingOptions, NetworkCaptureRule } from './types/network-tracking';\nexport { SAFE_HEADERS, FORBIDDEN_HEADERS } from './types/constants';\n\nexport { PageUrlEnrichmentOptions } from './types/page-url-enrichment';\n\n// Campaign\nexport { Campaign, UTMParameters, ReferrerParameters, ClickIdParameters, ICampaignParser } from './types/campaign';\nexport { EMPTY_VALUE, BASE_CAMPAIGN, MKTG } from './types/constants';\nexport { CampaignParser } from './campaign/campaign-parser';\nexport {\n getPageTitle,\n TEXT_MASK_ATTRIBUTE,\n MASKED_TEXT_VALUE,\n replaceSensitiveString,\n CC_REGEX,\n SSN_REGEX,\n EMAIL_REGEX,\n} from './plugins/helpers';\n\n// Browser\nexport {\n BrowserConfig,\n BrowserOptions,\n DefaultTrackingOptions,\n TrackingOptions,\n AutocaptureOptions,\n CookieOptions,\n AttributionOptions,\n RemoteConfigOptions,\n} from './types/config/browser-config';\nexport { BrowserClient } from './types/client/browser-client';\n\n// Node\nexport { NodeClient } from './types/client/node-client';\nexport { NodeConfig, NodeOptions } from './types/config/node-config';\n\n// React Native\nexport {\n ReactNativeConfig,\n ReactNativeTrackingOptions,\n ReactNativeOptions,\n ReactNativeAttributionOptions,\n} from './types/config/react-native-config';\nexport { ReactNativeClient } from './types/client/react-native-client';\n\nexport { Observable, asyncMap, merge, multicast, Unsubscribable } from './utils/observable';\n\nexport { InstanceProxy } from './types/proxy';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"browser-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,OAAO,CAAC;gBAAR,OAAO,CAAC,qBAAS;IAE/B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAcxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
1
+ {"version":3,"file":"browser-storage.d.ts","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qBAAa,cAAc,CAAC,CAAC,CAAE,YAAW,gBAAgB,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,OAAO,CAAC;gBAAR,OAAO,CAAC,qBAAS;IAE/B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAcxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAIhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
@@ -1,4 +1,5 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
+ import { UUID } from '../utils/uuid';
2
3
  var BrowserStorage = /** @class */ (function () {
3
4
  function BrowserStorage(storage) {
4
5
  this.storage = storage;
@@ -15,7 +16,7 @@ var BrowserStorage = /** @class */ (function () {
15
16
  }
16
17
  random = String(Date.now());
17
18
  testStorage = new BrowserStorage(this.storage);
18
- testKey = 'AMP_TEST';
19
+ testKey = "AMP_TEST_".concat(UUID().substring(0, 8));
19
20
  _b.label = 1;
20
21
  case 1:
21
22
  _b.trys.push([1, 4, 5, 7]);
@@ -1 +1 @@
1
- {"version":3,"file":"browser-storage.js","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":";AAEA;IACE,wBAAoB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAEnC,kCAAS,GAAf;;;;;;wBACE,wBAAwB;wBACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;4BACjB,sBAAO,KAAK,EAAC;yBACd;wBAEK,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;wBAC5B,WAAW,GAAG,IAAI,cAAc,CAAS,IAAI,CAAC,OAAO,CAAC,CAAC;wBACvD,OAAO,GAAG,UAAU,CAAC;;;;wBAEzB,qBAAM,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA;;wBAAtC,SAAsC,CAAC;wBACzB,qBAAM,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAA;;wBAAtC,KAAK,GAAG,SAA8B;wBAC5C,sBAAO,KAAK,KAAK,MAAM,EAAC;;;wBAExB,0BAA0B;wBAC1B,sBAAO,KAAK,EAAC;4BAEb,qBAAM,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAA;;wBAAjC,SAAiC,CAAC;;;;;;KAErC;IAEK,4BAAG,GAAT,UAAU,GAAW;;;;;;;wBAEH,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAA;;wBAA9B,KAAK,GAAG,SAAsB;wBACpC,IAAI,CAAC,KAAK,EAAE;4BACV,sBAAO,SAAS,EAAC;yBAClB;wBACD,+DAA+D;wBAC/D,sBAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;;;wBAEzB,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;wBACrE,sBAAO,SAAS,EAAC;;;;;KAEpB;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,sBAAO,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,GAAG,CAAC,KAAI,SAAS,EAAC;;;KAChD;IAEK,4BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;;gBAC7B,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;iBACnD;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,UAAU,CAAC,GAAG,CAAC,CAAC;iBAC/B;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,8BAAK,GAAX;;;;gBACE,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;iBACvB;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IACH,qBAAC;AAAD,CAAC,AAjED,IAiEC","sourcesContent":["import { Storage as AmplitudeStorage } from '../types/storage';\n\nexport class BrowserStorage<T> implements AmplitudeStorage<T> {\n constructor(private storage?: Storage) {}\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!this.storage) {\n return false;\n }\n\n const random = String(Date.now());\n const testStorage = new BrowserStorage<string>(this.storage);\n const testKey = 'AMP_TEST';\n try {\n await testStorage.set(testKey, random);\n const value = await testStorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n try {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n console.error(`[Amplitude] Error: Could not get value from storage`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n return this.storage?.getItem(key) || undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n try {\n this.storage?.setItem(key, JSON.stringify(value));\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n try {\n this.storage?.removeItem(key);\n } catch {\n //\n }\n }\n\n async reset(): Promise<void> {\n try {\n this.storage?.clear();\n } catch {\n //\n }\n }\n}\n"]}
1
+ {"version":3,"file":"browser-storage.js","sourceRoot":"","sources":["../../../src/storage/browser-storage.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAGrC;IACE,wBAAoB,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAEnC,kCAAS,GAAf;;;;;;wBACE,wBAAwB;wBACxB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;4BACjB,sBAAO,KAAK,EAAC;yBACd;wBAEK,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;wBAC5B,WAAW,GAAG,IAAI,cAAc,CAAS,IAAI,CAAC,OAAO,CAAC,CAAC;wBACvD,OAAO,GAAG,mBAAY,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,CAAC;;;;wBAEnD,qBAAM,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,EAAA;;wBAAtC,SAAsC,CAAC;wBACzB,qBAAM,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAA;;wBAAtC,KAAK,GAAG,SAA8B;wBAC5C,sBAAO,KAAK,KAAK,MAAM,EAAC;;;wBAExB,0BAA0B;wBAC1B,sBAAO,KAAK,EAAC;4BAEb,qBAAM,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAA;;wBAAjC,SAAiC,CAAC;;;;;;KAErC;IAEK,4BAAG,GAAT,UAAU,GAAW;;;;;;;wBAEH,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAA;;wBAA9B,KAAK,GAAG,SAAsB;wBACpC,IAAI,CAAC,KAAK,EAAE;4BACV,sBAAO,SAAS,EAAC;yBAClB;wBACD,+DAA+D;wBAC/D,sBAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAC;;;wBAEzB,OAAO,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;wBACrE,sBAAO,SAAS,EAAC;;;;;KAEpB;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,sBAAO,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,GAAG,CAAC,KAAI,SAAS,EAAC;;;KAChD;IAEK,4BAAG,GAAT,UAAU,GAAW,EAAE,KAAQ;;;;gBAC7B,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;iBACnD;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,+BAAM,GAAZ,UAAa,GAAW;;;;gBACtB,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,UAAU,CAAC,GAAG,CAAC,CAAC;iBAC/B;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IAEK,8BAAK,GAAX;;;;gBACE,IAAI;oBACF,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;iBACvB;gBAAC,WAAM;oBACN,EAAE;iBACH;;;;KACF;IACH,qBAAC;AAAD,CAAC,AAjED,IAiEC","sourcesContent":["import { UUID } from '../utils/uuid';\nimport { Storage as AmplitudeStorage } from '../types/storage';\n\nexport class BrowserStorage<T> implements AmplitudeStorage<T> {\n constructor(private storage?: Storage) {}\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!this.storage) {\n return false;\n }\n\n const random = String(Date.now());\n const testStorage = new BrowserStorage<string>(this.storage);\n const testKey = `AMP_TEST_${UUID().substring(0, 8)}`;\n try {\n await testStorage.set(testKey, random);\n const value = await testStorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n try {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n console.error(`[Amplitude] Error: Could not get value from storage`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n return this.storage?.getItem(key) || undefined;\n }\n\n async set(key: string, value: T): Promise<void> {\n try {\n this.storage?.setItem(key, JSON.stringify(value));\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n try {\n this.storage?.removeItem(key);\n } catch {\n //\n }\n }\n\n async reset(): Promise<void> {\n try {\n this.storage?.clear();\n } catch {\n //\n }\n }\n}\n"]}
@@ -1,8 +1,9 @@
1
- import { Storage, CookieStorageOptions } from '../types/storage';
1
+ import { Storage, CookieStorageOptions, CookieStorageConfig } from '../types/storage';
2
2
  export declare class CookieStorage<T> implements Storage<T> {
3
3
  options: CookieStorageOptions;
4
+ config: CookieStorageConfig;
4
5
  private static testValue;
5
- constructor(options?: CookieStorageOptions);
6
+ constructor(options?: CookieStorageOptions, config?: CookieStorageConfig);
6
7
  isEnabled(): Promise<boolean>;
7
8
  get(key: string): Promise<T | undefined>;
8
9
  getRaw(key: string): Promise<string | undefined>;
@@ -10,4 +11,15 @@ export declare class CookieStorage<T> implements Storage<T> {
10
11
  remove(key: string): Promise<void>;
11
12
  reset(): Promise<void>;
12
13
  }
14
+ /**
15
+ * Decodes a cookie value that was encoded with btoa(encodeURIComponent(...)).
16
+ * Handles both standard encoding and double URL encoding (used by Ruby Rails v7+).
17
+ */
18
+ export declare const decodeCookieValue: (value: string) => string | undefined;
19
+ /**
20
+ * Compares two domain strings for equality, ignoring leading dots.
21
+ * This is useful for comparing cookie domains since ".example.com" and "example.com"
22
+ * are effectively equivalent for cookie scoping.
23
+ */
24
+ export declare const isDomainEqual: (domain1: string | undefined, domain2: string | undefined) => boolean;
13
25
  //# sourceMappingURL=cookie.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGjE,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAqB;gBAEjC,OAAO,CAAC,EAAE,oBAAoB;IAIpC,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAmBxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAUhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B"}
1
+ {"version":3,"file":"cookie.d.ts","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAqBtF,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,OAAO,CAAC,CAAC,CAAC;IACjD,OAAO,EAAE,oBAAoB,CAAC;IAC9B,MAAM,EAAE,mBAAmB,CAAC;IAC5B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAqB;gBAEjC,OAAO,CAAC,EAAE,oBAAoB,EAAE,MAAM,GAAE,mBAAwB;IAKtE,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAqB7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAmBxC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IA6DhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAkChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAoBD;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,KAAG,MAAM,GAAG,SAE1D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,YAAa,MAAM,GAAG,SAAS,WAAW,MAAM,GAAG,SAAS,KAAG,OAOxF,CAAC"}
@@ -1,8 +1,10 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
1
+ import { __assign, __awaiter, __generator, __values } from "tslib";
2
2
  import { getGlobalScope } from '../global-scope';
3
3
  var CookieStorage = /** @class */ (function () {
4
- function CookieStorage(options) {
4
+ function CookieStorage(options, config) {
5
+ if (config === void 0) { config = {}; }
5
6
  this.options = __assign({}, options);
7
+ this.config = config;
6
8
  }
7
9
  CookieStorage.prototype.isEnabled = function () {
8
10
  return __awaiter(this, void 0, void 0, function () {
@@ -41,19 +43,18 @@ var CookieStorage = /** @class */ (function () {
41
43
  });
42
44
  };
43
45
  CookieStorage.prototype.get = function (key) {
44
- var _a;
45
46
  return __awaiter(this, void 0, void 0, function () {
46
47
  var value, decodedValue;
47
- return __generator(this, function (_b) {
48
- switch (_b.label) {
48
+ return __generator(this, function (_a) {
49
+ switch (_a.label) {
49
50
  case 0: return [4 /*yield*/, this.getRaw(key)];
50
51
  case 1:
51
- value = _b.sent();
52
+ value = _a.sent();
52
53
  if (!value) {
53
54
  return [2 /*return*/, undefined];
54
55
  }
55
56
  try {
56
- decodedValue = (_a = decodeCookiesAsDefault(value)) !== null && _a !== void 0 ? _a : decodeCookiesWithDoubleUrlEncoding(value);
57
+ decodedValue = decodeCookieValue(value);
57
58
  if (decodedValue === undefined) {
58
59
  console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(key, ", value: ").concat(value));
59
60
  return [2 /*return*/, undefined];
@@ -61,7 +62,7 @@ var CookieStorage = /** @class */ (function () {
61
62
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
62
63
  return [2 /*return*/, JSON.parse(decodedValue)];
63
64
  }
64
- catch (_c) {
65
+ catch (_b) {
65
66
  console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(key, ", value: ").concat(value));
66
67
  return [2 /*return*/, undefined];
67
68
  }
@@ -71,17 +72,82 @@ var CookieStorage = /** @class */ (function () {
71
72
  });
72
73
  };
73
74
  CookieStorage.prototype.getRaw = function (key) {
74
- var _a, _b;
75
+ var _a, _b, _c, _d;
75
76
  return __awaiter(this, void 0, void 0, function () {
76
- var globalScope, cookie, match;
77
- return __generator(this, function (_c) {
78
- globalScope = getGlobalScope();
79
- cookie = (_b = (_a = globalScope === null || globalScope === void 0 ? void 0 : globalScope.document) === null || _a === void 0 ? void 0 : _a.cookie.split('; ')) !== null && _b !== void 0 ? _b : [];
80
- match = cookie.find(function (c) { return c.indexOf(key + '=') === 0; });
81
- if (!match) {
82
- return [2 /*return*/, undefined];
77
+ var globalScope, globalScopeWithCookiesStore, cookieStore, cookies_2, cookies_1, cookies_1_1, cookie, ignoreError_1, cookies, match, duplicateResolverFn;
78
+ var e_1, _e;
79
+ var _this = this;
80
+ return __generator(this, function (_f) {
81
+ switch (_f.label) {
82
+ case 0:
83
+ globalScope = getGlobalScope();
84
+ globalScopeWithCookiesStore = globalScope;
85
+ _f.label = 1;
86
+ case 1:
87
+ _f.trys.push([1, 4, , 5]);
88
+ cookieStore = globalScopeWithCookiesStore === null || globalScopeWithCookiesStore === void 0 ? void 0 : globalScopeWithCookiesStore.cookieStore;
89
+ if (!cookieStore) return [3 /*break*/, 3];
90
+ return [4 /*yield*/, cookieStore.getAll(key)];
91
+ case 2:
92
+ cookies_2 = _f.sent();
93
+ if (cookies_2) {
94
+ /* istanbul ignore if */
95
+ if (cookies_2.length > 1) {
96
+ (_a = this.config.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.recordEvent('cookies.duplicate', {
97
+ cookies: cookies_2.map(function (cookie) { return cookie.domain; }),
98
+ });
99
+ (_b = this.config.diagnosticsClient) === null || _b === void 0 ? void 0 : _b.increment('cookies.duplicate.occurrence.cookieStore');
100
+ }
101
+ try {
102
+ for (cookies_1 = __values(cookies_2), cookies_1_1 = cookies_1.next(); !cookies_1_1.done; cookies_1_1 = cookies_1.next()) {
103
+ cookie = cookies_1_1.value;
104
+ if (isDomainEqual(cookie.domain, this.options.domain)) {
105
+ return [2 /*return*/, cookie.value];
106
+ }
107
+ }
108
+ }
109
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
110
+ finally {
111
+ try {
112
+ if (cookies_1_1 && !cookies_1_1.done && (_e = cookies_1.return)) _e.call(cookies_1);
113
+ }
114
+ finally { if (e_1) throw e_1.error; }
115
+ }
116
+ }
117
+ _f.label = 3;
118
+ case 3: return [3 /*break*/, 5];
119
+ case 4:
120
+ ignoreError_1 = _f.sent();
121
+ return [3 /*break*/, 5];
122
+ case 5:
123
+ cookies = ((_d = (_c = globalScope === null || globalScope === void 0 ? void 0 : globalScope.document) === null || _c === void 0 ? void 0 : _c.cookie.split('; ')) !== null && _d !== void 0 ? _d : []).filter(function (c) { return c.indexOf(key + '=') === 0; });
124
+ match = undefined;
125
+ duplicateResolverFn = this.config.duplicateResolverFn;
126
+ if (typeof duplicateResolverFn === 'function' && cookies.length > 1) {
127
+ match = cookies.find(function (c) {
128
+ var _a;
129
+ try {
130
+ var res = duplicateResolverFn(c.substring(key.length + 1));
131
+ if (!res) {
132
+ (_a = _this.config.diagnosticsClient) === null || _a === void 0 ? void 0 : _a.increment('cookies.duplicate.occurrence.document.cookie');
133
+ }
134
+ return res;
135
+ }
136
+ catch (ignoreError) {
137
+ /* istanbul ignore next */
138
+ return false;
139
+ }
140
+ });
141
+ }
142
+ // if match was not found, just get the first one that matches the key
143
+ if (!match) {
144
+ match = cookies[0];
145
+ }
146
+ if (!match) {
147
+ return [2 /*return*/, undefined];
148
+ }
149
+ return [2 /*return*/, match.substring(key.length + 1)];
83
150
  }
84
- return [2 /*return*/, match.substring(key.length + 1)];
85
151
  });
86
152
  });
87
153
  };
@@ -166,4 +232,25 @@ var decodeCookiesWithDoubleUrlEncoding = function (value) {
166
232
  return undefined;
167
233
  }
168
234
  };
235
+ /**
236
+ * Decodes a cookie value that was encoded with btoa(encodeURIComponent(...)).
237
+ * Handles both standard encoding and double URL encoding (used by Ruby Rails v7+).
238
+ */
239
+ export var decodeCookieValue = function (value) {
240
+ var _a;
241
+ return (_a = decodeCookiesAsDefault(value)) !== null && _a !== void 0 ? _a : decodeCookiesWithDoubleUrlEncoding(value);
242
+ };
243
+ /**
244
+ * Compares two domain strings for equality, ignoring leading dots.
245
+ * This is useful for comparing cookie domains since ".example.com" and "example.com"
246
+ * are effectively equivalent for cookie scoping.
247
+ */
248
+ export var isDomainEqual = function (domain1, domain2) {
249
+ if (!domain1 || !domain2) {
250
+ return false;
251
+ }
252
+ var normalized1 = domain1.startsWith('.') ? domain1.substring(1) : domain1;
253
+ var normalized2 = domain2.startsWith('.') ? domain2.substring(1) : domain2;
254
+ return normalized1.toLowerCase() === normalized2.toLowerCase();
255
+ };
169
256
  //# sourceMappingURL=cookie.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD;IAIE,uBAAY,OAA8B;QACxC,IAAI,CAAC,OAAO,gBAAQ,OAAO,CAAE,CAAC;IAChC,CAAC;IAEK,iCAAS,GAAf;;;;;;wBACE,wBAAwB;wBACxB,IAAI,CAAC,cAAc,EAAE,EAAE;4BACrB,sBAAO,KAAK,EAAC;yBACd;wBAED,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;wBACvC,WAAW,GAAG,IAAI,aAAa,CAAS,IAAI,CAAC,OAAO,CAAC,CAAC;wBACtD,OAAO,GAAG,UAAU,CAAC;;;;wBAEzB,qBAAM,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,EAAA;;wBAAvD,SAAuD,CAAC;wBAC1C,qBAAM,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,EAAA;;wBAAtC,KAAK,GAAG,SAA8B;wBAC5C,sBAAO,KAAK,KAAK,aAAa,CAAC,SAAS,EAAC;;;wBAEzC,0BAA0B;wBAC1B,sBAAO,KAAK,EAAC;4BAEb,qBAAM,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAA;;wBAAjC,SAAiC,CAAC;;;;;;KAErC;IAEK,2BAAG,GAAT,UAAU,GAAW;;;;;;4BACL,qBAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAA;;wBAA9B,KAAK,GAAG,SAAsB;wBACpC,IAAI,CAAC,KAAK,EAAE;4BACV,sBAAO,SAAS,EAAC;yBAClB;wBACD,IAAI;4BACI,YAAY,GAAG,MAAA,sBAAsB,CAAC,KAAK,CAAC,mCAAI,kCAAkC,CAAC,KAAK,CAAC,CAAC;4B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;;;;;KAC3B;IAEK,6BAAK,GAAX;;;gBACE,sBAAO;;;KACR;IACH,oBAAC;AAAD,CAAC,AAnGD,IAmGC;;AAED,IAAM,sBAAsB,GAAG,UAAC,KAAa;IAC3C,IAAI;QACF,OAAO,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;KACxC;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC;AAEF,IAAM,kCAAkC,GAAG,UAAC,KAAa;IACvD,uEAAuE;IACvE,kEAAkE;IAClE,IAAI;QACF,OAAO,kBAAkB,CAAC,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KAC5D;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;AACH,CAAC,CAAC","sourcesContent":["import { Storage, CookieStorageOptions } from '../types/storage';\nimport { getGlobalScope } from '../global-scope';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n private static testValue: undefined | string;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!getGlobalScope()) {\n return false;\n }\n\n CookieStorage.testValue = String(Date.now());\n const testStorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStorage.set(testKey, CookieStorage.testValue);\n const value = await testStorage.get(testKey);\n return value === CookieStorage.testValue;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n const decodedValue = decodeCookiesAsDefault(value) ?? decodeCookiesWithDoubleUrlEncoding(value);\n if (decodedValue === undefined) {\n console.error(`Amplitude Logger [Error]: Failed to decode cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(decodedValue);\n } catch {\n console.error(`Amplitude Logger [Error]: Failed to parse cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const globalScope = getGlobalScope();\n const cookie = globalScope?.document?.cookie.split('; ') ?? [];\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n const globalScope = getGlobalScope();\n if (globalScope) {\n globalScope.document.cookie = str;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Amplitude Logger [Error]: Failed to set cookie for key: ${key}. Error: ${errorMessage}`);\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n\nconst decodeCookiesAsDefault = (value: string): string | undefined => {\n try {\n return decodeURIComponent(atob(value));\n } catch {\n return undefined;\n }\n};\n\nconst decodeCookiesWithDoubleUrlEncoding = (value: string): string | undefined => {\n // Modern Ruby (v7+) automatically encodes cookies with URL encoding by\n // https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html\n try {\n return decodeURIComponent(atob(decodeURIComponent(value)));\n } catch {\n return undefined;\n }\n};\n"]}
1
+ {"version":3,"file":"cookie.js","sourceRoot":"","sources":["../../../src/storage/cookie.ts"],"names":[],"mappings":";AACA,OAAO,EA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AAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7E,OAAO,WAAW,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC;AACjE,CAAC,CAAC","sourcesContent":["import { Storage, CookieStorageOptions, CookieStorageConfig } from '../types/storage';\nimport { getGlobalScope } from '../global-scope';\n\n// CookieStore is a Web API not included in standard TypeScript lib types\n// https://developer.mozilla.org/en-US/docs/Web/API/CookieStore\ninterface CookieStoreSetOptions {\n name: string;\n value: string;\n expires?: number;\n domain?: string;\n sameSite?: 'strict' | 'lax' | 'none';\n}\n\ninterface CookieStore {\n getAll(key: string): Promise<CookieStoreSetOptions[] | undefined>;\n}\n\ntype GlobalScopeWithCookieStore = {\n cookieStore?: CookieStore;\n} & typeof global;\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n config: CookieStorageConfig;\n private static testValue: undefined | string;\n\n constructor(options?: CookieStorageOptions, config: CookieStorageConfig = {}) {\n this.options = { ...options };\n this.config = config;\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (!getGlobalScope()) {\n return false;\n }\n\n CookieStorage.testValue = String(Date.now());\n const testStorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStorage.set(testKey, CookieStorage.testValue);\n const value = await testStorage.get(testKey);\n return value === CookieStorage.testValue;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n const value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n const decodedValue = decodeCookieValue(value);\n if (decodedValue === undefined) {\n console.error(`Amplitude Logger [Error]: Failed to decode cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(decodedValue);\n } catch {\n console.error(`Amplitude Logger [Error]: Failed to parse cookie value for key: ${key}, value: ${value}`);\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const globalScope = getGlobalScope();\n\n // use CookieStore if available and enabled\n const globalScopeWithCookiesStore = globalScope as GlobalScopeWithCookieStore;\n try {\n const cookieStore = globalScopeWithCookiesStore?.cookieStore;\n if (cookieStore) {\n const cookies = await cookieStore.getAll(key);\n if (cookies) {\n /* istanbul ignore if */\n if (cookies.length > 1) {\n this.config.diagnosticsClient?.recordEvent('cookies.duplicate', {\n cookies: cookies.map((cookie) => cookie.domain),\n });\n this.config.diagnosticsClient?.increment('cookies.duplicate.occurrence.cookieStore');\n }\n\n for (const cookie of cookies) {\n if (isDomainEqual(cookie.domain, this.options.domain)) {\n return cookie.value;\n }\n }\n }\n }\n } catch (ignoreError) {\n /* istanbul ignore next */\n // if cookieStore had a surprise failure, fallback to document.cookie\n }\n\n const cookies = (globalScope?.document?.cookie.split('; ') ?? []).filter((c) => c.indexOf(key + '=') === 0);\n let match: string | undefined = undefined;\n\n // if matcher function is provided, use it to de-duplicate when there's more than one cookie\n /* istanbul ignore if */\n const duplicateResolverFn = this.config.duplicateResolverFn;\n if (typeof duplicateResolverFn === 'function' && cookies.length > 1) {\n match = cookies.find((c) => {\n try {\n const res = duplicateResolverFn(c.substring(key.length + 1));\n if (!res) {\n this.config.diagnosticsClient?.increment('cookies.duplicate.occurrence.document.cookie');\n }\n return res;\n } catch (ignoreError) {\n /* istanbul ignore next */\n return false;\n }\n });\n }\n\n // if match was not found, just get the first one that matches the key\n if (!match) {\n match = cookies[0];\n }\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n const globalScope = getGlobalScope();\n if (globalScope) {\n globalScope.document.cookie = str;\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n console.error(`Amplitude Logger [Error]: Failed to set cookie for key: ${key}. Error: ${errorMessage}`);\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n\nconst decodeCookiesAsDefault = (value: string): string | undefined => {\n try {\n return decodeURIComponent(atob(value));\n } catch {\n return undefined;\n }\n};\n\nconst decodeCookiesWithDoubleUrlEncoding = (value: string): string | undefined => {\n // Modern Ruby (v7+) automatically encodes cookies with URL encoding by\n // https://api.rubyonrails.org/classes/ActionDispatch/Cookies.html\n try {\n return decodeURIComponent(atob(decodeURIComponent(value)));\n } catch {\n return undefined;\n }\n};\n\n/**\n * Decodes a cookie value that was encoded with btoa(encodeURIComponent(...)).\n * Handles both standard encoding and double URL encoding (used by Ruby Rails v7+).\n */\nexport const decodeCookieValue = (value: string): string | undefined => {\n return decodeCookiesAsDefault(value) ?? decodeCookiesWithDoubleUrlEncoding(value);\n};\n\n/**\n * Compares two domain strings for equality, ignoring leading dots.\n * This is useful for comparing cookie domains since \".example.com\" and \"example.com\"\n * are effectively equivalent for cookie scoping.\n */\nexport const isDomainEqual = (domain1: string | undefined, domain2: string | undefined): boolean => {\n if (!domain1 || !domain2) {\n return false;\n }\n const normalized1 = domain1.startsWith('.') ? domain1.substring(1) : domain1;\n const normalized2 = domain2.startsWith('.') ? domain2.substring(1) : domain2;\n return normalized1.toLowerCase() === normalized2.toLowerCase();\n};\n"]}
@@ -1,3 +1,4 @@
1
+ import { IDiagnosticsClient } from '../diagnostics/diagnostics-client';
1
2
  export interface Storage<T> {
2
3
  isEnabled(): Promise<boolean>;
3
4
  get(key: string): Promise<T | undefined>;
@@ -12,5 +13,17 @@ export interface CookieStorageOptions {
12
13
  sameSite?: string;
13
14
  secure?: boolean;
14
15
  }
16
+ /**
17
+ * Configuration for CookieStorage behavior.
18
+ * Separated from options to keep storage-specific config distinct from cookie attributes.
19
+ */
20
+ export interface CookieStorageConfig {
21
+ /**
22
+ * Function to resolve duplicate cookies when multiple cookies with the same key exist.
23
+ * Returns true if the cookie value should be used, false otherwise.
24
+ */
25
+ duplicateResolverFn?: (value: string) => boolean;
26
+ diagnosticsClient?: IDiagnosticsClient;
27
+ }
15
28
  export type IdentityStorageType = 'cookie' | 'localStorage' | 'sessionStorage' | 'none';
16
29
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,cAAc,GAAG,gBAAgB,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,WAAW,OAAO,CAAC,CAAC;IACxB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IACzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACjD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,iBAAiB,CAAC,EAAE,kBAAkB,CAAC;CACxC;AAED,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,cAAc,GAAG,gBAAgB,GAAG,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"","sourcesContent":["export interface Storage<T> {\n isEnabled(): Promise<boolean>;\n get(key: string): Promise<T | undefined>;\n getRaw(key: string): Promise<string | undefined>;\n set(key: string, value: T): Promise<void>;\n remove(key: string): Promise<void>;\n reset(): Promise<void>;\n}\n\nexport interface CookieStorageOptions {\n domain?: string;\n expirationDays?: number;\n sameSite?: string;\n secure?: boolean;\n}\n\nexport type IdentityStorageType = 'cookie' | 'localStorage' | 'sessionStorage' | 'none';\n"]}
1
+ {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/types/storage.ts"],"names":[],"mappings":"","sourcesContent":["import { IDiagnosticsClient } from '../diagnostics/diagnostics-client';\n\nexport interface Storage<T> {\n isEnabled(): Promise<boolean>;\n get(key: string): Promise<T | undefined>;\n getRaw(key: string): Promise<string | undefined>;\n set(key: string, value: T): Promise<void>;\n remove(key: string): Promise<void>;\n reset(): Promise<void>;\n}\n\nexport interface CookieStorageOptions {\n domain?: string;\n expirationDays?: number;\n sameSite?: string;\n secure?: boolean;\n}\n\n/**\n * Configuration for CookieStorage behavior.\n * Separated from options to keep storage-specific config distinct from cookie attributes.\n */\nexport interface CookieStorageConfig {\n /**\n * Function to resolve duplicate cookies when multiple cookies with the same key exist.\n * Returns true if the cookie value should be used, false otherwise.\n */\n duplicateResolverFn?: (value: string) => boolean;\n diagnosticsClient?: IDiagnosticsClient;\n}\n\nexport type IdentityStorageType = 'cookie' | 'localStorage' | 'sessionStorage' | 'none';\n"]}
@@ -7,5 +7,6 @@ export interface UserSession {
7
7
  lastEventId?: number;
8
8
  pageCounter?: number;
9
9
  debugLogsEnabled?: boolean;
10
+ cookieDomain?: string;
10
11
  }
11
12
  //# sourceMappingURL=user-session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
1
+ {"version":3,"file":"user-session.d.ts","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"user-session.js","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"","sourcesContent":["export interface UserSession {\n userId?: string;\n deviceId?: string;\n sessionId?: number;\n lastEventTime?: number;\n optOut: boolean;\n lastEventId?: number;\n pageCounter?: number;\n debugLogsEnabled?: boolean;\n}\n"]}
1
+ {"version":3,"file":"user-session.js","sourceRoot":"","sources":["../../../src/types/user-session.ts"],"names":[],"mappings":"","sourcesContent":["export interface UserSession {\n userId?: string;\n deviceId?: string;\n sessionId?: number;\n lastEventTime?: number;\n optOut: boolean;\n lastEventId?: number;\n pageCounter?: number;\n debugLogsEnabled?: boolean;\n cookieDomain?: string;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/analytics-core",
3
- "version": "2.35.1-pnpm-migration.0",
3
+ "version": "2.35.1",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",