@driveflux/web-analytics 1.0.2
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/.eslintrc +3 -0
- package/.turbo/turbo-build.log +11 -0
- package/CHANGELOG.md +13 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/track.js +471 -0
- package/dist/track.d.ts +33 -0
- package/dist/track.d.ts.map +1 -0
- package/dist/track.js +445 -0
- package/package.json +38 -0
- package/src/track.ts +209 -0
- package/track.cjs +1 -0
- package/track.d.ts +1 -0
- package/tsconfig.json +12 -0
- package/tsconfig.tsbuildinfo +1 -0
package/.eslintrc
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
2
|
+
|
|
3
|
+
> @driveflux/web-analytics@1.0.2 build /Users/flux/Projects/flux-master/shared/web-analytics
|
|
4
|
+
> fab
|
|
5
|
+
|
|
6
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
7
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
8
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
9
|
+
[43m[30m WARN [39m[49m Issue while reading "/Users/flux/Projects/flux-master/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
10
|
+
Successfully compiled: 1 file with swc (255.81ms)
|
|
11
|
+
Successfully compiled: 1 file with swc (285.37ms)
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: all[name]
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
_export(exports, {
|
|
12
|
+
getGA4ClientId: function() {
|
|
13
|
+
return getGA4ClientId;
|
|
14
|
+
},
|
|
15
|
+
useAutoTrackEvent: function() {
|
|
16
|
+
return useAutoTrackEvent;
|
|
17
|
+
},
|
|
18
|
+
useTrackEvent: function() {
|
|
19
|
+
return useTrackEvent;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
var _google = require("@next/third-parties/google");
|
|
23
|
+
var _isEqual = /*#__PURE__*/ _interop_require_default(require("lodash/isEqual"));
|
|
24
|
+
var _router = require("next/router");
|
|
25
|
+
var _react = require("react");
|
|
26
|
+
function _array_like_to_array(arr, len) {
|
|
27
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
28
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
29
|
+
return arr2;
|
|
30
|
+
}
|
|
31
|
+
function _array_without_holes(arr) {
|
|
32
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
33
|
+
}
|
|
34
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
35
|
+
try {
|
|
36
|
+
var info = gen[key](arg);
|
|
37
|
+
var value = info.value;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
reject(error);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (info.done) {
|
|
43
|
+
resolve(value);
|
|
44
|
+
} else {
|
|
45
|
+
Promise.resolve(value).then(_next, _throw);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function _async_to_generator(fn) {
|
|
49
|
+
return function() {
|
|
50
|
+
var self = this, args = arguments;
|
|
51
|
+
return new Promise(function(resolve, reject) {
|
|
52
|
+
var gen = fn.apply(self, args);
|
|
53
|
+
function _next(value) {
|
|
54
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
55
|
+
}
|
|
56
|
+
function _throw(err) {
|
|
57
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
58
|
+
}
|
|
59
|
+
_next(undefined);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function _define_property(obj, key, value) {
|
|
64
|
+
if (key in obj) {
|
|
65
|
+
Object.defineProperty(obj, key, {
|
|
66
|
+
value: value,
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true
|
|
70
|
+
});
|
|
71
|
+
} else {
|
|
72
|
+
obj[key] = value;
|
|
73
|
+
}
|
|
74
|
+
return obj;
|
|
75
|
+
}
|
|
76
|
+
function _interop_require_default(obj) {
|
|
77
|
+
return obj && obj.__esModule ? obj : {
|
|
78
|
+
default: obj
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function _iterable_to_array(iter) {
|
|
82
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
83
|
+
}
|
|
84
|
+
function _non_iterable_spread() {
|
|
85
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
86
|
+
}
|
|
87
|
+
function _object_spread(target) {
|
|
88
|
+
for(var i = 1; i < arguments.length; i++){
|
|
89
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
90
|
+
var ownKeys = Object.keys(source);
|
|
91
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
92
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
93
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
ownKeys.forEach(function(key) {
|
|
97
|
+
_define_property(target, key, source[key]);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return target;
|
|
101
|
+
}
|
|
102
|
+
function _to_consumable_array(arr) {
|
|
103
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
104
|
+
}
|
|
105
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
106
|
+
if (!o) return;
|
|
107
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
108
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
109
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
110
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
111
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
112
|
+
}
|
|
113
|
+
function _ts_generator(thisArg, body) {
|
|
114
|
+
var f, y, t, g, _ = {
|
|
115
|
+
label: 0,
|
|
116
|
+
sent: function() {
|
|
117
|
+
if (t[0] & 1) throw t[1];
|
|
118
|
+
return t[1];
|
|
119
|
+
},
|
|
120
|
+
trys: [],
|
|
121
|
+
ops: []
|
|
122
|
+
};
|
|
123
|
+
return g = {
|
|
124
|
+
next: verb(0),
|
|
125
|
+
"throw": verb(1),
|
|
126
|
+
"return": verb(2)
|
|
127
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
128
|
+
return this;
|
|
129
|
+
}), g;
|
|
130
|
+
function verb(n) {
|
|
131
|
+
return function(v) {
|
|
132
|
+
return step([
|
|
133
|
+
n,
|
|
134
|
+
v
|
|
135
|
+
]);
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function step(op) {
|
|
139
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
140
|
+
while(_)try {
|
|
141
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
142
|
+
if (y = 0, t) op = [
|
|
143
|
+
op[0] & 2,
|
|
144
|
+
t.value
|
|
145
|
+
];
|
|
146
|
+
switch(op[0]){
|
|
147
|
+
case 0:
|
|
148
|
+
case 1:
|
|
149
|
+
t = op;
|
|
150
|
+
break;
|
|
151
|
+
case 4:
|
|
152
|
+
_.label++;
|
|
153
|
+
return {
|
|
154
|
+
value: op[1],
|
|
155
|
+
done: false
|
|
156
|
+
};
|
|
157
|
+
case 5:
|
|
158
|
+
_.label++;
|
|
159
|
+
y = op[1];
|
|
160
|
+
op = [
|
|
161
|
+
0
|
|
162
|
+
];
|
|
163
|
+
continue;
|
|
164
|
+
case 7:
|
|
165
|
+
op = _.ops.pop();
|
|
166
|
+
_.trys.pop();
|
|
167
|
+
continue;
|
|
168
|
+
default:
|
|
169
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
170
|
+
_ = 0;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
174
|
+
_.label = op[1];
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
178
|
+
_.label = t[1];
|
|
179
|
+
t = op;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
if (t && _.label < t[2]) {
|
|
183
|
+
_.label = t[2];
|
|
184
|
+
_.ops.push(op);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
if (t[2]) _.ops.pop();
|
|
188
|
+
_.trys.pop();
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
op = body.call(thisArg, _);
|
|
192
|
+
} catch (e) {
|
|
193
|
+
op = [
|
|
194
|
+
6,
|
|
195
|
+
e
|
|
196
|
+
];
|
|
197
|
+
y = 0;
|
|
198
|
+
} finally{
|
|
199
|
+
f = t = 0;
|
|
200
|
+
}
|
|
201
|
+
if (op[0] & 5) throw op[1];
|
|
202
|
+
return {
|
|
203
|
+
value: op[0] ? op[1] : void 0,
|
|
204
|
+
done: true
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
var eventsQueue = new Set();
|
|
209
|
+
var drainEvents = function() {
|
|
210
|
+
var events = _to_consumable_array(eventsQueue);
|
|
211
|
+
eventsQueue.clear();
|
|
212
|
+
events.forEach(function(event) {
|
|
213
|
+
(0, _google.sendGTMEvent)(event);
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
function getGA4ClientId() {
|
|
217
|
+
if (typeof document === 'undefined') {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
var cookies = document.cookie.split(';');
|
|
221
|
+
var gaCookie = cookies.find(function(cookie) {
|
|
222
|
+
return cookie.trim().startsWith('_ga=');
|
|
223
|
+
});
|
|
224
|
+
if (gaCookie) {
|
|
225
|
+
var matches = gaCookie.split('.');
|
|
226
|
+
if (matches.length > 2) {
|
|
227
|
+
return "".concat(matches[2], ".").concat(matches[3]) // Returns the GA4 client ID
|
|
228
|
+
;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return null // If no GA cookie is found or format is unexpected
|
|
232
|
+
;
|
|
233
|
+
}
|
|
234
|
+
function hashData(input) {
|
|
235
|
+
return _hashData.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
function _hashData() {
|
|
238
|
+
_hashData = _async_to_generator(function(input) {
|
|
239
|
+
var encoder, data, hashBuffer, hashArray, hashHex;
|
|
240
|
+
return _ts_generator(this, function(_state) {
|
|
241
|
+
switch(_state.label){
|
|
242
|
+
case 0:
|
|
243
|
+
encoder = new TextEncoder();
|
|
244
|
+
data = encoder.encode(input);
|
|
245
|
+
return [
|
|
246
|
+
4,
|
|
247
|
+
crypto.subtle.digest('SHA-256', data)
|
|
248
|
+
];
|
|
249
|
+
case 1:
|
|
250
|
+
hashBuffer = _state.sent();
|
|
251
|
+
hashArray = Array.from(new Uint8Array(hashBuffer)) // Convert buffer to byte array
|
|
252
|
+
;
|
|
253
|
+
hashHex = hashArray.map(function(b) {
|
|
254
|
+
return b.toString(16).padStart(2, '0');
|
|
255
|
+
}).join('') // Convert bytes to hex string
|
|
256
|
+
;
|
|
257
|
+
return [
|
|
258
|
+
2,
|
|
259
|
+
hashHex
|
|
260
|
+
];
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
return _hashData.apply(this, arguments);
|
|
265
|
+
}
|
|
266
|
+
var convertUserData = function() {
|
|
267
|
+
var _ref = _async_to_generator(function(dataInput) {
|
|
268
|
+
var _dataInput_addresses, _dataInput_addresses1, userAddress, _tmp, _tmp1, _tmp2, _tmp3, _tmp4, _tmp5;
|
|
269
|
+
return _ts_generator(this, function(_state) {
|
|
270
|
+
switch(_state.label){
|
|
271
|
+
case 0:
|
|
272
|
+
userAddress = ((_dataInput_addresses = dataInput.addresses) === null || _dataInput_addresses === void 0 ? void 0 : _dataInput_addresses.home) || ((_dataInput_addresses1 = dataInput.addresses) === null || _dataInput_addresses1 === void 0 ? void 0 : _dataInput_addresses1.billing);
|
|
273
|
+
_tmp = {
|
|
274
|
+
user_id: dataInput.id
|
|
275
|
+
};
|
|
276
|
+
return [
|
|
277
|
+
4,
|
|
278
|
+
hashData(dataInput.email)
|
|
279
|
+
];
|
|
280
|
+
case 1:
|
|
281
|
+
_tmp.email = _state.sent();
|
|
282
|
+
if (!dataInput.phoneNumber) return [
|
|
283
|
+
3,
|
|
284
|
+
3
|
|
285
|
+
];
|
|
286
|
+
return [
|
|
287
|
+
4,
|
|
288
|
+
hashData(dataInput.phoneNumber)
|
|
289
|
+
];
|
|
290
|
+
case 2:
|
|
291
|
+
_tmp1 = _state.sent();
|
|
292
|
+
return [
|
|
293
|
+
3,
|
|
294
|
+
4
|
|
295
|
+
];
|
|
296
|
+
case 3:
|
|
297
|
+
_tmp1 = undefined;
|
|
298
|
+
_state.label = 4;
|
|
299
|
+
case 4:
|
|
300
|
+
_tmp.phone_number = _tmp1;
|
|
301
|
+
if (!userAddress) return [
|
|
302
|
+
3,
|
|
303
|
+
11
|
|
304
|
+
];
|
|
305
|
+
_tmp3 = {};
|
|
306
|
+
if (!dataInput.firstName) return [
|
|
307
|
+
3,
|
|
308
|
+
6
|
|
309
|
+
];
|
|
310
|
+
return [
|
|
311
|
+
4,
|
|
312
|
+
hashData(dataInput.firstName)
|
|
313
|
+
];
|
|
314
|
+
case 5:
|
|
315
|
+
_tmp4 = _state.sent();
|
|
316
|
+
return [
|
|
317
|
+
3,
|
|
318
|
+
7
|
|
319
|
+
];
|
|
320
|
+
case 6:
|
|
321
|
+
_tmp4 = undefined;
|
|
322
|
+
_state.label = 7;
|
|
323
|
+
case 7:
|
|
324
|
+
_tmp3.first_name = _tmp4;
|
|
325
|
+
if (!dataInput.lastName) return [
|
|
326
|
+
3,
|
|
327
|
+
9
|
|
328
|
+
];
|
|
329
|
+
return [
|
|
330
|
+
4,
|
|
331
|
+
hashData(dataInput.lastName)
|
|
332
|
+
];
|
|
333
|
+
case 8:
|
|
334
|
+
_tmp5 = _state.sent();
|
|
335
|
+
return [
|
|
336
|
+
3,
|
|
337
|
+
10
|
|
338
|
+
];
|
|
339
|
+
case 9:
|
|
340
|
+
_tmp5 = undefined;
|
|
341
|
+
_state.label = 10;
|
|
342
|
+
case 10:
|
|
343
|
+
_tmp2 = (_tmp3.last_name = _tmp5, _tmp3.street = [
|
|
344
|
+
userAddress.street1,
|
|
345
|
+
userAddress.street2
|
|
346
|
+
].join(', '), _tmp3.city = userAddress.city, _tmp3.region = userAddress.state, _tmp3.postal_code = userAddress.postalCode, _tmp3.country = userAddress.country, _tmp3);
|
|
347
|
+
return [
|
|
348
|
+
3,
|
|
349
|
+
12
|
|
350
|
+
];
|
|
351
|
+
case 11:
|
|
352
|
+
_tmp2 = undefined;
|
|
353
|
+
_state.label = 12;
|
|
354
|
+
case 12:
|
|
355
|
+
return [
|
|
356
|
+
2,
|
|
357
|
+
(_tmp.address = _tmp2, _tmp)
|
|
358
|
+
];
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
return function convertUserData(dataInput) {
|
|
363
|
+
return _ref.apply(this, arguments);
|
|
364
|
+
};
|
|
365
|
+
}();
|
|
366
|
+
var useTrackEvent = function() {
|
|
367
|
+
var userData = (0, _react.useRef)();
|
|
368
|
+
var track = (0, _react.useCallback)(function(eventName, eventData) {
|
|
369
|
+
console.log('🚨🚨🚨 firing event', eventName, eventData);
|
|
370
|
+
if (!eventName) {
|
|
371
|
+
console.error('No event name provided');
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
var event = _object_spread({
|
|
375
|
+
event: eventName
|
|
376
|
+
}, userData.current ? {
|
|
377
|
+
user_data: userData.current
|
|
378
|
+
} : {}, eventData);
|
|
379
|
+
if (!window.fluxDataLayer) {
|
|
380
|
+
eventsQueue.add(event);
|
|
381
|
+
return;
|
|
382
|
+
}
|
|
383
|
+
(0, _google.sendGTMEvent)(event);
|
|
384
|
+
}, []);
|
|
385
|
+
var setUserData = (0, _react.useCallback)(function() {
|
|
386
|
+
var _ref = _async_to_generator(function(dataInput) {
|
|
387
|
+
return _ts_generator(this, function(_state) {
|
|
388
|
+
switch(_state.label){
|
|
389
|
+
case 0:
|
|
390
|
+
return [
|
|
391
|
+
4,
|
|
392
|
+
convertUserData(dataInput)
|
|
393
|
+
];
|
|
394
|
+
case 1:
|
|
395
|
+
userData.current = _state.sent();
|
|
396
|
+
localStorage.setItem('ud', Buffer.from(JSON.stringify(userData.current), 'utf8').toString('base64'));
|
|
397
|
+
return [
|
|
398
|
+
2
|
|
399
|
+
];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
return function(dataInput) {
|
|
404
|
+
return _ref.apply(this, arguments);
|
|
405
|
+
};
|
|
406
|
+
}(), []);
|
|
407
|
+
(0, _react.useEffect)(function() {
|
|
408
|
+
var interval = setInterval(function() {
|
|
409
|
+
if (window.fluxDataLayer) {
|
|
410
|
+
drainEvents();
|
|
411
|
+
clearInterval(interval);
|
|
412
|
+
}
|
|
413
|
+
}, 100);
|
|
414
|
+
return function() {
|
|
415
|
+
return clearInterval(interval);
|
|
416
|
+
};
|
|
417
|
+
}, []);
|
|
418
|
+
(0, _react.useEffect)(function() {
|
|
419
|
+
var ud = localStorage.getItem('ud');
|
|
420
|
+
if (!ud) {
|
|
421
|
+
return;
|
|
422
|
+
}
|
|
423
|
+
try {
|
|
424
|
+
var json = Buffer.from(ud, 'base64').toString('utf8');
|
|
425
|
+
userData.current = JSON.parse(json);
|
|
426
|
+
} catch (e) {}
|
|
427
|
+
}, []);
|
|
428
|
+
return {
|
|
429
|
+
track: track,
|
|
430
|
+
setUserData: setUserData
|
|
431
|
+
};
|
|
432
|
+
};
|
|
433
|
+
var useAutoTrackEvent = function(eventName, eventData) {
|
|
434
|
+
var router = (0, _router.useRouter)();
|
|
435
|
+
var canFireEvents = router.isReady;
|
|
436
|
+
var previousEventData = (0, _react.useRef)();
|
|
437
|
+
var firedFirstEvent = (0, _react.useRef)(false);
|
|
438
|
+
(0, _react.useEffect)(function() {
|
|
439
|
+
var interval = setInterval(function() {
|
|
440
|
+
if (window.fluxDataLayer) {
|
|
441
|
+
drainEvents();
|
|
442
|
+
clearInterval(interval);
|
|
443
|
+
}
|
|
444
|
+
}, 100);
|
|
445
|
+
return function() {
|
|
446
|
+
return clearInterval(interval);
|
|
447
|
+
};
|
|
448
|
+
}, []);
|
|
449
|
+
(0, _react.useEffect)(function() {
|
|
450
|
+
if (!canFireEvents) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
if ((0, _isEqual.default)(previousEventData.current, eventData) && firedFirstEvent.current) {
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
firedFirstEvent.current = true;
|
|
457
|
+
console.log('🚨🚨🚨 firing event', eventName, eventData);
|
|
458
|
+
var event = _object_spread({
|
|
459
|
+
event: eventName
|
|
460
|
+
}, eventData);
|
|
461
|
+
if (!window.fluxDataLayer) {
|
|
462
|
+
eventsQueue.add(event);
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
(0, _google.sendGTMEvent)(event);
|
|
466
|
+
previousEventData.current = eventData;
|
|
467
|
+
}, [
|
|
468
|
+
canFireEvents,
|
|
469
|
+
eventData
|
|
470
|
+
]);
|
|
471
|
+
};
|
package/dist/track.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
fluxDataLayer?: Object[];
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
interface Address {
|
|
7
|
+
name?: string | null;
|
|
8
|
+
street1: string;
|
|
9
|
+
street2?: string | null;
|
|
10
|
+
city: string;
|
|
11
|
+
state: string;
|
|
12
|
+
country: string;
|
|
13
|
+
postalCode: string;
|
|
14
|
+
}
|
|
15
|
+
interface UserLikeData {
|
|
16
|
+
id: string;
|
|
17
|
+
email: string;
|
|
18
|
+
phoneNumber?: string | null;
|
|
19
|
+
firstName?: string | null;
|
|
20
|
+
lastName?: string | null;
|
|
21
|
+
addresses?: {
|
|
22
|
+
home?: Address | null;
|
|
23
|
+
billing?: Address | null;
|
|
24
|
+
} | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function getGA4ClientId(): string | null;
|
|
27
|
+
export declare const useTrackEvent: () => {
|
|
28
|
+
track: (eventName: string, eventData?: Record<string, any>) => void;
|
|
29
|
+
setUserData: (dataInput: UserLikeData) => Promise<void>;
|
|
30
|
+
};
|
|
31
|
+
export declare const useAutoTrackEvent: (eventName: string, eventData?: Record<string, any>) => void;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=track.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAKA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACZ,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;KAC5B;CACF;AAED,UAAU,OAAO;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;CACnB;AAED,UAAU,YAAY;IACpB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,CAAC,EAAE;QACV,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;QACrB,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;KACzB,GAAG,IAAI,CAAA;CACT;AA2BD,wBAAgB,cAAc,kBAc7B;AA+BD,eAAO,MAAM,aAAa;uBAGc,MAAM,cAAc,OAAO,MAAM,EAAE,GAAG,CAAC;6BA2B3B,YAAY;CA+B/D,CAAA;AAED,eAAO,MAAM,iBAAiB,cAAe,MAAM,cAAc,OAAO,MAAM,EAAE,GAAG,CAAC,SA0CnF,CAAA"}
|