Skip to content

Commit

Permalink
Merge branch 'develop' into chore.upgrade-to-node-20
Browse files Browse the repository at this point in the history
  • Loading branch information
bardisg authored Oct 9, 2023
2 parents 5a17bbf + a58c919 commit 69e1be7
Show file tree
Hide file tree
Showing 20 changed files with 198 additions and 75 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/build-and-quality-checks-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ env:
jobs:
build:
name: Build & Code Quality Checks v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v3
with:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-beta-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ env:
jobs:
deploy-tag:
name: Deploy BETA/BugBash Feature v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/heads/beta/') || startsWith(github.ref, 'refs/tags/bugbash')

steps:
- name: Extract feature name from branch
id: extract_branch
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-dev-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ env:
jobs:
deploy-tag:
name: Deploy to DEV v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/v3-hotfix/') || startsWith(github.ref, 'refs/heads/develop/') || github.event.pull_request.merged == true

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-npm-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ env:
jobs:
deploy-tag:
name: Deploy to NPM v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main') || github.event.pull_request.merged == true

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-prod-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ env:
jobs:
deploy-tag:
name: Deploy to PROD v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main') || github.event.pull_request.merged == true

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-sanity-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ env:
jobs:
deploy-tag:
name: Deploy Sanity Suite
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-staging-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ env:
jobs:
deploy-tag:
name: Deploy to STAGING v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/develop') || startsWith(github.ref, 'refs/heads/v3-hotfix-release') || startsWith(github.ref, 'refs/heads/v3-release') || startsWith(github.ref, 'refs/heads/v3-hotfix/')

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/publish-new-release-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ env:
jobs:
release:
name: Publish new release v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: (startsWith(github.event.pull_request.head.ref, 'v3-release/') || startsWith(github.event.pull_request.head.ref, 'v3-hotfix-release/')) && github.event.pull_request.merged == true # only merged pull requests must trigger this job

steps:
- name: Extract version from branch name (for release branches)
id: extract-version
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/rollback-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ env:
jobs:
deploy-tag:
name: Rollback v3
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/main')

steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/test-v3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ env:
jobs:
build:
name: 'Unit Tests, Coverage & Sonar v3'
runs-on: ubuntu-latest
runs-on: [self-hosted, Linux, X64]

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Setup Node
uses: actions/setup-node@v3
with:
Expand Down
9 changes: 5 additions & 4 deletions packages/analytics-js-common/src/types/IRudderAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ import { ApiCallback, ApiOptions } from './EventApi';
import { AnonymousIdOptions, LoadOptions } from './LoadOptions';
import { ApiObject } from './ApiObject';
import { ILogger } from './Logger';
import { IdentifyTraits } from './traits';

