Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Change the args of the main methods to be optional #203

Merged
merged 4 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 4.0.4 / 2020-09-11

- Change the arguments of the main methods to be optional in the typedef to match the documentation. (#203)

# 4.0.3 / 2020-09-11

- Bump `debug` to a version that fixed security vulnerabilities.
Expand Down
30 changes: 15 additions & 15 deletions lib/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,10 @@ Analytics.prototype.add = function(integration: {
*/

Analytics.prototype.identify = function(
id: string,
traits: unknown,
options: SegmentOpts,
fn: Function | SegmentOpts
id?: string,
traits?: unknown,
options?: SegmentOpts,
fn?: Function | SegmentOpts
): SegmentAnalytics {
// Argument reshuffling.
/* eslint-disable no-unused-expressions, no-sequences */
Expand Down Expand Up @@ -355,9 +355,9 @@ Analytics.prototype.user = function(): object {

Analytics.prototype.group = function(
id: string,
traits: unknown,
options: unknown,
fn: unknown
traits?: unknown,
options?: unknown,
fn?: unknown
): SegmentAnalytics {
/* eslint-disable no-unused-expressions, no-sequences */
if (!arguments.length) return group;
Expand Down Expand Up @@ -399,9 +399,9 @@ Analytics.prototype.group = function(

Analytics.prototype.track = function(
event: string,
properties: unknown,
options: unknown,
fn: unknown
properties?: unknown,
options?: unknown,
fn?: unknown
): SegmentAnalytics {
// Argument reshuffling.
/* eslint-disable no-unused-expressions, no-sequences */
Expand Down Expand Up @@ -564,11 +564,11 @@ Analytics.prototype.trackSubmit = Analytics.prototype.trackForm = function(
*/

Analytics.prototype.page = function(
category: string,
name: string,
properties: any,
options: any,
fn: unknown
category?: string,
name?: string,
properties?: any,
options?: any,
fn?: unknown
): SegmentAnalytics {
// Argument reshuffling.
/* eslint-disable no-unused-expressions, no-sequences */
Expand Down
30 changes: 15 additions & 15 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ export declare namespace SegmentAnalytics {
* Identify a user by optional `id` and `traits`.
*/
identify(
id: string,
traits: unknown,
options: SegmentOpts,
fn: Function | SegmentOpts
id?: string,
traits?: unknown,
options?: SegmentOpts,
fn?: Function | SegmentOpts
): AnalyticsJS;

/**
Expand All @@ -147,19 +147,19 @@ export declare namespace SegmentAnalytics {
*/
group(
id: string,
traits: unknown,
options: unknown,
fn: unknown
traits?: unknown,
options?: unknown,
fn?: unknown
): AnalyticsJS;

/**
* Track an `event` that a user has triggered with optional `properties`.
*/
track(
event: string,
properties: unknown,
options: unknown,
fn: unknown
properties?: unknown,
options?: unknown,
fn?: unknown
): AnalyticsJS;

/**
Expand Down Expand Up @@ -220,11 +220,11 @@ export declare namespace SegmentAnalytics {
* `name` and `properties`.
*/
page(
category: string,
name: string,
properties: any,
options: any,
fn: unknown
category?: string,
name?: string,
properties?: any,
options?: any,
fn?: unknown
): AnalyticsJS;

/**
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-core",
"author": "Segment <[email protected]>",
"version": "4.0.3",
"version": "4.0.4",
"description": "The hassle-free way to integrate analytics into any web application.",
"types": "lib/index.d.ts",
"keywords": [
Expand Down