@segment/analytics-node
Advanced tools
Comparing version 0.0.1-beta.6 to 0.0.1-beta.7
@@ -7,2 +7,9 @@ # @segment/analytics-node | ||
- Updated dependencies [[`90b915a`](https://github.com/segmentio/analytics-next/commit/90b915ac3447d76673e98661c54bf5a0ced2a555), [`108c77e`](https://github.com/segmentio/analytics-next/commit/108c77e81a4e9d2a64eb56e78f707ae6c2ea6ed2)]: | ||
- @segment/analytics-core@1.1.5 | ||
## 0.0.1 | ||
### Patch Changes | ||
- Updated dependencies [[`ecb4b8d`](https://github.com/segmentio/analytics-next/commit/ecb4b8db0194e06a3ee3c8cae57d4f327d15dc02)]: | ||
@@ -9,0 +16,0 @@ - @segment/analytics-core@1.1.4 |
{ | ||
"name": "@segment/analytics-node", | ||
"version": "0.0.1-beta.6", | ||
"version": "0.0.1-beta.7", | ||
"main": "./dist/cjs/src/index.js", | ||
@@ -36,3 +36,3 @@ "module": "./dist/esm/src/index.js", | ||
"@lukeed/uuid": "^2.0.0", | ||
"@segment/analytics-core": "1.1.4", | ||
"@segment/analytics-core": "1.1.5", | ||
"node-fetch": "^2.6.7", | ||
@@ -43,3 +43,4 @@ "tslib": "^2.4.0" | ||
"@internal/config": "0.0.0", | ||
"@types/node": "^14" | ||
"@types/node": "^14", | ||
"nock": "^13.2.9" | ||
}, | ||
@@ -46,0 +47,0 @@ "packageManager": "yarn@3.2.1", |
@@ -44,2 +44,3 @@ "use strict"; | ||
maxEventsInBatch: settings.maxEventsInBatch ?? 15, | ||
httpRequestTimeout: settings.httpRequestTimeout, | ||
flushInterval, | ||
@@ -46,0 +47,0 @@ }); |
@@ -5,2 +5,3 @@ "use strict"; | ||
const analytics_core_1 = require("@segment/analytics-core"); | ||
const abort_1 = require("../../lib/abort"); | ||
const create_url_1 = require("../../lib/create-url"); | ||
@@ -18,3 +19,3 @@ const extract_promise_parts_1 = require("../../lib/extract-promise-parts"); | ||
class Publisher { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, }) { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, }) { | ||
this._maxRetries = maxRetries; | ||
@@ -25,2 +26,3 @@ this._maxEventsInBatch = Math.max(maxEventsInBatch, 1); | ||
this._url = (0, create_url_1.tryCreateFormattedUrl)(host ?? 'https://api.segment.io', path ?? '/v1/batch'); | ||
this._httpRequestTimeout = httpRequestTimeout ?? 10000; | ||
} | ||
@@ -130,4 +132,6 @@ createBatch() { | ||
let failureReason; | ||
const [signal, timeoutId] = (0, abort_1.abortSignalAfterTimeout)(this._httpRequestTimeout); | ||
try { | ||
const response = await (0, fetch_1.fetch)(this._url, { | ||
signal: signal, | ||
method: 'POST', | ||
@@ -141,2 +145,3 @@ headers: { | ||
}); | ||
clearTimeout(timeoutId); | ||
if (response.ok) { | ||
@@ -143,0 +148,0 @@ // Successfully sent events, so exit! |
{ | ||
"name": "@segment/analytics-node", | ||
"version": "0.0.1-beta.6", | ||
"version": "0.0.1-beta.7", | ||
"main": "./dist/cjs/src/index.js", | ||
@@ -36,3 +36,3 @@ "module": "./dist/esm/src/index.js", | ||
"@lukeed/uuid": "^2.0.0", | ||
"@segment/analytics-core": "1.1.4", | ||
"@segment/analytics-core": "1.1.5", | ||
"node-fetch": "^2.6.7", | ||
@@ -43,3 +43,4 @@ "tslib": "^2.4.0" | ||
"@internal/config": "0.0.0", | ||
"@types/node": "^14" | ||
"@types/node": "^14", | ||
"nock": "^13.2.9" | ||
}, | ||
@@ -46,0 +47,0 @@ "packageManager": "yarn@3.2.1", |
@@ -40,2 +40,3 @@ import { CoreContext, EventQueue, bindAll, PriorityQueue, pTimeout, } from '@segment/analytics-core'; | ||
maxEventsInBatch: settings.maxEventsInBatch ?? 15, | ||
httpRequestTimeout: settings.httpRequestTimeout, | ||
flushInterval, | ||
@@ -42,0 +43,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
export { Analytics, Context } from './app/analytics-node'; | ||
export { Analytics, Context, } from './app/analytics-node'; | ||
// export Analytics as both a named export and a default export (for backwards-compat. reasons) | ||
@@ -3,0 +3,0 @@ import { Analytics } from './app/analytics-node'; |
import { backoff } from '@segment/analytics-core'; | ||
import { abortSignalAfterTimeout } from '../../lib/abort'; | ||
import { tryCreateFormattedUrl } from '../../lib/create-url'; | ||
@@ -14,3 +15,3 @@ import { extractPromiseParts } from '../../lib/extract-promise-parts'; | ||
export class Publisher { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, }) { | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, }) { | ||
this._maxRetries = maxRetries; | ||
@@ -21,2 +22,3 @@ this._maxEventsInBatch = Math.max(maxEventsInBatch, 1); | ||
this._url = tryCreateFormattedUrl(host ?? 'https://api.segment.io', path ?? '/v1/batch'); | ||
this._httpRequestTimeout = httpRequestTimeout ?? 10000; | ||
} | ||
@@ -126,4 +128,6 @@ createBatch() { | ||
let failureReason; | ||
const [signal, timeoutId] = abortSignalAfterTimeout(this._httpRequestTimeout); | ||
try { | ||
const response = await fetch(this._url, { | ||
signal: signal, | ||
method: 'POST', | ||
@@ -137,2 +141,3 @@ headers: { | ||
}); | ||
clearTimeout(timeoutId); | ||
if (response.ok) { | ||
@@ -139,0 +144,0 @@ // Successfully sent events, so exit! |
@@ -1,2 +0,2 @@ | ||
import { EventProperties, Traits, CoreAnalytics, CoreContext, CorePlugin, CoreSegmentEvent, Integrations } from '@segment/analytics-core'; | ||
import { EventProperties, CoreAnalytics, CoreContext, CorePlugin, CoreSegmentEvent, Integrations, CoreExtraContext, CoreAnalyticsTraits } from '@segment/analytics-core'; | ||
import { AnalyticsSettings } from './settings'; | ||
@@ -24,3 +24,14 @@ import { Callback } from './dispatch-emit'; | ||
*/ | ||
declare type AdditionalContext = Record<string, any>; | ||
export interface ExtraContext extends CoreExtraContext { | ||
} | ||
/** | ||
* Traits are pieces of information you know about a user that are included in an identify call. These could be demographics like age or gender, account-specific like plan, or even things like whether a user has seen a particular A/B test variation. Up to you! | ||
* Segment has reserved some traits that have semantic meanings for users, and we handle them in special ways. For example, Segment always expects email to be a string of the user’s email address. | ||
* | ||
* We’ll send this on to destinations like Mailchimp that require an email address for their tracking. | ||
* | ||
* You should only use reserved traits for their intended meaning. | ||
*/ | ||
export interface Traits extends CoreAnalyticsTraits { | ||
} | ||
declare type SegmentEventType = 'track' | 'page' | 'identify' | 'alias' | 'screen'; | ||
@@ -57,3 +68,3 @@ export interface SegmentEvent extends CoreSegmentEvent { | ||
previousId: string; | ||
context?: AdditionalContext; | ||
context?: ExtraContext; | ||
timestamp?: Timestamp; | ||
@@ -69,3 +80,3 @@ integrations?: Integrations; | ||
traits?: Traits; | ||
context?: AdditionalContext; | ||
context?: ExtraContext; | ||
timestamp?: Timestamp; | ||
@@ -80,3 +91,3 @@ integrations?: Integrations; | ||
traits?: Traits; | ||
context?: AdditionalContext; | ||
context?: ExtraContext; | ||
integrations?: Integrations; | ||
@@ -93,3 +104,3 @@ }, callback?: Callback): void; | ||
timestamp?: Timestamp; | ||
context?: AdditionalContext; | ||
context?: ExtraContext; | ||
integrations?: Integrations; | ||
@@ -111,3 +122,3 @@ }, callback?: Callback): void; | ||
properties?: EventProperties; | ||
context?: AdditionalContext; | ||
context?: ExtraContext; | ||
timestamp?: Timestamp; | ||
@@ -114,0 +125,0 @@ integrations?: Integrations; |
@@ -27,4 +27,8 @@ export interface AnalyticsSettings { | ||
flushInterval?: number; | ||
/** | ||
* The maximum number of milliseconds to wait for an http request. Default: 10000 | ||
*/ | ||
httpRequestTimeout?: number; | ||
} | ||
export declare const validateSettings: (settings: AnalyticsSettings) => void; | ||
//# sourceMappingURL=settings.d.ts.map |
@@ -1,2 +0,2 @@ | ||
export { Analytics, Context, Plugin } from './app/analytics-node'; | ||
export { Analytics, Context, Plugin, ExtraContext, Traits, } from './app/analytics-node'; | ||
export type { AnalyticsSettings } from './app/settings'; | ||
@@ -3,0 +3,0 @@ import { Analytics } from './app/analytics-node'; |
@@ -9,2 +9,3 @@ import { CoreContext } from '@segment/analytics-core'; | ||
writeKey: string; | ||
httpRequestTimeout?: number; | ||
} | ||
@@ -23,3 +24,4 @@ /** | ||
private _closeAndFlushPendingItemsCount?; | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, }: PublisherProps); | ||
private _httpRequestTimeout; | ||
constructor({ host, path, maxRetries, maxEventsInBatch, flushInterval, writeKey, httpRequestTimeout, }: PublisherProps); | ||
private createBatch; | ||
@@ -26,0 +28,0 @@ private clearBatch; |
{ | ||
"name": "@segment/analytics-node", | ||
"version": "0.0.1-beta.6", | ||
"version": "0.0.1-beta.7", | ||
"main": "./dist/cjs/src/index.js", | ||
@@ -36,3 +36,3 @@ "module": "./dist/esm/src/index.js", | ||
"@lukeed/uuid": "^2.0.0", | ||
"@segment/analytics-core": "1.1.4", | ||
"@segment/analytics-core": "1.1.5", | ||
"node-fetch": "^2.6.7", | ||
@@ -43,3 +43,4 @@ "tslib": "^2.4.0" | ||
"@internal/config": "0.0.0", | ||
"@types/node": "^14" | ||
"@types/node": "^14", | ||
"nock": "^13.2.9" | ||
}, | ||
@@ -46,0 +47,0 @@ "packageManager": "yarn@3.2.1", |
@@ -227,3 +227,3 @@ # @segment/analytics-node | ||
// new | ||
import { Analytics } from '@segment/analytics-next' | ||
import { Analytics } from '@segment/analytics-node' | ||
``` | ||
@@ -329,7 +329,5 @@ | ||
// we need to await before returning, otherwise the lambda will exit before sending the request. | ||
await new Promise((resolve) => { | ||
analytics().track({ | ||
event: 'Hello world', | ||
anonymousId: 'foo', | ||
}, () => resolve()) | ||
await new Promise((resolve) => | ||
analytics().track({ event: 'My Event', anonymousId: 'foo' }, resolve) | ||
) | ||
@@ -336,0 +334,0 @@ return { |
import { | ||
EventProperties, | ||
Traits, | ||
CoreAnalytics, | ||
@@ -14,2 +13,4 @@ CoreContext, | ||
Integrations, | ||
CoreExtraContext, | ||
CoreAnalyticsTraits, | ||
} from '@segment/analytics-core' | ||
@@ -40,4 +41,14 @@ import { AnalyticsSettings, validateSettings } from './settings' | ||
*/ | ||
type AdditionalContext = Record<string, any> | ||
export interface ExtraContext extends CoreExtraContext {} | ||
/** | ||
* Traits are pieces of information you know about a user that are included in an identify call. These could be demographics like age or gender, account-specific like plan, or even things like whether a user has seen a particular A/B test variation. Up to you! | ||
* Segment has reserved some traits that have semantic meanings for users, and we handle them in special ways. For example, Segment always expects email to be a string of the user’s email address. | ||
* | ||
* We’ll send this on to destinations like Mailchimp that require an email address for their tracking. | ||
* | ||
* You should only use reserved traits for their intended meaning. | ||
*/ | ||
export interface Traits extends CoreAnalyticsTraits {} | ||
class NodePriorityQueue extends PriorityQueue<Context> { | ||
@@ -93,2 +104,3 @@ constructor() { | ||
maxEventsInBatch: settings.maxEventsInBatch ?? 15, | ||
httpRequestTimeout: settings.httpRequestTimeout, | ||
flushInterval, | ||
@@ -166,3 +178,3 @@ }) | ||
previousId: string | ||
context?: AdditionalContext | ||
context?: ExtraContext | ||
timestamp?: Timestamp | ||
@@ -197,3 +209,3 @@ integrations?: Integrations | ||
traits?: Traits | ||
context?: AdditionalContext | ||
context?: ExtraContext | ||
timestamp?: Timestamp | ||
@@ -228,3 +240,3 @@ integrations?: Integrations | ||
traits?: Traits | ||
context?: AdditionalContext | ||
context?: ExtraContext | ||
integrations?: Integrations | ||
@@ -265,3 +277,3 @@ }, | ||
timestamp?: Timestamp | ||
context?: AdditionalContext | ||
context?: ExtraContext | ||
integrations?: Integrations | ||
@@ -325,3 +337,3 @@ }, | ||
properties?: EventProperties | ||
context?: AdditionalContext | ||
context?: ExtraContext | ||
timestamp?: Timestamp | ||
@@ -328,0 +340,0 @@ integrations?: Integrations |
@@ -29,2 +29,6 @@ import { ValidationError } from '@segment/analytics-core' | ||
flushInterval?: number | ||
/** | ||
* The maximum number of milliseconds to wait for an http request. Default: 10000 | ||
*/ | ||
httpRequestTimeout?: number | ||
} | ||
@@ -31,0 +35,0 @@ |
@@ -1,2 +0,8 @@ | ||
export { Analytics, Context, Plugin } from './app/analytics-node' | ||
export { | ||
Analytics, | ||
Context, | ||
Plugin, | ||
ExtraContext, | ||
Traits, | ||
} from './app/analytics-node' | ||
export type { AnalyticsSettings } from './app/settings' | ||
@@ -3,0 +9,0 @@ |
import { backoff, CoreContext } from '@segment/analytics-core' | ||
import { abortSignalAfterTimeout } from '../../lib/abort' | ||
import { tryCreateFormattedUrl } from '../../lib/create-url' | ||
@@ -25,2 +26,3 @@ import { extractPromiseParts } from '../../lib/extract-promise-parts' | ||
writeKey: string | ||
httpRequestTimeout?: number | ||
} | ||
@@ -41,2 +43,3 @@ | ||
private _closeAndFlushPendingItemsCount?: number | ||
private _httpRequestTimeout: number | ||
@@ -50,2 +53,3 @@ constructor({ | ||
writeKey, | ||
httpRequestTimeout, | ||
}: PublisherProps) { | ||
@@ -60,2 +64,3 @@ this._maxRetries = maxRetries | ||
) | ||
this._httpRequestTimeout = httpRequestTimeout ?? 10000 | ||
} | ||
@@ -182,4 +187,8 @@ | ||
let failureReason: unknown | ||
const [signal, timeoutId] = abortSignalAfterTimeout( | ||
this._httpRequestTimeout | ||
) | ||
try { | ||
const response = await fetch(this._url, { | ||
signal: signal, | ||
method: 'POST', | ||
@@ -193,2 +202,3 @@ headers: { | ||
}) | ||
clearTimeout(timeoutId) | ||
@@ -195,0 +205,0 @@ if (response.ok) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
152292
104
2404
3
338
+ Added@segment/analytics-core@1.1.5(transitive)
- Removed@segment/analytics-core@1.1.4(transitive)