Skip to content

feat: analytics.js 2.2.0 #214

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

Merged
merged 1 commit into from
Nov 13, 2023
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: 1 addition & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ module.exports = {
ecmaVersion: 13,
sourceType: "module",
},
plugins: [
"vitest"
],
plugins: ["vitest"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
},
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/checkpr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ env:
node_version: "18"
pnpm_version: "8"


# This is to avoid running multiple actions when a PR is updated repeatedly. See
# https://docs.github.com/en/actions/using-jobs/using-concurrency
concurrency:
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
We follow the format used by [Open Telemetry](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md).

## Version 2.2.0 (2023-11-13)

### Added

- support passing `additionalAttribution`

### Refactor

- Stop publishing to codebuild/s3
- Update dependencies

## Version 2.1.0 (2023-08-30)

### Added
Expand Down
21 changes: 7 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ npm install @topsort/analytics.js --save
url: "https://api.topsort.com", // change this if you want to test against the staging environment
};
</script>
<script src="https://unpkg.com/@topsort/analytics.js@2.1.0/dist/ts.js"></script>
<script src="https://unpkg.com/@topsort/analytics.js@2.2.0/dist/ts.js"></script>
```

### Add markup to your products
Expand All @@ -39,24 +39,16 @@ Either mix quotes (single/double) or escape certain characters inside your value
const newvalue = currentvalue.replace('"', "&quot;").replace("'", "&apos;"); // etc.
```

Add the following markup to promoted products:
Add the following markup to promoted products:

```html
<div
class="product"
data-ts-resolved-bid="<resolvedBidId>"
>
...
</div>
<div class="product" data-ts-resolved-bid="<resolvedBidId>">...</div>
```

and the following for organic products (which is optional)

```html
<div
class="product"
data-ts-product="<productId>"
>
...
</div>
<div class="product" data-ts-product="<productId>">...</div>
```

Additionally, in case not all the container is clickable (i.e., does not produce an action or does not take you to the product page) or parts of it lead you to a non-related product page, make sure to use the `data-ts-clickable` attribute to indicate what portions of the product should count as a conversion.
Expand Down Expand Up @@ -93,6 +85,7 @@ Finally, in case you are using banners and want to have further control on the a
...
</div>
```

# E2E tests

Execute `npm run test:e2e`, at the end it will show you the url you need to visit to test the library.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@topsort/analytics.js",
"version": "2.1.0",
"version": "2.2.0",
"description": "JS library to automatically report events to Topsort's Analytics",
"main": "dist/ts.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 51 additions & 8 deletions tests/test.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
td.ok {
background-color: #66bb6a;
}
#vanilla-js, #root, a:active, a:visited, a:hover {
#vanilla-js,
#root,
a:active,
a:visited,
a:hover {
color: white;
}
button {
Expand Down Expand Up @@ -75,15 +79,54 @@
</table>
</div>
<div id="vanilla-js">
<div data-ts-product="product-id-impression-1" data-ts-resolved-bid="17785055-9d99-4b4e-9fb0-5fc4cff0af3f">P</div>
<div id="click1" data-ts-product="product-id-click-1" data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e3ba5d">P</div>
<div id="click2" data-ts-product="product-id-click-2" data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e30000"><a id="click-area" style="visibility: hidden;">Link</a></div>
<div data-ts-action="purchase" data-ts-items='[{"product": "product-id-purchase-1", "quantity":1, "price": 2399}, {"product": "product-id-purchase-2", "quantity": 2, "price": 399}]'>P</div>
<div
data-ts-product="product-id-impression-1"
data-ts-resolved-bid="17785055-9d99-4b4e-9fb0-5fc4cff0af3f"
>
P
</div>
<div
id="click1"
data-ts-product="product-id-click-1"
data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e3ba5d"
>
P
</div>
<div
id="click2"
data-ts-product="product-id-click-2"
data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e30000"
>
<a id="click-area" style="visibility: hidden">Link</a>
</div>
<div
data-ts-action="purchase"
data-ts-items='[{"product": "product-id-purchase-1", "quantity":1, "price": 2399}, {"product": "product-id-purchase-2", "quantity": 2, "price": 399}]'
>
P
</div>
<div id="old-product" data-ts-product="product-id-attr-impression-1">P</div>
<div id="hidden-product" data-ts-product="product-id-impression-hidden" style="visibility: none;">H</div>
<div
id="hidden-product"
data-ts-product="product-id-impression-hidden"
style="visibility: none"
>
H
</div>

<div id="banner" data-ts-resolved-bid="17785055-1111-4b4e-9fb0-5fc4cff0af3f">Banner</div>
<div id="banner-product" data-ts-product="additional-product-banner" data-ts-resolved-bid="inherit">P</div>
<div
id="banner"
data-ts-resolved-bid="17785055-1111-4b4e-9fb0-5fc4cff0af3f"
>
Banner
</div>
<div
id="banner-product"
data-ts-product="additional-product-banner"
data-ts-resolved-bid="inherit"
>
P
</div>
</div>
<div id="root"></div>
<script>
Expand Down
18 changes: 4 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
"compilerOptions": {
"lib": [
"ESNext",
"dom"
],
"types": [
"node"
],
"lib": ["ESNext", "dom"],
"types": ["node"],
"module": "es2020",
"outDir": "dist",
"removeComments": true,
Expand All @@ -27,11 +22,6 @@
"noUnusedParameters": true,
"jsx": "react"
},
"include": [
"./**/*.ts",
"./**/*.tsx"
],
"exclude": [
"node_modules/**/*"
]
"include": ["./**/*.ts", "./**/*.tsx"],
"exclude": ["node_modules/**/*"]
}
20 changes: 4 additions & 16 deletions tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"compilerOptions": {
"lib": [
"es2020",
"dom"
],
"lib": ["es2020", "dom"],
"target": "es2015",
"strict": true,
"allowUnreachableCode": false,
Expand All @@ -26,17 +23,8 @@
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"alwaysStrict": false,
"typeRoots": [
"@types",
"node_modules/@types"
]
"typeRoots": ["@types", "node_modules/@types"]
},
"include": [
"src/**/*.ts",
"@types/**/*.ts"
],
"exclude": [
"node_modules",
"src/**/*.test.ts"
]
"include": ["src/**/*.ts", "@types/**/*.ts"],
"exclude": ["node_modules", "src/**/*.test.ts"]
}