Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fetch transport implementation #1823

Open
wants to merge 113 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 108 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
cf5c443
feat: upgrade all the packages to latest
saikumarrs Aug 9, 2024
92b9132
chore: fix all formatting issues
saikumarrs Aug 9, 2024
aca402a
feat: add fetch queue plugin
saikumarrs Aug 9, 2024
cd729a9
refactor: remove unwanted getData method
saikumarrs Aug 9, 2024
2de8561
chore: upgrade all sample apps to latest
saikumarrs Aug 12, 2024
fbb0616
feat: add type interfaces for different transports
saikumarrs Aug 12, 2024
da6a742
feat: add support for different transport types
saikumarrs Aug 16, 2024
7f7e775
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Aug 16, 2024
06e3dbe
chore: fix tsconfig files
saikumarrs Aug 16, 2024
0a9c6ef
fix: fetch transport
saikumarrs Aug 17, 2024
9a42ae6
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Aug 20, 2024
04bcb8f
chore: update loading snippet in all the examples
saikumarrs Aug 20, 2024
e9d5c39
chore: clean up types
saikumarrs Aug 20, 2024
45ea91d
fix: headers in requests
saikumarrs Aug 20, 2024
b28a463
chore: clean up transports
saikumarrs Aug 23, 2024
e0dbe81
fix: update pageleave utility to accept arguments
saikumarrs Aug 23, 2024
ed98903
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Aug 26, 2024
ca0a310
fix: implement page unload behavior
saikumarrs Aug 26, 2024
7a9cac9
chore: address review comments from coderabbitai
saikumarrs Aug 27, 2024
2ed69c5
chore: upgrade all packages to latest
saikumarrs Aug 27, 2024
c8dfeb3
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Aug 30, 2024
c9d3d5b
fix: xhr queue plugin
saikumarrs Aug 30, 2024
3920e5c
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Sep 2, 2024
06e0fd8
chore: update size limit
saikumarrs Sep 2, 2024
2100e88
chore: upgrade all the packages to latest
saikumarrs Sep 2, 2024
a7c9795
chore: lint and format fixes
saikumarrs Sep 2, 2024
13c82a3
chore: add missing changes
saikumarrs Sep 2, 2024
63462f5
fix: retry queue
saikumarrs Sep 3, 2024
ce011f6
fix: get rid of deprecated plugins
saikumarrs Sep 3, 2024
8d58a6f
refactor: move code around to optimize
saikumarrs Sep 4, 2024
752e0d5
refactor: dissolve queue status object constants
saikumarrs Sep 4, 2024
01040d1
refactor: retry queue improvements
saikumarrs Sep 4, 2024
81b0d6e
refactor: optimize size with the help of special prefix
saikumarrs Sep 4, 2024
313cd86
Revert "refactor: optimize size with the help of special prefix"
saikumarrs Sep 6, 2024
054f866
refactor: remove enum
saikumarrs Sep 6, 2024
707d9b3
chore: mangle private properties
saikumarrs Sep 6, 2024
fb6ddde
refactor: use constant
saikumarrs Sep 6, 2024
5d5fd8e
chore: mangle private properties
saikumarrs Sep 6, 2024
e8f6ef5
Revert "Revert "refactor: optimize size with the help of special pref…
saikumarrs Sep 6, 2024
1f5a020
refactor: rename private identifiers
saikumarrs Sep 6, 2024
96dcc3a
refactor: rename private identifiers
saikumarrs Sep 6, 2024
9d2bf05
chore: fix misc issues
saikumarrs Sep 6, 2024
1c71f5c
test: implement test suite for HttpClient
saikumarrs Sep 9, 2024
b426b30
fix: request handling logic
saikumarrs Sep 10, 2024
517857c
test: add tests to improve coverage
saikumarrs Sep 10, 2024
318abae
test: add tests to improve coverage
saikumarrs Sep 10, 2024
8c81b40
test: add tests to improve coverage
saikumarrs Sep 10, 2024
6b27709
Merge branch 'develop' into feat.fetch-transport-plugin-sdk-1730
saikumarrs Sep 10, 2024
09841d3
chore: restrict security check to only prod deps
saikumarrs Sep 10, 2024
75b7c0f
chore: complete tests for queue reclaim
saikumarrs Sep 10, 2024
a87496e
test: add tests to improve coverage
saikumarrs Sep 11, 2024
3a19e5c
test: finish tests for retry queue module
saikumarrs Sep 11, 2024
d58acae
test: improve coverage and refactor ext src loader
saikumarrs Sep 11, 2024
ddbdddb
test: add tests to improve coverage
saikumarrs Sep 11, 2024
194effb
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 3, 2024
f5c05ca
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 3, 2024
8ada54b
chore: reset unwanted files
saikumarrs Oct 3, 2024
a517797
chore: revert unnecessary changes to the html files
saikumarrs Oct 3, 2024
81614d2
refactor: js file loader
saikumarrs Oct 3, 2024
7b91104
chore: revert unnecessary changes
saikumarrs Oct 3, 2024
2f2042b
chore: fix lint and format issue
saikumarrs Oct 4, 2024
d2fe623
refactor: move utility function to common package and fix misc issues
saikumarrs Oct 7, 2024
ed13aab
fix: handle inProgress queue from older SDKs
saikumarrs Oct 7, 2024
f4f8cb5
fix: remove deprecated bugsnag plugin from manager
saikumarrs Oct 7, 2024
e6ebb7f
fix: events callback using keepalive flag
saikumarrs Oct 7, 2024
7740b8c
refactor: address sonarcloud issues
saikumarrs Oct 7, 2024
bef3752
test: improve code coverage
saikumarrs Oct 7, 2024
954181d
refactor: simiply code and improve coverage
saikumarrs Oct 7, 2024
d7df452
test: improve code coverage
saikumarrs Oct 8, 2024
e129c5a
test: improve code coverage
saikumarrs Oct 8, 2024
e5ec7a1
test: improve code coverage
saikumarrs Oct 8, 2024
47f0ecb
fix: invalid invocation
saikumarrs Oct 9, 2024
7f0cb17
fix: upgrade all packages to latest
saikumarrs Oct 9, 2024
9b94c64
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 11, 2024
74e9c44
chore: organize time utilities
saikumarrs Oct 11, 2024
f4f2e50
test: improve code coverage for device mode dest utils
saikumarrs Oct 11, 2024
f626207
refactor: fix the function invocation
saikumarrs Oct 14, 2024
35e9f1a
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 14, 2024
4e7b078
fix: upgrade all packages to latest
saikumarrs Oct 14, 2024
db4cf6b
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 15, 2024
2458557
fix: backward compatibility
saikumarrs Oct 15, 2024
0889485
fix: address ai bot review comments
saikumarrs Oct 15, 2024
d2df7e7
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 21, 2024
3acc60d
chore: clean up code to remove unnecessary logic
saikumarrs Oct 21, 2024
de30f6c
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Oct 22, 2024
0fe9fba
test: add test for data plane events queue utilities
saikumarrs Oct 22, 2024
862d33a
test: add tests for data plane events queue
saikumarrs Oct 22, 2024
dca0059
chore: fix named inputs
saikumarrs Oct 22, 2024
53a7f00
test: add more tests for data plane events queue
saikumarrs Oct 22, 2024
e6de654
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Nov 6, 2024
50c9e89
test: refactor test suite as per ai bot comments
saikumarrs Nov 6, 2024
9758426
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Nov 8, 2024
d707cae
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Nov 8, 2024
f9dc898
chore: replace favicon url to prevent redirection
saikumarrs Nov 8, 2024
9493110
test: improve code coverage for config manager
saikumarrs Nov 8, 2024
ab24ef7
refactor: address ai bot review comments
saikumarrs Nov 8, 2024
c9be93a
test: improve code coverage
saikumarrs Nov 8, 2024
bd79c67
test: improve code coverage
saikumarrs Nov 8, 2024
7581b9b
chore: use satisfies instead of typecasting
saikumarrs Nov 8, 2024
f9397de
fix: address ai bot review comments
saikumarrs Nov 9, 2024
46d040f
fix: address ai bot review comments
saikumarrs Nov 9, 2024
be05bbb
fix: data type
saikumarrs Nov 9, 2024
d0f33a7
fix: restore script load error behavior
saikumarrs Nov 9, 2024
b0c51ff
fix: address review comments, format and lint issues
saikumarrs Nov 9, 2024
e066615
chore: update snippet version
saikumarrs Nov 9, 2024
71269a9
test: fix coverage issues in data plane events queue
saikumarrs Nov 9, 2024
9b51331
fix: correct typo and improve test coverage
saikumarrs Nov 9, 2024
a7ed3a9
test: improve code coverage
saikumarrs Nov 9, 2024
8463fcd
chore: fix loading scripts build issue
saikumarrs Nov 9, 2024
4f8b4d1
chore: fix spec file as well
saikumarrs Nov 9, 2024
783107e
Merge remote-tracking branch 'origin/develop' into feat.fetch-transpo…
saikumarrs Nov 11, 2024
87a5b80
fix: load options normalization for boolean values
saikumarrs Nov 12, 2024
789d370
fix: plugin import statements
saikumarrs Nov 14, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .coderabbit/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# .coderabbit/config.yml
reviews:
instructions:
- pattern: '**/*'
instruction: |
# Ignore code coverage issues
Do not mention code coverage warnings or code coverage reports in the review.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ tsconfig.build.tsbuildinfo
nativeSdkLoader.js
nativeSdkLoader.ts
assets/
package.json
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@
"CustomEvent",
"requestAnimationFrame",
"cancelAnimationFrame",
"navigator.sendBeacon",
"Uint8Array",
"Set",
"atob"
"atob",
"AbortController",
"fetch",
"Response"
]
},
"env": {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ permissions:
contents: read # This is required for actions/checkout

env:
NODE_OPTIONS: "--no-warnings"
NODE_OPTIONS: '--no-warnings'

jobs:
get-deploy-inputs:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-sanity-suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
current_version=$(jq -r .version packages/sanity-suite/package.json)
echo "CURRENT_VERSION_VALUE=$current_version" >> $GITHUB_ENV
echo "DATE=$(date)" >> $GITHUB_ENV

if [ "${{ inputs.environment }}" == "staging" ]; then
echo "AWS_ACCOUNT_ID=${{ secrets.AWS_STAGING_ACCOUNT_ID }}" >> $GITHUB_ENV
echo "AWS_S3_SYNC_ROLE=${{ secrets.AWS_STAGING_S3_SYNC_ROLE }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -101,7 +101,7 @@ jobs:

- name: Install AWS CLI
uses: unfor19/install-aws-cli-action@master

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ permissions:
contents: read # This is required for actions/checkout

env:
NODE_OPTIONS: "--no-warnings"
NODE_OPTIONS: '--no-warnings'
CACHE_MAX_AGE: 3600

jobs:
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/draft-new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ jobs:
pr_title: 'chore(release): pull ${{ steps.create-release.outputs.branch_name }} into main'
pr_body: |
:crown: *An automated PR*

This PR is created automatically by the GitHub Actions workflow to merge the release branch into the main branch.

Linear Ticket:
https://linear.app/rudderstack/issue/${{ github.event.inputs.release_ticket_id }}

Expand All @@ -134,4 +134,3 @@ jobs:
console.error(`Error deleting branch ${branchToDelete}:`, error);
process.exit(1); // Fail the workflow if branch deletion fails
}

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
types: ['opened', 'reopened', 'synchronize']

