@kompasid/lit-web-components 0.7.4 → 0.7.6

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 CHANGED
@@ -262,7 +262,7 @@
262
262
  .tracker_page_domain=${trackerPageDomain}
263
263
  ></kompasid-metered-wall-register>
264
264
 
265
- <!-- <kompasid-grace-period totalGracePeriod="5" subscriptionId="9802032"></kompasid-grace-period> -->
265
+ <!-- <kompasid-grace-period totalGracePeriod="5"></kompasid-grace-period> -->
266
266
  `,
267
267
  document.querySelector('#demo')
268
268
  )
@@ -8,12 +8,40 @@ export declare class KompasGracePeriod extends LitElement {
8
8
  * property totalGracePeriod = how many days are left in grace period
9
9
  * property isColumn = changes how the component looks on different screen sizes
10
10
  * property isShowButton = shows or hides a subscription button
11
- * property subscriptionId = used for renewal subs
11
+ * property paywall_location = the location where user encounter the paywall
12
+ * property paywall_subscription_package = the name of the subscription package viewed by user
13
+ * property paywall_subscription_id = the ID of the subscription package viewed by user
14
+ * property paywall_subscription_price = the price of the subscriprtion package viewed by user
15
+ * property paywall_position = the position of the subscription package viewed by user
16
+ * property tracker_page_type = type of the page
17
+ * property tracker_content_id = ID of article (slug)
18
+ * property tracker_content_type = whether it's free article or paid article
19
+ * property tracker_content_title = the title of article
20
+ * property tracker_content_categories = the category of the content
21
+ * property tracker_user_type = type of user based on their subscription
22
+ * property tracker_subscription_status = status of their subscription
23
+ * property tracker_page_domain = page Domain
24
+ * property tracker_metered_wall_type = the type of Metered Wall
25
+ * property tracker_metered_wall_balance = the balance of their metered wall
12
26
  */
13
27
  totalGracePeriod: number;
14
28
  isColumn: boolean;
15
29
  isShowButton: boolean;
16
- subscriptionId: string;
30
+ paywall_location: string;
31
+ paywall_subscription_package: string;
32
+ paywall_subscription_id: number;
33
+ paywall_subscription_price: number;
34
+ paywall_position: number;
35
+ tracker_page_type: string;
36
+ tracker_content_id: string;
37
+ tracker_content_title: string;
38
+ tracker_content_categories: string;
39
+ tracker_content_type: string;
40
+ tracker_user_type: string;
41
+ tracker_subscription_status: string;
42
+ tracker_page_domain: string;
43
+ tracker_metered_wall_type: string;
44
+ tracker_metered_wall_balance: number;
17
45
  /**
18
46
  * State
19
47
  */
@@ -21,6 +49,8 @@ export declare class KompasGracePeriod extends LitElement {
21
49
  private updateSubscription;
22
50
  private getCountdownGracePeriod;
23
51
  private redirectToBerlangganan;
52
+ private getGtmParams;
53
+ private sendGtmEvent;
24
54
  private dataLayeronPerbaruiLanggananButton;
25
55
  private dataLayeronGracePeriod;
26
56
  private gracePeriodTemplate;
@@ -13,12 +13,40 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
13
13
  * property totalGracePeriod = how many days are left in grace period
14
14
  * property isColumn = changes how the component looks on different screen sizes
15
15
  * property isShowButton = shows or hides a subscription button
16
- * property subscriptionId = used for renewal subs
16
+ * property paywall_location = the location where user encounter the paywall
17
+ * property paywall_subscription_package = the name of the subscription package viewed by user
18
+ * property paywall_subscription_id = the ID of the subscription package viewed by user
19
+ * property paywall_subscription_price = the price of the subscriprtion package viewed by user
20
+ * property paywall_position = the position of the subscription package viewed by user
21
+ * property tracker_page_type = type of the page
22
+ * property tracker_content_id = ID of article (slug)
23
+ * property tracker_content_type = whether it's free article or paid article
24
+ * property tracker_content_title = the title of article
25
+ * property tracker_content_categories = the category of the content
26
+ * property tracker_user_type = type of user based on their subscription
27
+ * property tracker_subscription_status = status of their subscription
28
+ * property tracker_page_domain = page Domain
29
+ * property tracker_metered_wall_type = the type of Metered Wall
30
+ * property tracker_metered_wall_balance = the balance of their metered wall
17
31
  */
18
32
  this.totalGracePeriod = 0;
19
33
  this.isColumn = false;
20
34
  this.isShowButton = false;
21
- this.subscriptionId = '';
35
+ this.paywall_location = '';
36
+ this.paywall_subscription_package = '';
37
+ this.paywall_subscription_id = 0;
38
+ this.paywall_subscription_price = 0;
39
+ this.paywall_position = 0;
40
+ this.tracker_page_type = '';
41
+ this.tracker_content_id = '';
42
+ this.tracker_content_title = '';
43
+ this.tracker_content_categories = '';
44
+ this.tracker_content_type = '';
45
+ this.tracker_user_type = '';
46
+ this.tracker_subscription_status = '';
47
+ this.tracker_page_domain = '';
48
+ this.tracker_metered_wall_type = '';
49
+ this.tracker_metered_wall_balance = 0;
22
50
  /**
23
51
  * State
24
52
  */
@@ -49,7 +77,42 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
49
77
  }
50
78
  redirectToBerlangganan() {
51
79
  this.dataLayeronPerbaruiLanggananButton();
52
- window.open(`${this.updateSubscription}/kdp?productId=${this.subscriptionId}`);
80
+ const originHost = encodeURIComponent(window.location.href);
81
+ this.sendGtmEvent('subscribe_button_clicked');
82
+ window.open(`${this.updateSubscription}/kdp?productId=${this.paywall_subscription_id}&referrer=${originHost}&source=article`);
83
+ }
84
+ getGtmParams() {
85
+ return {
86
+ paywall_location: this.paywall_location,
87
+ paywall_subscription_package: this.paywall_subscription_package,
88
+ paywall_subscription_id: this.paywall_subscription_id,
89
+ paywall_subscription_price: this.paywall_subscription_price,
90
+ paywall_position: this.paywall_position,
91
+ page_type: this.tracker_page_type,
92
+ content_id: this.tracker_content_id,
93
+ content_title: this.tracker_content_title,
94
+ content_categories: this.tracker_content_categories,
95
+ content_type: this.tracker_content_type,
96
+ user_type: this.tracker_user_type,
97
+ subscription_status: this.tracker_subscription_status,
98
+ page_domain: this.tracker_page_domain || 'Kompas.id',
99
+ metered_wall_type: this.tracker_metered_wall_type || 'GP',
100
+ metered_wall_balance: this.tracker_metered_wall_balance,
101
+ };
102
+ }
103
+ sendGtmEvent(event) {
104
+ let gtmParams = { event };
105
+ if (event === 'paywall_viewed') {
106
+ gtmParams.impressions = [
107
+ {
108
+ ...this.getGtmParams(),
109
+ },
110
+ ];
111
+ }
112
+ else {
113
+ gtmParams = { ...gtmParams, ...this.getGtmParams() };
114
+ }
115
+ window.dataLayer.push(gtmParams);
53
116
  }
54
117
  dataLayeronPerbaruiLanggananButton() {
55
118
  window.dataLayer.push({
@@ -96,6 +159,7 @@ let KompasGracePeriod = class KompasGracePeriod extends LitElement {
96
159
  }
97
160
  async connectedCallback() {
98
161
  super.connectedCallback();
162
+ this.sendGtmEvent('paywall_viewed');
99
163
  this.dataLayeronGracePeriod();
100
164
  }
101
165
  render() {
@@ -132,7 +196,49 @@ __decorate([
132
196
  ], KompasGracePeriod.prototype, "isShowButton", void 0);
133
197
  __decorate([
134
198
  property({ type: String })
135
- ], KompasGracePeriod.prototype, "subscriptionId", void 0);
199
+ ], KompasGracePeriod.prototype, "paywall_location", void 0);
200
+ __decorate([
201
+ property({ type: String })
202
+ ], KompasGracePeriod.prototype, "paywall_subscription_package", void 0);
203
+ __decorate([
204
+ property({ type: Number })
205
+ ], KompasGracePeriod.prototype, "paywall_subscription_id", void 0);
206
+ __decorate([
207
+ property({ type: Number })
208
+ ], KompasGracePeriod.prototype, "paywall_subscription_price", void 0);
209
+ __decorate([
210
+ property({ type: Number })
211
+ ], KompasGracePeriod.prototype, "paywall_position", void 0);
212
+ __decorate([
213
+ property({ type: String })
214
+ ], KompasGracePeriod.prototype, "tracker_page_type", void 0);
215
+ __decorate([
216
+ property({ type: String })
217
+ ], KompasGracePeriod.prototype, "tracker_content_id", void 0);
218
+ __decorate([
219
+ property({ type: String })
220
+ ], KompasGracePeriod.prototype, "tracker_content_title", void 0);
221
+ __decorate([
222
+ property({ type: String })
223
+ ], KompasGracePeriod.prototype, "tracker_content_categories", void 0);
224
+ __decorate([
225
+ property({ type: String })
226
+ ], KompasGracePeriod.prototype, "tracker_content_type", void 0);
227
+ __decorate([
228
+ property({ type: String })
229
+ ], KompasGracePeriod.prototype, "tracker_user_type", void 0);
230
+ __decorate([
231
+ property({ type: String })
232
+ ], KompasGracePeriod.prototype, "tracker_subscription_status", void 0);
233
+ __decorate([
234
+ property({ type: String })
235
+ ], KompasGracePeriod.prototype, "tracker_page_domain", void 0);
236
+ __decorate([
237
+ property({ type: String })
238
+ ], KompasGracePeriod.prototype, "tracker_metered_wall_type", void 0);
239
+ __decorate([
240
+ property({ type: Number })
241
+ ], KompasGracePeriod.prototype, "tracker_metered_wall_balance", void 0);
136
242
  __decorate([
137
243
  state()
138
244
  ], KompasGracePeriod.prototype, "maxGracePeriod", void 0);
@@ -1 +1 @@
1
- {"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/KompasGracePeriod.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAA;AAGjD,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QAiBL;;WAEG;QACH;;;;;WAKG;QAEyB,qBAAgB,GAAG,CAAC,CAAA;QACnB,aAAQ,GAAG,KAAK,CAAA;QAChB,iBAAY,GAAG,KAAK,CAAA;QACrB,mBAAc,GAAG,EAAE,CAAA;QAE/C;;WAEG;QACc,mBAAc,GAAG,CAAC,CAAA;QAClB,uBAAkB,GAAG,8BAA8B,CAAA;IA0FtE,CAAC;IAxFS,uBAAuB;QAC7B,MAAM,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAA;QACjC,MAAM,EAAE,cAAc,EAAE,GAAG,IAAI,CAAA;QAC/B,IAAI,gBAAgB,KAAK,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAA;;;;;;OAMV,CAAA;SACF;QACD,OAAO,IAAI,CAAA;;;;aAIF,cAAc,GAAG,gBAAgB,GAAG,CAAC;;;;KAI7C,CAAA;IACH,CAAC;IAEO,sBAAsB;QAC5B,IAAI,CAAC,kCAAkC,EAAE,CAAA;QACzC,MAAM,CAAC,IAAI,CACT,GAAG,IAAI,CAAC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D,QAAQ;CACT,CAAA;AAY2B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAqB;AACnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAiB;AAChB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAqB;AACrB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAAoB;AAKtC;IAAR,KAAK,EAAE;yDAA2B;AAC1B;IAAR,KAAK,EAAE;6DAA4D;AApCzD,iBAAiB;IAD7B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CA8H7B;SA9HY,iBAAiB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property subscriptionId = used for renewal subs\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = false\n @property({ type: String }) subscriptionId = ''\n\n /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private updateSubscription = 'https://checkoutv2.kompas.id'\n\n private getCountdownGracePeriod() {\n const { totalGracePeriod } = this\n const { maxGracePeriod } = this\n if (totalGracePeriod === 7) {\n return html`\n <p>\n Anda dalam <b class=\"text-orange-500\"> hari terakhir</b> masa tenggang\n langganan. Segera perbarui paket langganan untuk tetap mengakses\n konten premium tanpa batas.\n </p>\n `\n }\n return html`\n <p>\n Masa tenggang langganan Anda tersisa\n <b class=\"text-orange-500\"\n >${maxGracePeriod - totalGracePeriod + 1} hari lagi</b\n >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n tanpa batas.\n </p>\n `\n }\n\n private redirectToBerlangganan(): void {\n this.dataLayeronPerbaruiLanggananButton()\n window.open(\n `${this.updateSubscription}/kdp?productId=${this.subscriptionId}`\n )\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n return html`\n <div\n class=\"${this.isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8'} flex flex-col w-full justify-end py-4 md:space-x-4 px-4 bottom-0 max-w-7xl mx-auto\"\n >\n <div class=\"text-grey-600 text-sm md:text-base self-center text-left\">\n ${this.getCountdownGracePeriod()}\n </div>\n ${!this.isShowButton\n ? html`\n <div\n class=\"flex self-center w-full md:w-1/2 justify-end pt-4 md:pt-0\"\n >\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-green-500 p-2 px-5 rounded-md font-bold text-grey-100 text-sm md:text-base w-full md:w-auto\"\n >\n Perbarui Langganan\n </button>\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n this.dataLayeronGracePeriod()\n }\n\n render() {\n return html`\n <div class=\"sticky bottom-0 w-full h-full bg-orange-100\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}
1
+ {"version":3,"file":"KompasGracePeriod.js","sourceRoot":"","sources":["../../../../src/components/kompasid-grace-period/K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B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAuB;AACtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sEAAiC;AAChC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8DAAyB;AACxB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oEAA+B;AAC9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAAiC;AAKnD;IAAR,KAAK,EAAE;yDAA2B;AAC1B;IAAR,KAAK,EAAE;6DAA4D;AAhEzD,iBAAiB;IAD7B,aAAa,CAAC,uBAAuB,CAAC;GAC1B,iBAAiB,CAqM7B;SArMY,iBAAiB","sourcesContent":["import { LitElement, html, css, nothing } from 'lit'\nimport { customElement, property, state } from 'lit/decorators.js'\nimport { deviceType } from '../../utils/deviceType.js'\nimport { TWStyles } from '../../../tailwind/tailwind.js'\n\n@customElement('kompasid-grace-period')\nexport class KompasGracePeriod extends LitElement {\n static styles = [\n css`\n :host {\n font-family: 'PT Sans', sans-serif;\n }\n\n .body {\n position: sticky;\n top: 0;\n height: 100%;\n width: 100%;\n }\n `,\n TWStyles,\n ]\n\n /**\n * Props\n */\n /**\n * property totalGracePeriod = how many days are left in grace period\n * property isColumn = changes how the component looks on different screen sizes\n * property isShowButton = shows or hides a subscription button\n * property paywall_location = the location where user encounter the paywall\n * property paywall_subscription_package = the name of the subscription package viewed by user\n * property paywall_subscription_id = the ID of the subscription package viewed by user\n * property paywall_subscription_price = the price of the subscriprtion package viewed by user\n * property paywall_position = the position of the subscription package viewed by user\n * property tracker_page_type = type of the page\n * property tracker_content_id = ID of article (slug)\n * property tracker_content_type = whether it's free article or paid article\n * property tracker_content_title = the title of article\n * property tracker_content_categories = the category of the content\n * property tracker_user_type = type of user based on their subscription\n * property tracker_subscription_status = status of their subscription\n * property tracker_page_domain = page Domain\n * property tracker_metered_wall_type = the type of Metered Wall\n * property tracker_metered_wall_balance = the balance of their metered wall\n */\n\n @property({ type: Number }) totalGracePeriod = 0\n @property({ type: Boolean }) isColumn = false\n @property({ type: Boolean }) isShowButton = false\n @property({ type: String }) paywall_location = ''\n @property({ type: String }) paywall_subscription_package = ''\n @property({ type: Number }) paywall_subscription_id = 0\n @property({ type: Number }) paywall_subscription_price = 0\n @property({ type: Number }) paywall_position = 0\n @property({ type: String }) tracker_page_type = ''\n @property({ type: String }) tracker_content_id = ''\n @property({ type: String }) tracker_content_title = ''\n @property({ type: String }) tracker_content_categories = ''\n @property({ type: String }) tracker_content_type = ''\n @property({ type: String }) tracker_user_type = ''\n @property({ type: String }) tracker_subscription_status = ''\n @property({ type: String }) tracker_page_domain = ''\n @property({ type: String }) tracker_metered_wall_type = ''\n @property({ type: Number }) tracker_metered_wall_balance = 0\n\n /**\n * State\n */\n @state() private maxGracePeriod = 7\n @state() private updateSubscription = 'https://checkoutv2.kompas.id'\n\n private getCountdownGracePeriod() {\n const { totalGracePeriod } = this\n const { maxGracePeriod } = this\n if (totalGracePeriod === 7) {\n return html`\n <p>\n Anda dalam <b class=\"text-orange-500\"> hari terakhir</b> masa tenggang\n langganan. Segera perbarui paket langganan untuk tetap mengakses\n konten premium tanpa batas.\n </p>\n `\n }\n return html`\n <p>\n Masa tenggang langganan Anda tersisa\n <b class=\"text-orange-500\"\n >${maxGracePeriod - totalGracePeriod + 1} hari lagi</b\n >. Segera perbarui paket langganan untuk tetap mengakses konten premium\n tanpa batas.\n </p>\n `\n }\n\n private redirectToBerlangganan(): void {\n this.dataLayeronPerbaruiLanggananButton()\n const originHost: string = encodeURIComponent(window.location.href)\n\n this.sendGtmEvent('subscribe_button_clicked')\n\n window.open(\n `${this.updateSubscription}/kdp?productId=${this.paywall_subscription_id}&referrer=${originHost}&source=article`\n )\n }\n\n private getGtmParams(): Record<string, any> {\n return {\n paywall_location: this.paywall_location,\n paywall_subscription_package: this.paywall_subscription_package,\n paywall_subscription_id: this.paywall_subscription_id,\n paywall_subscription_price: this.paywall_subscription_price,\n paywall_position: this.paywall_position,\n page_type: this.tracker_page_type,\n content_id: this.tracker_content_id,\n content_title: this.tracker_content_title,\n content_categories: this.tracker_content_categories,\n content_type: this.tracker_content_type,\n user_type: this.tracker_user_type,\n subscription_status: this.tracker_subscription_status,\n page_domain: this.tracker_page_domain || 'Kompas.id',\n metered_wall_type: this.tracker_metered_wall_type || 'GP',\n metered_wall_balance: this.tracker_metered_wall_balance,\n }\n }\n\n private sendGtmEvent(event: string) {\n let gtmParams: Record<string, any> = { event }\n\n if (event === 'paywall_viewed') {\n gtmParams.impressions = [\n {\n ...this.getGtmParams(),\n },\n ]\n } else {\n gtmParams = { ...gtmParams, ...this.getGtmParams() }\n }\n\n window.dataLayer.push(gtmParams)\n }\n\n private dataLayeronPerbaruiLanggananButton(): void {\n window.dataLayer.push({\n event: 'gracePeriodClick',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private dataLayeronGracePeriod(): void {\n window.dataLayer.push({\n event: 'gracePeriodImpression',\n interface: deviceType(),\n dayLeft: this.maxGracePeriod - this.totalGracePeriod,\n urlName: window.location.href,\n })\n }\n\n private gracePeriodTemplate() {\n return html`\n <div\n class=\"${this.isColumn\n ? 'rounded-lg'\n : 'md:flex-row lg:px-8'} flex flex-col w-full justify-end py-4 md:space-x-4 px-4 bottom-0 max-w-7xl mx-auto\"\n >\n <div class=\"text-grey-600 text-sm md:text-base self-center text-left\">\n ${this.getCountdownGracePeriod()}\n </div>\n ${!this.isShowButton\n ? html`\n <div\n class=\"flex self-center w-full md:w-1/2 justify-end pt-4 md:pt-0\"\n >\n <button\n @click=${this.redirectToBerlangganan}\n class=\"bg-green-500 p-2 px-5 rounded-md font-bold text-grey-100 text-sm md:text-base w-full md:w-auto\"\n >\n Perbarui Langganan\n </button>\n </div>\n `\n : nothing}\n </div>\n `\n }\n\n override async connectedCallback() {\n super.connectedCallback()\n\n this.sendGtmEvent('paywall_viewed')\n\n this.dataLayeronGracePeriod()\n }\n\n render() {\n return html`\n <div class=\"sticky bottom-0 w-full h-full bg-orange-100\">\n ${this.totalGracePeriod > 0 ? this.gracePeriodTemplate() : nothing}\n </div>\n `\n }\n}\n"]}