@subiz/widget-v4 4.0.68 → 4.0.71

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.
@@ -29,6 +29,14 @@ cookie.defaults.path = '/';
29
29
  cookie.expiresMultiplier = 60 * 60 * 24;
30
30
  cookie.defaults.expires = 3650;
31
31
  const MAX_CONVO = 20;
32
+ let ga_client_id = '';
33
+ setTimeout(() => {
34
+ if (window.gtag) {
35
+ window.gtag('get', 'UA-XXXXXXXX-Y', 'client_id', clientid => {
36
+ ga_client_id = clientid;
37
+ });
38
+ }
39
+ }, 100);
32
40
 
33
41
  const page_loaded = _index.default.Date.now();
34
42
 
@@ -170,7 +178,9 @@ class Store {
170
178
 
171
179
  _defineProperty(this, "seenQueue", []);
172
180
 
173
- _defineProperty(this, "_typing", _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000));
181
+ _defineProperty(this, "_typing", _index.default.throttle(convoid => this.api.sendTyping(convoid), 3000, {
182
+ trailing: false
183
+ }));
174
184
 
175
185
  _defineProperty(this, "onConvoEvent", (o, cb) => this.pubsub.on2(o, 'events', cb));
176
186
 
@@ -1182,20 +1192,22 @@ const inmemCookie = {
1182
1192
  };
1183
1193
 
1184
1194
  function getGaClientId() {
1185
- var clientId = '';
1186
- if (!hasGA()) return clientId;
1195
+ if (ga_client_id) return ga_client_id;
1196
+ if (!hasGA()) return ga_client_id;
1197
+ if (!window.ga) return;
1187
1198
  var allTrackers = window.ga.getAll() || [];
1188
1199
  allTrackers.forEach(function (tracker) {
1189
- clientId = tracker.get('clientId');
1200
+ ga_client_id = tracker.get('clientId');
1190
1201
  });
1191
- return clientId;
1202
+ return ga_client_id;
1192
1203
  }
1193
1204
 
1194
- const hasGA = () => !!(window.ga && window.ga.getAll);
1205
+ const hasGA = () => !!(window.ga && window.ga.getAll || window.gtag);
1195
1206
 