env:
NODE_OPTIONS: "--no-warnings"
NODE_OPTIONS: '--no-warnings'
BASE_REF: ${{ github.event.pull_request.base.sha || 'HEAD' }}

jobs:
Expand Down Expand Up @@ -62,6 +62,7 @@ jobs:

- name: Execute code quality checks
run: |
npm run check:circular
npm run check:duplicates

- name: Build the project
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests-and-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
types: ['opened', 'reopened', 'synchronize']

env:
NODE_OPTIONS: "--no-warnings"
NODE_OPTIONS: '--no-warnings'
BASE_REF: ${{ github.event.pull_request.base.sha || 'HEAD' }}

jobs:
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,8 @@ tsconfig.build.tsbuildinfo

.nx/cache
.nx/workspace-data

.angular/
build/
vendor/

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.11.1
20.18.0
20 changes: 9 additions & 11 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
dist/
node_modules/
reports/
stats/
# Include patterns from .gitignore
# .gitignore

# Additional Prettier-specific ignore patterns
**/public/index.html
assets/
cdnSDK.js
cdnSDKv3.js
CHANGELOG.md
CHANGELOG_LATEST.md
CONTRIBUTING.md

examples/chrome-extension/**/rudderAnalytics.js
examples/chrome-extension/**/foreground.js
examples/**/index.html
**/public/index.html