export type AnalyticsIdentifyMethod = {
(
userId?: string,
traits?: Nullable<ApiObject>,
traits?: Nullable<IdentifyTraits>,
options?: Nullable<ApiOptions>,
callback?: ApiCallback,
): void;
(userId: string, traits: Nullable<ApiObject>, callback: ApiCallback): void;
(userId: string, traits: Nullable<IdentifyTraits>, callback: ApiCallback): void;
(userId: string, callback: ApiCallback): void;
(traits: Nullable<ApiObject>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
(traits: Nullable<ApiObject>, callback?: ApiCallback): void;
(traits: Nullable<IdentifyTraits>, options: Nullable<ApiOptions>, callback?: ApiCallback): void;
(traits: Nullable<IdentifyTraits>, callback?: ApiCallback): void;
};

export type AnalyticsPageMethod = {
Expand Down
91 changes: 91 additions & 0 deletions packages/analytics-js-common/src/types/traits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { ApiObject } from './ApiObject';

type Address = {
city?: string;
City?: string;
country?: string;
Country?: string;
postalCode?: string;
state?: string;
State?: string;
street?: string;
};

type Company = {
name?: string;
id?: string;
industry?: string;
employee_count?: string;
plan?: string;
};

/**
* Represents a traits object in the Identify API
*/
export type IdentifyTraits = {
id?: string;
userId?: string;
firstName?: string;
firstname?: string;
first_name?: string;
lastName?: string;
lastname?: string;
last_name?: string;
name?: string;
Name?: string;
age?: number;
email?: string;
Email?: string;
'E-mail'?: string;
phone?: string;
address?: string | Address;
birthday?: string;
company?: Company;
createdAt?: string;
description?: string;
gender?: string;
title?: string;
username?: string;
website?: string;
avatar?: string;
zip?: string | number;
state?: string;
State?: string;
dob?: string;
employed?: string | boolean;
education?: string;
married?: string | boolean;
customerType?: string | number;
euConsent?: string;
euConsentMessage?: string;
newEmail?: string;
tags?: string | string[];
removeTags?: string | string[];
prospect?: string | boolean;
doubleOptin?: string | boolean;
event_id?: string;
constructor?: Record<string, string>;
organization?: string;
region?: string;
anonymous?: string | boolean;
country?: string;
custom?: string;
ip?: string;
privateAttributeNames?: any;
secondary?: any;
customPageId?: string;
isRudderEvents?: boolean;
optOutType?: boolean | string | number;
groupType?: string | number;
anonymousId?: string | number;
ip_address?: string;
number?: string | number;
[index: string]:
| string
| number
| boolean
| ApiObject
| null
| (string | number | boolean | null | ApiObject)[]
| undefined;
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Nullable } from '../types/Nullable';
import { isObjectLiteralAndNotNull, mergeDeepRight } from './object';
import { isDefined, isDefinedAndNotNull, isFunction, isNull, isString } from './checks';
import { tryStringify } from './string';
import { IdentifyTraits } from '../types/traits';

export type PageCallOptions = {
category?: string;
Expand All @@ -23,7 +24,7 @@ export type TrackCallOptions = {

export type IdentifyCallOptions = {
userId?: string | null;
traits?: Nullable<ApiObject>;
traits?: Nullable<IdentifyTraits>;
options?: Nullable<ApiOptions>;
callback?: ApiCallback;
};
Expand Down Expand Up @@ -196,14 +197,14 @@ const trackArgumentsToCallOptions = (
* Normalise the overloaded arguments of the identify call facade
*/
const identifyArgumentsToCallOptions = (
userId?: Nullable<ApiObject | string | number>,
traits?: Nullable<ApiObject> | ApiCallback,
userId?: Nullable<IdentifyTraits | string | number>,
traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback,
options?: Nullable<ApiOptions> | ApiCallback,
callback?: ApiCallback,
): IdentifyCallOptions => {
const payload: IdentifyCallOptions = {
userId: userId as string,
traits: traits as Nullable<ApiObject>,
traits: traits as Nullable<IdentifyTraits>,
options: options as Nullable<ApiOptions>,
};

Expand All @@ -213,7 +214,7 @@ const identifyArgumentsToCallOptions = (

if (isFunction(options)) {
payload.userId = userId as string;
payload.traits = traits as Nullable<ApiObject>;
payload.traits = traits as Nullable<IdentifyTraits>;
delete payload.options;
payload.callback = options as ApiCallback;
}
Expand All @@ -229,7 +230,7 @@ const identifyArgumentsToCallOptions = (
// Explicitly set null to prevent resetting the existing value
// in the Analytics class
payload.userId = null;
payload.traits = userId as Nullable<ApiObject>;
payload.traits = userId as Nullable<IdentifyTraits>;
payload.options = traits as Nullable<ApiOptions>;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ApiCallback, ApiOptions } from '@rudderstack/analytics-js-common/types/
import { IntegrationOpts } from '@rudderstack/analytics-js-common/types/Integration';
import { Nullable } from '@rudderstack/analytics-js-common/types/Nullable';
import { IErrorHandler } from '@rudderstack/analytics-js-common/types/ErrorHandler';
import { IdentifyTraits } from '@rudderstack/analytics-js-common/types/traits';
import { checks } from '../shared-chunks/common';
import { eventMethodOverloads, destinations } from '../shared-chunks/deviceModeDestinations';
import { DeviceModeDestinationsAnalyticsInstance } from './types';
Expand Down Expand Up @@ -90,8 +91,8 @@ const createDestinationInstance = (
eventMethodOverloads.trackArgumentsToCallOptions(event, properties, options, callback),
),
identify: (
userId?: string | number | Nullable<ApiObject>,
traits?: Nullable<ApiObject> | ApiCallback,
userId?: string | number | Nullable<IdentifyTraits>,
traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback,
options?: Nullable<ApiOptions> | ApiCallback,
callback?: ApiCallback,
) =>
Expand Down
5 changes: 3 additions & 2 deletions packages/analytics-js/src/app/RudderAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { ApiCallback, ApiOptions } from '@rudderstack/analytics-js-common/types/
import { ApiObject } from '@rudderstack/analytics-js-common/types/ApiObject';
import { RS_APP } from '@rudderstack/analytics-js-common/constants/loggerContexts';
import { isString } from '@rudderstack/analytics-js-common/utilities/checks';
import { IdentifyTraits } from '@rudderstack/analytics-js-common/types/traits';
import { GLOBAL_PRELOAD_BUFFER } from '../constants/app';
import { getPreloadedLoadEvent } from '../components/preloadBuffer';
import { PreloadedEventCall } from '../components/preloadBuffer/types';
Expand Down Expand Up @@ -199,8 +200,8 @@ class RudderAnalytics implements IRudderAnalytics<IAnalytics> {
* Process identify arguments and forward to page call
*/
identify(
userId?: string | number | Nullable<ApiObject>,
traits?: Nullable<ApiObject> | ApiCallback,
userId?: string | number | Nullable<IdentifyTraits>,
traits?: Nullable<IdentifyTraits> | Nullable<ApiOptions> | ApiCallback,
options?: Nullable<ApiOptions> | ApiCallback,
callback?: ApiCallback,
) {
Expand Down
Loading

0 comments on commit 69e1be7

Please sign in to comment.