@kompasid/lit-web-components 0.9.10 → 0.9.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/index.html +2 -2
- package/dist/src/components/kompasid-freewall/KompasFreewall.d.ts +9 -24
- package/dist/src/components/kompasid-freewall/KompasFreewall.js +44 -100
- package/dist/src/components/kompasid-freewall/KompasFreewall.js.map +1 -1
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.d.ts +96 -0
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.js +305 -0
- package/dist/src/components/kompasid-freewall/old_KompasFreewall.js.map +1 -0
- package/dist/src/components/kompasid-freewall/types.d.ts +26 -0
- package/dist/src/components/kompasid-freewall/types.js.map +1 -1
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.d.ts +9 -14
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js +58 -102
- package/dist/src/components/kompasid-freewall-body/KompasFreewallBody.js.map +1 -1
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.d.ts +34 -0
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js +228 -0
- package/dist/src/components/kompasid-freewall-body/old_KompasFreewallBody.js.map +1 -0
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.d.ts +8 -19
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js +33 -52
- package/dist/src/components/kompasid-freewall-head/KompasFreewallHead.js.map +1 -1
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.d.ts +38 -0
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js +125 -0
- package/dist/src/components/kompasid-freewall-head/old_KompasFreewallHead.js.map +1 -0
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js +1 -1
- package/dist/src/components/kompasid-grace-period/KompasGracePeriod.js.map +1 -1
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js +10 -13
- package/dist/src/components/kompasid-menu-side-bar/KompasMenuSideBar.js.map +1 -1
- package/dist/src/components/kompasid-metered-paywall/KompasMeteredPaywall.js +19 -17
- package/dist/src/components/kompasid-metered-paywall/KompasMeteredPaywall.js.map +1 -1
- package/dist/tailwind/tailwind.js +50 -10
- package/dist/tailwind/tailwind.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/kompasid-freewall/KompasFreewall.ts +52 -85
- package/src/components/kompasid-freewall/old_KompasFreewall.ts +255 -0
- package/src/components/kompasid-freewall/readme.md +40 -84
- package/src/components/kompasid-freewall/types.ts +29 -0
- package/src/components/kompasid-freewall-body/KompasFreewallBody.ts +59 -101
- package/src/components/kompasid-freewall-body/old_KompasFreewallBody.ts +224 -0
- package/src/components/kompasid-freewall-body/readme.md +31 -7
- package/src/components/kompasid-freewall-head/KompasFreewallHead.ts +31 -39
- package/src/components/kompasid-freewall-head/old_KompasFreewallHead.ts +103 -0
- package/src/components/kompasid-freewall-head/readme.md +29 -13
- package/src/components/kompasid-grace-period/KompasGracePeriod.ts +1 -1
- package/src/components/kompasid-menu-side-bar/KompasMenuSideBar.ts +10 -13
- package/src/components/kompasid-metered-paywall/KompasMeteredPaywall.ts +21 -18
- package/tailwind/tailwind.css +50 -8
- package/tailwind/tailwind.ts +50 -10
- package/tailwind.config.js +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { html, css, LitElement, nothing } from 'lit'
|
|
2
2
|
import { property, customElement, state } from 'lit/decorators.js'
|
|
3
3
|
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
4
|
-
import {
|
|
5
|
-
import { redirectToCheckout } from '../../utils/cta.js'
|
|
4
|
+
import { JsonPullDataFreeWall, CardPackage } from './types.js'
|
|
6
5
|
import '../kompasid-freewall-head/KompasFreewallHead.js'
|
|
7
6
|
import '../kompasid-freewall-body/KompasFreewallBody.js'
|
|
8
7
|
|
|
@@ -25,39 +24,25 @@ export class KompasFreewall extends LitElement {
|
|
|
25
24
|
* Props
|
|
26
25
|
*/
|
|
27
26
|
/**
|
|
28
|
-
* property
|
|
29
|
-
* property type untuk menghandle tipe freewall
|
|
30
|
-
* property head_copy_expand to update copy header when expand
|
|
31
|
-
* property head_copy_collapse to update copy header when collapse
|
|
27
|
+
* property type untuk menghandle tipe freewall (akan menyematkan beberapa tipe data layer)
|
|
32
28
|
* property expand to handle expand/collapse
|
|
33
|
-
* property
|
|
34
|
-
* property paywall_subscription_package is the name of the subscription package viewed by user
|
|
35
|
-
* property paywall_subscription_id is the ID of the subscription package viewed by user
|
|
36
|
-
* property paywall_subscription_price is the price of the subscription package viewed by user
|
|
37
|
-
* property paywall_position is the position of the subscription package viewed by user
|
|
29
|
+
* property tracker_paywall_location is the location where user encounter the paywall
|
|
38
30
|
* property tracker_page_type is the type of the page
|
|
39
31
|
* property tracker_page_title is the title of the page
|
|
40
|
-
* property tracker_content_id is the ID of article (slug)
|
|
41
|
-
* property content_title is the title of article
|
|
42
|
-
* property tracker_content_categories is the category of the content
|
|
43
|
-
* property tracker_content_type is to decide whether it's free article or paid article
|
|
44
32
|
* property tracker_user_type is the type of user based on their subscription
|
|
45
33
|
* property tracker_subscription_status is the status of their subscription
|
|
46
34
|
* property tracker_page_domain is the page domain
|
|
47
35
|
* property tracker_metered_wall_type is the type of metered wall
|
|
48
36
|
* property tracker_metered_wall_balance is the balance of their metered wall
|
|
37
|
+
* property tracker_content_title is the title of article [type=article]
|
|
38
|
+
* property tracker_content_id is the ID of article (slug) [type=article]
|
|
39
|
+
* property tracker_content_categories is the category of the content [type=article]
|
|
40
|
+
* property tracker_content_type is to decide whether it's free article or paid article [type=article]
|
|
49
41
|
*/
|
|
50
42
|
|
|
51
|
-
@property({ type: Boolean }) isLogin = false
|
|
52
43
|
@property({ type: String }) type: 'article' | 'landing_page' = 'article'
|
|
53
|
-
@property({ type: String }) head_copy_expand = ''
|
|
54
|
-
@property({ type: String }) head_copy_collapse = ''
|
|
55
44
|
@property({ type: Boolean }) expand = true
|
|
56
|
-
@property({ type: String })
|
|
57
|
-
@property({ type: String }) paywall_subscription_package = ''
|
|
58
|
-
@property({ type: Number }) paywall_subscription_id = 0
|
|
59
|
-
@property({ type: Number }) paywall_subscription_price = 0
|
|
60
|
-
@property({ type: Number }) paywall_position = 1
|
|
45
|
+
@property({ type: String }) tracker_paywall_location = ''
|
|
61
46
|
@property({ type: String }) tracker_page_type = ''
|
|
62
47
|
@property({ type: String }) tracker_page_title = ''
|
|
63
48
|
@property({ type: String }) tracker_content_id = ''
|
|
@@ -88,8 +73,7 @@ export class KompasFreewall extends LitElement {
|
|
|
88
73
|
|
|
89
74
|
@state() private isLoading: Boolean = true
|
|
90
75
|
@state() private isExpand: boolean = true
|
|
91
|
-
@state() private
|
|
92
|
-
@state() private jsonPackageData: JsonPackageData = {} as JsonPackageData
|
|
76
|
+
@state() private pullData: JsonPullDataFreeWall = {} as JsonPullDataFreeWall
|
|
93
77
|
|
|
94
78
|
/**
|
|
95
79
|
* Getter
|
|
@@ -103,22 +87,19 @@ export class KompasFreewall extends LitElement {
|
|
|
103
87
|
* Data Layer
|
|
104
88
|
*/
|
|
105
89
|
|
|
106
|
-
private prepareImpressionsData(): Record<string, any> {
|
|
90
|
+
private prepareImpressionsData(item: CardPackage): Record<string, any> {
|
|
107
91
|
const baseData = {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
page_type: this.tracker_page_type,
|
|
120
|
-
metered_wall_type: this.tracker_metered_wall_type || 'FP',
|
|
121
|
-
metered_wall_balance: this.tracker_metered_wall_balance,
|
|
92
|
+
paywall_subscription_package: item.packageSlug,
|
|
93
|
+
paywall_subscription_id: item.packageId,
|
|
94
|
+
paywall_subscription_price: item.priceDiscount || item.priceBased,
|
|
95
|
+
paywall_position: item.position,
|
|
96
|
+
paywall_location: this.tracker_paywall_location, // from user
|
|
97
|
+
user_type: this.tracker_user_type, // from user
|
|
98
|
+
subscription_status: this.tracker_subscription_status, // from user
|
|
99
|
+
page_domain: this.tracker_page_domain || 'Kompas.id', // from user
|
|
100
|
+
page_type: this.tracker_page_type, // from user
|
|
101
|
+
metered_wall_type: this.tracker_metered_wall_type || 'FP', // from user
|
|
102
|
+
metered_wall_balance: this.tracker_metered_wall_balance, // from user
|
|
122
103
|
}
|
|
123
104
|
|
|
124
105
|
if (this.isArticle) {
|
|
@@ -138,23 +119,29 @@ export class KompasFreewall extends LitElement {
|
|
|
138
119
|
|
|
139
120
|
private sendDataLayer(
|
|
140
121
|
event: string,
|
|
141
|
-
|
|
122
|
+
position: number = 0 // ganti ke specific package
|
|
142
123
|
): void {
|
|
143
|
-
const impressionsData = this.
|
|
124
|
+
const impressionsData = this.pullData.body.map((item: CardPackage) =>
|
|
125
|
+
this.prepareImpressionsData(item)
|
|
126
|
+
)
|
|
144
127
|
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
128
|
+
const get = this.pullData.body.find(item => item.position === position)
|
|
129
|
+
|
|
130
|
+
const specificData = get ? this.prepareImpressionsData(get) : []
|
|
131
|
+
|
|
132
|
+
const data = position
|
|
133
|
+
? { event, ...specificData }
|
|
134
|
+
: { event, impressions: [impressionsData] }
|
|
148
135
|
|
|
149
136
|
window.dataLayer.push(data)
|
|
150
137
|
}
|
|
151
138
|
|
|
152
139
|
private sendDataLayerPaywallViewed(): void {
|
|
153
|
-
if (this.isExpand) this.sendDataLayer('paywall_viewed'
|
|
140
|
+
if (this.isExpand) this.sendDataLayer('paywall_viewed')
|
|
154
141
|
}
|
|
155
142
|
|
|
156
|
-
private sendDataLayerSubscribeButtonClicked(): void {
|
|
157
|
-
this.sendDataLayer('subscribe_button_clicked')
|
|
143
|
+
private sendDataLayerSubscribeButtonClicked(pos?: number): void {
|
|
144
|
+
this.sendDataLayer('subscribe_button_clicked', pos)
|
|
158
145
|
}
|
|
159
146
|
|
|
160
147
|
/**
|
|
@@ -166,12 +153,10 @@ export class KompasFreewall extends LitElement {
|
|
|
166
153
|
this.sendDataLayerPaywallViewed()
|
|
167
154
|
}
|
|
168
155
|
|
|
169
|
-
private
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
source: this.type,
|
|
174
|
-
})
|
|
156
|
+
private goToUrl(url: string, position?: number) {
|
|
157
|
+
if (!url) return
|
|
158
|
+
this.sendDataLayerSubscribeButtonClicked(position)
|
|
159
|
+
window.open(url, '_blank')
|
|
175
160
|
}
|
|
176
161
|
|
|
177
162
|
/**
|
|
@@ -183,9 +168,6 @@ export class KompasFreewall extends LitElement {
|
|
|
183
168
|
await this.updateComplete
|
|
184
169
|
|
|
185
170
|
this.isExpand = this.expand
|
|
186
|
-
|
|
187
|
-
const originHost: string = encodeURIComponent(window.location.href)
|
|
188
|
-
this.packageData = { ...this.showPackage, referrer: originHost }
|
|
189
171
|
this.getFreewallData()
|
|
190
172
|
|
|
191
173
|
this.sendDataLayerPaywallViewed()
|
|
@@ -194,21 +176,10 @@ export class KompasFreewall extends LitElement {
|
|
|
194
176
|
async getFreewallData() {
|
|
195
177
|
try {
|
|
196
178
|
const response = await fetch(
|
|
197
|
-
'https://cdn-www.kompas.id/web-component/freewall.json'
|
|
179
|
+
'https://cdn-www.kompas.id/web-component/freewall-new.json'
|
|
198
180
|
)
|
|
199
|
-
const json = await response.json()
|
|
200
|
-
this.
|
|
201
|
-
headCopyCollapse: json.headCopyCollapse,
|
|
202
|
-
headCopyExpand: json.headCopyExpand,
|
|
203
|
-
subscriptionUrl: json.subscriptionUrl,
|
|
204
|
-
subscriptionTitle: json.subscriptionTitle,
|
|
205
|
-
subscriptionTitleGuest: json.subscriptionTitleGuest,
|
|
206
|
-
subscriptionDescription: json.subscriptionDescription,
|
|
207
|
-
subscriptionButtonText: json.subscriptionButtonText,
|
|
208
|
-
registerTitle: json.registerTitle,
|
|
209
|
-
registerDescription: json.registerDescription,
|
|
210
|
-
registerButtonText: json.registerButtonText,
|
|
211
|
-
}
|
|
181
|
+
const json: JsonPullDataFreeWall = await response.json()
|
|
182
|
+
this.pullData = json
|
|
212
183
|
} catch (error) {
|
|
213
184
|
throw Error('Failed to get metered paywall data')
|
|
214
185
|
} finally {
|
|
@@ -225,27 +196,23 @@ export class KompasFreewall extends LitElement {
|
|
|
225
196
|
? html`
|
|
226
197
|
<div class="sticky bottom-0 w-full h-full z-20 top-shadow">
|
|
227
198
|
<div
|
|
228
|
-
class="flex flex-col w-full bg-blue-100 justify-center ${this
|
|
199
|
+
class="flex flex-col transition-all w-full bg-blue-100 justify-center ${this
|
|
229
200
|
.isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24"
|
|
230
201
|
>
|
|
231
202
|
<kompasid-freewall-head
|
|
232
203
|
.expand=${this.isExpand}
|
|
233
|
-
.type=${this.type}
|
|
234
|
-
.head_copy_expand=${this.jsonPackageData.headCopyExpand}
|
|
235
|
-
.head_copy_collapse=${this.jsonPackageData.headCopyCollapse}
|
|
236
204
|
.toggleExpand=${() => this.toggleExpand()}
|
|
237
|
-
.
|
|
238
|
-
.
|
|
239
|
-
.jsonPackageData=${this.jsonPackageData}
|
|
205
|
+
.headData=${this.pullData.head}
|
|
206
|
+
.onButtonClick=${(url: string) => this.goToUrl(url)}
|
|
240
207
|
></kompasid-freewall-head>
|
|
241
208
|
${this.isExpand
|
|
242
|
-
? html
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
209
|
+
? html` <div>
|
|
210
|
+
<kompasid-freewall-body
|
|
211
|
+
.bodyData=${this.pullData.body}
|
|
212
|
+
.onButtonClick=${(url: string, position: number) =>
|
|
213
|
+
this.goToUrl(url, position)}
|
|
214
|
+
></kompasid-freewall-body>
|
|
215
|
+
</div>`
|
|
249
216
|
: nothing}
|
|
250
217
|
</div>
|
|
251
218
|
</div>
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { html, css, LitElement, nothing } from 'lit'
|
|
2
|
+
import { property, customElement, state } from 'lit/decorators.js'
|
|
3
|
+
import { TWStyles } from '../../../tailwind/tailwind.js'
|
|
4
|
+
import { JsonPackageData, PackageData } from './types.js'
|
|
5
|
+
import { redirectToCheckout } from '../../utils/cta.js'
|
|
6
|
+
import '../kompasid-freewall-head/KompasFreewallHead.js'
|
|
7
|
+
import '../kompasid-freewall-body/KompasFreewallBody.js'
|
|
8
|
+
|
|
9
|
+
@customElement('kompasid-freewall')
|
|
10
|
+
export class KompasFreewall extends LitElement {
|
|
11
|
+
static styles = [
|
|
12
|
+
css`
|
|
13
|
+
:host {
|
|
14
|
+
font-family: 'PT Sans', sans-serif;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.top-shadow {
|
|
18
|
+
box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.16);
|
|
19
|
+
}
|
|
20
|
+
`,
|
|
21
|
+
TWStyles,
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Props
|
|
26
|
+
*/
|
|
27
|
+
/**
|
|
28
|
+
* property isLogin untuk menghandle apakah user sudah login atau belum
|
|
29
|
+
* property type untuk menghandle tipe freewall
|
|
30
|
+
* property head_copy_expand to update copy header when expand
|
|
31
|
+
* property head_copy_collapse to update copy header when collapse
|
|
32
|
+
* property expand to handle expand/collapse
|
|
33
|
+
* property paywall_location is the location where user encounter the paywall
|
|
34
|
+
* property paywall_subscription_package is the name of the subscription package viewed by user
|
|
35
|
+
* property paywall_subscription_id is the ID of the subscription package viewed by user
|
|
36
|
+
* property paywall_subscription_price is the price of the subscription package viewed by user
|
|
37
|
+
* property paywall_position is the position of the subscription package viewed by user
|
|
38
|
+
* property tracker_page_type is the type of the page
|
|
39
|
+
* property tracker_page_title is the title of the page
|
|
40
|
+
* property tracker_content_id is the ID of article (slug)
|
|
41
|
+
* property content_title is the title of article
|
|
42
|
+
* property tracker_content_categories is the category of the content
|
|
43
|
+
* property tracker_content_type is to decide whether it's free article or paid article
|
|
44
|
+
* property tracker_user_type is the type of user based on their subscription
|
|
45
|
+
* property tracker_subscription_status is the status of their subscription
|
|
46
|
+
* property tracker_page_domain is the page domain
|
|
47
|
+
* property tracker_metered_wall_type is the type of metered wall
|
|
48
|
+
* property tracker_metered_wall_balance is the balance of their metered wall
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
@property({ type: Boolean }) isLogin = false
|
|
52
|
+
@property({ type: String }) type: 'article' | 'landing_page' = 'article'
|
|
53
|
+
@property({ type: String }) head_copy_expand = ''
|
|
54
|
+
@property({ type: String }) head_copy_collapse = ''
|
|
55
|
+
@property({ type: Boolean }) expand = true
|
|
56
|
+
@property({ type: String }) paywall_location = ''
|
|
57
|
+
@property({ type: String }) paywall_subscription_package = ''
|
|
58
|
+
@property({ type: Number }) paywall_subscription_id = 0
|
|
59
|
+
@property({ type: Number }) paywall_subscription_price = 0
|
|
60
|
+
@property({ type: Number }) paywall_position = 1
|
|
61
|
+
@property({ type: String }) tracker_page_type = ''
|
|
62
|
+
@property({ type: String }) tracker_page_title = ''
|
|
63
|
+
@property({ type: String }) tracker_content_id = ''
|
|
64
|
+
@property({ type: String }) tracker_content_title = ''
|
|
65
|
+
@property({ type: String }) tracker_content_categories = ''
|
|
66
|
+
@property({ type: String }) tracker_content_type = ''
|
|
67
|
+
@property({ type: String }) tracker_user_type = ''
|
|
68
|
+
@property({ type: String }) tracker_subscription_status = ''
|
|
69
|
+
@property({ type: String }) tracker_page_domain = ''
|
|
70
|
+
@property({ type: String }) tracker_metered_wall_type = ''
|
|
71
|
+
@property({ type: Number }) tracker_metered_wall_balance = 0
|
|
72
|
+
|
|
73
|
+
showPackage = {
|
|
74
|
+
duration: 1,
|
|
75
|
+
durationType: 3,
|
|
76
|
+
id: '9802035',
|
|
77
|
+
link: 'kdp?productId=9802035&referrer=',
|
|
78
|
+
price: 50000,
|
|
79
|
+
position: 1,
|
|
80
|
+
title: 'Kompas Digital Premium 1 Bulan',
|
|
81
|
+
slug: 'cash-b2c-halaman-berlangganan-reguler_digital-kdp-1',
|
|
82
|
+
referrer: '',
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* State
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
@state() private isLoading: Boolean = true
|
|
90
|
+
@state() private isExpand: boolean = true
|
|
91
|
+
@state() private packageData: PackageData = {} as PackageData
|
|
92
|
+
@state() private jsonPackageData: JsonPackageData = {} as JsonPackageData
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Getter
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
get isArticle() {
|
|
99
|
+
return this.type === 'article'
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Data Layer
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
private prepareImpressionsData(): Record<string, any> {
|
|
107
|
+
const baseData = {
|
|
108
|
+
paywall_location: this.paywall_location,
|
|
109
|
+
paywall_subscription_package:
|
|
110
|
+
this.paywall_subscription_package || this.packageData.slug,
|
|
111
|
+
paywall_subscription_id:
|
|
112
|
+
this.paywall_subscription_id || this.packageData.id,
|
|
113
|
+
paywall_subscription_price:
|
|
114
|
+
this.paywall_subscription_price || this.packageData.price,
|
|
115
|
+
paywall_position: this.paywall_position || this.packageData.position,
|
|
116
|
+
user_type: this.tracker_user_type,
|
|
117
|
+
subscription_status: this.tracker_subscription_status,
|
|
118
|
+
page_domain: this.tracker_page_domain || 'Kompas.id',
|
|
119
|
+
page_type: this.tracker_page_type,
|
|
120
|
+
metered_wall_type: this.tracker_metered_wall_type || 'FP',
|
|
121
|
+
metered_wall_balance: this.tracker_metered_wall_balance,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.isArticle) {
|
|
125
|
+
return {
|
|
126
|
+
...baseData,
|
|
127
|
+
content_id: this.tracker_content_id,
|
|
128
|
+
content_title: this.tracker_content_title,
|
|
129
|
+
content_categories: this.tracker_content_categories,
|
|
130
|
+
content_type: this.tracker_content_type,
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
...baseData,
|
|
135
|
+
page_title: this.tracker_page_title,
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private sendDataLayer(
|
|
140
|
+
event: string,
|
|
141
|
+
includeImpressions: boolean = false
|
|
142
|
+
): void {
|
|
143
|
+
const impressionsData = this.prepareImpressionsData()
|
|
144
|
+
|
|
145
|
+
const data = includeImpressions
|
|
146
|
+
? { event, impressions: [impressionsData] }
|
|
147
|
+
: { event, ...impressionsData }
|
|
148
|
+
|
|
149
|
+
window.dataLayer.push(data)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private sendDataLayerPaywallViewed(): void {
|
|
153
|
+
if (this.isExpand) this.sendDataLayer('paywall_viewed', true)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private sendDataLayerSubscribeButtonClicked(): void {
|
|
157
|
+
this.sendDataLayer('subscribe_button_clicked')
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Logic Function
|
|
162
|
+
*/
|
|
163
|
+
|
|
164
|
+
private toggleExpand() {
|
|
165
|
+
this.isExpand = !this.isExpand
|
|
166
|
+
this.sendDataLayerPaywallViewed()
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private onSubscriptionClick() {
|
|
170
|
+
this.sendDataLayerSubscribeButtonClicked()
|
|
171
|
+
redirectToCheckout({
|
|
172
|
+
link: `${this.jsonPackageData.subscriptionUrl}&referrer=${this.packageData.referrer}`,
|
|
173
|
+
source: this.type,
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Lifecycle
|
|
179
|
+
*/
|
|
180
|
+
|
|
181
|
+
override async connectedCallback() {
|
|
182
|
+
super.connectedCallback()
|
|
183
|
+
await this.updateComplete
|
|
184
|
+
|
|
185
|
+
this.isExpand = this.expand
|
|
186
|
+
|
|
187
|
+
const originHost: string = encodeURIComponent(window.location.href)
|
|
188
|
+
this.packageData = { ...this.showPackage, referrer: originHost }
|
|
189
|
+
this.getFreewallData()
|
|
190
|
+
|
|
191
|
+
this.sendDataLayerPaywallViewed()
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async getFreewallData() {
|
|
195
|
+
try {
|
|
196
|
+
const response = await fetch(
|
|
197
|
+
'https://cdn-www.kompas.id/web-component/freewall.json'
|
|
198
|
+
)
|
|
199
|
+
const json = await response.json()
|
|
200
|
+
this.jsonPackageData = {
|
|
201
|
+
headCopyCollapse: json.headCopyCollapse,
|
|
202
|
+
headCopyExpand: json.headCopyExpand,
|
|
203
|
+
subscriptionUrl: json.subscriptionUrl,
|
|
204
|
+
subscriptionTitle: json.subscriptionTitle,
|
|
205
|
+
subscriptionTitleGuest: json.subscriptionTitleGuest,
|
|
206
|
+
subscriptionDescription: json.subscriptionDescription,
|
|
207
|
+
subscriptionButtonText: json.subscriptionButtonText,
|
|
208
|
+
registerTitle: json.registerTitle,
|
|
209
|
+
registerDescription: json.registerDescription,
|
|
210
|
+
registerButtonText: json.registerButtonText,
|
|
211
|
+
}
|
|
212
|
+
} catch (error) {
|
|
213
|
+
throw Error('Failed to get metered paywall data')
|
|
214
|
+
} finally {
|
|
215
|
+
this.isLoading = false
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Render Statement
|
|
221
|
+
*/
|
|
222
|
+
|
|
223
|
+
render() {
|
|
224
|
+
return !this.isLoading
|
|
225
|
+
? html`
|
|
226
|
+
<div class="sticky bottom-0 w-full h-full z-20 top-shadow">
|
|
227
|
+
<div
|
|
228
|
+
class="flex flex-col w-full bg-blue-100 justify-center ${this
|
|
229
|
+
.isExpand && 'pb-6 md:pb-7'} md:px-4 lg:px-24"
|
|
230
|
+
>
|
|
231
|
+
<kompasid-freewall-head
|
|
232
|
+
.expand=${this.isExpand}
|
|
233
|
+
.type=${this.type}
|
|
234
|
+
.head_copy_expand=${this.jsonPackageData.headCopyExpand}
|
|
235
|
+
.head_copy_collapse=${this.jsonPackageData.headCopyCollapse}
|
|
236
|
+
.toggleExpand=${() => this.toggleExpand()}
|
|
237
|
+
.onSubscriptionClick=${() => this.onSubscriptionClick()}
|
|
238
|
+
.packageData=${this.packageData}
|
|
239
|
+
.jsonPackageData=${this.jsonPackageData}
|
|
240
|
+
></kompasid-freewall-head>
|
|
241
|
+
${this.isExpand
|
|
242
|
+
? html`<kompasid-freewall-body
|
|
243
|
+
.type=${this.type}
|
|
244
|
+
.onSubscriptionClick=${() => this.onSubscriptionClick()}
|
|
245
|
+
.packageData=${this.packageData}
|
|
246
|
+
.jsonPackageData=${this.jsonPackageData}
|
|
247
|
+
?isLogin=${this.isLogin}
|
|
248
|
+
></kompasid-freewall-body>`
|
|
249
|
+
: nothing}
|
|
250
|
+
</div>
|
|
251
|
+
</div>
|
|
252
|
+
`
|
|
253
|
+
: nothing
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -2,87 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
## Properties
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
|
9
|
-
|
|
|
10
|
-
| `
|
|
11
|
-
| `
|
|
12
|
-
| `
|
|
13
|
-
| `
|
|
14
|
-
| `
|
|
15
|
-
| `
|
|
16
|
-
| `
|
|
17
|
-
| `
|
|
18
|
-
| `
|
|
19
|
-
| `
|
|
20
|
-
| `tracker_metered_wall_balance`
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
| `
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
| `paywall_subscription_price` | `paywall_subscription_price` | property paywall_subscription_price is the price of the subscription package viewed by user | `number` | `0` |
|
|
46
|
-
| `paywall_position` | `paywall_position` | property paywall_position is the position of the subscription package viewed by user | `number` | `1` |
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
## JSON ([https://cdn-www.kompas.id/web-component/freewall.json](https://cdn-www.kompas.id/web-component/freewall.json))
|
|
50
|
-
Example:
|
|
51
|
-
|
|
52
|
-
```json
|
|
53
|
-
{
|
|
54
|
-
"headCopyCollapse": "Akses seluruh konten dan fitur Kompas.id dengan berlangganan.",
|
|
55
|
-
"headCopyExpand": "Akses seluruh konten dan fitur Kompas.id dengan berlangganan.",
|
|
56
|
-
"subscriptionUrl": "kdp?productId=9802035",
|
|
57
|
-
"subscriptionTitle": "Dukung Jurnalisme Mencerahkan dengan Berlangganan",
|
|
58
|
-
"subscriptionTitleGuest": "Mulai Berlangganan",
|
|
59
|
-
"subscriptionDescription": [
|
|
60
|
-
"Akses seluruh konten Kompas.id di web & aplikasi",
|
|
61
|
-
"ePaper hingga 30 edisi terakhir",
|
|
62
|
-
"Buku digital tiap bulannya di aplikasi"
|
|
63
|
-
],
|
|
64
|
-
"subscriptionButtonText": "Langganan Rp 50.000 / bulan",
|
|
65
|
-
"registerTitle": "Daftar Akun Gratis",
|
|
66
|
-
"registerDescription": [
|
|
67
|
-
"Akses ke 3 artikel berbayar gratis tiap bulan"
|
|
68
|
-
],
|
|
69
|
-
"registerButtonText": "Daftar Gratis"
|
|
70
|
-
}
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Dependencies
|
|
74
|
-
|
|
75
|
-
### Depends on
|
|
76
|
-
|
|
77
|
-
- [kompasid-freewall-head](../kompasid-freewall-head)
|
|
78
|
-
- [kompasid-freewall-body](../kompasid-freewall-body)
|
|
79
|
-
|
|
80
|
-
### Graph
|
|
81
|
-
```mermaid
|
|
82
|
-
graph TD;
|
|
83
|
-
kompasid-freewall --> kompasid-freewall-head
|
|
84
|
-
kompasid-freewall --> kompasid-freewall-body
|
|
85
|
-
style kompasid-freewall fill:#023B73,stroke:#333,stroke-width:4px
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
*Terbikin oleh tim front-end kompas.id*
|
|
5
|
+
| Property | Attribute | Description | Type | Default |
|
|
6
|
+
| ------------------------------- | ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | --------------- |
|
|
7
|
+
| `type` | `type` | Tipe tampilan freewall yang menentukan skema data layer berbeda (contoh: `article` untuk artikel dengan konten detail, atau `landing_page`). | `"article" \| "landing_page"` | `"article"` |
|
|
8
|
+
| `expand` | `expand` | Status default expand/collapse paywall saat pertama kali di-load. | `boolean` | `true` |
|
|
9
|
+
| `tracker_paywall_location` | `tracker_paywall_location` | Lokasi atau penempatan di mana user menemukan paywall (untuk tracking/data layer). | `string` | `""` |
|
|
10
|
+
| `tracker_page_type` | `tracker_page_type` | Jenis halaman yang menampilkan paywall (untuk tracking/data layer). | `string` | `""` |
|
|
11
|
+
| `tracker_page_title` | `tracker_page_title` | Judul halaman ketika paywall muncul (untuk tracking/data layer). | `string` | `""` |
|
|
12
|
+
| `tracker_content_id` | `tracker_content_id` | ID atau slug artikel (dipakai jika `type=article`). | `string` | `""` |
|
|
13
|
+
| `tracker_content_title` | `tracker_content_title` | Judul konten/artikel (dipakai jika `type=article`). | `string` | `""` |
|
|
14
|
+
| `tracker_content_categories` | `tracker_content_categories` | Kategori konten/artikel (dipakai jika `type=article`). | `string` | `""` |
|
|
15
|
+
| `tracker_content_type` | `tracker_content_type` | Tipe konten: apakah artikel gratis atau berbayar (dipakai jika `type=article`). | `string` | `""` |
|
|
16
|
+
| `tracker_user_type` | `tracker_user_type` | Tipe user berdasarkan status langganan (untuk tracking/data layer). | `string` | `""` |
|
|
17
|
+
| `tracker_subscription_status` | `tracker_subscription_status` | Status langganan user saat itu (untuk tracking/data layer). | `string` | `""` |
|
|
18
|
+
| `tracker_page_domain` | `tracker_page_domain` | Domain halaman yang menampilkan paywall (untuk tracking/data layer). | `string` | `""` |
|
|
19
|
+
| `tracker_metered_wall_type` | `tracker_metered_wall_type` | Tipe metered wall (contoh: FP) untuk tracking/data layer. | `string` | `""` |
|
|
20
|
+
| `tracker_metered_wall_balance` | `tracker_metered_wall_balance` | Jumlah sisa balance (akses gratis) pada metered paywall. | `number` | `0` |
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## State (Internal)
|
|
25
|
+
|
|
26
|
+
> Properti berikut tidak untuk diatur langsung lewat atribut. Digunakan secara internal oleh komponen:
|
|
27
|
+
|
|
28
|
+
| Property | Description | Type | Default |
|
|
29
|
+
| ------------- | ------------------------------------------------------------------------------------------------------- | ------------------------ | ----------- |
|
|
30
|
+
| `isLoading` | Status untuk menandai proses pengambilan data freewall JSON. | `boolean` | `true` |
|
|
31
|
+
| `isExpand` | Status expand/collapse yang aktif saat ini. | `boolean` | `true` |
|
|
32
|
+
| `pullData` | Data hasil fetch dari endpoint JSON (berisi objek `head` dan `body`). | `JsonPullDataFreeWall` | `{}` |
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Description
|
|
37
|
+
|
|
38
|
+
`<kompasid-freewall>` adalah **komponen wrapper utama** untuk paywall Kompas.id.
|
|
39
|
+
|
|
40
|
+
✅ Memuat:
|
|
41
|
+
- **Header** dengan teks/copy, tombol toggle expand/collapse (menggunakan `<kompasid-freewall-head>`).
|
|
42
|
+
- **Body** berupa daftar kartu paket langganan (menggunakan `<kompasid-freewall-body>`).
|
|
43
|
+
|
|
44
|
+
✅ Otomatis fetch data JSON dari:
|
|
@@ -22,3 +22,32 @@ export interface JsonPackageData {
|
|
|
22
22
|
registerDescription: string[]
|
|
23
23
|
registerButtonText: string
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
export interface CardPackage {
|
|
27
|
+
title: string
|
|
28
|
+
ribbon: boolean
|
|
29
|
+
packageSlug: string
|
|
30
|
+
packageId: string
|
|
31
|
+
priceBased: number
|
|
32
|
+
priceDiscount: number
|
|
33
|
+
position: number
|
|
34
|
+
duration: string
|
|
35
|
+
cta: {
|
|
36
|
+
text: string
|
|
37
|
+
url: string
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface HeadDataFreeWall {
|
|
42
|
+
headCopyExpand: string
|
|
43
|
+
headCopyCollapse: string
|
|
44
|
+
cta: {
|
|
45
|
+
text: string
|
|
46
|
+
url: string
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface JsonPullDataFreeWall {
|
|
51
|
+
head: HeadDataFreeWall
|
|
52
|
+
body: CardPackage[]
|
|
53
|
+
}
|