/.nx/cache
/.nx/workspace-data
examples/gatsby/sample-gatsby-site/public/
examples/gatsby/sample-gatsby-plugin-usage/public/
**/nativeSdkLoader.js
composer.lock
saikumarrs marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 6 additions & 6 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ As far as the law allows, the software comes as is, without any warranty or cond

## Definitions

The *licensor* is the entity offering these terms, and the *software* is the software the licensor makes available under these terms, including any portion of it.
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.

*you* refers to the individual or entity agreeing to these terms.
_you_ refers to the individual or entity agreeing to these terms.

*your company* is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. *control* means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.

*your licenses* are all the licenses granted to you for the software under these terms.
_your licenses_ are all the licenses granted to you for the software under these terms.

*use* means anything you do with the software requiring one of your licenses.
_use_ means anything you do with the software requiring one of your licenses.

*trademark* means trademarks, service marks, and similar rights.
_trademark_ means trademarks, service marks, and similar rights.
23 changes: 23 additions & 0 deletions babel-plugin-mark-private.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function renamePrivateMember(t, node) {
if (node.accessibility === 'private') {
if (t.isIdentifier(node.key)) {
node.key.name = `private_${node.key.name}`;
} else if (t.isStringLiteral(node.key)) {
node.key.value = `private_${node.key.value}`;
}
// Handle other cases if necessary
}
}
saikumarrs marked this conversation as resolved.
Show resolved Hide resolved

