ng-easycommerce 0.0.687 → 0.0.688
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/README.md +4 -0
- package/bundles/ng-easycommerce.umd.js +108 -18
- package/bundles/ng-easycommerce.umd.js.map +1 -1
- package/bundles/ng-easycommerce.umd.min.js +1 -1
- package/bundles/ng-easycommerce.umd.min.js.map +1 -1
- package/esm2015/lib/services/parameters.service.js +11 -3
- package/esm2015/lib/utils/analytics/facebook-pixel.service.js +102 -20
- package/esm5/lib/services/parameters.service.js +11 -3
- package/esm5/lib/utils/analytics/facebook-pixel.service.js +101 -19
- package/fesm2015/ng-easycommerce.js +110 -20
- package/fesm2015/ng-easycommerce.js.map +1 -1
- package/fesm5/ng-easycommerce.js +109 -19
- package/fesm5/ng-easycommerce.js.map +1 -1
- package/lib/services/parameters.service.d.ts +1 -0
- package/lib/utils/analytics/facebook-pixel.service.d.ts +11 -4
- package/ng-easycommerce.metadata.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# Version 0.0.688
|
|
2
|
+
- Facebook Pixel: se mantiene la carga única e idempotente, evitando reinyecciones y dobles inicializaciones del script.
|
|
3
|
+
- Facebook Pixel: el tracking se ejecuta fuera de la zona de Angular y conserva un fallback seguro si `NgZone` no está disponible.
|
|
4
|
+
- `ParametersService` evita inicializaciones duplicadas y vuelve a respetar la ejecución solo en producción en ambos flujos de carga de parámetros.
|
|
1
5
|
# Version 0.0.687
|
|
2
6
|
- PlaceToPay: se soluciona error que no cargaba el boton de pagar.
|
|
3
7
|
|
|
@@ -2533,28 +2533,83 @@
|
|
|
2533
2533
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
2534
2534
|
};
|
|
2535
2535
|
var FacebookPixelService = /** @class */ (function () {
|
|
2536
|
-
function FacebookPixelService(rendererFactory, document) {
|
|
2536
|
+
function FacebookPixelService(rendererFactory, document, ngZone) {
|
|
2537
2537
|
var _this = this;
|
|
2538
2538
|
this.rendererFactory = rendererFactory;
|
|
2539
2539
|
this.document = document;
|
|
2540
|
+
this.ngZone = ngZone;
|
|
2540
2541
|
this.enabled = false;
|
|
2542
|
+
this.loading = false;
|
|
2543
|
+
this.initializedPixelId = null;
|
|
2544
|
+
this.pageViewScheduled = false;
|
|
2545
|
+
this.pageViewTracked = false;
|
|
2541
2546
|
this.initialize = function (pixel_id) {
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2547
|
+
var normalizedPixelId = ("" + (pixel_id !== null && pixel_id !== void 0 ? pixel_id : '')).trim();
|
|
2548
|
+
if (!normalizedPixelId) {
|
|
2549
|
+
return;
|
|
2550
|
+
}
|
|
2551
|
+
if (_this.loading) {
|
|
2552
|
+
return;
|
|
2553
|
+
}
|
|
2554
|
+
if (_this.enabled && _this.initializedPixelId === normalizedPixelId) {
|
|
2555
|
+
_this.schedulePageViewOnce();
|
|
2556
|
+
return;
|
|
2557
|
+
}
|
|
2558
|
+
if (_this.enabled && _this.initializedPixelId && _this.initializedPixelId !== normalizedPixelId) {
|
|
2559
|
+
return;
|
|
2549
2560
|
}
|
|
2550
|
-
|
|
2561
|
+
_this.loading = true;
|
|
2562
|
+
_this.runOutsideAngular(function () {
|
|
2563
|
+
try {
|
|
2564
|
+
if (!_this.document.getElementById('facebook_pixel')) {
|
|
2565
|
+
var new_analityc_script = _this.renderer.createElement('script');
|
|
2566
|
+
new_analityc_script.id = 'facebook_pixel';
|
|
2567
|
+
new_analityc_script.type = 'text/javascript';
|
|
2568
|
+
new_analityc_script.text = "!function(f,b,e,v,n,t,s) {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', " + normalizedPixelId + ");";
|
|
2569
|
+
_this.renderer.appendChild(_this.document.body, new_analityc_script);
|
|
2570
|
+
}
|
|
2571
|
+
else {
|
|
2572
|
+
if (typeof fbq !== 'function') {
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2575
|
+
fbq('init', normalizedPixelId);
|
|
2576
|
+
}
|
|
2577
|
+
_this.enabled = true;
|
|
2578
|
+
_this.initializedPixelId = normalizedPixelId;
|
|
2579
|
+
_this.schedulePageViewOnce();
|
|
2580
|
+
}
|
|
2581
|
+
catch (error) {
|
|
2582
|
+
_this.enabled = false;
|
|
2583
|
+
_this.initializedPixelId = null;
|
|
2584
|
+
_this.pageViewScheduled = false;
|
|
2585
|
+
}
|
|
2586
|
+
finally {
|
|
2587
|
+
_this.loading = false;
|
|
2588
|
+
}
|
|
2589
|
+
});
|
|
2551
2590
|
};
|
|
2552
2591
|
this.callEvent = function (event_name, data) {
|
|
2553
2592
|
if (data === void 0) { data = {}; }
|
|
2554
|
-
if (!_this.enabled)
|
|
2555
|
-
return;
|
|
2593
|
+
if (!_this.enabled) {
|
|
2594
|
+
return false;
|
|
2595
|
+
}
|
|
2596
|
+
if (typeof fbq !== 'function') {
|
|
2597
|
+
return false;
|
|
2598
|
+
}
|
|
2556
2599
|
var event = _this.translateEventName(event_name);
|
|
2557
|
-
|
|
2600
|
+
if (!event) {
|
|
2601
|
+
return false;
|
|
2602
|
+
}
|
|
2603
|
+
try {
|
|
2604
|
+
fbq('track', event, _this.evalEvent(event_name, data));
|
|
2605
|
+
if (event_name === 'initialize') {
|
|
2606
|
+
_this.pageViewTracked = true;
|
|
2607
|
+
}
|
|
2608
|
+
return true;
|
|
2609
|
+
}
|
|
2610
|
+
catch (error) {
|
|
2611
|
+
return false;
|
|
2612
|
+
}
|
|
2558
2613
|
};
|
|
2559
2614
|
this.translateEventName = function (event_name) {
|
|
2560
2615
|
switch (event_name) {
|
|
@@ -2580,11 +2635,37 @@
|
|
|
2580
2635
|
};
|
|
2581
2636
|
this.callCustomEvent = function (event_name, data) {
|
|
2582
2637
|
if (data === void 0) { data = {}; }
|
|
2583
|
-
if (!_this.enabled)
|
|
2584
|
-
return;
|
|
2585
|
-
|
|
2638
|
+
if (!_this.enabled || typeof fbq !== 'function') {
|
|
2639
|
+
return false;
|
|
2640
|
+
}
|
|
2641
|
+
try {
|
|
2642
|
+
fbq('trackCustom', event_name, data);
|
|
2643
|
+
return true;
|
|
2644
|
+
}
|
|
2645
|
+
catch (error) {
|
|
2646
|
+
return false;
|
|
2647
|
+
}
|
|
2586
2648
|
};
|
|
2587
2649
|
this.disable = function () { return _this.enabled = false; };
|
|
2650
|
+
this.schedulePageViewOnce = function () {
|
|
2651
|
+
if (_this.pageViewTracked || _this.pageViewScheduled) {
|
|
2652
|
+
return;
|
|
2653
|
+
}
|
|
2654
|
+
_this.pageViewScheduled = true;
|
|
2655
|
+
_this.runOutsideAngular(function () {
|
|
2656
|
+
window.setTimeout(function () {
|
|
2657
|
+
_this.callEvent('initialize');
|
|
2658
|
+
_this.pageViewScheduled = false;
|
|
2659
|
+
}, 1000);
|
|
2660
|
+
});
|
|
2661
|
+
};
|
|
2662
|
+
this.runOutsideAngular = function (callback) {
|
|
2663
|
+
if (_this.ngZone && typeof _this.ngZone.runOutsideAngular === 'function') {
|
|
2664
|
+
_this.ngZone.runOutsideAngular(callback);
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
callback();
|
|
2668
|
+
};
|
|
2588
2669
|
this.toViewContent = function (data) {
|
|
2589
2670
|
var _a, _b, _c, _d;
|
|
2590
2671
|
var lastProduct = ((_a = data) === null || _a === void 0 ? void 0 : _a.name) || 'not-product';
|
|
@@ -2656,7 +2737,8 @@
|
|
|
2656
2737
|
}
|
|
2657
2738
|
FacebookPixelService.ctorParameters = function () { return [
|
|
2658
2739
|
{ type: core.RendererFactory2 },
|
|
2659
|
-
{ type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] }
|
|
2740
|
+
{ type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] },
|
|
2741
|
+
{ type: core.NgZone }
|
|
2660
2742
|
]; };
|
|
2661
2743
|
FacebookPixelService = __decorate$b([
|
|
2662
2744
|
core.Injectable(),
|
|
@@ -7246,13 +7328,21 @@
|
|
|
7246
7328
|
this.analyticsService = analyticsService;
|
|
7247
7329
|
this.parametersSubject = new rxjs.BehaviorSubject(null);
|
|
7248
7330
|
this.readyParamsSubject = new rxjs.ReplaySubject(1);
|
|
7331
|
+
this.analyticsInitializationRequested = false;
|
|
7249
7332
|
this.parameters = this.parametersSubject.asObservable();
|
|
7250
7333
|
this.ready$ = this.readyParamsSubject.asObservable();
|
|
7251
7334
|
this.getAllParametersAPI = function () { return 'shop-api/' + (_this.constants.getMasterChannel() || _this.constants.getChannel()) + '/parameters'; };
|
|
7252
7335
|
this.insertAnalitycs = function () {
|
|
7336
|
+
var initializeAnalyticsIfNeeded = function (params) {
|
|
7337
|
+
if (_this.analyticsInitializationRequested) {
|
|
7338
|
+
return;
|
|
7339
|
+
}
|
|
7340
|
+
_this.analyticsInitializationRequested = true;
|
|
7341
|
+
_this.initializeAnalytics(params);
|
|
7342
|
+
};
|
|
7253
7343
|
_this.parametersSubject.value
|
|
7254
|
-
? _this.constants.onlyIfProduction(
|
|
7255
|
-
: _this.waitUntilData(_this.
|
|
7344
|
+
? _this.constants.onlyIfProduction(initializeAnalyticsIfNeeded, _this.parametersSubject.value)
|
|
7345
|
+
: _this.waitUntilData(function (params) { return _this.constants.onlyIfProduction(initializeAnalyticsIfNeeded, params); });
|
|
7256
7346
|
};
|
|
7257
7347
|
this.initializeAnalytics = function (params) {
|
|
7258
7348
|
var facebook = params.find(function (param) { return param.code.includes("_" + _this.constants.getChannel() + "_") && param.code.includes('facebook') && param.code.includes('id'); });
|