@amplitude/analytics-core 0.1.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.
- package/README.md +1 -0
- package/lib/cjs/__mocks__/logger.d.ts +8 -0
- package/lib/cjs/__mocks__/logger.d.ts.map +1 -0
- package/lib/cjs/__mocks__/logger.js +24 -0
- package/lib/cjs/__mocks__/logger.js.map +1 -0
- package/lib/cjs/config.d.ts +44 -0
- package/lib/cjs/config.d.ts.map +1 -0
- package/lib/cjs/config.js +86 -0
- package/lib/cjs/config.js.map +1 -0
- package/lib/cjs/constants.d.ts +8 -0
- package/lib/cjs/constants.d.ts.map +1 -0
- package/lib/cjs/constants.js +10 -0
- package/lib/cjs/constants.js.map +1 -0
- package/lib/cjs/core-client.d.ts +13 -0
- package/lib/cjs/core-client.d.ts.map +1 -0
- package/lib/cjs/core-client.js +91 -0
- package/lib/cjs/core-client.js.map +1 -0
- package/lib/cjs/identify.d.ts +19 -0
- package/lib/cjs/identify.d.ts.map +1 -0
- package/lib/cjs/identify.js +94 -0
- package/lib/cjs/identify.js.map +1 -0
- package/lib/cjs/index.d.ts +10 -0
- package/lib/cjs/index.d.ts.map +1 -0
- package/lib/cjs/index.js +30 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/logger.d.ts +11 -0
- package/lib/cjs/logger.d.ts.map +1 -0
- package/lib/cjs/logger.js +49 -0
- package/lib/cjs/logger.js.map +1 -0
- package/lib/cjs/messages.d.ts +6 -0
- package/lib/cjs/messages.d.ts.map +1 -0
- package/lib/cjs/messages.js +8 -0
- package/lib/cjs/messages.js.map +1 -0
- package/lib/cjs/plugins/destination.d.ts +29 -0
- package/lib/cjs/plugins/destination.d.ts.map +1 -0
- package/lib/cjs/plugins/destination.js +245 -0
- package/lib/cjs/plugins/destination.js.map +1 -0
- package/lib/cjs/revenue.d.ts +20 -0
- package/lib/cjs/revenue.d.ts.map +1 -0
- package/lib/cjs/revenue.js +52 -0
- package/lib/cjs/revenue.js.map +1 -0
- package/lib/cjs/timeline.d.ts +8 -0
- package/lib/cjs/timeline.d.ts.map +1 -0
- package/lib/cjs/timeline.js +134 -0
- package/lib/cjs/timeline.js.map +1 -0
- package/lib/cjs/transports/http.d.ts +5 -0
- package/lib/cjs/transports/http.d.ts.map +1 -0
- package/lib/cjs/transports/http.js +51 -0
- package/lib/cjs/transports/http.js.map +1 -0
- package/lib/cjs/utils/chunk.d.ts +2 -0
- package/lib/cjs/utils/chunk.d.ts.map +1 -0
- package/lib/cjs/utils/chunk.js +18 -0
- package/lib/cjs/utils/chunk.js.map +1 -0
- package/lib/cjs/utils/event-builder.d.ts +7 -0
- package/lib/cjs/utils/event-builder.d.ts.map +1 -0
- package/lib/cjs/utils/event-builder.js +47 -0
- package/lib/cjs/utils/event-builder.js.map +1 -0
- package/lib/cjs/utils/response-builder.d.ts +3 -0
- package/lib/cjs/utils/response-builder.d.ts.map +1 -0
- package/lib/cjs/utils/response-builder.js +74 -0
- package/lib/cjs/utils/response-builder.js.map +1 -0
- package/lib/cjs/utils/result-builder.d.ts +3 -0
- package/lib/cjs/utils/result-builder.d.ts.map +1 -0
- package/lib/cjs/utils/result-builder.js +10 -0
- package/lib/cjs/utils/result-builder.js.map +1 -0
- package/lib/cjs/utils/status-builder.d.ts +3 -0
- package/lib/cjs/utils/status-builder.d.ts.map +1 -0
- package/lib/cjs/utils/status-builder.js +26 -0
- package/lib/cjs/utils/status-builder.js.map +1 -0
- package/lib/cjs/utils/valid-properties.d.ts +5 -0
- package/lib/cjs/utils/valid-properties.d.ts.map +1 -0
- package/lib/cjs/utils/valid-properties.js +55 -0
- package/lib/cjs/utils/valid-properties.js.map +1 -0
- package/lib/esm/__mocks__/logger.d.ts +8 -0
- package/lib/esm/__mocks__/logger.d.ts.map +1 -0
- package/lib/esm/__mocks__/logger.js +22 -0
- package/lib/esm/__mocks__/logger.js.map +1 -0
- package/lib/esm/config.d.ts +44 -0
- package/lib/esm/config.d.ts.map +1 -0
- package/lib/esm/config.js +80 -0
- package/lib/esm/config.js.map +1 -0
- package/lib/esm/constants.d.ts +8 -0
- package/lib/esm/constants.d.ts.map +1 -0
- package/lib/esm/constants.js +8 -0
- package/lib/esm/constants.js.map +1 -0
- package/lib/esm/core-client.d.ts +13 -0
- package/lib/esm/core-client.d.ts.map +1 -0
- package/lib/esm/core-client.js +78 -0
- package/lib/esm/core-client.js.map +1 -0
- package/lib/esm/identify.d.ts +19 -0
- package/lib/esm/identify.d.ts.map +1 -0
- package/lib/esm/identify.js +92 -0
- package/lib/esm/identify.js.map +1 -0
- package/lib/esm/index.d.ts +10 -0
- package/lib/esm/index.d.ts.map +1 -0
- package/lib/esm/index.js +10 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/logger.d.ts +11 -0
- package/lib/esm/logger.d.ts.map +1 -0
- package/lib/esm/logger.js +47 -0
- package/lib/esm/logger.js.map +1 -0
- package/lib/esm/messages.d.ts +6 -0
- package/lib/esm/messages.d.ts.map +1 -0
- package/lib/esm/messages.js +6 -0
- package/lib/esm/messages.js.map +1 -0
- package/lib/esm/plugins/destination.d.ts +29 -0
- package/lib/esm/plugins/destination.d.ts.map +1 -0
- package/lib/esm/plugins/destination.js +243 -0
- package/lib/esm/plugins/destination.js.map +1 -0
- package/lib/esm/revenue.d.ts +20 -0
- package/lib/esm/revenue.d.ts.map +1 -0
- package/lib/esm/revenue.js +50 -0
- package/lib/esm/revenue.js.map +1 -0
- package/lib/esm/timeline.d.ts +8 -0
- package/lib/esm/timeline.d.ts.map +1 -0
- package/lib/esm/timeline.js +126 -0
- package/lib/esm/timeline.js.map +1 -0
- package/lib/esm/transports/http.d.ts +5 -0
- package/lib/esm/transports/http.d.ts.map +1 -0
- package/lib/esm/transports/http.js +49 -0
- package/lib/esm/transports/http.js.map +1 -0
- package/lib/esm/utils/chunk.d.ts +2 -0
- package/lib/esm/utils/chunk.d.ts.map +1 -0
- package/lib/esm/utils/chunk.js +15 -0
- package/lib/esm/utils/chunk.js.map +1 -0
- package/lib/esm/utils/event-builder.d.ts +7 -0
- package/lib/esm/utils/event-builder.d.ts.map +1 -0
- package/lib/esm/utils/event-builder.js +40 -0
- package/lib/esm/utils/event-builder.js.map +1 -0
- package/lib/esm/utils/response-builder.d.ts +3 -0
- package/lib/esm/utils/response-builder.d.ts.map +1 -0
- package/lib/esm/utils/response-builder.js +71 -0
- package/lib/esm/utils/response-builder.js.map +1 -0
- package/lib/esm/utils/result-builder.d.ts +3 -0
- package/lib/esm/utils/result-builder.d.ts.map +1 -0
- package/lib/esm/utils/result-builder.js +7 -0
- package/lib/esm/utils/result-builder.js.map +1 -0
- package/lib/esm/utils/status-builder.d.ts +3 -0
- package/lib/esm/utils/status-builder.d.ts.map +1 -0
- package/lib/esm/utils/status-builder.js +23 -0
- package/lib/esm/utils/status-builder.js.map +1 -0
- package/lib/esm/utils/valid-properties.d.ts +5 -0
- package/lib/esm/utils/valid-properties.d.ts.map +1 -0
- package/lib/esm/utils/valid-properties.js +51 -0
- package/lib/esm/utils/valid-properties.js.map +1 -0
- package/package.json +41 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"destination.js","sourceRoot":"","sources":["../../../src/plugins/destination.ts"],"names":[],"mappings":";AAAA,OAAO,EAOL,UAAU,EAIV,MAAM,GAEP,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC;IAAA;QACE,SAAI,GAAG,WAAW,CAAC;QACnB,SAAI,GAAG,UAAU,CAAC,WAAoB,CAAC;QAEvC,YAAO,GAAG,IAAI,CAAC;QACf,aAAQ,GA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;QACvC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC3D,CAAC;IACH,kBAAC;AAAD,CAAC,AA5ND,IA4NC","sourcesContent":["import {\n Config,\n DestinationContext as Context,\n DestinationPlugin,\n Event,\n InvalidResponse,\n PayloadTooLargeResponse,\n PluginType,\n RateLimitResponse,\n Response,\n Result,\n Status,\n SuccessResponse,\n} from '@amplitude/analytics-types';\nimport { MISSING_API_KEY_MESSAGE, SUCCESS_MESSAGE, UNEXPECTED_ERROR_MESSAGE } from '../messages';\nimport { STORAGE_PREFIX } from '../constants';\nimport { chunk } from '../utils/chunk';\nimport { buildResult } from '../utils/result-builder';\nimport { getApiHost } from '../config';\n\nexport class Destination implements DestinationPlugin {\n name = 'amplitude';\n type = PluginType.DESTINATION as const;\n\n backoff = 1000;\n throttle = 30000;\n storageKey = '';\n backup: Set<Event> = new Set();\n // this.config is defined in setup() which will always be called first\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n config: Config;\n scheduled = false;\n queue: Context[] = [];\n\n setup(config: Config) {\n this.config = config;\n\n this.storageKey = `${STORAGE_PREFIX}_${this.config.apiKey.substring(0, 10)}`;\n const unsent = this.config.storageProvider.get(this.storageKey);\n this.snapshot(); // sets storage to '[]'\n if (unsent && unsent.length > 0) {\n void Promise.all(unsent.map((event) => this.execute(event))).catch();\n }\n\n return Promise.resolve(undefined);\n }\n\n execute(event: Event): Promise<Result> {\n return new Promise((resolve) => {\n const context = {\n event,\n attempts: 0,\n callback: (result: Result) => resolve(result),\n delay: 0,\n };\n this.addToQueue(context);\n });\n }\n\n addToQueue(...list: Context[]) {\n const tryable = list.filter((context) => {\n if (context.attempts < this.config.flushMaxRetries) {\n return true;\n }\n this.fulfillRequest([context], 500, Status.Unknown);\n return false;\n });\n\n this.addToBackup(...tryable.map((context) => context.event));\n tryable.forEach((context) => {\n context.attempts += 1;\n const delay = context.delay;\n context.delay = 0;\n if (context.attempts === 1 && !context.delay) {\n this.queue = this.queue.concat(context);\n this.schedule(this.config.flushIntervalMillis);\n return;\n }\n setTimeout(() => {\n this.queue = this.queue.concat(context);\n this.schedule(this.config.flushIntervalMillis);\n }, delay || context.attempts * this.backoff);\n });\n }\n\n schedule(timeout: number) {\n if (this.scheduled) return;\n this.scheduled = true;\n setTimeout(() => {\n void this.flush().then(() => {\n this.scheduled = false;\n if (this.queue.length > 0) {\n this.schedule(timeout);\n }\n });\n }, timeout);\n }\n\n async flush() {\n const list = this.queue;\n this.queue = [];\n const batches = chunk(list, this.config.flushQueueSize);\n await Promise.all(batches.map((batch) => this.send(batch)));\n }\n\n async send(list: Context[]) {\n if (!this.config.apiKey) {\n return this.fulfillRequest(list, 400, MISSING_API_KEY_MESSAGE);\n }\n\n const payload = {\n api_key: this.config.apiKey,\n events: list.map((context) => context.event),\n };\n\n try {\n const res = await this.config.transportProvider.send(getApiHost(this.config), payload);\n if (res === null) {\n this.fulfillRequest(list, 0, UNEXPECTED_ERROR_MESSAGE);\n return;\n }\n this.handleReponse(res, list);\n } catch (e) {\n this.fulfillRequest(list, 0, String(e));\n }\n }\n\n handleReponse(res: Response, list: Context[]) {\n const { status } = res;\n switch (status) {\n case Status.Success:\n this.handleSuccessResponse(res, list);\n break;\n\n case Status.Invalid:\n this.handleInvalidResponse(res, list);\n break;\n\n case Status.PayloadTooLarge:\n this.handlePayloadTooLargeResponse(res, list);\n break;\n\n case Status.RateLimit:\n this.handleRateLimitResponse(res, list);\n break;\n\n default:\n this.handleOtherReponse(list);\n }\n }\n\n handleSuccessResponse(res: SuccessResponse, list: Context[]) {\n this.fulfillRequest(list, res.statusCode, SUCCESS_MESSAGE);\n }\n\n handleInvalidResponse(res: InvalidResponse, list: Context[]) {\n if (res.body.missingField) {\n this.fulfillRequest(list, res.statusCode, res.body.error);\n return;\n }\n\n const dropIndex = [\n ...Object.values(res.body.eventsWithInvalidFields),\n ...Object.values(res.body.eventsWithMissingFields),\n ...res.body.silencedEvents,\n ].flat();\n const dropIndexSet = new Set(dropIndex);\n\n const retry = list.filter((context, index) => {\n if (dropIndexSet.has(index)) {\n this.fulfillRequest([context], res.statusCode, res.status);\n return;\n }\n return true;\n });\n\n this.addToQueue(...retry);\n }\n\n handlePayloadTooLargeResponse(res: PayloadTooLargeResponse, list: Context[]) {\n if (list.length === 1) {\n this.fulfillRequest(list, res.statusCode, res.body.error);\n return;\n }\n this.config.flushQueueSize /= 2;\n this.addToQueue(...list);\n }\n\n handleRateLimitResponse(res: RateLimitResponse, list: Context[]) {\n const dropUserIds = Object.keys(res.body.exceededDailyQuotaUsers);\n const dropDeviceIds = Object.keys(res.body.exceededDailyQuotaDevices);\n const throttledIndex = res.body.throttledEvents;\n const dropUserIdsSet = new Set(dropUserIds);\n const dropDeviceIdsSet = new Set(dropDeviceIds);\n const throttledIndexSet = new Set(throttledIndex);\n\n const retry = list.filter((context, index) => {\n if (\n (context.event.user_id && dropUserIdsSet.has(context.event.user_id)) ||\n (context.event.device_id && dropDeviceIdsSet.has(context.event.device_id))\n ) {\n this.fulfillRequest([context], res.statusCode, res.status);\n return;\n }\n if (throttledIndexSet.has(index)) {\n context.delay = this.throttle;\n }\n return true;\n });\n\n this.addToQueue(...retry);\n }\n\n handleOtherReponse(list: Context[]) {\n this.addToQueue(...list);\n }\n\n fulfillRequest(list: Context[], code: number, message: string) {\n this.removeFromBackup(...list.map((context) => context.event));\n list.forEach((context) => context.callback(buildResult(context.event, code, message)));\n }\n\n addToBackup(...events: Event[]) {\n if (!this.config.saveEvents) return;\n events.forEach((event) => this.backup.add(event));\n this.snapshot();\n }\n\n removeFromBackup(...events: Event[]) {\n if (!this.config.saveEvents) return;\n events.forEach((event) => this.backup.delete(event));\n this.snapshot();\n }\n\n snapshot() {\n if (!this.config.saveEvents) return;\n const events = Array.from(this.backup);\n this.config.storageProvider.set(this.storageKey, events);\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RevenueEventProperties, Revenue as IRevenue, ValidPropertyType } from '@amplitude/analytics-types';
|
|
2
|
+
export declare class Revenue implements IRevenue {
|
|
3
|
+
private productId;
|
|
4
|
+
private quantity;
|
|
5
|
+
private price;
|
|
6
|
+
private revenueType?;
|
|
7
|
+
private properties?;
|
|
8
|
+
private revenue?;
|
|
9
|
+
constructor();
|
|
10
|
+
setProductId(productId: string): this;
|
|
11
|
+
setQuantity(quantity: number): this;
|
|
12
|
+
setPrice(price: number): this;
|
|
13
|
+
setRevenueType(revenueType: string): this;
|
|
14
|
+
setRevenue(revenue: number): this;
|
|
15
|
+
setEventProperties(properties: {
|
|
16
|
+
[key: string]: ValidPropertyType;
|
|
17
|
+
}): this;
|
|
18
|
+
getEventProperties(): RevenueEventProperties;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=revenue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenue.d.ts","sourceRoot":"","sources":["../../src/revenue.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,sBAAsB,EACtB,OAAO,IAAI,QAAQ,EACnB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAGpC,qBAAa,OAAQ,YAAW,QAAQ;IACtC,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAC,CAAyB;IAC5C,OAAO,CAAC,OAAO,CAAC,CAAS;;IAQzB,YAAY,CAAC,SAAS,EAAE,MAAM;IAK9B,WAAW,CAAC,QAAQ,EAAE,MAAM;IAO5B,QAAQ,CAAC,KAAK,EAAE,MAAM;IAKtB,cAAc,CAAC,WAAW,EAAE,MAAM;IAKlC,UAAU,CAAC,OAAO,EAAE,MAAM;IAK1B,kBAAkB,CAAC,UAAU,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAA;KAAE;IAOnE,kBAAkB,IAAI,sBAAsB;CAS7C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { RevenueProperty, } from '@amplitude/analytics-types';
|
|
3
|
+
import { isValidObject } from './utils/valid-properties';
|
|
4
|
+
var Revenue = /** @class */ (function () {
|
|
5
|
+
function Revenue() {
|
|
6
|
+
this.productId = '';
|
|
7
|
+
this.quantity = 1;
|
|
8
|
+
this.price = 0.0;
|
|
9
|
+
}
|
|
10
|
+
Revenue.prototype.setProductId = function (productId) {
|
|
11
|
+
this.productId = productId;
|
|
12
|
+
return this;
|
|
13
|
+
};
|
|
14
|
+
Revenue.prototype.setQuantity = function (quantity) {
|
|
15
|
+
if (quantity > 0) {
|
|
16
|
+
this.quantity = quantity;
|
|
17
|
+
}
|
|
18
|
+
return this;
|
|
19
|
+
};
|
|
20
|
+
Revenue.prototype.setPrice = function (price) {
|
|
21
|
+
this.price = price;
|
|
22
|
+
return this;
|
|
23
|
+
};
|
|
24
|
+
Revenue.prototype.setRevenueType = function (revenueType) {
|
|
25
|
+
this.revenueType = revenueType;
|
|
26
|
+
return this;
|
|
27
|
+
};
|
|
28
|
+
Revenue.prototype.setRevenue = function (revenue) {
|
|
29
|
+
this.revenue = revenue;
|
|
30
|
+
return this;
|
|
31
|
+
};
|
|
32
|
+
Revenue.prototype.setEventProperties = function (properties) {
|
|
33
|
+
if (isValidObject(properties)) {
|
|
34
|
+
this.properties = properties;
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
};
|
|
38
|
+
Revenue.prototype.getEventProperties = function () {
|
|
39
|
+
var eventProperties = this.properties ? __assign({}, this.properties) : {};
|
|
40
|
+
eventProperties[RevenueProperty.REVENUE_PRODUCT_ID] = this.productId;
|
|
41
|
+
eventProperties[RevenueProperty.REVENUE_QUANTITY] = this.quantity;
|
|
42
|
+
eventProperties[RevenueProperty.REVENUE_PRICE] = this.price;
|
|
43
|
+
eventProperties[RevenueProperty.REVENUE_TYPE] = this.revenueType;
|
|
44
|
+
eventProperties[RevenueProperty.REVENUE] = this.revenue;
|
|
45
|
+
return eventProperties;
|
|
46
|
+
};
|
|
47
|
+
return Revenue;
|
|
48
|
+
}());
|
|
49
|
+
export { Revenue };
|
|
50
|
+
//# sourceMappingURL=revenue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revenue.js","sourceRoot":"","sources":["../../src/revenue.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,eAAe,GAIhB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;IAQE;QACE,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;IACnB,CAAC;IAED,8BAAY,GAAZ,UAAa,SAAiB;QAC5B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6BAAW,GAAX,UAAY,QAAgB;QAC1B,IAAI,QAAQ,GAAG,CAAC,EAAE;YAChB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;SAC1B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,0BAAQ,GAAR,UAAS,KAAa;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,gCAAc,GAAd,UAAe,WAAmB;QAChC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,4BAAU,GAAV,UAAW,OAAe;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oCAAkB,GAAlB,UAAmB,UAAgD;QACjE,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;YAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;SAC9B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,oCAAkB,GAAlB;QACE,IAAM,eAAe,GAA2B,IAAI,CAAC,UAAU,CAAC,CAAC,cAAM,IAAI,CAAC,UAAU,EAAG,CAAC,CAAC,EAAE,CAAC;QAC9F,eAAe,CAAC,eAAe,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC;QACrE,eAAe,CAAC,eAAe,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC;QAClE,eAAe,CAAC,eAAe,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5D,eAAe,CAAC,eAAe,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC;QACjE,eAAe,CAAC,eAAe,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC;QACxD,OAAO,eAAe,CAAC;IACzB,CAAC;IACH,cAAC;AAAD,CAAC,AAzDD,IAyDC","sourcesContent":["import {\n RevenueProperty,\n RevenueEventProperties,\n Revenue as IRevenue,\n ValidPropertyType,\n} from '@amplitude/analytics-types';\nimport { isValidObject } from './utils/valid-properties';\n\nexport class Revenue implements IRevenue {\n private productId: string;\n private quantity: number;\n private price: number;\n private revenueType?: string;\n private properties?: { [key: string]: any };\n private revenue?: number;\n\n constructor() {\n this.productId = '';\n this.quantity = 1;\n this.price = 0.0;\n }\n\n setProductId(productId: string) {\n this.productId = productId;\n return this;\n }\n\n setQuantity(quantity: number) {\n if (quantity > 0) {\n this.quantity = quantity;\n }\n return this;\n }\n\n setPrice(price: number) {\n this.price = price;\n return this;\n }\n\n setRevenueType(revenueType: string) {\n this.revenueType = revenueType;\n return this;\n }\n\n setRevenue(revenue: number) {\n this.revenue = revenue;\n return this;\n }\n\n setEventProperties(properties: { [key: string]: ValidPropertyType }) {\n if (isValidObject(properties)) {\n this.properties = properties;\n }\n return this;\n }\n\n getEventProperties(): RevenueEventProperties {\n const eventProperties: RevenueEventProperties = this.properties ? { ...this.properties } : {};\n eventProperties[RevenueProperty.REVENUE_PRODUCT_ID] = this.productId;\n eventProperties[RevenueProperty.REVENUE_QUANTITY] = this.quantity;\n eventProperties[RevenueProperty.REVENUE_PRICE] = this.price;\n eventProperties[RevenueProperty.REVENUE_TYPE] = this.revenueType;\n eventProperties[RevenueProperty.REVENUE] = this.revenue;\n return eventProperties;\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config, Event, EventCallback, Plugin, Result } from '@amplitude/analytics-types';
|
|
2
|
+
export declare const queue: [Event, EventCallback, Plugin[]][];
|
|
3
|
+
export declare const register: (plugin: Plugin, config: Config) => Promise<void>;
|
|
4
|
+
export declare const deregister: (pluginName: string, config: Config) => Promise<void>;
|
|
5
|
+
export declare const push: (event: Event, config: Config) => Promise<Result>;
|
|
6
|
+
export declare const scheduleApply: (timeout: number) => void;
|
|
7
|
+
export declare const apply: () => Promise<void>;
|
|
8
|
+
//# sourceMappingURL=timeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timeline.d.ts","sourceRoot":"","sources":["../../src/timeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAGN,KAAK,EACL,aAAa,EACb,MAAM,EAEN,MAAM,EACP,MAAM,4BAA4B,CAAC;AAIpC,eAAO,MAAM,KAAK,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC,EAAO,CAAC;AAG5D,eAAO,MAAM,QAAQ,WAAkB,MAAM,UAAU,MAAM,kBAG5D,CAAC;AAEF,eAAO,MAAM,UAAU,eAAgB,MAAM,UAAU,MAAM,kBAM5D,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,KAAK,UAAU,MAAM,oBAShD,CAAC;AAEF,eAAO,MAAM,aAAa,YAAa,MAAM,SAW5C,CAAC;AAEF,eAAO,MAAM,KAAK,qBAwCjB,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { __assign, __awaiter, __generator, __read, __values } from "tslib";
|
|
2
|
+
import { PluginType, } from '@amplitude/analytics-types';
|
|
3
|
+
import { OPT_OUT_MESSAGE } from './messages';
|
|
4
|
+
import { buildResult } from './utils/result-builder';
|
|
5
|
+
export var queue = [];
|
|
6
|
+
var applying = false;
|
|
7
|
+
export var register = function (plugin, config) { return __awaiter(void 0, void 0, void 0, function () {
|
|
8
|
+
return __generator(this, function (_a) {
|
|
9
|
+
switch (_a.label) {
|
|
10
|
+
case 0: return [4 /*yield*/, plugin.setup(config)];
|
|
11
|
+
case 1:
|
|
12
|
+
_a.sent();
|
|
13
|
+
config.plugins.push(plugin);
|
|
14
|
+
return [2 /*return*/];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}); };
|
|
18
|
+
export var deregister = function (pluginName, config) {
|
|
19
|
+
config.plugins.splice(config.plugins.findIndex(function (plugin) { return plugin.name === pluginName; }), 1);
|
|
20
|
+
return Promise.resolve();
|
|
21
|
+
};
|
|
22
|
+
export var push = function (event, config) {
|
|
23
|
+
return new Promise(function (resolve) {
|
|
24
|
+
if (config.optOut) {
|
|
25
|
+
resolve(buildResult(event, 0, OPT_OUT_MESSAGE));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
queue.push([event, resolve, config.plugins]);
|
|
29
|
+
scheduleApply(0);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
export var scheduleApply = function (timeout) {
|
|
33
|
+
if (applying)
|
|
34
|
+
return;
|
|
35
|
+
applying = true;
|
|
36
|
+
setTimeout(function () {
|
|
37
|
+
void apply().then(function () {
|
|
38
|
+
applying = false;
|
|
39
|
+
if (queue.length > 0) {
|
|
40
|
+
scheduleApply(0);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}, timeout);
|
|
44
|
+
};
|
|
45
|
+
export var apply = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var item, _a, event, _b, resolve, plugins, before, before_1, before_1_1, plugin, e_1_1, enrichment, enrichment_1, enrichment_1_1, plugin, e_2_1, destination, executeDestinations;
|
|
47
|
+
var e_1, _c, e_2, _d;
|
|
48
|
+
return __generator(this, function (_e) {
|
|
49
|
+
switch (_e.label) {
|
|
50
|
+
case 0:
|
|
51
|
+
item = queue.shift();
|
|
52
|
+
if (!item) {
|
|
53
|
+
return [2 /*return*/];
|
|
54
|
+
}
|
|
55
|
+
_a = __read(item, 1), event = _a[0];
|
|
56
|
+
_b = __read(item, 3), resolve = _b[1], plugins = _b[2];
|
|
57
|
+
before = plugins.filter(function (plugin) { return plugin.type === PluginType.BEFORE; });
|
|
58
|
+
_e.label = 1;
|
|
59
|
+
case 1:
|
|
60
|
+
_e.trys.push([1, 6, 7, 8]);
|
|
61
|
+
before_1 = __values(before), before_1_1 = before_1.next();
|
|
62
|
+
_e.label = 2;
|
|
63
|
+
case 2:
|
|
64
|
+
if (!!before_1_1.done) return [3 /*break*/, 5];
|
|
65
|
+
plugin = before_1_1.value;
|
|
66
|
+
return [4 /*yield*/, plugin.execute(__assign({}, event))];
|
|
67
|
+
case 3:
|
|
68
|
+
event = _e.sent();
|
|
69
|
+
_e.label = 4;
|
|
70
|
+
case 4:
|
|
71
|
+
before_1_1 = before_1.next();
|
|
72
|
+
return [3 /*break*/, 2];
|
|
73
|
+
case 5: return [3 /*break*/, 8];
|
|
74
|
+
case 6:
|
|
75
|
+
e_1_1 = _e.sent();
|
|
76
|
+
e_1 = { error: e_1_1 };
|
|
77
|
+
return [3 /*break*/, 8];
|
|
78
|
+
case 7:
|
|
79
|
+
try {
|
|
80
|
+
if (before_1_1 && !before_1_1.done && (_c = before_1.return)) _c.call(before_1);
|
|
81
|
+
}
|
|
82
|
+
finally { if (e_1) throw e_1.error; }
|
|
83
|
+
return [7 /*endfinally*/];
|
|
84
|
+
case 8:
|
|
85
|
+
enrichment = plugins.filter(function (plugin) { return plugin.type === PluginType.ENRICHMENT; });
|
|
86
|
+
_e.label = 9;
|
|
87
|
+
case 9:
|
|
88
|
+
_e.trys.push([9, 14, 15, 16]);
|
|
89
|
+
enrichment_1 = __values(enrichment), enrichment_1_1 = enrichment_1.next();
|
|
90
|
+
_e.label = 10;
|
|
91
|
+
case 10:
|
|
92
|
+
if (!!enrichment_1_1.done) return [3 /*break*/, 13];
|
|
93
|
+
plugin = enrichment_1_1.value;
|
|
94
|
+
return [4 /*yield*/, plugin.execute(__assign({}, event))];
|
|
95
|
+
case 11:
|
|
96
|
+
event = _e.sent();
|
|
97
|
+
_e.label = 12;
|
|
98
|
+
case 12:
|
|
99
|
+
enrichment_1_1 = enrichment_1.next();
|
|
100
|
+
return [3 /*break*/, 10];
|
|
101
|
+
case 13: return [3 /*break*/, 16];
|
|
102
|
+
case 14:
|
|
103
|
+
e_2_1 = _e.sent();
|
|
104
|
+
e_2 = { error: e_2_1 };
|
|
105
|
+
return [3 /*break*/, 16];
|
|
106
|
+
case 15:
|
|
107
|
+
try {
|
|
108
|
+
if (enrichment_1_1 && !enrichment_1_1.done && (_d = enrichment_1.return)) _d.call(enrichment_1);
|
|
109
|
+
}
|
|
110
|
+
finally { if (e_2) throw e_2.error; }
|
|
111
|
+
return [7 /*endfinally*/];
|
|
112
|
+
case 16:
|
|
113
|
+
destination = plugins.filter(function (plugin) { return plugin.type === PluginType.DESTINATION; });
|
|
114
|
+
executeDestinations = destination.map(function (plugin) {
|
|
115
|
+
var eventClone = __assign({}, event);
|
|
116
|
+
return plugin.execute(eventClone).catch(function (e) { return buildResult(eventClone, 0, String(e)); });
|
|
117
|
+
});
|
|
118
|
+
void Promise.all(executeDestinations).then(function (_a) {
|
|
119
|
+
var _b = __read(_a, 1), result = _b[0];
|
|
120
|
+
resolve(result);
|
|
121
|
+
});
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}); };
|
|
126
|
+
//# sourceMappingURL=timeline.js.map
|
|
@@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,GAAG,SAAkC,CAAC;;;;;;;;;;;;;;;;;gBAGvC,WAAW,GAAG,OAAO,CAAC,MAAM,CAChC,UAAC,MAAc,IAAkC,OAAA,MAAM,CAAC,IAAI,KAAK,UAAU,CAAC,WAAW,EAAtC,CAAsC,CACxF,CAAC;gBAEI,mBAAmB,GAAG,WAAW,CAAC,GAAG,CAAC,UAAC,MAAM;oBACjD,IAAM,UAAU,gBAAQ,KAAK,CAAE,CAAC;oBAChC,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,UAAC,CAAC,IAAK,OAAA,WAAW,CAAC,UAAU,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAArC,CAAqC,CAAC,CAAC;gBACxF,CAAC,CAAC,CAAC;gBAEH,KAAK,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,IAAI,CAAC,UAAC,EAAQ;wBAAR,KAAA,aAAQ,EAAP,MAAM,QAAA;oBACjD,OAAO,CAAC,MAAM,CAAC,CAAC;gBAClB,CAAC,CAAC,CAAC;gBAEH,sBAAO;;;KACR,CAAC","sourcesContent":["import {\n BeforePlugin,\n Config,\n DestinationPlugin,\n EnrichmentPlugin,\n Event,\n EventCallback,\n Plugin,\n PluginType,\n Result,\n} from '@amplitude/analytics-types';\nimport { OPT_OUT_MESSAGE } from './messages';\nimport { buildResult } from './utils/result-builder';\n\nexport const queue: [Event, EventCallback, Plugin[]][] = [];\nlet applying = false;\n\nexport const register = async (plugin: Plugin, config: Config) => {\n await plugin.setup(config);\n config.plugins.push(plugin);\n};\n\nexport const deregister = (pluginName: string, config: Config) => {\n config.plugins.splice(\n config.plugins.findIndex((plugin) => plugin.name === pluginName),\n 1,\n );\n return Promise.resolve();\n};\n\nexport const push = (event: Event, config: Config) => {\n return new Promise<Result>((resolve) => {\n if (config.optOut) {\n resolve(buildResult(event, 0, OPT_OUT_MESSAGE));\n return;\n }\n queue.push([event, resolve, config.plugins]);\n scheduleApply(0);\n });\n};\n\nexport const scheduleApply = (timeout: number) => {\n if (applying) return;\n applying = true;\n setTimeout(() => {\n void apply().then(() => {\n applying = false;\n if (queue.length > 0) {\n scheduleApply(0);\n }\n });\n }, timeout);\n};\n\nexport const apply = async () => {\n const item = queue.shift();\n\n if (!item) {\n return;\n }\n\n let [event] = item;\n const [, resolve, plugins] = item;\n\n const before = plugins.filter<BeforePlugin>(\n (plugin: Plugin): plugin is BeforePlugin => plugin.type === PluginType.BEFORE,\n );\n\n for (const plugin of before) {\n event = await plugin.execute({ ...event });\n }\n\n const enrichment = plugins.filter<EnrichmentPlugin>(\n (plugin: Plugin): plugin is EnrichmentPlugin => plugin.type === PluginType.ENRICHMENT,\n );\n\n for (const plugin of enrichment) {\n event = await plugin.execute({ ...event });\n }\n\n const destination = plugins.filter<DestinationPlugin>(\n (plugin: Plugin): plugin is DestinationPlugin => plugin.type === PluginType.DESTINATION,\n );\n\n const executeDestinations = destination.map((plugin) => {\n const eventClone = { ...event };\n return plugin.execute(eventClone).catch((e) => buildResult(eventClone, 0, String(e)));\n });\n\n void Promise.all(executeDestinations).then(([result]) => {\n resolve(result);\n });\n\n return;\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/transports/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAI1E,qBAAa,IAAK,YAAW,SAAS;IACpC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;CAwCpE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
2
|
+
import { buildResponse } from '../utils/response-builder';
|
|
3
|
+
var Http = /** @class */ (function () {
|
|
4
|
+
function Http() {
|
|
5
|
+
}
|
|
6
|
+
Http.prototype.send = function (serverUrl, payload) {
|
|
7
|
+
var url = new URL(serverUrl);
|
|
8
|
+
var requestPayload = JSON.stringify(payload);
|
|
9
|
+
var options = {
|
|
10
|
+
headers: {
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
'Content-Length': Buffer.byteLength(requestPayload),
|
|
13
|
+
},
|
|
14
|
+
hostname: url.hostname,
|
|
15
|
+
method: 'POST',
|
|
16
|
+
path: url.pathname,
|
|
17
|
+
port: url.port,
|
|
18
|
+
protocol: url.protocol,
|
|
19
|
+
};
|
|
20
|
+
return new Promise(function (resolve) {
|
|
21
|
+
var req = http.request(options, function (res) {
|
|
22
|
+
res.setEncoding('utf8');
|
|
23
|
+
var responsePayload = '';
|
|
24
|
+
res.on('data', function (chunk) {
|
|
25
|
+
responsePayload += chunk;
|
|
26
|
+
});
|
|
27
|
+
res.on('end', function () {
|
|
28
|
+
if (res.complete && responsePayload.length > 0) {
|
|
29
|
+
try {
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
31
|
+
var parsedResponsePayload = JSON.parse(responsePayload);
|
|
32
|
+
var result = buildResponse(parsedResponsePayload);
|
|
33
|
+
resolve(result);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
catch (_a) {
|
|
37
|
+
resolve(null);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
req.on('error', buildResponse);
|
|
43
|
+
req.end(requestPayload);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return Http;
|
|
47
|
+
}());
|
|
48
|
+
export { Http };
|
|
49
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/transports/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;IAAA;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AAC;YACL,CAAC,CAAC,CAAC;YACH,GAAG,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;YAC/B,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IACH,WAAC;AAAD,CAAC,AAzCD,IAyCC","sourcesContent":["import { Payload, Response, Transport } from '@amplitude/analytics-types';\nimport * as http from 'http';\nimport { buildResponse } from '../utils/response-builder';\n\nexport class Http implements Transport {\n send(serverUrl: string, payload: Payload): Promise<Response | null> {\n const url = new URL(serverUrl);\n const requestPayload = JSON.stringify(payload);\n const options = {\n headers: {\n 'Content-Type': 'application/json',\n 'Content-Length': Buffer.byteLength(requestPayload),\n },\n hostname: url.hostname,\n method: 'POST',\n path: url.pathname,\n port: url.port,\n protocol: url.protocol,\n };\n return new Promise((resolve) => {\n const req = http.request(options, (res) => {\n res.setEncoding('utf8');\n let responsePayload = '';\n res.on('data', (chunk: string) => {\n responsePayload += chunk;\n });\n\n res.on('end', () => {\n if (res.complete && responsePayload.length > 0) {\n try {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const parsedResponsePayload: Record<string, any> = JSON.parse(responsePayload);\n const result = buildResponse(parsedResponsePayload);\n resolve(result);\n return;\n } catch {\n resolve(null);\n }\n }\n });\n });\n req.on('error', buildResponse);\n req.end(requestPayload);\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.d.ts","sourceRoot":"","sources":["../../../src/utils/chunk.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,KAAK,sBAAuB,MAAM,UAU9C,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Creates an array of elements split into groups the length of size.
|
|
2
|
+
// If array can't be split evenly, the final chunk will be the remaining elements.
|
|
3
|
+
// Works similary as https://lodash.com/docs/4.17.15#chunk
|
|
4
|
+
export var chunk = function (arr, size) {
|
|
5
|
+
var chunkSize = Math.max(size, 1);
|
|
6
|
+
return arr.reduce(function (chunks, element, index) {
|
|
7
|
+
var chunkIndex = Math.floor(index / chunkSize);
|
|
8
|
+
if (!chunks[chunkIndex]) {
|
|
9
|
+
chunks[chunkIndex] = [];
|
|
10
|
+
}
|
|
11
|
+
chunks[chunkIndex].push(element);
|
|
12
|
+
return chunks;
|
|
13
|
+
}, []);
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=chunk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../../src/utils/chunk.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,kFAAkF;AAClF,0DAA0D;AAE1D,MAAM,CAAC,IAAM,KAAK,GAAG,UAAI,GAAQ,EAAE,IAAY;IAC7C,IAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC,MAAM,CAAQ,UAAC,MAAM,EAAE,OAAO,EAAE,KAAK;QAC9C,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,SAAS,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;YACvB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC;SACzB;QACD,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC,CAAC","sourcesContent":["// Creates an array of elements split into groups the length of size.\n// If array can't be split evenly, the final chunk will be the remaining elements.\n// Works similary as https://lodash.com/docs/4.17.15#chunk\n\nexport const chunk = <T>(arr: T[], size: number) => {\n const chunkSize = Math.max(size, 1);\n return arr.reduce<T[][]>((chunks, element, index) => {\n const chunkIndex = Math.floor(index / chunkSize);\n if (!chunks[chunkIndex]) {\n chunks[chunkIndex] = [];\n }\n chunks[chunkIndex].push(element);\n return chunks;\n }, []);\n};\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TrackEvent, IdentifyEvent, GroupIdentifyEvent, Identify as IIdentify, Revenue, RevenueEvent, EventOptions } from '@amplitude/analytics-types';
|
|
2
|
+
export declare const createTrackEvent: (eventType: string, eventProperties?: Record<string, any> | undefined, eventOptions?: EventOptions | undefined) => TrackEvent;
|
|
3
|
+
export declare const createIdentifyEvent: (userId: string | undefined, deviceId: string | undefined, identify: IIdentify, eventOptions?: EventOptions | undefined) => IdentifyEvent;
|
|
4
|
+
export declare const createGroupIdentifyEvent: (userId: string | undefined, deviceId: string | undefined, groupType: string, groupName: string | string[], identify: IIdentify, eventOptions?: EventOptions | undefined) => GroupIdentifyEvent;
|
|
5
|
+
export declare const createGroupEvent: (groupType: string, groupName: string | string[]) => IdentifyEvent;
|
|
6
|
+
export declare const createRevenueEvent: (revenue: Revenue, eventOptions?: EventOptions | undefined) => RevenueEvent;
|
|
7
|
+
//# sourceMappingURL=event-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/event-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAElB,QAAQ,IAAI,SAAS,EACrB,OAAO,EACP,YAAY,EACZ,YAAY,EACb,MAAM,4BAA4B,CAAC;AAGpC,eAAO,MAAM,gBAAgB,cAChB,MAAM,iGAGhB,UAMF,CAAC;AAEF,eAAO,MAAM,mBAAmB,WACtB,MAAM,GAAG,SAAS,YAChB,MAAM,GAAG,SAAS,YAClB,SAAS,8CAElB,aAaF,CAAC;AAEF,eAAO,MAAM,wBAAwB,WAC3B,MAAM,GAAG,SAAS,YAChB,MAAM,GAAG,SAAS,aACjB,MAAM,aACN,MAAM,GAAG,MAAM,EAAE,YAClB,SAAS,8CAElB,kBAgBF,CAAC;AAEF,eAAO,MAAM,gBAAgB,cAAe,MAAM,aAAa,MAAM,GAAG,MAAM,EAAE,kBAY/E,CAAC;AAEF,eAAO,MAAM,kBAAkB,YAAa,OAAO,8CAAgC,YAMlF,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { SpecialEventType, } from '@amplitude/analytics-types';
|
|
3
|
+
import { Identify } from '../identify';
|
|
4
|
+
export var createTrackEvent = function (eventType, eventProperties, eventOptions) {
|
|
5
|
+
return __assign(__assign(__assign({}, eventOptions), { event_type: eventType }), (eventProperties && { event_properties: eventProperties }));
|
|
6
|
+
};
|
|
7
|
+
export var createIdentifyEvent = function (userId, deviceId, identify, eventOptions) {
|
|
8
|
+
var identifyEvent = __assign(__assign({}, eventOptions), { event_type: SpecialEventType.IDENTIFY, user_properties: identify.getUserProperties(), user_id: userId });
|
|
9
|
+
if (deviceId !== undefined && deviceId.length > 0) {
|
|
10
|
+
identifyEvent.device_id = deviceId;
|
|
11
|
+
}
|
|
12
|
+
return identifyEvent;
|
|
13
|
+
};
|
|
14
|
+
export var createGroupIdentifyEvent = function (userId, deviceId, groupType, groupName, identify, eventOptions) {
|
|
15
|
+
var _a;
|
|
16
|
+
var groupIdentify = __assign(__assign({}, eventOptions), { event_type: SpecialEventType.GROUP_IDENTIFY, group_properties: identify.getUserProperties(), groups: (_a = {},
|
|
17
|
+
_a[groupType] = groupName,
|
|
18
|
+
_a), user_id: userId });
|
|
19
|
+
if (deviceId !== undefined && deviceId.length > 0) {
|
|
20
|
+
groupIdentify.device_id = deviceId;
|
|
21
|
+
}
|
|
22
|
+
return groupIdentify;
|
|
23
|
+
};
|
|
24
|
+
export var createGroupEvent = function (groupType, groupName) {
|
|
25
|
+
var _a;
|
|
26
|
+
var identify = new Identify();
|
|
27
|
+
identify.set(groupType, groupName);
|
|
28
|
+
var groupEvent = {
|
|
29
|
+
event_type: SpecialEventType.IDENTIFY,
|
|
30
|
+
user_properties: identify.getUserProperties(),
|
|
31
|
+
groups: (_a = {},
|
|
32
|
+
_a[groupType] = groupName,
|
|
33
|
+
_a),
|
|
34
|
+
};
|
|
35
|
+
return groupEvent;
|
|
36
|
+
};
|
|
37
|
+
export var createRevenueEvent = function (revenue, eventOptions) {
|
|
38
|
+
return __assign(__assign({}, eventOptions), { event_type: SpecialEventType.REVENUE, event_properties: revenue.getEventProperties() });
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=event-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event-builder.js","sourceRoot":"","sources":["../../../src/utils/event-builder.ts"],"names":[],"mappings":";AAAA,OAAO,EAIL,gBAAgB,GAKjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAC9B,SAAiB,EACjB,eAAqC,EACrC,YAA2B;IAE3B,sCACK,YAAY,KACf,UAAU,EAAE,SAAS,KAClB,CAAC,eAAe,IAAI,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC,EAC7D;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,mBAAmB,GAAG,UACjC,MAA0B,EAC1B,QAA4B,EAC5B,QAAmB,EACnB,YAA2B;IAE3B,IAAM,aAAa,yBACd,YAAY,KACf,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EACrC,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EAAE,EAC7C,OAAO,EAAE,MAAM,GAChB,CAAC;IAEF,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,aAAa,CAAC,SAAS,GAAG,QAAQ,CAAC;KACpC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,wBAAwB,GAAG,UACtC,MAA0B,EAC1B,QAA4B,EAC5B,SAAiB,EACjB,SAA4B,EAC5B,QAAmB,EACnB,YAA2B;;IAE3B,IAAM,aAAa,yBACd,YAAY,KACf,UAAU,EAAE,gBAAgB,CAAC,cAAc,EAC3C,gBAAgB,EAAE,QAAQ,CAAC,iBAAiB,EAAE,EAC9C,MAAM;YACJ,GAAC,SAAS,IAAG,SAAS;iBAExB,OAAO,EAAE,MAAM,GAChB,CAAC;IAEF,IAAI,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACjD,aAAa,CAAC,SAAS,GAAG,QAAQ,CAAC;KACpC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,gBAAgB,GAAG,UAAC,SAAiB,EAAE,SAA4B;;IAC9E,IAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;IAChC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAEnC,IAAM,UAAU,GAAkB;QAChC,UAAU,EAAE,gBAAgB,CAAC,QAAQ;QACrC,eAAe,EAAE,QAAQ,CAAC,iBAAiB,EAAE;QAC7C,MAAM;YACJ,GAAC,SAAS,IAAG,SAAS;eACvB;KACF,CAAC;IACF,OAAO,UAAU,CAAC;AACpB,CAAC,CAAC;AAEF,MAAM,CAAC,IAAM,kBAAkB,GAAG,UAAC,OAAgB,EAAE,YAA2B;IAC9E,6BACK,YAAY,KACf,UAAU,EAAE,gBAAgB,CAAC,OAAO,EACpC,gBAAgB,EAAE,OAAO,CAAC,kBAAkB,EAAE,IAC9C;AACJ,CAAC,CAAC","sourcesContent":["import {\n TrackEvent,\n IdentifyEvent,\n GroupIdentifyEvent,\n SpecialEventType,\n Identify as IIdentify,\n Revenue,\n RevenueEvent,\n EventOptions,\n} from '@amplitude/analytics-types';\nimport { Identify } from '../identify';\n\nexport const createTrackEvent = (\n eventType: string,\n eventProperties?: Record<string, any>,\n eventOptions?: EventOptions,\n): TrackEvent => {\n return {\n ...eventOptions,\n event_type: eventType,\n ...(eventProperties && { event_properties: eventProperties }),\n };\n};\n\nexport const createIdentifyEvent = (\n userId: string | undefined,\n deviceId: string | undefined,\n identify: IIdentify,\n eventOptions?: EventOptions,\n): IdentifyEvent => {\n const identifyEvent: IdentifyEvent = {\n ...eventOptions,\n event_type: SpecialEventType.IDENTIFY,\n user_properties: identify.getUserProperties(),\n user_id: userId,\n };\n\n if (deviceId !== undefined && deviceId.length > 0) {\n identifyEvent.device_id = deviceId;\n }\n\n return identifyEvent;\n};\n\nexport const createGroupIdentifyEvent = (\n userId: string | undefined,\n deviceId: string | undefined,\n groupType: string,\n groupName: string | string[],\n identify: IIdentify,\n eventOptions?: EventOptions,\n): GroupIdentifyEvent => {\n const groupIdentify: GroupIdentifyEvent = {\n ...eventOptions,\n event_type: SpecialEventType.GROUP_IDENTIFY,\n group_properties: identify.getUserProperties(),\n groups: {\n [groupType]: groupName,\n },\n user_id: userId,\n };\n\n if (deviceId !== undefined && deviceId.length > 0) {\n groupIdentify.device_id = deviceId;\n }\n\n return groupIdentify;\n};\n\nexport const createGroupEvent = (groupType: string, groupName: string | string[]) => {\n const identify = new Identify();\n identify.set(groupType, groupName);\n\n const groupEvent: IdentifyEvent = {\n event_type: SpecialEventType.IDENTIFY,\n user_properties: identify.getUserProperties(),\n groups: {\n [groupType]: groupName,\n },\n };\n return groupEvent;\n};\n\nexport const createRevenueEvent = (revenue: Revenue, eventOptions?: EventOptions): RevenueEvent => {\n return {\n ...eventOptions,\n event_type: SpecialEventType.REVENUE,\n event_properties: revenue.getEventProperties(),\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/response-builder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAU,MAAM,4BAA4B,CAAC;AAG9D,eAAO,MAAM,aAAa,iBAAkB,OAAO,MAAM,EAAE,GAAG,CAAC,KAAG,QAAQ,GAAG,IAkE5E,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
4
|
+
import { Status } from '@amplitude/analytics-types';
|
|
5
|
+
import { buildStatus } from './status-builder';
|
|
6
|
+
export var buildResponse = function (responseJSON) {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
8
|
+
if (typeof responseJSON !== 'object') {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
var statusCode = responseJSON.code || 0;
|
|
12
|
+
var status = buildStatus(statusCode);
|
|
13
|
+
switch (status) {
|
|
14
|
+
case Status.Success:
|
|
15
|
+
return {
|
|
16
|
+
status: status,
|
|
17
|
+
statusCode: statusCode,
|
|
18
|
+
body: {
|
|
19
|
+
eventsIngested: (_a = responseJSON.events_ingested) !== null && _a !== void 0 ? _a : 0,
|
|
20
|
+
payloadSizeBytes: (_b = responseJSON.payload_size_bytes) !== null && _b !== void 0 ? _b : 0,
|
|
21
|
+
serverUploadTime: (_c = responseJSON.server_upload_time) !== null && _c !== void 0 ? _c : 0,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
case Status.Invalid:
|
|
25
|
+
return {
|
|
26
|
+
status: status,
|
|
27
|
+
statusCode: statusCode,
|
|
28
|
+
body: {
|
|
29
|
+
error: (_d = responseJSON.error) !== null && _d !== void 0 ? _d : '',
|
|
30
|
+
missingField: (_e = responseJSON.missing_field) !== null && _e !== void 0 ? _e : '',
|
|
31
|
+
eventsWithInvalidFields: (_f = responseJSON.events_with_invalid_fields) !== null && _f !== void 0 ? _f : {},
|
|
32
|
+
eventsWithMissingFields: (_g = responseJSON.events_with_missing_fields) !== null && _g !== void 0 ? _g : {},
|
|
33
|
+
epsThreshold: (_h = responseJSON.eps_threshold) !== null && _h !== void 0 ? _h : 0,
|
|
34
|
+
exceededDailyQuotaDevices: (_j = responseJSON.exceeded_daily_quota_devices) !== null && _j !== void 0 ? _j : {},
|
|
35
|
+
silencedDevices: (_k = responseJSON.silenced_devices) !== null && _k !== void 0 ? _k : [],
|
|
36
|
+
silencedEvents: (_l = responseJSON.silenced_events) !== null && _l !== void 0 ? _l : [],
|
|
37
|
+
throttledDevices: (_m = responseJSON.throttled_devices) !== null && _m !== void 0 ? _m : {},
|
|
38
|
+
throttledEvents: (_o = responseJSON.throttled_events) !== null && _o !== void 0 ? _o : [],
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
case Status.PayloadTooLarge:
|
|
42
|
+
return {
|
|
43
|
+
status: status,
|
|
44
|
+
statusCode: statusCode,
|
|
45
|
+
body: {
|
|
46
|
+
error: (_p = responseJSON.error) !== null && _p !== void 0 ? _p : '',
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
case Status.RateLimit:
|
|
50
|
+
return {
|
|
51
|
+
status: status,
|
|
52
|
+
statusCode: statusCode,
|
|
53
|
+
body: {
|
|
54
|
+
error: (_q = responseJSON.error) !== null && _q !== void 0 ? _q : '',
|
|
55
|
+
epsThreshold: (_r = responseJSON.eps_threshold) !== null && _r !== void 0 ? _r : 0,
|
|
56
|
+
throttledDevices: (_s = responseJSON.throttled_devices) !== null && _s !== void 0 ? _s : {},
|
|
57
|
+
throttledUsers: (_t = responseJSON.throttled_users) !== null && _t !== void 0 ? _t : {},
|
|
58
|
+
exceededDailyQuotaDevices: (_u = responseJSON.exceeded_daily_quota_devices) !== null && _u !== void 0 ? _u : {},
|
|
59
|
+
exceededDailyQuotaUsers: (_v = responseJSON.exceeded_daily_quota_users) !== null && _v !== void 0 ? _v : {},
|
|
60
|
+
throttledEvents: (_w = responseJSON.throttled_events) !== null && _w !== void 0 ? _w : [],
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
case Status.Timeout:
|
|
64
|
+
default:
|
|
65
|
+
return {
|
|
66
|
+
status: status,
|
|
67
|
+
statusCode: statusCode,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=response-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response-builder.js","sourceRoot":"","sources":["../../../src/utils/response-builder.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,4DAA4D;AAC5D,sDAAsD;AACtD,OAAO,EAAY,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,CAAC,IAAM,aAAa,GAAG,UAAC,YAAiC;;IAC7D,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE;QACpC,OAAO,IAAI,CAAC;KACb;IAED,IAAM,UAAU,GAAG,YAAY,CAAC,IAAI,IAAI,CAAC,CAAC;IAC1C,IAAM,MAAM,GAAG,WAAW,CAAC,UAAU,CAAC,CAAC;IAEvC,QAAQ,MAAM,EAAE;QACd,KAAK,MAAM,CAAC,OAAO;YACjB,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;gBACV,IAAI,EAAE;oBACJ,cAAc,EAAE,MAAA,YAAY,CAAC,eAAe,mCAAI,CAAC;oBACjD,gBAAgB,EAAE,MAAA,YAAY,CAAC,kBAAkB,mCAAI,CAAC;oBACtD,gBAAgB,EAAE,MAAA,YAAY,CAAC,kBAAkB,mCAAI,CAAC;iBACvD;aACF,CAAC;QAEJ,KAAK,MAAM,CAAC,OAAO;YACjB,OAAO;gBACL,MAAM,QAAA;gBACN,UAAU,YAAA;gBACV,IAAI,EAAE;oBACJ,KAAK,EAAE,MAAA,YAAY,CAAC,KAAK,mCAAI,EAAE;oBAC/B,YAAY,EAAE,MAAA,YAAY,CAAC,aAAa,mCAAI,EAAE;oBAC9C,uBAAuB,EAAE,MAAA,YAAY,CAAC,0BAA0B,mCAAI,EAAE;oBACtE,uBAAuB,EAAE,MAAA,YAA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Content":["/* eslint-disable @typescript-eslint/no-unsafe-argument */\n/* eslint-disable @typescript-eslint/no-unsafe-assignment */\n/* eslint-disable @typescript-eslint/no-unsafe-call */\nimport { Response, Status } from '@amplitude/analytics-types';\nimport { buildStatus } from './status-builder';\n\nexport const buildResponse = (responseJSON: Record<string, any>): Response | null => {\n if (typeof responseJSON !== 'object') {\n return null;\n }\n\n const statusCode = responseJSON.code || 0;\n const status = buildStatus(statusCode);\n\n switch (status) {\n case Status.Success:\n return {\n status,\n statusCode,\n body: {\n eventsIngested: responseJSON.events_ingested ?? 0,\n payloadSizeBytes: responseJSON.payload_size_bytes ?? 0,\n serverUploadTime: responseJSON.server_upload_time ?? 0,\n },\n };\n\n case Status.Invalid:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n missingField: responseJSON.missing_field ?? '',\n eventsWithInvalidFields: responseJSON.events_with_invalid_fields ?? {},\n eventsWithMissingFields: responseJSON.events_with_missing_fields ?? {},\n epsThreshold: responseJSON.eps_threshold ?? 0,\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n silencedDevices: responseJSON.silenced_devices ?? [],\n silencedEvents: responseJSON.silenced_events ?? [],\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.PayloadTooLarge:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n },\n };\n case Status.RateLimit:\n return {\n status,\n statusCode,\n body: {\n error: responseJSON.error ?? '',\n epsThreshold: responseJSON.eps_threshold ?? 0,\n throttledDevices: responseJSON.throttled_devices ?? {},\n throttledUsers: responseJSON.throttled_users ?? {},\n exceededDailyQuotaDevices: responseJSON.exceeded_daily_quota_devices ?? {},\n exceededDailyQuotaUsers: responseJSON.exceeded_daily_quota_users ?? {},\n throttledEvents: responseJSON.throttled_events ?? [],\n },\n };\n case Status.Timeout:\n default:\n return {\n status,\n statusCode,\n };\n }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/result-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAU,MAAM,4BAA4B,CAAC;AAEnE,eAAO,MAAM,WAAW,UAAW,KAAK,2BAAqB,MAAM,KAAoB,MAEtF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Status } from '@amplitude/analytics-types';
|
|
2
|
+
export var buildResult = function (event, code, message) {
|
|
3
|
+
if (code === void 0) { code = 0; }
|
|
4
|
+
if (message === void 0) { message = Status.Unknown; }
|
|
5
|
+
return { event: event, code: code, message: message };
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=result-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result-builder.js","sourceRoot":"","sources":["../../../src/utils/result-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,KAAY,EAAE,IAAQ,EAAE,OAAgC;IAA1C,qBAAA,EAAA,QAAQ;IAAE,wBAAA,EAAA,UAAkB,MAAM,CAAC,OAAO;IAClF,OAAO,EAAE,KAAK,OAAA,EAAE,IAAI,MAAA,EAAE,OAAO,SAAA,EAAE,CAAC;AAClC,CAAC,CAAC","sourcesContent":["import { Event, Result, Status } from '@amplitude/analytics-types';\n\nexport const buildResult = (event: Event, code = 0, message: string = Status.Unknown): Result => {\n return { event, code, message };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-builder.d.ts","sourceRoot":"","sources":["../../../src/utils/status-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0BhD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Status } from '@amplitude/analytics-types';
|
|
2
|
+
export function buildStatus(code) {
|
|
3
|
+
if (code >= 200 && code < 300) {
|
|
4
|
+
return Status.Success;
|
|
5
|
+
}
|
|
6
|
+
if (code === 429) {
|
|
7
|
+
return Status.RateLimit;
|
|
8
|
+
}
|
|
9
|
+
if (code === 413) {
|
|
10
|
+
return Status.PayloadTooLarge;
|
|
11
|
+
}
|
|
12
|
+
if (code === 408) {
|
|
13
|
+
return Status.Timeout;
|
|
14
|
+
}
|
|
15
|
+
if (code >= 400 && code < 500) {
|
|
16
|
+
return Status.Invalid;
|
|
17
|
+
}
|
|
18
|
+
if (code >= 500) {
|
|
19
|
+
return Status.Failed;
|
|
20
|
+
}
|
|
21
|
+
return Status.Unknown;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=status-builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-builder.js","sourceRoot":"","sources":["../../../src/utils/status-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEpD,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,MAAM,CAAC,SAAS,CAAC;KACzB;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,MAAM,CAAC,eAAe,CAAC;KAC/B;IAED,IAAI,IAAI,KAAK,GAAG,EAAE;QAChB,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,GAAG,EAAE;QAC7B,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAED,IAAI,IAAI,IAAI,GAAG,EAAE;QACf,OAAO,MAAM,CAAC,MAAM,CAAC;KACtB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC;AACxB,CAAC","sourcesContent":["import { Status } from '@amplitude/analytics-types';\n\nexport function buildStatus(code: number): Status {\n if (code >= 200 && code < 300) {\n return Status.Success;\n }\n\n if (code === 429) {\n return Status.RateLimit;\n }\n\n if (code === 413) {\n return Status.PayloadTooLarge;\n }\n\n if (code === 408) {\n return Status.Timeout;\n }\n\n if (code >= 400 && code < 500) {\n return Status.Invalid;\n }\n\n if (code >= 500) {\n return Status.Failed;\n }\n\n return Status.Unknown;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"valid-properties.d.ts","sourceRoot":"","sources":["../../../src/utils/valid-properties.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa;;MAAyC,OAUlE,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,MAAM,SAAS,GAAG,KAAG,OAmBhE,CAAC"}
|