Skip to content

Commit e165864

Browse files
authored
Merge pull request #13 from adjust/v110
Version 1.1.0
2 parents 9b63701 + 1fefecc commit e165864

24 files changed

+271
-153
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
### Version 1.1.0 (25th January 2024)
2+
3+
#### Added
4+
- Implemented impressions tracking.
5+
6+
#### Fixed
7+
- Fixed CTA styles to limit its max-width.
8+
- Fixed CTA click behaviour when banner is implemented in iframe.
9+
10+
---
11+
112
### Version 1.0.2 (13th December 2023)
213

314
#### Fixed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To <a id="loading-snippet">load Smart Banner SDK through CDN</a> paste the follo
3232
</script>
3333
```
3434

35-
When loading the sdk through CDN we suggest using minified version. You can target specific version like `https://cdn.adjust.com/adjust-smart-banner-1.0.2.min.js`, or you can target latest version `https://cdn.adjust.com/adjust-smart-banner-latest.min.js` if you want automatic updates without need to change the target file. The sdk files are cached so they are served as fast as possible, and the cache is refreshed every half an hour. If you want updates immediately make sure to target specific version.
35+
When loading the sdk through CDN we suggest using minified version. You can target specific version like `https://cdn.adjust.com/adjust-smart-banner-1.1.0.min.js`, or you can target latest version `https://cdn.adjust.com/adjust-smart-banner-latest.min.js` if you want automatic updates without need to change the target file. The sdk files are cached so they are served as fast as possible, and the cache is refreshed every half an hour. If you want updates immediately make sure to target specific version.
3636

3737

3838
## <a id="initialization">Initialization</a>

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"test": "echo \"Error: no test specified\" && exit 1"
1111
},
1212
"dependencies": {
13-
"@adjustcom/smart-banner-sdk": "^1.0.2",
13+
"@adjustcom/smart-banner-sdk": "^1.1.0",
1414
"lorem-ipsum": "^2.0.8"
1515
},
1616
"author": "Adjust GmbH",

layout/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@adjustcom/smart-banner-sdk-layout",
3-
"version": "3.0.4",
3+
"version": "3.0.6",
44
"description": "Adjust Smart Banner SDK Layout",
55
"scripts": {
66
"build": "npm run build:src && npm run build:types",

layout/src/action-button/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ export class ActionButton {
77

88
constructor(private banner: SmartBannerViewData, private trackerUrl: string = '') {
99
this.link = document.createElement('a');
10+
11+
// In a case when banner in an iframe rendered, open a link in current window instead of the iframe
12+
this.link.target = '_top';
1013
}
1114

1215
private applyColors() {

layout/src/action-button/styles.module.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
line-height: 20px;
2323
cursor: pointer;
2424
text-decoration: none;
25+
white-space: nowrap;
26+
overflow: hidden;
27+
text-overflow: ellipsis;
28+
29+
:global(.small) & {
30+
max-width: 115px;
31+
}
2532

2633
:global(.medium) & {
2734
align-self: stretch;

layout/src/banner-body/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ActionButton } from '../action-button';
22
import { AppIcon } from '../app-icon';
33
import { DismissButton } from '../dismiss-button';
44
import { BannerText, TextType } from '../text';
5+
import { ImpressionPixel } from '../impression-pixel';
56
import { SmartBannerViewData } from '../data-types';
67

78
import styles from './styles.module.scss';
@@ -13,8 +14,9 @@ export class BannerBody {
1314
private bannerBody: HTMLElement;
1415
private title: BannerText;
1516
private description: BannerText;
17+
private pixel: ImpressionPixel;
1618

17-
constructor(private banner: SmartBannerViewData, onDismiss: () => void, trackerUrl?: string) {
19+
constructor(private banner: SmartBannerViewData, onDismiss: () => void, trackerUrl: string = '', impressionUrl: string = '') {
1820
this.bannerBody = document.createElement('div');
1921
this.bannerBody.className = styles['banner-body'];
2022

@@ -23,6 +25,8 @@ export class BannerBody {
2325
this.actionButton = new ActionButton(banner, trackerUrl);
2426
this.title = new BannerText(TextType.Title, banner.title, banner.titleColor);
2527
this.description = new BannerText(TextType.Description, banner.description, banner.descriptionColor);
28+
29+
this.pixel = new ImpressionPixel(impressionUrl);
2630
}
2731

2832
private renderBackground(backgroundColor?: string, backgroundImageUrl?: string) {
@@ -64,16 +68,20 @@ export class BannerBody {
6468

6569
this.bannerBody.appendChild(this.renderInnerElements());
6670

71+
this.pixel.render(this.bannerBody);
72+
6773
root.appendChild(this.bannerBody);
6874
}
6975

70-
public update(banner: SmartBannerViewData, trackerUrl: string) {
76+
public update(banner: SmartBannerViewData, trackerUrl: string, impressionUrl?: string) {
7177
this.dismissButton.update(banner.dismissalButtonColor);
7278
this.appIcon.update(banner.iconUrl, banner.appName);
7379
this.actionButton.update(banner, trackerUrl);
7480
this.title.update(banner.title, banner.titleColor);
7581
this.description.update(banner.description, banner.descriptionColor);
7682

83+
this.pixel.update(impressionUrl);
84+
7785
this.renderBackground(banner.backgroundColor, banner.backgroundImageUrl);
7886

7987
this.banner = banner;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import styles from './styles.module.scss';
2+
3+
export class ImpressionPixel {
4+
private image: HTMLImageElement;
5+
6+
constructor(private impressionUrl: string = '') {
7+
this.image = document.createElement('img');
8+
this.image.className = styles.pixel;
9+
this.image.width = 0;
10+
this.image.height = 0;
11+
12+
this.applyUrl();
13+
}
14+
15+
private applyUrl() {
16+
if (this.impressionUrl && this.impressionUrl !== '') {
17+
this.image.src = this.impressionUrl;
18+
} else {
19+
this.image.removeAttribute('src');
20+
}
21+
}
22+
23+
public render(root: HTMLElement) {
24+
root.appendChild(this.image);
25+
}
26+
27+
public update(impressionUrl: string = '') {
28+
this.impressionUrl = impressionUrl;
29+
30+
this.applyUrl();
31+
}
32+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.pixel {
2+
pointer-events: none;
3+
position: fixed;
4+
}

layout/src/smart-banner-layout-factory.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { SmartBannerViewData } from './data-types';
44
// eslint-disable-next-line
55
const emptyHandler = () => { }
66

7-
const emptyTrackerUrl = '';
7+
const emptyLink = '';
88

99
export class SmartBannerLayoutFactory {
1010
static createPreview(data: SmartBannerViewData): SmartBannerLayout {
11-
return new SmartBannerView(data, emptyTrackerUrl, emptyHandler);
11+
return new SmartBannerView(data, emptyLink, emptyLink, emptyHandler);
1212
}
1313

14-
static createViewForSdk(data: SmartBannerViewData, trackerUrl: string, onDismiss: () => void): SmartBannerLayout {
15-
return new SmartBannerView(data, trackerUrl, onDismiss);
14+
static createViewForSdk(data: SmartBannerViewData, trackerUrl: string, impressionUrl: string, onDismiss: () => void): SmartBannerLayout {
15+
return new SmartBannerView(data, trackerUrl, impressionUrl, onDismiss);
1616
}
1717
}

0 commit comments

Comments
 (0)