1196
1207
  function getGaTrackingIds() {
1197
1208
  var trackingIds = [];
1198
1209
  if (!hasGA()) return trackingIds;
1210
+ if (!window.ga) return [];
1199
1211
  const allTrackers = window.ga.getAll() || [];
1200
1212
  allTrackers.forEach(function (tracker) {
1201
1213
  var trackingId = tracker.get('trackingId');
@@ -1214,11 +1226,18 @@ function sendToFBPixel(category, action, label) {
1214
1226
 
1215
1227
  function sendToGA(category, action, label) {
1216
1228
  if (!hasGA()) return;
1217
- const allTrackers = window.ga.getAll() || [];
1218
- allTrackers.forEach(function (tracker) {
1219
- const name = tracker.get('name');
1220
- window.ga(name + '.send', 'event', category, action, label);
1229
+ if (window.gtag) window.gtag('event', category, {
1230
+ Action: action,
1231
+ Label: label
1221
1232
  });
1233
+
1234
+ if (window.ga) {
1235
+ const allTrackers = window.ga.getAll() || [];
1236
+ allTrackers.forEach(function (tracker) {
1237
+ const name = tracker.get('name');
1238
+ window.ga(name + '.send', 'event', category, action, label);
1239
+ });
1240
+ }
1222
1241
  }
1223
1242
 
1224
1243
  function sendEventToThirdParty(category, action, label) {
package/dist/441.js CHANGED
@@ -96,6 +96,9 @@ function escape(html, encode) {
96
96
 
97
97
  const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
98
98
 
99
+ /**
100
+ * @param {string} html
101
+ */
99
102
  function unescape(html) {
100
103
  // explicitly match decimal, hex, and named HTML entities
101
104
  return html.replace(unescapeTest, (_, n) => {
@@ -111,8 +114,13 @@ function unescape(html) {
111
114
  }
112
115
 
113
116
  const caret = /(^|[^\[])\^/g;
117
+
118
+ /**
119
+ * @param {string | RegExp} regex
120
+ * @param {string} opt
121
+ */
114
122
  function edit(regex, opt) {
115
- regex = regex.source || regex;
123
+ regex = typeof regex === 'string' ? regex : regex.source;
116
124
  opt = opt || '';
117
125
  const obj = {
118
126
  replace: (name, val) => {
@@ -130,6 +138,12 @@ function edit(regex, opt) {
130
138
 
131
139
  const nonWordAndColonTest = /[^\w:]/g;
132
140
  const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
141
+
142
+ /**
143
+ * @param {boolean} sanitize
144
+ * @param {string} base
145
+ * @param {string} href
146
+ */
133
147
  function cleanUrl(sanitize, base, href) {
134
148
  if (sanitize) {
135
149
  let prot;
@@ -160,6 +174,10 @@ const justDomain = /^[^:]+:\/*[^/]*$/;
160
174
  const protocol = /^([^:]+:)[\s\S]*$/;
161
175
  const domain = /^([^:]+:\/*[^/]*)[\s\S]*$/;
162
176
 
177
+ /**
178
+ * @param {string} base
179
+ * @param {string} href
180
+ */
163
181
  function resolveUrl(base, href) {
164
182
  if (!baseUrls[' ' + base]) {
165
183
  // we can ignore everything in base after the last slash of its path component,
@@ -244,9 +262,14 @@ function splitCells(tableRow, count) {
244
262
  return cells;
245
263
  }
246
264
 
247
- // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
248
- // /c*$/ is vulnerable to REDOS.
249
- // invert: Remove suffix of non-c chars instead. Default falsey.
265
+ /**
266
+ * Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
267
+ * /c*$/ is vulnerable to REDOS.
268
+ *
269
+ * @param {string} str
270
+ * @param {string} c
271
+ * @param {boolean} invert Remove suffix of non-c chars instead. Default falsey.
272
+ */
250
273
  function rtrim(str, c, invert) {
251
274
  const l = str.length;
252
275
  if (l === 0) {
@@ -268,7 +291,7 @@ function rtrim(str, c, invert) {
268
291
  }
269
292
  }
270
293
 
271
- return str.substr(0, l - suffLen);
294
+ return str.slice(0, l - suffLen);
272
295
  }
273
296
 
274
297
  function findClosingBracket(str, b) {
@@ -300,6 +323,10 @@ function checkSanitizeDeprecation(opt) {
300
323
  }
301
324
 
302
325
  // copied from https://stackoverflow.com/a/5450113/806777
326
+ /**
327
+ * @param {string} pattern
328
+ * @param {number} count
329
+ */
303
330
  function repeatString(pattern, count) {
304
331
  if (count < 1) {
305
332
  return '';
@@ -460,7 +487,7 @@ class Tokenizer {
460
487
  blockquote(src) {
461
488
  const cap = this.rules.block.blockquote.exec(src);
462
489
  if (cap) {
463
- const text = cap[0].replace(/^ *> ?/gm, '');
490
+ const text = cap[0].replace(/^ *>[ \t]?/gm, '');
464
491
 
465
492
  return {
466
493
  type: 'blockquote',
@@ -496,7 +523,7 @@ class Tokenizer {
496
523
  }
497
524
 
498
525
  // Get next list item
499
- const itemRegex = new RegExp(`^( {0,3}${bull})((?: [^\\n]*)?(?:\\n|$))`);
526
+ const itemRegex = new RegExp(`^( {0,3}${bull})((?:[\t ][^\\n]*)?(?:\\n|$))`);
500
527
 
501
528
  // Check if current bullet point can start a new List Item
502
529
  while (src) {
@@ -1083,10 +1110,10 @@ const block = {
1083
1110
  newline: /^(?: *(?:\n|$))+/,
1084
1111
  code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,
1085
1112
  fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?=\n|$)|$)/,
1086
- hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
1113
+ hr: /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,
1087
1114
  heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,
1088
1115
  blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
1089
- list: /^( {0,3}bull)( [^\n]+?)?(?:\n|$)/,
1116
+ list: /^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/,
1090
1117
  html: '^ {0,3}(?:' // optional indentation
1091
1118
  + '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
1092
1119
  + '|comment[^\\n]*(\\n+|$)' // (2)
@@ -1240,9 +1267,9 @@ const inline = {
1240
1267
  emStrong: {
1241
1268
  lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,
1242
1269
  // (1) and (2) can only be a Right Delimiter. (3) and (4) can only be Left. (5) and (6) can be either Left or Right.
1243
- // () Skip orphan delim inside strong (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1244
- rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
1245
- rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
1270
+ // () Skip orphan inside strong () Consume to delim (1) #*** (2) a***#, a*** (3) #***a, ***a (4) ***# (5) #***# (6) a***a
1271
+ rDelimAst: /^[^_*]*?\_\_[^_*]*?\*[^_*]*?(?=\_\_)|[^*]+(?=[^*])|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,
1272
+ rDelimUnd: /^[^_*]*?\*\*[^_*]*?\_[^_*]*?(?=\*\*)|[^_]+(?=[^_])|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ // ^- Not allowed for _
1246
1273
  },
1247
1274
  code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
1248
1275
  br: /^( {2,}|\\)\n(?!\s*$)/,
@@ -1375,6 +1402,7 @@ inline.breaks = merge({}, inline.gfm, {
1375
1402
 
1376
1403
  /**
1377
1404
  * smartypants text replacement
1405
+ * @param {string} text
1378
1406
  */
1379
1407
  function smartypants(text) {
1380
1408
  return text
@@ -1396,6 +1424,7 @@ function smartypants(text) {
1396
1424
 
1397
1425
  /**
1398
1426
  * mangle email addresses
1427
+ * @param {string} text
1399
1428
  */
1400
1429
  function mangle(text) {
1401
1430
  let out = '',
@@ -1483,8 +1512,7 @@ class Lexer {
1483
1512
  */
1484
1513
  lex(src) {
1485
1514
  src = src
1486
- .replace(/\r\n|\r/g, '\n')
1487
- .replace(/\t/g, ' ');
1515
+ .replace(/\r\n|\r/g, '\n');
1488
1516
 
1489
1517
  this.blockTokens(src, this.tokens);
1490
1518
 
@@ -1501,8 +1529,13 @@ class Lexer {
1501
1529
  */
1502
1530
  blockTokens(src, tokens = []) {
1503
1531
  if (this.options.pedantic) {
1504
- src = src.replace(/^ +$/gm, '');
1532
+ src = src.replace(/\t/g, ' ').replace(/^ +$/gm, '');
1533
+ } else {
1534
+ src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
1535
+ return leading + ' '.repeat(tabs.length);
1536
+ });
1505
1537
  }
1538
+
1506
1539
  let token, lastToken, cutSrc, lastParagraphClipped;
1507
1540
 
1508
1541
  while (src) {
@@ -1898,29 +1931,31 @@ class Renderer {
1898
1931
  + '</code></pre>\n';
1899
1932
  }
1900
1933
 
1934
+ /**
1935
+ * @param {string} quote
1936
+ */
1901
1937
  blockquote(quote) {
1902
- return '<blockquote>\n' + quote + '</blockquote>\n';
1938
+ return `<blockquote>\n${quote}</blockquote>\n`;
1903
1939
  }
1904
1940
 
1905
1941
  html(html) {
1906
1942
  return html;
1907
1943
  }
1908
1944
 
1945
+ /**
1946
+ * @param {string} text
1947
+ * @param {string} level
1948
+ * @param {string} raw
1949
+ * @param {any} slugger
1950
+ */
1909
1951
  heading(text, level, raw, slugger) {
1910
1952
  if (this.options.headerIds) {
1911
- return '<h'
1912
- + level
1913
- + ' id="'
1914
- + this.options.headerPrefix
1915
- + slugger.slug(raw)
1916
- + '">'
1917
- + text
1918
- + '</h'
1919
- + level
1920
- + '>\n';
1953
+ const id = this.options.headerPrefix + slugger.slug(raw);
1954
+ return `<h${level} id="${id}">${text}</h${level}>\n`;
1921
1955
  }
1956
+
1922
1957
  // ignore IDs
1923
- return '<h' + level + '>' + text + '</h' + level + '>\n';
1958
+ return `<h${level}>${text}</h${level}>\n`;
1924
1959
  }
1925
1960
 
1926
1961
  hr() {
@@ -1933,8 +1968,11 @@ class Renderer {
1933
1968
  return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
1934
1969
  }
1935
1970
 
1971
+ /**
1972
+ * @param {string} text
1973
+ */
1936
1974
  listitem(text) {
1937
- return '<li>' + text + '</li>\n';
1975
+ return `<li>${text}</li>\n`;
1938
1976
  }
1939
1977
 
1940
1978
  checkbox(checked) {
@@ -1945,12 +1983,19 @@ class Renderer {
1945
1983
  + '> ';
1946
1984
  }
1947
1985
 
1986
+ /**
1987
+ * @param {string} text
1988
+ */
1948
1989
  paragraph(text) {
1949
- return '<p>' + text + '</p>\n';
1990
+ return `<p>${text}</p>\n`;
1950
1991
  }
1951
1992
 
1993
+ /**
1994
+ * @param {string} header
1995
+ * @param {string} body
1996
+ */
1952
1997
  table(header, body) {
1953
- if (body) body = '<tbody>' + body + '</tbody>';
1998
+ if (body) body = `<tbody>${body}</tbody>`;
1954
1999
 
1955
2000
  return '<table>\n'
1956
2001
  + '<thead>\n'
@@ -1960,39 +2005,59 @@ class Renderer {
1960
2005
  + '</table>\n';
1961
2006
  }
1962
2007
 
2008
+ /**
2009
+ * @param {string} content
2010
+ */
1963
2011
  tablerow(content) {
1964
- return '<tr>\n' + content + '</tr>\n';
2012
+ return `<tr>\n${content}</tr>\n`;
1965
2013
  }
1966
2014
 
1967
2015
  tablecell(content, flags) {
1968
2016
  const type = flags.header ? 'th' : 'td';
1969
2017
  const tag = flags.align
1970
- ? '<' + type + ' align="' + flags.align + '">'
1971
- : '<' + type + '>';
1972
- return tag + content + '</' + type + '>\n';
2018
+ ? `<${type} align="${flags.align}">`
2019
+ : `<${type}>`;
2020
+ return tag + content + `</${type}>\n`;
1973
2021
  }
1974
2022
 
1975
- // span level renderer
2023
+ /**
2024
+ * span level renderer
2025
+ * @param {string} text
2026
+ */
1976
2027
  strong(text) {
1977
- return '<strong>' + text + '</strong>';
2028
+ return `<strong>${text}</strong>`;
1978
2029
  }
1979
2030
 
2031
+ /**
2032
+ * @param {string} text
2033
+ */
1980
2034
  em(text) {
1981
- return '<em>' + text + '</em>';
2035
+ return `<em>${text}</em>`;
1982
2036
  }
1983
2037
 
2038
+ /**
2039
+ * @param {string} text
2040
+ */
1984
2041
  codespan(text) {
1985
- return '<code>' + text + '</code>';
2042
+ return `<code>${text}</code>`;
1986
2043
  }
1987
2044
 
1988
2045
  br() {
1989
2046
  return this.options.xhtml ? '<br/>' : '<br>';
1990
2047
  }
1991
2048
 
2049
+ /**
2050
+ * @param {string} text
2051
+ */
1992
2052
  del(text) {
1993
- return '<del>' + text + '</del>';
2053
+ return `<del>${text}</del>`;
1994
2054
  }
1995
2055
 
2056
+ /**
2057
+ * @param {string} href
2058
+ * @param {string} title
2059
+ * @param {string} text
2060
+ */
1996
2061
  link(href, title, text) {
1997
2062
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
1998
2063
  if (href === null) {
@@ -2006,15 +2071,20 @@ class Renderer {
2006
2071
  return out;
2007
2072
  }
2008
2073
 
2074
+ /**
2075
+ * @param {string} href
2076
+ * @param {string} title
2077
+ * @param {string} text
2078
+ */
2009
2079
  image(href, title, text) {
2010
2080
  href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
2011
2081
  if (href === null) {
2012
2082
  return text;
2013
2083
  }
2014
2084
 
2015
- let out = '<img src="' + href + '" alt="' + text + '"';
2085
+ let out = `<img src="${href}" alt="${text}"`;
2016
2086
  if (title) {
2017
- out += ' title="' + title + '"';
2087
+ out += ` title="${title}"`;
2018
2088
  }
2019
2089
  out += this.options.xhtml ? '/>' : '>';
2020
2090
  return out;
@@ -2076,6 +2146,9 @@ class Slugger {
2076
2146
  this.seen = {};
2077
2147
  }
2078
2148
 
2149
+ /**
2150
+ * @param {string} value
2151
+ */
2079
2152
  serialize(value) {
2080
2153
  return value
2081
2154
  .toLowerCase()
@@ -2089,6 +2162,8 @@ class Slugger {
2089
2162
 
2090
2163
  /**
2091
2164
  * Finds the next safe (unique) slug to use
2165
+ * @param {string} originalSlug
2166
+ * @param {boolean} isDryRun
2092
2167
  */
2093
2168
  getNextSafeSlug(originalSlug, isDryRun) {
2094
2169
  let slug = originalSlug;
@@ -2109,8 +2184,9 @@ class Slugger {
2109
2184
 
2110
2185
  /**
2111
2186
  * Convert string to unique id
2112
- * @param {object} options
2113
- * @param {boolean} options.dryrun Generates the next unique slug without updating the internal accumulator.
2187
+ * @param {object} [options]
2188
+ * @param {boolean} [options.dryrun] Generates the next unique slug without
2189
+ * updating the internal accumulator.
2114
2190
  */
2115
2191
  slug(value, options = {}) {
2116
2192
  const slug = this.serialize(value);
@@ -2671,6 +2747,7 @@ marked.walkTokens = function(tokens, callback) {
2671
2747
 
2672
2748
  /**
2673
2749
  * Parse Inline
2750
+ * @param {string} src
2674
2751
  */
2675
2752
  marked.parseInline = function(src, opt) {
2676
2753
  // throw error in case of non string input
package/dist/HASH CHANGED
@@ -1 +1 @@
1
- 1801c652a77
1
+ 1804ba3360a
@@ -4,4 +4,4 @@
4
4
  }
5
5
  body {
6
6
  background: #ddd;
7
- }</style></head><body><script defer="defer" src="https://vcdn.subiz-cdn.com/widget-v4/public/1801c652a77.screenshoot.js"></script></body></html>
7
+ }</style></head><body><script defer="defer" src="https://vcdn.subiz-cdn.com/widget-v4/public/1804ba3360a.screenshoot.js"></script></body></html>
@@ -4181,6 +4181,14 @@ cookie.defaults.path = '/';
4181
4181
  cookie.expiresMultiplier = 60 * 60 * 24;
4182
4182
  cookie.defaults.expires = 3650;
4183
4183
  const MAX_CONVO = 20;
4184
+ let ga_client_id = '';
4185
+ setTimeout(() => {
4186
+ if (window.gtag) {
4187
+ window.gtag('get', 'UA-XXXXXXXX-Y', 'client_id', clientid => {
4188
+ ga_client_id = clientid;
4189
+ });
4190
+ }
4191
+ }, 100);
4184
4192
  const page_loaded = util/* default.Date.now */.Z.Date.now();
4185
4193
  class Store {
4186
4194
  constructor(ApiURL, FileURL, RealtimeURL, inmem, fakeapi, agenttoken) {
@@ -4318,7 +4326,9 @@ class Store {
4318
4326
 
4319
4327
  store_defineProperty(this, "seenQueue", []);
4320
4328
 
4321
- store_defineProperty(this, "_typing", util/* default.throttle */.Z.throttle(convoid => this.api.sendTyping(convoid), 3000));
4329
+ store_defineProperty(this, "_typing", util/* default.throttle */.Z.throttle(convoid => this.api.sendTyping(convoid), 3000, {
4330
+ trailing: false
4331
+ }));
4322
4332
 
4323
4333
  store_defineProperty(this, "onConvoEvent", (o, cb) => this.pubsub.on2(o, 'events', cb));
4324
4334
 
@@ -5266,20 +5276,22 @@ const inmemCookie = {
5266
5276
  };
5267
5277
 
5268
5278
  function getGaClientId() {
5269
- var clientId = '';
5270
- if (!hasGA()) return clientId;
5279
+ if (ga_client_id) return ga_client_id;
5280
+ if (!hasGA()) return ga_client_id;
5281
+ if (!window.ga) return;
5271
5282
  var allTrackers = window.ga.getAll() || [];
5272
5283
  allTrackers.forEach(function (tracker) {
5273
- clientId = tracker.get('clientId');
5284
+ ga_client_id = tracker.get('clientId');
5274
5285
  });
5275
- return clientId;
5286
+ return ga_client_id;
5276
5287
  }
5277
5288
 
5278
- const hasGA = () => !!(window.ga && window.ga.getAll);
5289
+ const hasGA = () => !!(window.ga && window.ga.getAll || window.gtag);
5279
5290
 
5280
5291
  function getGaTrackingIds() {
5281
5292
  var trackingIds = [];
5282
5293
  if (!hasGA()) return trackingIds;
5294
+ if (!window.ga) return [];
5283
5295
  const allTrackers = window.ga.getAll() || [];
5284
5296
  allTrackers.forEach(function (tracker) {
5285
5297
  var trackingId = tracker.get('trackingId');
@@ -5298,11 +5310,18 @@ function sendToFBPixel(category, action, label) {
5298
5310
 
5299
5311
  function sendToGA(category, action, label) {
5300
5312
  if (!hasGA()) return;
5301
- const allTrackers = window.ga.getAll() || [];
5302
- allTrackers.forEach(function (tracker) {
5303
- const name = tracker.get('name');
5304
- window.ga(name + '.send', 'event', category, action, label);
5313
+ if (window.gtag) window.gtag('event', category, {
5314
+ Action: action,
5315
+ Label: label
5305
5316
  });
5317
+
5318
+ if (window.ga) {
5319
+ const allTrackers = window.ga.getAll() || [];
5320
+ allTrackers.forEach(function (tracker) {
5321
+ const name = tracker.get('name');
5322
+ window.ga(name + '.send', 'event', category, action, label);
5323
+ });
5324
+ }
5306
5325
  }
5307
5326
 
5308
5327
  function sendEventToThirdParty(category, action, label) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@subiz/widget-v4",
3
- "version": "4.0.68",
3
+ "version": "4.0.71",
4
4
  "main": "./compiled_src/lib.js",
5
5
  "scripts": {
6
6
  "dev": "npx webpack serve --config webpack.dev.js",
@@ -14,16 +14,16 @@
14
14
  "@subiz/storage": "0.0.8",
15
15
  "@subiz/wsclient": "^3.1.7",
16
16
  "cookie_js": "1.4.2",
17
- "core-js": "^3.21.1",
17
+ "core-js": "^3.22.1",
18
18
  "css-loader": "5.2.7",
19
19
  "file-loader": "^6.2.0",
20
20
  "less": "^4.1.2",
21
21
  "less-loader": "^10.2.0",
22
- "marked": "^4.0.12",
23
- "preact": "^10.7.0"
22
+ "marked": "^4.0.14",
23
+ "preact": "^10.7.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@babel/core": "^7.17.8",
26
+ "@babel/core": "^7.17.9",
27
27
  "@babel/plugin-proposal-class-properties": "^7.16.7",
28
28
  "@babel/plugin-transform-react-jsx": "^7.17.3",
29
29
  "@babel/preset-env": "^7.16.11",
@@ -31,10 +31,10 @@
31
31
  "babel-loader": "^8.2.4",
32
32
  "babel-plugin-syntax-jsx": "^6.18.0",
33
33
  "html-webpack-plugin": "^5.5.0",
34
- "puppeteer": "^13.5.2",
35
- "webpack": "^5.70.0",
34
+ "puppeteer": "^13.6.0",
35
+ "webpack": "^5.72.0",
36
36
  "webpack-bundle-analyzer": "^4.5.0",
37
37
  "webpack-cli": "^4.9.2",
38
- "webpack-dev-server": "^4.7.4"
38
+ "webpack-dev-server": "^4.8.1"
39
39
  }
40
40
  }
@@ -11,6 +11,15 @@ cookie.expiresMultiplier = 60 * 60 * 24 // days
11
11
  cookie.defaults.expires = 3650 // 10 year
12
12
 
13
13
  const MAX_CONVO = 20
14
+ let ga_client_id = ''
15
+
16
+ setTimeout(() => {
17
+ if (window.gtag) {
18
+ window.gtag('get', 'UA-XXXXXXXX-Y', 'client_id', (clientid) => {
19
+ ga_client_id = clientid
20
+ })
21
+ }
22
+ }, 100)
14
23
 
15
24
  const page_loaded = sb.Date.now()
16
25
 
@@ -740,7 +749,7 @@ export default class Store {
740
749
  this._typing(cid)
741
750
  }
742
751
 
743
- _typing = sb.throttle((convoid) => this.api.sendTyping(convoid), 3000)
752
+ _typing = sb.throttle((convoid) => this.api.sendTyping(convoid), 3000, {trailing: false})
744
753
 
745
754
  async startConvo(req) {
746
755
  await this.readyGate.entry()
@@ -1091,19 +1100,20 @@ const inmemCookie = {
1091
1100
  // getGaClientId returns ID of the client in Google Analytics
1092
1101
  // return empty string if GA is not installed
1093
1102
  function getGaClientId() {
1094
- var clientId = ''
1095
- if (!hasGA()) return clientId
1103
+ if (ga_client_id) return ga_client_id
1104
+ if (!hasGA()) return ga_client_id
1096
1105
 
1106
+ if (!window.ga) return
1097
1107
  var allTrackers = window.ga.getAll() || []
1098
1108
  allTrackers.forEach(function (tracker) {
1099
- clientId = tracker.get('clientId')
1109
+ ga_client_id = tracker.get('clientId')
1100
1110
  })
1101
1111
 
1102
- return clientId
1112
+ return ga_client_id
1103
1113
  }
1104
1114
 
1105
1115
  // hasGA tells if the website is using Google Analytics or not
1106
- const hasGA = () => !!(window.ga && window.ga.getAll)
1116
+ const hasGA = () => !!((window.ga && window.ga.getAll) || window.gtag)
1107
1117
 
1108
1118
  // getGaTrackingIds returns all tracking ids in Google Analytics
1109
1119
  // return empty array if GA is not installed
@@ -1111,6 +1121,7 @@ function getGaTrackingIds() {
1111
1121
  var trackingIds = []
1112
1122
  if (!hasGA()) return trackingIds
1113
1123
 
1124
+ if (!window.ga) return []
1114
1125
  const allTrackers = window.ga.getAll() || []
1115
1126
  allTrackers.forEach(function (tracker) {
1116
1127
  var trackingId = tracker.get('trackingId')
@@ -1129,11 +1140,15 @@ function sendToFBPixel(category, action, label) {
1129
1140
  function sendToGA(category, action, label) {
1130
1141
  if (!hasGA()) return
1131
1142
 
1132
- const allTrackers = window.ga.getAll() || []
1133
- allTrackers.forEach(function (tracker) {
1134
- const name = tracker.get('name')
1135
- window.ga(name + '.send', 'event', category, action, label)
1136
- })
1143
+ if (window.gtag) window.gtag('event', category, {Action: action, Label: label})
1144
+
1145
+ if (window.ga) {
1146
+ const allTrackers = window.ga.getAll() || []
1147
+ allTrackers.forEach(function (tracker) {
1148
+ const name = tracker.get('name')
1149
+ window.ga(name + '.send', 'event', category, action, label)
1150
+ })
1151
+ }
1137
1152
  }
1138
1153
 
1139
1154
  function sendEventToThirdParty(category, action, label) {
package/up CHANGED
@@ -38,6 +38,6 @@ sleep 5
38
38
 
39
39
  echo "Remove cloudfare cache"
40
40
  # PURGE CLOUD FLARE CACHE
41
- curl -X POST "https://api.cloudflare.com/client/v4/zones/e8f5c860cbbc130dd389313324a6c35e/purge_cache" -H "X-Auth-Email: thanhpham@vietnambiz.com" -H "X-Auth-Key: $(cat ~/.cloudflare)"
41
+ curl -X POST "https://api.cloudflare.com/client/v4/zones/e8f5c860cbbc130dd389313324a6c35e/purge_cache" -H "X-Auth-Email: thanhpham@vietnambiz.com" -H "X-Auth-Key: $(cat ~/.cloudflare)" -H "Content-Type: application/json" --data '{"purge_everything":true}'
42
42
 
43
43
  echo "Success. $(cat dist/HASH)"