Skip to content

Commit 699aaa0

Browse files
authored
feat: analytics.js 2.2.0
Main change being supporting `additionalAttribution`. PR: #214
1 parent 5fdb57b commit 699aaa0

File tree

9 files changed

+80
-58
lines changed

9 files changed

+80
-58
lines changed

Diff for: .eslintrc.cjs

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ module.exports = {
1313
ecmaVersion: 13,
1414
sourceType: "module",
1515
},
16-
plugins: [
17-
"vitest"
18-
],
16+
plugins: ["vitest"],
1917
rules: {
2018
"@typescript-eslint/no-explicit-any": "off",
2119
},

Diff for: .github/workflows/checkpr.yml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ env:
1515
node_version: "18"
1616
pnpm_version: "8"
1717

18-
1918
# This is to avoid running multiple actions when a PR is updated repeatedly. See
2019
# https://docs.github.com/en/actions/using-jobs/using-concurrency
2120
concurrency:

Diff for: CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77
We follow the format used by [Open Telemetry](https://github.com/open-telemetry/opentelemetry-python/blob/main/CHANGELOG.md).
88

9+
## Version 2.2.0 (2023-11-13)
10+
11+
### Added
12+
13+
- support passing `additionalAttribution`
14+
15+
### Refactor
16+
17+
- Stop publishing to codebuild/s3
18+
- Update dependencies
19+
920
## Version 2.1.0 (2023-08-30)
1021

1122
### Added

Diff for: README.md

+7-14
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ npm install @topsort/analytics.js --save
2828
url: "https://api.topsort.com", // change this if you want to test against the staging environment
2929
};
3030
</script>
31-
<script src="https://unpkg.com/@topsort/analytics.js@2.1.0/dist/ts.js"></script>
31+
<script src="https://unpkg.com/@topsort/analytics.js@2.2.0/dist/ts.js"></script>
3232
```
3333

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

42-
Add the following markup to promoted products:
42+
Add the following markup to promoted products:
43+
4344
```html
44-
<div
45-
class="product"
46-
data-ts-resolved-bid="<resolvedBidId>"
47-
>
48-
...
49-
</div>
45+
<div class="product" data-ts-resolved-bid="<resolvedBidId>">...</div>
5046
```
5147

5248
and the following for organic products (which is optional)
49+
5350
```html
54-
<div
55-
class="product"
56-
data-ts-product="<productId>"
57-
>
58-
...
59-
</div>
51+
<div class="product" data-ts-product="<productId>">...</div>
6052
```
6153

6254
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.
@@ -93,6 +85,7 @@ Finally, in case you are using banners and want to have further control on the a
9385
...
9486
</div>
9587
```
88+
9689
# E2E tests
9790

9891
Execute `npm run test:e2e`, at the end it will show you the url you need to visit to test the library.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@topsort/analytics.js",
3-
"version": "2.1.0",
3+
"version": "2.2.0",
44
"description": "JS library to automatically report events to Topsort's Analytics",
55
"main": "dist/ts.js",
66
"type": "module",

Diff for: pnpm-lock.yaml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: tests/test.html

+51-8
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
td.ok {
1111
background-color: #66bb6a;
1212
}
13-
#vanilla-js, #root, a:active, a:visited, a:hover {
13+
#vanilla-js,
14+
#root,
15+
a:active,
16+
a:visited,
17+
a:hover {
1418
color: white;
1519
}
1620
button {
@@ -75,15 +79,54 @@
7579
</table>
7680
</div>
7781
<div id="vanilla-js">
78-
<div data-ts-product="product-id-impression-1" data-ts-resolved-bid="17785055-9d99-4b4e-9fb0-5fc4cff0af3f">P</div>
79-
<div id="click1" data-ts-product="product-id-click-1" data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e3ba5d">P</div>
80-
<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>
81-
<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>
82+
<div
83+
data-ts-product="product-id-impression-1"
84+
data-ts-resolved-bid="17785055-9d99-4b4e-9fb0-5fc4cff0af3f"
85+
>
86+
P
87+
</div>
88+
<div
89+
id="click1"
90+
data-ts-product="product-id-click-1"
91+
data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e3ba5d"
92+
>
93+
P
94+
</div>
95+
<div
96+
id="click2"
97+
data-ts-product="product-id-click-2"
98+
data-ts-resolved-bid="dc7d20e0-c56f-4a2f-9359-cfb363e30000"
99+
>
100+
<a id="click-area" style="visibility: hidden">Link</a>
101+
</div>
102+
<div
103+
data-ts-action="purchase"
104+
data-ts-items='[{"product": "product-id-purchase-1", "quantity":1, "price": 2399}, {"product": "product-id-purchase-2", "quantity": 2, "price": 399}]'
105+
>
106+
P
107+
</div>
82108
<div id="old-product" data-ts-product="product-id-attr-impression-1">P</div>
83-
<div id="hidden-product" data-ts-product="product-id-impression-hidden" style="visibility: none;">H</div>
109+
<div
110+
id="hidden-product"
111+
data-ts-product="product-id-impression-hidden"
112+
style="visibility: none"
113+
>
114+
H
115+
</div>
84116

85-
<div id="banner" data-ts-resolved-bid="17785055-1111-4b4e-9fb0-5fc4cff0af3f">Banner</div>
86-
<div id="banner-product" data-ts-product="additional-product-banner" data-ts-resolved-bid="inherit">P</div>
117+
<div
118+
id="banner"
119+
data-ts-resolved-bid="17785055-1111-4b4e-9fb0-5fc4cff0af3f"
120+
>
121+
Banner
122+
</div>
123+
<div
124+
id="banner-product"
125+
data-ts-product="additional-product-banner"
126+
data-ts-resolved-bid="inherit"
127+
>
128+
P
129+
</div>
87130
</div>
88131
<div id="root"></div>
89132
<script>

Diff for: tsconfig.json

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
{
22
"compilerOptions": {
3-
"lib": [
4-
"ESNext",
5-
"dom"
6-
],
7-
"types": [
8-
"node"
9-
],
3+
"lib": ["ESNext", "dom"],
4+
"types": ["node"],
105
"module": "es2020",
116
"outDir": "dist",
127
"removeComments": true,
@@ -27,11 +22,6 @@
2722
"noUnusedParameters": true,
2823
"jsx": "react"
2924
},
30-
"include": [
31-
"./**/*.ts",
32-
"./**/*.tsx"
33-
],
34-
"exclude": [
35-
"node_modules/**/*"
36-
]
25+
"include": ["./**/*.ts", "./**/*.tsx"],
26+
"exclude": ["node_modules/**/*"]
3727
}

Diff for: tsconfig.types.json

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"compilerOptions": {
3-
"lib": [
4-
"es2020",
5-
"dom"
6-
],
3+
"lib": ["es2020", "dom"],
74
"target": "es2015",
85
"strict": true,
96
"allowUnreachableCode": false,
@@ -26,17 +23,8 @@
2623
"allowSyntheticDefaultImports": true,
2724
"importHelpers": true,
2825
"alwaysStrict": false,
29-
"typeRoots": [
30-
"@types",
31-
"node_modules/@types"
32-
]
26+
"typeRoots": ["@types", "node_modules/@types"]
3327
},
34-
"include": [
35-
"src/**/*.ts",
36-
"@types/**/*.ts"
37-
],
38-
"exclude": [
39-
"node_modules",
40-
"src/**/*.test.ts"
41-
]
28+
"include": ["src/**/*.ts", "@types/**/*.ts"],
29+
"exclude": ["node_modules", "src/**/*.test.ts"]
4230
}

0 commit comments

Comments
 (0)