@segment/analytics-browser-actions-reddit-pixel 1.1.0
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 +31 -0
- package/dist/cjs/fields.d.ts +8 -0
- package/dist/cjs/fields.js +473 -0
- package/dist/cjs/fields.js.map +1 -0
- package/dist/cjs/generated-types.d.ts +4 -0
- package/dist/cjs/generated-types.js +3 -0
- package/dist/cjs/generated-types.js.map +1 -0
- package/dist/cjs/index.d.ts +11 -0
- package/dist/cjs/index.js +140 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/init-pixel.d.ts +1 -0
- package/dist/cjs/init-pixel.js +30 -0
- package/dist/cjs/init-pixel.js.map +1 -0
- package/dist/cjs/reportCustomWebEvent/generated-types.d.ts +25 -0
- package/dist/cjs/reportCustomWebEvent/generated-types.js +3 -0
- package/dist/cjs/reportCustomWebEvent/generated-types.js.map +1 -0
- package/dist/cjs/reportCustomWebEvent/index.d.ts +6 -0
- package/dist/cjs/reportCustomWebEvent/index.js +24 -0
- package/dist/cjs/reportCustomWebEvent/index.js.map +1 -0
- package/dist/cjs/reportWebEvent/generated-types.d.ts +25 -0
- package/dist/cjs/reportWebEvent/generated-types.js +3 -0
- package/dist/cjs/reportWebEvent/generated-types.js.map +1 -0
- package/dist/cjs/reportWebEvent/index.d.ts +6 -0
- package/dist/cjs/reportWebEvent/index.js +24 -0
- package/dist/cjs/reportWebEvent/index.js.map +1 -0
- package/dist/cjs/types.d.ts +26 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils.d.ts +6 -0
- package/dist/cjs/utils.js +36 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/fields.d.ts +8 -0
- package/dist/esm/fields.js +470 -0
- package/dist/esm/fields.js.map +1 -0
- package/dist/esm/generated-types.d.ts +4 -0
- package/dist/esm/generated-types.js +2 -0
- package/dist/esm/generated-types.js.map +1 -0
- package/dist/esm/index.d.ts +11 -0
- package/dist/esm/index.js +136 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/init-pixel.d.ts +1 -0
- package/dist/esm/init-pixel.js +26 -0
- package/dist/esm/init-pixel.js.map +1 -0
- package/dist/esm/reportCustomWebEvent/generated-types.d.ts +25 -0
- package/dist/esm/reportCustomWebEvent/generated-types.js +2 -0
- package/dist/esm/reportCustomWebEvent/generated-types.js.map +1 -0
- package/dist/esm/reportCustomWebEvent/index.d.ts +6 -0
- package/dist/esm/reportCustomWebEvent/index.js +22 -0
- package/dist/esm/reportCustomWebEvent/index.js.map +1 -0
- package/dist/esm/reportWebEvent/generated-types.d.ts +25 -0
- package/dist/esm/reportWebEvent/generated-types.js +2 -0
- package/dist/esm/reportWebEvent/generated-types.js.map +1 -0
- package/dist/esm/reportWebEvent/index.d.ts +6 -0
- package/dist/esm/reportWebEvent/index.js +22 -0
- package/dist/esm/reportWebEvent/index.js.map +1 -0
- package/dist/esm/types.d.ts +26 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils.d.ts +6 -0
- package/dist/esm/utils.js +31 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +24 -0
- package/src/__tests__/index.test.ts +300 -0
- package/src/fields.ts +484 -0
- package/src/generated-types.ts +12 -0
- package/src/index.ts +154 -0
- package/src/init-pixel.ts +31 -0
- package/src/reportCustomWebEvent/generated-types.ts +84 -0
- package/src/reportCustomWebEvent/index.ts +27 -0
- package/src/reportWebEvent/generated-types.ts +84 -0
- package/src/reportWebEvent/index.ts +27 -0
- package/src/types.ts +30 -0
- package/src/utils.ts +40 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.destination = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const shim_1 = require("@segment/browser-destination-runtime/shim");
|
|
6
|
+
const actions_core_1 = require("@segment/actions-core");
|
|
7
|
+
const init_pixel_1 = require("./init-pixel");
|
|
8
|
+
const reportWebEvent_1 = tslib_1.__importDefault(require("./reportWebEvent"));
|
|
9
|
+
const reportCustomWebEvent_1 = tslib_1.__importDefault(require("./reportCustomWebEvent"));
|
|
10
|
+
exports.destination = {
|
|
11
|
+
name: 'Reddit Pixel',
|
|
12
|
+
slug: 'actions-reddit-pixel',
|
|
13
|
+
mode: 'device',
|
|
14
|
+
description: 'The Reddit Pixel Browser Destination allows you to install the Reddit Javascript pixel onto your site and pass mapped Segment events and metadata to Reddit.',
|
|
15
|
+
presets: [
|
|
16
|
+
{
|
|
17
|
+
name: 'Page Visit',
|
|
18
|
+
subscribe: 'type = "page"',
|
|
19
|
+
partnerAction: 'reportWebEvent',
|
|
20
|
+
mapping: {
|
|
21
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
22
|
+
tracking_type: 'PageVisit'
|
|
23
|
+
},
|
|
24
|
+
type: 'automatic'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'View Content',
|
|
28
|
+
subscribe: 'type = "track" and event = "Product Viewed"',
|
|
29
|
+
partnerAction: 'reportWebEvent',
|
|
30
|
+
mapping: {
|
|
31
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
32
|
+
tracking_type: 'ViewContent'
|
|
33
|
+
},
|
|
34
|
+
type: 'automatic'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'Search',
|
|
38
|
+
subscribe: 'type = "track" and event = "Products Searched"',
|
|
39
|
+
partnerAction: 'reportWebEvent',
|
|
40
|
+
mapping: {
|
|
41
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
42
|
+
tracking_type: 'Search'
|
|
43
|
+
},
|
|
44
|
+
type: 'automatic'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: 'Add to Cart',
|
|
48
|
+
subscribe: 'type = "track" and event = "Product Added"',
|
|
49
|
+
partnerAction: 'reportWebEvent',
|
|
50
|
+
mapping: {
|
|
51
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
52
|
+
tracking_type: 'AddToCart',
|
|
53
|
+
event_metadata: {
|
|
54
|
+
currency: { '@path': '$.properties.currency' },
|
|
55
|
+
itemCount: { '@path': '$.properties.quantity' },
|
|
56
|
+
value: { '@path': '$.properties.price' }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
type: 'automatic'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: 'Add to Wishlist',
|
|
63
|
+
subscribe: 'type = "track" and event = "Product Added to Wishlist"',
|
|
64
|
+
partnerAction: 'reportWebEvent',
|
|
65
|
+
mapping: {
|
|
66
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
67
|
+
tracking_type: 'AddToWishlist',
|
|
68
|
+
event_metadata: {
|
|
69
|
+
currency: { '@path': '$.properties.currency' },
|
|
70
|
+
itemCount: { '@path': '$.properties.quantity' },
|
|
71
|
+
value: { '@path': '$.properties.price' }
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
type: 'automatic'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'Purchase',
|
|
78
|
+
subscribe: 'type = "track" and event = "Order Completed"',
|
|
79
|
+
partnerAction: 'reportWebEvent',
|
|
80
|
+
mapping: {
|
|
81
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
82
|
+
tracking_type: 'Purchase'
|
|
83
|
+
},
|
|
84
|
+
type: 'automatic'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'Lead',
|
|
88
|
+
subscribe: 'type = "track" and event = "Lead Generated"',
|
|
89
|
+
partnerAction: 'reportWebEvent',
|
|
90
|
+
mapping: {
|
|
91
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
92
|
+
tracking_type: 'Lead',
|
|
93
|
+
event_metadata: {
|
|
94
|
+
currency: { '@path': '$.properties.currency' },
|
|
95
|
+
value: { '@path': '$.properties.value' }
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
type: 'automatic'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'Sign Up',
|
|
102
|
+
subscribe: 'type = "track" and event = "Signed Up"',
|
|
103
|
+
partnerAction: 'reportWebEvent',
|
|
104
|
+
mapping: {
|
|
105
|
+
...(0, actions_core_1.defaultValues)(reportWebEvent_1.default.fields),
|
|
106
|
+
tracking_type: 'SignUp',
|
|
107
|
+
event_metadata: {
|
|
108
|
+
currency: { '@path': '$.properties.currency' },
|
|
109
|
+
value: { '@path': '$.properties.value' }
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
type: 'automatic'
|
|
113
|
+
}
|
|
114
|
+
],
|
|
115
|
+
settings: {
|
|
116
|
+
pixel_id: {
|
|
117
|
+
label: 'Pixel ID',
|
|
118
|
+
type: 'string',
|
|
119
|
+
description: 'Your Reddit Pixel ID',
|
|
120
|
+
required: true
|
|
121
|
+
},
|
|
122
|
+
ldu: {
|
|
123
|
+
label: 'Limited Data Use',
|
|
124
|
+
type: 'boolean',
|
|
125
|
+
default: false,
|
|
126
|
+
description: 'Limited Data Use - When the LDU flag is enabled, it may impact campaign performance and limit the size of targetable audiences. See [this documentation](https://business.reddithelp.com/s/article/Limited-Data-Use) for more information. If enabling this toggle, also go into each event and configure the Country and Region in the Data Processing Options for each event being sent.'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
initialize: async ({ settings }, deps) => {
|
|
130
|
+
(0, init_pixel_1.initializePixel)(settings);
|
|
131
|
+
await deps.resolveWhen(() => window.rdt != null, 100);
|
|
132
|
+
return window.rdt;
|
|
133
|
+
},
|
|
134
|
+
actions: {
|
|
135
|
+
reportWebEvent: reportWebEvent_1.default,
|
|
136
|
+
reportCustomWebEvent: reportCustomWebEvent_1.default
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
exports.default = (0, shim_1.browserDestination)(exports.destination);
|
|
140
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initializePixel(settings: any): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializePixel = void 0;
|
|
4
|
+
function initializePixel(settings) {
|
|
5
|
+
!(function (w, d) {
|
|
6
|
+
if (!w.rdt) {
|
|
7
|
+
var p = (w.rdt = function () {
|
|
8
|
+
p.sendEvent ? p.sendEvent.apply(p, arguments) : p.callQueue.push(arguments);
|
|
9
|
+
});
|
|
10
|
+
p.callQueue = [];
|
|
11
|
+
var t = d.createElement('script');
|
|
12
|
+
t.src = 'https://www.redditstatic.com/ads/pixel.js';
|
|
13
|
+
t.async = true;
|
|
14
|
+
var s = d.getElementsByTagName('script')[0];
|
|
15
|
+
s.parentNode.insertBefore(t, s);
|
|
16
|
+
}
|
|
17
|
+
})(window, document);
|
|
18
|
+
rdt.init = (pixel_id, ldu) => {
|
|
19
|
+
if (!rdt.init_already_called) {
|
|
20
|
+
rdt('init', pixel_id, ldu);
|
|
21
|
+
}
|
|
22
|
+
rdt.init_already_called = true;
|
|
23
|
+
};
|
|
24
|
+
rdt.track = (eventName, eventMetadata) => {
|
|
25
|
+
rdt('track', eventName, eventMetadata);
|
|
26
|
+
};
|
|
27
|
+
rdt.init_already_called = false;
|
|
28
|
+
}
|
|
29
|
+
exports.initializePixel = initializePixel;
|
|
30
|
+
//# sourceMappingURL=init-pixel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-pixel.js","sourceRoot":"","sources":["../../src/init-pixel.ts"],"names":[],"mappings":";;;AAGA,SAAgB,eAAe,CAAC,QAAQ;IACtC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;QACd,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE;YACV,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG;gBACf,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;YAC7E,CAAC,CAAC,CAAA;YACF,CAAC,CAAC,SAAS,GAAG,EAAE,CAAA;YAChB,IAAI,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;YACjC,CAAC,CAAC,GAAG,GAAG,2CAA2C,CAAA;YACnD,CAAC,CAAC,KAAK,GAAG,IAAI,CAAA;YACd,IAAI,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;YAC3C,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;SAChC;IACH,CAAC,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAEpB,GAAG,CAAC,IAAI,GAAG,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE;QAC3B,IAAI,CAAC,GAAG,CAAC,mBAAmB,EAAE;YAC5B,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;SAC3B;QACD,GAAG,CAAC,mBAAmB,GAAG,IAAI,CAAA;IAChC,CAAC,CAAA;IAED,GAAG,CAAC,KAAK,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,EAAE;QACvC,GAAG,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,CAAA;IACxC,CAAC,CAAA;IAED,GAAG,CAAC,mBAAmB,GAAG,KAAK,CAAA;AACjC,CAAC;AA3BD,0CA2BC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
conversion_id?: string;
|
|
3
|
+
event_metadata?: {
|
|
4
|
+
currency?: string;
|
|
5
|
+
itemCount?: number;
|
|
6
|
+
value?: number;
|
|
7
|
+
};
|
|
8
|
+
user?: {
|
|
9
|
+
advertising_id?: string;
|
|
10
|
+
device_type?: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
externalId?: string;
|
|
13
|
+
phoneNumber?: string;
|
|
14
|
+
};
|
|
15
|
+
products?: {
|
|
16
|
+
category?: string;
|
|
17
|
+
id?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
}[];
|
|
20
|
+
data_processing_options?: {
|
|
21
|
+
country?: string;
|
|
22
|
+
region?: string;
|
|
23
|
+
};
|
|
24
|
+
custom_event_name: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/reportCustomWebEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import type { Settings } from '../generated-types';
|
|
3
|
+
import type { Payload } from './generated-types';
|
|
4
|
+
import { RedditPixel } from '../types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, RedditPixel, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fields_1 = require("../fields");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Reddit Pixel - Custom Event',
|
|
7
|
+
description: 'Send Custom Pixel Events to Reddit.',
|
|
8
|
+
defaultSubscription: 'type = "track"',
|
|
9
|
+
platform: 'web',
|
|
10
|
+
fields: {
|
|
11
|
+
conversion_id: fields_1.conversion_id,
|
|
12
|
+
event_metadata: fields_1.event_metadata,
|
|
13
|
+
user: fields_1.user,
|
|
14
|
+
products: fields_1.products,
|
|
15
|
+
data_processing_options: fields_1.data_processing_options,
|
|
16
|
+
custom_event_name: fields_1.custom_event_name
|
|
17
|
+
},
|
|
18
|
+
perform: (rdt, { payload, settings }) => {
|
|
19
|
+
(0, utils_1.initPixel)(rdt, payload, settings);
|
|
20
|
+
(0, utils_1.trackCall)(rdt, payload);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.default = action;
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reportCustomWebEvent/index.ts"],"names":[],"mappings":";;AAGA,sCAAqH;AAErH,oCAA+C;AAE/C,MAAM,MAAM,GAA4D;IACtE,KAAK,EAAE,6BAA6B;IACpC,WAAW,EAAE,qCAAqC;IAClD,mBAAmB,EAAE,gBAAgB;IACrC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,aAAa,EAAb,sBAAa;QACb,cAAc,EAAd,uBAAc;QACd,IAAI,EAAJ,aAAI;QACJ,QAAQ,EAAR,iBAAQ;QACR,uBAAuB,EAAvB,gCAAuB;QACvB,iBAAiB,EAAjB,0BAAiB;KAClB;IACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACtC,IAAA,iBAAS,EAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QACjC,IAAA,iBAAS,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACzB,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface Payload {
|
|
2
|
+
tracking_type: string;
|
|
3
|
+
products?: {
|
|
4
|
+
category?: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
}[];
|
|
8
|
+
user?: {
|
|
9
|
+
advertising_id?: string;
|
|
10
|
+
device_type?: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
externalId?: string;
|
|
13
|
+
phoneNumber?: string;
|
|
14
|
+
};
|
|
15
|
+
data_processing_options?: {
|
|
16
|
+
country?: string;
|
|
17
|
+
region?: string;
|
|
18
|
+
};
|
|
19
|
+
event_metadata?: {
|
|
20
|
+
currency?: string;
|
|
21
|
+
itemCount?: number;
|
|
22
|
+
value?: number;
|
|
23
|
+
};
|
|
24
|
+
conversion_id?: string;
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-types.js","sourceRoot":"","sources":["../../../src/reportWebEvent/generated-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { BrowserActionDefinition } from '@segment/browser-destination-runtime/types';
|
|
2
|
+
import type { Settings } from '../generated-types';
|
|
3
|
+
import type { Payload } from './generated-types';
|
|
4
|
+
import { RedditPixel } from '../types';
|
|
5
|
+
declare const action: BrowserActionDefinition<Settings, RedditPixel, Payload>;
|
|
6
|
+
export default action;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const fields_1 = require("../fields");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
const action = {
|
|
6
|
+
title: 'Reddit Pixel',
|
|
7
|
+
description: 'Send Standard Pixel Events to Reddit. This includes pagevisits, addtocarts, search, etc.',
|
|
8
|
+
defaultSubscription: 'type = "track"',
|
|
9
|
+
platform: 'web',
|
|
10
|
+
fields: {
|
|
11
|
+
tracking_type: fields_1.tracking_type,
|
|
12
|
+
products: fields_1.products,
|
|
13
|
+
user: fields_1.user,
|
|
14
|
+
data_processing_options: fields_1.data_processing_options,
|
|
15
|
+
event_metadata: fields_1.event_metadata,
|
|
16
|
+
conversion_id: fields_1.conversion_id
|
|
17
|
+
},
|
|
18
|
+
perform: (rdt, { payload, settings }) => {
|
|
19
|
+
(0, utils_1.initPixel)(rdt, payload, settings);
|
|
20
|
+
(0, utils_1.trackCall)(rdt, payload);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
exports.default = action;
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/reportWebEvent/index.ts"],"names":[],"mappings":";;AAGA,sCAAiH;AAEjH,oCAA+C;AAE/C,MAAM,MAAM,GAA4D;IACtE,KAAK,EAAE,cAAc;IACrB,WAAW,EAAE,0FAA0F;IACvG,mBAAmB,EAAE,gBAAgB;IACrC,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE;QACN,aAAa,EAAb,sBAAa;QACb,QAAQ,EAAR,iBAAQ;QACR,IAAI,EAAJ,aAAI;QACJ,uBAAuB,EAAvB,gCAAuB;QACvB,cAAc,EAAd,uBAAc;QACd,aAAa,EAAb,sBAAa;KACd;IACD,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;QACtC,IAAA,iBAAS,EAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;QACjC,IAAA,iBAAS,EAAC,GAAG,EAAE,OAAO,CAAC,CAAA;IACzB,CAAC;CACF,CAAA;AAED,kBAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface RedditPixel {
|
|
2
|
+
page: () => void;
|
|
3
|
+
init: (pixelId: string, ldu?: {
|
|
4
|
+
dpm?: string;
|
|
5
|
+
dpcc?: string;
|
|
6
|
+
dprc?: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
track: (eventName: string, eventMetadata?: EventMetadata) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface EventMetadata {
|
|
11
|
+
currency?: string;
|
|
12
|
+
itemCount?: number;
|
|
13
|
+
value?: number;
|
|
14
|
+
customEventName?: string;
|
|
15
|
+
conversionId?: string;
|
|
16
|
+
aaid?: string;
|
|
17
|
+
idfa?: string;
|
|
18
|
+
email?: string;
|
|
19
|
+
phoneNumber?: string;
|
|
20
|
+
externalId?: string;
|
|
21
|
+
products?: {
|
|
22
|
+
id?: string | undefined;
|
|
23
|
+
category?: string | undefined;
|
|
24
|
+
name?: string | undefined;
|
|
25
|
+
}[];
|
|
26
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Settings } from './generated-types';
|
|
2
|
+
import type { Payload as StandardEvent } from './reportWebEvent/generated-types';
|
|
3
|
+
import type { Payload as CustomEvent } from './reportCustomWebEvent/generated-types';
|
|
4
|
+
import { RedditPixel } from './types';
|
|
5
|
+
export declare function initPixel(rdt: RedditPixel, payload: StandardEvent | CustomEvent, settings: Settings): void;
|
|
6
|
+
export declare function trackCall(rdt: RedditPixel, payload: StandardEvent | CustomEvent): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackCall = exports.initPixel = void 0;
|
|
4
|
+
function initPixel(rdt, payload, settings) {
|
|
5
|
+
rdt.init(settings.pixel_id, {
|
|
6
|
+
...(settings.ldu && {
|
|
7
|
+
dpm: 'LDU',
|
|
8
|
+
dpcc: payload.data_processing_options?.country,
|
|
9
|
+
dprc: payload.data_processing_options?.region
|
|
10
|
+
})
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
exports.initPixel = initPixel;
|
|
14
|
+
function trackCall(rdt, payload) {
|
|
15
|
+
if (['PageVisit', 'ViewContent', 'Search'].includes(payload?.tracking_type)) {
|
|
16
|
+
delete payload.event_metadata;
|
|
17
|
+
}
|
|
18
|
+
const fullPayload = {
|
|
19
|
+
...payload.event_metadata,
|
|
20
|
+
products: payload.products ?? undefined,
|
|
21
|
+
conversionId: payload.conversion_id ?? undefined,
|
|
22
|
+
email: payload?.user?.email ?? undefined,
|
|
23
|
+
externalId: payload?.user?.externalId ?? undefined,
|
|
24
|
+
phoneNumber: payload?.user?.phoneNumber ?? undefined,
|
|
25
|
+
aaid: payload?.user?.advertising_id && payload?.user?.device_type?.toLowerCase() === 'android'
|
|
26
|
+
? payload?.user?.advertising_id
|
|
27
|
+
: undefined,
|
|
28
|
+
idfa: payload?.user?.advertising_id && payload?.user?.device_type?.toLowerCase() === 'ios'
|
|
29
|
+
? payload?.user?.advertising_id
|
|
30
|
+
: undefined,
|
|
31
|
+
customEventName: payload.custom_event_name ?? undefined
|
|
32
|
+
};
|
|
33
|
+
rdt.track(payload.tracking_type ?? 'Custom', fullPayload);
|
|
34
|
+
}
|
|
35
|
+
exports.trackCall = trackCall;
|
|
36
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAKA,SAAgB,SAAS,CAAC,GAAgB,EAAE,OAAoC,EAAE,QAAkB;IAClG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;QAC1B,GAAG,CAAC,QAAQ,CAAC,GAAG,IAAI;YAClB,GAAG,EAAE,KAAK;YACV,IAAI,EAAE,OAAO,CAAC,uBAAuB,EAAE,OAAO;YAC9C,IAAI,EAAE,OAAO,CAAC,uBAAuB,EAAE,MAAM;SAC9C,CAAC;KACH,CAAC,CAAA;AACJ,CAAC;AARD,8BAQC;AAED,SAAgB,SAAS,CAAC,GAAgB,EAAE,OAAoC;IAC9E,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAE,OAAyB,EAAE,aAAa,CAAC,EAAE;QAC9F,OAAO,OAAO,CAAC,cAAc,CAAA;KAC9B;IAED,MAAM,WAAW,GAAkB;QACjC,GAAG,OAAO,CAAC,cAAc;QACzB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,SAAS;QACvC,YAAY,EAAE,OAAO,CAAC,aAAa,IAAI,SAAS;QAChD,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS;QACxC,UAAU,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,IAAI,SAAS;QAClD,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,IAAI,SAAS;QACpD,IAAI,EACF,OAAO,EAAE,IAAI,EAAE,cAAc,IAAI,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,SAAS;YACtF,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,cAAc;YAC/B,CAAC,CAAC,SAAS;QACf,IAAI,EACF,OAAO,EAAE,IAAI,EAAE,cAAc,IAAI,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,KAAK;YAClF,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,cAAc;YAC/B,CAAC,CAAC,SAAS;QACf,eAAe,EAAG,OAAuB,CAAC,iBAAiB,IAAI,SAAS;KACzE,CAAA;IAED,GAAG,CAAC,KAAK,CAAE,OAAyB,CAAC,aAAa,IAAI,QAAQ,EAAE,WAAW,CAAC,CAAA;AAC9E,CAAC;AAxBD,8BAwBC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InputField } from '@segment/actions-core';
|
|
2
|
+
export declare const custom_event_name: InputField;
|
|
3
|
+
export declare const tracking_type: InputField;
|
|
4
|
+
export declare const conversion_id: InputField;
|
|
5
|
+
export declare const event_metadata: InputField;
|
|
6
|
+
export declare const products: InputField;
|
|
7
|
+
export declare const user: InputField;
|
|
8
|
+
export declare const data_processing_options: InputField;
|