@amplitude/analytics-core 0.8.1 → 0.9.0

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.
@@ -1,4 +1,4 @@
1
- import { Event, Config as IConfig, Logger as ILogger, InitOptions, LogLevel, Storage, Transport, Plan, ServerZone } from '@amplitude/analytics-types';
1
+ import { Event, Config as IConfig, Logger as ILogger, InitOptions, LogLevel, Storage, Transport, Plan, IngestionMetadata, ServerZone } from '@amplitude/analytics-types';
2
2
  import { Logger } from './logger';
3
3
  export declare const getDefaultConfig: () => {
4
4
  flushMaxRetries: number;
@@ -20,6 +20,7 @@ export declare class Config implements IConfig {
20
20
  logLevel: LogLevel;
21
21
  minIdLength?: number;
22
22
  plan?: Plan;
23
+ ingestionMetadata?: IngestionMetadata;
23
24
  serverUrl: string | undefined;
24
25
  serverZone?: ServerZone;
25
26
  transportProvider: Transport;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,UAAU,EACX,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;;;CAU3B,CAAC;AAEH,qBAAa,MAAO,YAAW,OAAO;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,SAAS,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BAAiB,EAAE,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,OAAO,CAAS;IACxB,IAAI,MAAM,IAGS,OAAO,CADzB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAEzB;gBAEW,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;CAuB1C;AAED,eAAO,MAAM,YAAY,eAAgB,UAAU,YAAY,OAAO,kKAKrE,CAAC;AAEF,eAAO,MAAM,kBAAkB,oCAEjB,UAAU,aACZ,OAAO;;;;;;CAUlB,CAAC"}
package/lib/cjs/config.js CHANGED
@@ -28,6 +28,7 @@ var Config = /** @class */ (function () {
28
28
  this.logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : defaultConfig.logLevel;
29
29
  this.minIdLength = options.minIdLength;
30
30
  this.plan = options.plan;
31
+ this.ingestionMetadata = options.ingestionMetadata;
31
32
  this.optOut = (_b = options.optOut) !== null && _b !== void 0 ? _b : defaultConfig.optOut;
32
33
  this.serverUrl = options.serverUrl;
33
34
  this.serverZone = options.serverZone || defaultConfig.serverZone;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;AAAA,8DAUoC;AACpC,yCAKqB;AAErB,mCAAkC;AAE3B,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,KAAK;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,eAAM,EAAE;IAC5B,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,gCAAoB;IAC/B,UAAU,EAAE,4BAAU,CAAC,EAAE;IACzB,QAAQ,EAAE,KAAK;CAChB,CAAC,EAVoC,CAUpC,CAAC;AAVU,QAAA,gBAAgB,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QACL,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,IAAA,oBAAY,EAAC,WAAW,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B","sourcesContent":["import {\n Event,\n Config as IConfig,\n Logger as ILogger,\n InitOptions,\n LogLevel,\n Storage,\n Transport,\n Plan,\n ServerZone,\n} from '@amplitude/analytics-types';\nimport {\n AMPLITUDE_SERVER_URL,\n AMPLITUDE_BATCH_SERVER_URL,\n EU_AMPLITUDE_SERVER_URL,\n EU_AMPLITUDE_BATCH_SERVER_URL,\n} from './constants';\n\nimport { Logger } from './logger';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 12,\n flushQueueSize: 200,\n flushIntervalMillis: 10000,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n optOut: false,\n serverUrl: AMPLITUDE_SERVER_URL,\n serverZone: ServerZone.US,\n useBatch: false,\n});\n\nexport class Config implements IConfig {\n apiKey: string;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n loggerProvider: ILogger;\n logLevel: LogLevel;\n minIdLength?: number;\n plan?: Plan;\n serverUrl: string | undefined;\n serverZone?: ServerZone;\n transportProvider: Transport;\n storageProvider?: Storage<Event[]>;\n useBatch: boolean;\n\n private _optOut = false;\n get optOut() {\n return this._optOut;\n }\n set optOut(optOut: boolean) {\n this._optOut = optOut;\n }\n\n constructor(options: InitOptions<IConfig>) {\n const defaultConfig = getDefaultConfig();\n this.apiKey = options.apiKey;\n this.flushIntervalMillis = options.flushIntervalMillis || defaultConfig.flushIntervalMillis;\n this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;\n this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;\n this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;\n this.logLevel = options.logLevel ?? defaultConfig.logLevel;\n this.minIdLength = options.minIdLength;\n this.plan = options.plan;\n this.optOut = options.optOut ?? defaultConfig.optOut;\n this.serverUrl = options.serverUrl;\n this.serverZone = options.serverZone || defaultConfig.serverZone;\n this.storageProvider = options.storageProvider;\n this.transportProvider = options.transportProvider;\n this.useBatch = options.useBatch ?? defaultConfig.useBatch;\n this.loggerProvider.enable(this.logLevel);\n\n const serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);\n this.serverZone = serverConfig.serverZone;\n this.serverUrl = serverConfig.serverUrl;\n }\n}\n\nexport const getServerUrl = (serverZone: ServerZone, useBatch: boolean) => {\n if (serverZone === ServerZone.EU) {\n return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;\n }\n return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;\n};\n\nexport const createServerConfig = (\n serverUrl = '',\n serverZone: ServerZone = getDefaultConfig().serverZone,\n useBatch: boolean = getDefaultConfig().useBatch,\n) => {\n if (serverUrl) {\n return { serverUrl, serverZone: undefined };\n }\n const _serverZone = [ServerZone.US, ServerZone.EU].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;\n return {\n serverZone: _serverZone,\n serverUrl: getServerUrl(_serverZone, useBatch),\n };\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;AAAA,8DAWoC;AACpC,yCAKqB;AAErB,mCAAkC;AAE3B,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,KAAK;IAC1B,QAAQ,EAAE,0BAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,eAAM,EAAE;IAC5B,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,gCAAoB;IAC/B,UAAU,EAAE,4BAAU,CAAC,EAAE;IACzB,QAAQ,EAAE,KAAK;CAChB,CAAC,EAVoC,CAUpC,CAAC;AAVU,QAAA,gBAAgB,oBAU1B;AA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AA,wBAAgB,GAAE,CAAC,UAAU,CAAC;IACrH,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,IAAA,oBAAY,EAAC,WAAW,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,kBAAkB,sBAa7B","sourcesContent":["import {\n Event,\n Config as IConfig,\n Logger as ILogger,\n InitOptions,\n LogLevel,\n Storage,\n Transport,\n Plan,\n IngestionMetadata,\n ServerZone,\n} from '@amplitude/analytics-types';\nimport {\n AMPLITUDE_SERVER_URL,\n AMPLITUDE_BATCH_SERVER_URL,\n EU_AMPLITUDE_SERVER_URL,\n EU_AMPLITUDE_BATCH_SERVER_URL,\n} from './constants';\n\nimport { Logger } from './logger';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 12,\n flushQueueSize: 200,\n flushIntervalMillis: 10000,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n optOut: false,\n serverUrl: AMPLITUDE_SERVER_URL,\n serverZone: ServerZone.US,\n useBatch: false,\n});\n\nexport class Config implements IConfig {\n apiKey: string;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n loggerProvider: ILogger;\n logLevel: LogLevel;\n minIdLength?: number;\n plan?: Plan;\n ingestionMetadata?: IngestionMetadata;\n serverUrl: string | undefined;\n serverZone?: ServerZone;\n transportProvider: Transport;\n storageProvider?: Storage<Event[]>;\n useBatch: boolean;\n\n private _optOut = false;\n get optOut() {\n return this._optOut;\n }\n set optOut(optOut: boolean) {\n this._optOut = optOut;\n }\n\n constructor(options: InitOptions<IConfig>) {\n const defaultConfig = getDefaultConfig();\n this.apiKey = options.apiKey;\n this.flushIntervalMillis = options.flushIntervalMillis || defaultConfig.flushIntervalMillis;\n this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;\n this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;\n this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;\n this.logLevel = options.logLevel ?? defaultConfig.logLevel;\n this.minIdLength = options.minIdLength;\n this.plan = options.plan;\n this.ingestionMetadata = options.ingestionMetadata;\n this.optOut = options.optOut ?? defaultConfig.optOut;\n this.serverUrl = options.serverUrl;\n this.serverZone = options.serverZone || defaultConfig.serverZone;\n this.storageProvider = options.storageProvider;\n this.transportProvider = options.transportProvider;\n this.useBatch = options.useBatch ?? defaultConfig.useBatch;\n this.loggerProvider.enable(this.logLevel);\n\n const serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);\n this.serverZone = serverConfig.serverZone;\n this.serverUrl = serverConfig.serverUrl;\n }\n}\n\nexport const getServerUrl = (serverZone: ServerZone, useBatch: boolean) => {\n if (serverZone === ServerZone.EU) {\n return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;\n }\n return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;\n};\n\nexport const createServerConfig = (\n serverUrl = '',\n serverZone: ServerZone = getDefaultConfig().serverZone,\n useBatch: boolean = getDefaultConfig().useBatch,\n) => {\n if (serverUrl) {\n return { serverUrl, serverZone: undefined };\n }\n const _serverZone = [ServerZone.US, ServerZone.EU].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;\n return {\n serverZone: _serverZone,\n serverUrl: getServerUrl(_serverZone, useBatch),\n };\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { Event, Config as IConfig, Logger as ILogger, InitOptions, LogLevel, Storage, Transport, Plan, ServerZone } from '@amplitude/analytics-types';
1
+ import { Event, Config as IConfig, Logger as ILogger, InitOptions, LogLevel, Storage, Transport, Plan, IngestionMetadata, ServerZone } from '@amplitude/analytics-types';
2
2
  import { Logger } from './logger';
3
3
  export declare const getDefaultConfig: () => {
4
4
  flushMaxRetries: number;
@@ -20,6 +20,7 @@ export declare class Config implements IConfig {
20
20
  logLevel: LogLevel;
21
21
  minIdLength?: number;
22
22
  plan?: Plan;
23
+ ingestionMetadata?: IngestionMetadata;
23
24
  serverUrl: string | undefined;
24
25
  serverZone?: ServerZone;
25
26
  transportProvider: Transport;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,UAAU,EACX,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;;;CAU3B,CAAC;AAEH,qBAAa,MAAO,YAAW,OAAO;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,OAAO,CAAS;IACxB,IAAI,MAAM,IAGS,OAAO,CADzB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAEzB;gBAEW,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;CAsB1C;AAED,eAAO,MAAM,YAAY,eAAgB,UAAU,YAAY,OAAO,kKAKrE,CAAC;AAEF,eAAO,MAAM,kBAAkB,oCAEjB,UAAU,aACZ,OAAO;;;;;;CAUlB,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,IAAI,OAAO,EACjB,MAAM,IAAI,OAAO,EACjB,WAAW,EACX,QAAQ,EACR,OAAO,EACP,SAAS,EACT,IAAI,EACJ,iBAAiB,EACjB,UAAU,EACX,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;;;CAU3B,CAAC;AAEH,qBAAa,MAAO,YAAW,OAAO;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAElB,OAAO,CAAC,OAAO,CAAS;IACxB,IAAI,MAAM,IAGS,OAAO,CADzB;IACD,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,EAEzB;gBAEW,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC;CAuB1C;AAED,eAAO,MAAM,YAAY,eAAgB,UAAU,YAAY,OAAO,kKAKrE,CAAC;AAEF,eAAO,MAAM,kBAAkB,oCAEjB,UAAU,aACZ,OAAO;;;;;;CAUlB,CAAC"}
package/lib/esm/config.js CHANGED
@@ -25,6 +25,7 @@ var Config = /** @class */ (function () {
25
25
  this.logLevel = (_a = options.logLevel) !== null && _a !== void 0 ? _a : defaultConfig.logLevel;
26
26
  this.minIdLength = options.minIdLength;
27
27
  this.plan = options.plan;
28
+ this.ingestionMetadata = options.ingestionMetadata;
28
29
  this.optOut = (_b = options.optOut) !== null && _b !== void 0 ? _b : defaultConfig.optOut;
29
30
  this.serverUrl = options.serverUrl;
30
31
  this.serverZone = options.serverZone || defaultConfig.serverZone;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EAIR,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,KAAK;IAC1B,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,MAAM,EAAE;IAC5B,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,oBAAoB;IAC/B,UAAU,EAAE,UAAU,CAAC,EAAE;IACzB,QAAQ,EAAE,KAAK;CAChB,CAAC,EAVoC,CAUpC,CAAC;AAEH;IAuBE,gBAAY,OAA6B;;QARjC,YAAO,GAAG,KAAK,CAAC;QAStB,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,aAAa,CAAC,mBAAmB,CAAC;QAC5F,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,aAAa,CAAC,eAAe,CAAC;QAChF,IAA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;OAHA;IA2BH,aAAC;AAAD,CAAC,AA7CD,IA6CC;;AAED,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,UAAsB,EAAE,QAAiB;IACpE,IAAI,UAAU,KAAK,UAAU,CAAC,EAAE,EAAE;QAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,uBAAuB,CAAC;KAC3E;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAChC,SAAc,EACd,UAAsD,EACtD,QAA+C;IAF/C,0BAAA,EAAA,cAAc;IACd,2BAAA,EAAA,aAAyB,gBAAgB,EAAE,CAAC,UAAU;IACtD,yBAAA,EAAA,WAAoB,gBAAgB,EAAE,CAAC,QAAQ;IAE/C,IAAI,SAAS,EAAE;QACb,OAAO,EAAE,SAAS,WAAA,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;KAC7C;IACD,IAAM,WAAW,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC;IACrH,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n Event,\n Config as IConfig,\n Logger as ILogger,\n InitOptions,\n LogLevel,\n Storage,\n Transport,\n Plan,\n ServerZone,\n} from '@amplitude/analytics-types';\nimport {\n AMPLITUDE_SERVER_URL,\n AMPLITUDE_BATCH_SERVER_URL,\n EU_AMPLITUDE_SERVER_URL,\n EU_AMPLITUDE_BATCH_SERVER_URL,\n} from './constants';\n\nimport { Logger } from './logger';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 12,\n flushQueueSize: 200,\n flushIntervalMillis: 10000,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n optOut: false,\n serverUrl: AMPLITUDE_SERVER_URL,\n serverZone: ServerZone.US,\n useBatch: false,\n});\n\nexport class Config implements IConfig {\n apiKey: string;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n loggerProvider: ILogger;\n logLevel: LogLevel;\n minIdLength?: number;\n plan?: Plan;\n serverUrl: string | undefined;\n serverZone?: ServerZone;\n transportProvider: Transport;\n storageProvider?: Storage<Event[]>;\n useBatch: boolean;\n\n private _optOut = false;\n get optOut() {\n return this._optOut;\n }\n set optOut(optOut: boolean) {\n this._optOut = optOut;\n }\n\n constructor(options: InitOptions<IConfig>) {\n const defaultConfig = getDefaultConfig();\n this.apiKey = options.apiKey;\n this.flushIntervalMillis = options.flushIntervalMillis || defaultConfig.flushIntervalMillis;\n this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;\n this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;\n this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;\n this.logLevel = options.logLevel ?? defaultConfig.logLevel;\n this.minIdLength = options.minIdLength;\n this.plan = options.plan;\n this.optOut = options.optOut ?? defaultConfig.optOut;\n this.serverUrl = options.serverUrl;\n this.serverZone = options.serverZone || defaultConfig.serverZone;\n this.storageProvider = options.storageProvider;\n this.transportProvider = options.transportProvider;\n this.useBatch = options.useBatch ?? defaultConfig.useBatch;\n this.loggerProvider.enable(this.logLevel);\n\n const serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);\n this.serverZone = serverConfig.serverZone;\n this.serverUrl = serverConfig.serverUrl;\n }\n}\n\nexport const getServerUrl = (serverZone: ServerZone, useBatch: boolean) => {\n if (serverZone === ServerZone.EU) {\n return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;\n }\n return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;\n};\n\nexport const createServerConfig = (\n serverUrl = '',\n serverZone: ServerZone = getDefaultConfig().serverZone,\n useBatch: boolean = getDefaultConfig().useBatch,\n) => {\n if (serverUrl) {\n return { serverUrl, serverZone: undefined };\n }\n const _serverZone = [ServerZone.US, ServerZone.EU].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;\n return {\n serverZone: _serverZone,\n serverUrl: getServerUrl(_serverZone, useBatch),\n };\n};\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,QAAQ,EAKR,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,uBAAuB,EACvB,6BAA6B,GAC9B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,IAAM,gBAAgB,GAAG,cAAM,OAAA,CAAC;IACrC,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,KAAK;IAC1B,QAAQ,EAAE,QAAQ,CAAC,IAAI;IACvB,cAAc,EAAE,IAAI,MAAM,EAAE;IAC5B,MAAM,EAAE,KAAK;IACb,SAAS,EAAE,oBAAoB;IAC/B,UAAU,EAAE,UAAU,CAAC,EAAE;IACzB,QAAQ,EAAE,KAAK;CAChB,CAAC,EAVoC,CAUpC,CAAC;AAEH;IAwBE,gBAAY,OAA6B;;QARjC,YAAO,GAAG,KAAK,CAAC;QAStB,IAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,aAAa,CAAC,mBAAmB,CAAC;QAC5F,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAA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AAC,OAAO,CAAC;QACtB,CAAC;aACD,UAAW,MAAe;YACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC;;;OAHA;IA4BH,aAAC;AAAD,CAAC,AA/CD,IA+CC;;AAED,MAAM,CAAC,IAAM,YAAY,GAAG,UAAC,UAAsB,EAAE,QAAiB;IACpE,IAAI,UAAU,KAAK,UAAU,CAAC,EAAE,EAAE;QAChC,OAAO,QAAQ,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,uBAAuB,CAAC;KAC3E;IACD,OAAO,QAAQ,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,oBAAoB,CAAC;AACtE,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAChC,SAAc,EACd,UAAsD,EACtD,QAA+C;IAF/C,0BAAA,EAAA,cAAc;IACd,2BAAA,EAAA,aAAyB,gBAAgB,EAAE,CAAC,UAAU;IACtD,yBAAA,EAAA,WAAoB,gBAAgB,EAAE,CAAC,QAAQ;IAE/C,IAAI,SAAS,EAAE;QACb,OAAO,EAAE,SAAS,WAAA,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;KAC7C;IACD,IAAM,WAAW,GAAG,CAAC,UAAU,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,UAAU,CAAC;IACrH,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,SAAS,EAAE,YAAY,CAAC,WAAW,EAAE,QAAQ,CAAC;KAC/C,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {\n Event,\n Config as IConfig,\n Logger as ILogger,\n InitOptions,\n LogLevel,\n Storage,\n Transport,\n Plan,\n IngestionMetadata,\n ServerZone,\n} from '@amplitude/analytics-types';\nimport {\n AMPLITUDE_SERVER_URL,\n AMPLITUDE_BATCH_SERVER_URL,\n EU_AMPLITUDE_SERVER_URL,\n EU_AMPLITUDE_BATCH_SERVER_URL,\n} from './constants';\n\nimport { Logger } from './logger';\n\nexport const getDefaultConfig = () => ({\n flushMaxRetries: 12,\n flushQueueSize: 200,\n flushIntervalMillis: 10000,\n logLevel: LogLevel.Warn,\n loggerProvider: new Logger(),\n optOut: false,\n serverUrl: AMPLITUDE_SERVER_URL,\n serverZone: ServerZone.US,\n useBatch: false,\n});\n\nexport class Config implements IConfig {\n apiKey: string;\n flushIntervalMillis: number;\n flushMaxRetries: number;\n flushQueueSize: number;\n loggerProvider: ILogger;\n logLevel: LogLevel;\n minIdLength?: number;\n plan?: Plan;\n ingestionMetadata?: IngestionMetadata;\n serverUrl: string | undefined;\n serverZone?: ServerZone;\n transportProvider: Transport;\n storageProvider?: Storage<Event[]>;\n useBatch: boolean;\n\n private _optOut = false;\n get optOut() {\n return this._optOut;\n }\n set optOut(optOut: boolean) {\n this._optOut = optOut;\n }\n\n constructor(options: InitOptions<IConfig>) {\n const defaultConfig = getDefaultConfig();\n this.apiKey = options.apiKey;\n this.flushIntervalMillis = options.flushIntervalMillis || defaultConfig.flushIntervalMillis;\n this.flushMaxRetries = options.flushMaxRetries || defaultConfig.flushMaxRetries;\n this.flushQueueSize = options.flushQueueSize || defaultConfig.flushQueueSize;\n this.loggerProvider = options.loggerProvider || defaultConfig.loggerProvider;\n this.logLevel = options.logLevel ?? defaultConfig.logLevel;\n this.minIdLength = options.minIdLength;\n this.plan = options.plan;\n this.ingestionMetadata = options.ingestionMetadata;\n this.optOut = options.optOut ?? defaultConfig.optOut;\n this.serverUrl = options.serverUrl;\n this.serverZone = options.serverZone || defaultConfig.serverZone;\n this.storageProvider = options.storageProvider;\n this.transportProvider = options.transportProvider;\n this.useBatch = options.useBatch ?? defaultConfig.useBatch;\n this.loggerProvider.enable(this.logLevel);\n\n const serverConfig = createServerConfig(options.serverUrl, options.serverZone, options.useBatch);\n this.serverZone = serverConfig.serverZone;\n this.serverUrl = serverConfig.serverUrl;\n }\n}\n\nexport const getServerUrl = (serverZone: ServerZone, useBatch: boolean) => {\n if (serverZone === ServerZone.EU) {\n return useBatch ? EU_AMPLITUDE_BATCH_SERVER_URL : EU_AMPLITUDE_SERVER_URL;\n }\n return useBatch ? AMPLITUDE_BATCH_SERVER_URL : AMPLITUDE_SERVER_URL;\n};\n\nexport const createServerConfig = (\n serverUrl = '',\n serverZone: ServerZone = getDefaultConfig().serverZone,\n useBatch: boolean = getDefaultConfig().useBatch,\n) => {\n if (serverUrl) {\n return { serverUrl, serverZone: undefined };\n }\n const _serverZone = [ServerZone.US, ServerZone.EU].includes(serverZone) ? serverZone : getDefaultConfig().serverZone;\n return {\n serverZone: _serverZone,\n serverUrl: getServerUrl(_serverZone, useBatch),\n };\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/analytics-core",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "description": "",
5
5
  "author": "Amplitude Inc",
6
6
  "homepage": "https://github.com/amplitude/Amplitude-TypeScript",
@@ -33,11 +33,11 @@
33
33
  "url": "https://github.com/amplitude/Amplitude-TypeScript/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@amplitude/analytics-types": "^0.8.1",
36
+ "@amplitude/analytics-types": "^0.9.0",
37
37
  "tslib": "^2.3.1"
38
38
  },
39
39
  "files": [
40
40
  "lib"
41
41
  ],
42
- "gitHead": "404f81a1cdcf1cce9bd35d04561016a65dab635a"
42
+ "gitHead": "b05595653967707fa6db014030f071ff5eca6e82"
43
43
  }