export default function ({ types: t }) {
return {
visitor: {
ClassMethod(path) {
renamePrivateMember(t, path.node);
},
ClassProperty(path) {
renamePrivateMember(t, path.node);
},
},
};
}
2 changes: 1 addition & 1 deletion examples/angular/sample-app/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<script>
(function() {
"use strict";
window.RudderSnippetVersion = "3.0.30";
window.RudderSnippetVersion = "3.0.39";
var identifier = "rudderanalytics";
if (!window[identifier]) {
window[identifier] = [];
Expand Down
32 changes: 18 additions & 14 deletions examples/chrome-extension/background-script-websockets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ It can also give you more insights about how to turn a v2 extension to v3.

In other words, this is a **working, installable v3 extension** example meant for you to **jumpstart** the development of your own extension.


## Installation

- **Fork** this repo, then **clone your forked repo locally**. If you don't have a github account, you can simply download a zip of the repo and unzip it on your computer.
- **Open [the extensions page](chrome://extensions)** in your browser: `chrome://extensions`. This link works on any chromium-based browser.
- If you did not do it already, **toggle the "developer mode"**. This is usually a toggle button at the top right of the extensions page.
Expand All @@ -21,18 +21,20 @@ In other words, this is a **working, installable v3 extension** example meant fo
- **Done!** A new extension called _Chrome Addon v3 Starter_ should have appeared in the list.

## Q&A

> Does this work only on Chrome or on **other web browsers** as well?

At the moment, this works on every chromium-based web browser that supports v3 extensions.
Therefore, you should be able to install this extension on any of the following browsers (as long as they are up-to-date):

- _Free and open-source browsers_:
- Chromium
- Brave
- Chromium
- Brave
- _Proprietary browsers_:
- Chrome
- Edge
- Vivaldi
- Opera
- Chrome
- Edge
- Vivaldi
- Opera

> So it doesn't work on **Firefox** or **Safari**?

Expand Down Expand Up @@ -68,6 +70,7 @@ You should read the [official migration page (v2 to v3)](https://developer.chrom
Using the debugger if your service worker is not loaded is not possible.

However, if you want to test some piece of code before putting it in your service worker, you can:

- load your extension with a working version of the service worker.
- click on "service worker" on the page _chrome://extensions_. This will open the console attached to the service worker.
- paste your code in the console and see if any error is logged.
Expand All @@ -86,15 +89,16 @@ Note that in this console, you have access to anything your service worker has a
- If you forked this repo and cloned your own fork locally, git will push to your fork on your account automatically (i.e. use the command `git push` or `git push origin <your-branch>`).

- If you downloaded a zip or simply cloned this repo locally, do the following:
- Create a github account if you don't already have one and install git on your machine.
- Create a new (empty) repo on your github and copy its url.
- Open a terminal in the folder where the extension is cloned.
- Run the command `git init`, then `git commit -am "Initial commit"`
- Run the command `git remote add origin <url-of-your-repo>`
- Run `git push -u origin master`. The extension code is now on your repo, on brnach _master_.
- If you want, you can make the _master_ branch the default one and delete the _main_ branch in the settings of your repo.
- Create a github account if you don't already have one and install git on your machine.
- Create a new (empty) repo on your github and copy its url.
- Open a terminal in the folder where the extension is cloned.
- Run the command `git init`, then `git commit -am "Initial commit"`
- Run the command `git remote add origin <url-of-your-repo>`
- Run `git push -u origin master`. The extension code is now on your repo, on brnach _master_.
- If you want, you can make the _master_ branch the default one and delete the _main_ branch in the settings of your repo.

## External resources

- [Official feature summary for manifest v3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-overview/)
- [Migrating from v2 to v3](https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/) + [very useful checklist once you think you are done](https://developer.chrome.com/docs/extensions/mv3/mv3-migration-checklist/)
- [Excellent write-ups of a migration](https://github.com/kentbrew/learning-manifest-v3)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
body {
background-color: #222;
color: #eee;
background-color: #222;
color: #eee;

width: 16rem;
height: 4rem;
width: 16rem;
height: 4rem;
}

.special-text {
color: red;
color: red;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="popup.css">
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="popup.css" />
<title>RudderStack SDK: Chrome Extension Background Script Sample</title>
</head>
<body>
</head>
<body>
This is the <span class="special-text">HTML</span> body of the addon.
</body>
</body>
</html>
Loading
Loading