@walkeros/server-destination-linkedin 3.3.0-next-1776098542393

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.
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/examples/index.ts
21
+ var examples_exports = {};
22
+ __export(examples_exports, {
23
+ env: () => env_exports,
24
+ step: () => step_exports
25
+ });
26
+ module.exports = __toCommonJS(examples_exports);
27
+
28
+ // src/examples/env.ts
29
+ var env_exports = {};
30
+ __export(env_exports, {
31
+ push: () => push,
32
+ simulation: () => simulation
33
+ });
34
+ async function mockSendServer(url, data, options) {
35
+ return {
36
+ ok: true,
37
+ data: {}
38
+ };
39
+ }
40
+ var push = {
41
+ sendServer: mockSendServer
42
+ };
43
+ var simulation = ["sendServer"];
44
+
45
+ // src/examples/step.ts
46
+ var step_exports = {};
47
+ __export(step_exports, {
48
+ lead: () => lead,
49
+ purchase: () => purchase,
50
+ purchaseWithLiFatId: () => purchaseWithLiFatId
51
+ });
52
+ var import_core = require("@walkeros/core");
53
+ var purchase = {
54
+ in: (0, import_core.getEvent)("order complete", {
55
+ timestamp: 17000009e5,
56
+ data: { total: 249.99, currency: "EUR" },
57
+ user: { email: "jane@example.com" },
58
+ source: { type: "server", id: "https://shop.example.com", previous_id: "" }
59
+ }),
60
+ mapping: {
61
+ settings: {
62
+ conversion: {
63
+ map: {
64
+ value: "data.total",
65
+ currency: { key: "data.currency", value: "EUR" }
66
+ }
67
+ }
68
+ }
69
+ },
70
+ out: {
71
+ elements: [
72
+ {
73
+ conversion: "urn:lla:llaPartnerConversion:12345678",
74
+ conversionHappenedAt: 17000009e5,
75
+ conversionValue: {
76
+ currencyCode: "EUR",
77
+ amount: "249.99"
78
+ },
79
+ user: {
80
+ userIds: [
81
+ {
82
+ idType: "SHA256_EMAIL",
83
+ idValue: "8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d"
84
+ }
85
+ ]
86
+ },
87
+ eventId: "1700000900000-gr0up-1"
88
+ }
89
+ ]
90
+ }
91
+ };
92
+ var lead = {
93
+ in: (0, import_core.getEvent)("form submit", {
94
+ timestamp: 1700000901e3,
95
+ user: { email: "user@example.com" },
96
+ source: { type: "server", id: "https://example.com", previous_id: "" }
97
+ }),
98
+ mapping: void 0,
99
+ out: {
100
+ elements: [
101
+ {
102
+ conversion: "urn:lla:llaPartnerConversion:12345678",
103
+ conversionHappenedAt: 1700000901e3,
104
+ user: {
105
+ userIds: [
106
+ {
107
+ idType: "SHA256_EMAIL",
108
+ idValue: "b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"
109
+ }
110
+ ]
111
+ },
112
+ eventId: "1700000901000-gr0up-1"
113
+ }
114
+ ]
115
+ }
116
+ };
117
+ var purchaseWithLiFatId = {
118
+ in: (0, import_core.getEvent)("order complete", {
119
+ timestamp: 1700000902e3,
120
+ data: { total: 89.99, currency: "USD" },
121
+ user: { email: "buyer@co.com" },
122
+ context: { li_fat_id: ["abc123-fat-id", 0] },
123
+ source: { type: "server", id: "https://shop.example.com", previous_id: "" }
124
+ }),
125
+ mapping: {
126
+ settings: {
127
+ conversion: {
128
+ map: {
129
+ value: "data.total",
130
+ currency: { key: "data.currency", value: "USD" }
131
+ }
132
+ }
133
+ },
134
+ data: {
135
+ map: {
136
+ user_data: {
137
+ map: {
138
+ li_fat_id: "context.li_fat_id"
139
+ }
140
+ }
141
+ }
142
+ }
143
+ },
144
+ out: {
145
+ elements: [
146
+ {
147
+ conversion: "urn:lla:llaPartnerConversion:12345678",
148
+ conversionHappenedAt: 1700000902e3,
149
+ conversionValue: {
150
+ currencyCode: "USD",
151
+ amount: "89.99"
152
+ },
153
+ user: {
154
+ userIds: [
155
+ {
156
+ idType: "SHA256_EMAIL",
157
+ idValue: "484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66"
158
+ },
159
+ {
160
+ idType: "LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID",
161
+ idValue: "abc123-fat-id"
162
+ }
163
+ ]
164
+ },
165
+ eventId: "1700000902000-gr0up-1"
166
+ }
167
+ ]
168
+ }
169
+ };
170
+ // Annotate the CommonJS export names for ESM import in node:
171
+ 0 && (module.exports = {
172
+ env,
173
+ step
174
+ });
@@ -0,0 +1,152 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, { get: all[name], enumerable: true });
5
+ };
6
+
7
+ // src/examples/env.ts
8
+ var env_exports = {};
9
+ __export(env_exports, {
10
+ push: () => push,
11
+ simulation: () => simulation
12
+ });
13
+ async function mockSendServer(url, data, options) {
14
+ return {
15
+ ok: true,
16
+ data: {}
17
+ };
18
+ }
19
+ var push = {
20
+ sendServer: mockSendServer
21
+ };
22
+ var simulation = ["sendServer"];
23
+
24
+ // src/examples/step.ts
25
+ var step_exports = {};
26
+ __export(step_exports, {
27
+ lead: () => lead,
28
+ purchase: () => purchase,
29
+ purchaseWithLiFatId: () => purchaseWithLiFatId
30
+ });
31
+ import { getEvent } from "@walkeros/core";
32
+ var purchase = {
33
+ in: getEvent("order complete", {
34
+ timestamp: 17000009e5,
35
+ data: { total: 249.99, currency: "EUR" },
36
+ user: { email: "jane@example.com" },
37
+ source: { type: "server", id: "https://shop.example.com", previous_id: "" }
38
+ }),
39
+ mapping: {
40
+ settings: {
41
+ conversion: {
42
+ map: {
43
+ value: "data.total",
44
+ currency: { key: "data.currency", value: "EUR" }
45
+ }
46
+ }
47
+ }
48
+ },
49
+ out: {
50
+ elements: [
51
+ {
52
+ conversion: "urn:lla:llaPartnerConversion:12345678",
53
+ conversionHappenedAt: 17000009e5,
54
+ conversionValue: {
55
+ currencyCode: "EUR",
56
+ amount: "249.99"
57
+ },
58
+ user: {
59
+ userIds: [
60
+ {
61
+ idType: "SHA256_EMAIL",
62
+ idValue: "8c87b489ce35cf2e2f39f80e282cb2e804932a56a213983eeeb428407d43b52d"
63
+ }
64
+ ]
65
+ },
66
+ eventId: "1700000900000-gr0up-1"
67
+ }
68
+ ]
69
+ }
70
+ };
71
+ var lead = {
72
+ in: getEvent("form submit", {
73
+ timestamp: 1700000901e3,
74
+ user: { email: "user@example.com" },
75
+ source: { type: "server", id: "https://example.com", previous_id: "" }
76
+ }),
77
+ mapping: void 0,
78
+ out: {
79
+ elements: [
80
+ {
81
+ conversion: "urn:lla:llaPartnerConversion:12345678",
82
+ conversionHappenedAt: 1700000901e3,
83
+ user: {
84
+ userIds: [
85
+ {
86
+ idType: "SHA256_EMAIL",
87
+ idValue: "b4c9a289323b21a01c3e940f150eb9b8c542587f1abfd8f0e1cc1ffc5e475514"
88
+ }
89
+ ]
90
+ },
91
+ eventId: "1700000901000-gr0up-1"
92
+ }
93
+ ]
94
+ }
95
+ };
96
+ var purchaseWithLiFatId = {
97
+ in: getEvent("order complete", {
98
+ timestamp: 1700000902e3,
99
+ data: { total: 89.99, currency: "USD" },
100
+ user: { email: "buyer@co.com" },
101
+ context: { li_fat_id: ["abc123-fat-id", 0] },
102
+ source: { type: "server", id: "https://shop.example.com", previous_id: "" }
103
+ }),
104
+ mapping: {
105
+ settings: {
106
+ conversion: {
107
+ map: {
108
+ value: "data.total",
109
+ currency: { key: "data.currency", value: "USD" }
110
+ }
111
+ }
112
+ },
113
+ data: {
114
+ map: {
115
+ user_data: {
116
+ map: {
117
+ li_fat_id: "context.li_fat_id"
118
+ }
119
+ }
120
+ }
121
+ }
122
+ },
123
+ out: {
124
+ elements: [
125
+ {
126
+ conversion: "urn:lla:llaPartnerConversion:12345678",
127
+ conversionHappenedAt: 1700000902e3,
128
+ conversionValue: {
129
+ currencyCode: "USD",
130
+ amount: "89.99"
131
+ },
132
+ user: {
133
+ userIds: [
134
+ {
135
+ idType: "SHA256_EMAIL",
136
+ idValue: "484c39bfb51212665d9673805c112b5ba04cbf0460b6d3f00bcdc18b92afed66"
137
+ },
138
+ {
139
+ idType: "LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID",
140
+ idValue: "abc123-fat-id"
141
+ }
142
+ ]
143
+ },
144
+ eventId: "1700000902000-gr0up-1"
145
+ }
146
+ ]
147
+ }
148
+ };
149
+ export {
150
+ env_exports as env,
151
+ step_exports as step
152
+ };
@@ -0,0 +1,89 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer, sendServer } from '@walkeros/server-core';
3
+
4
+ interface Settings {
5
+ accessToken: string;
6
+ conversionRuleId: string;
7
+ apiVersion?: string;
8
+ doNotHash?: string[];
9
+ url?: string;
10
+ user_data?: Mapping$1.Map;
11
+ }
12
+ type InitSettings = Partial<Settings>;
13
+ interface Mapping {
14
+ conversion?: Mapping$1.Value;
15
+ }
16
+ interface Env extends DestinationServer.Env {
17
+ sendServer?: typeof sendServer;
18
+ }
19
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
20
+ interface Destination extends DestinationServer.Destination<Types> {
21
+ init: DestinationServer.InitFn<Types>;
22
+ }
23
+ type Config = {
24
+ settings: Settings;
25
+ } & DestinationServer.Config<Types>;
26
+ type InitFn = DestinationServer.InitFn<Types>;
27
+ type PushFn = DestinationServer.PushFn<Types>;
28
+ type PartialConfig = DestinationServer.PartialConfig<Types>;
29
+ type PushEvents = DestinationServer.PushEvents<Mapping>;
30
+ type Rule = Mapping$1.Rule<Mapping>;
31
+ type Rules = Mapping$1.Rules<Rule>;
32
+ type UserIdType = 'SHA256_EMAIL' | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID' | 'ACXIOM_ID' | 'ORACLE_MOAT_ID';
33
+ interface UserIdentifier {
34
+ idType: UserIdType;
35
+ idValue: string;
36
+ }
37
+ interface UserInfo {
38
+ firstName: string;
39
+ lastName: string;
40
+ title?: string;
41
+ companyName?: string;
42
+ countryCode?: string;
43
+ }
44
+ interface ConversionUser {
45
+ userIds: UserIdentifier[];
46
+ userInfo?: UserInfo;
47
+ }
48
+ interface ConversionValue {
49
+ currencyCode: string;
50
+ amount: string;
51
+ }
52
+ interface ConversionEvent {
53
+ conversion: string;
54
+ conversionHappenedAt: number;
55
+ conversionValue?: ConversionValue;
56
+ user: ConversionUser;
57
+ eventId?: string;
58
+ }
59
+ interface ConversionEventsRequest {
60
+ elements: ConversionEvent[];
61
+ }
62
+
63
+ type index_Config = Config;
64
+ type index_ConversionEvent = ConversionEvent;
65
+ type index_ConversionEventsRequest = ConversionEventsRequest;
66
+ type index_ConversionUser = ConversionUser;
67
+ type index_ConversionValue = ConversionValue;
68
+ type index_Destination = Destination;
69
+ type index_Env = Env;
70
+ type index_InitFn = InitFn;
71
+ type index_InitSettings = InitSettings;
72
+ type index_Mapping = Mapping;
73
+ type index_PartialConfig = PartialConfig;
74
+ type index_PushEvents = PushEvents;
75
+ type index_PushFn = PushFn;
76
+ type index_Rule = Rule;
77
+ type index_Rules = Rules;
78
+ type index_Settings = Settings;
79
+ type index_Types = Types;
80
+ type index_UserIdType = UserIdType;
81
+ type index_UserIdentifier = UserIdentifier;
82
+ type index_UserInfo = UserInfo;
83
+ declare namespace index {
84
+ export type { index_Config as Config, index_ConversionEvent as ConversionEvent, index_ConversionEventsRequest as ConversionEventsRequest, index_ConversionUser as ConversionUser, index_ConversionValue as ConversionValue, index_Destination as Destination, index_Env as Env, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types, index_UserIdType as UserIdType, index_UserIdentifier as UserIdentifier, index_UserInfo as UserInfo };
85
+ }
86
+
87
+ declare const destinationLinkedIn: Destination;
88
+
89
+ export { index as DestinationLinkedIn, destinationLinkedIn as default, destinationLinkedIn };
@@ -0,0 +1,89 @@
1
+ import { Mapping as Mapping$1, Destination as Destination$1 } from '@walkeros/core';
2
+ import { DestinationServer, sendServer } from '@walkeros/server-core';
3
+
4
+ interface Settings {
5
+ accessToken: string;
6
+ conversionRuleId: string;
7
+ apiVersion?: string;
8
+ doNotHash?: string[];
9
+ url?: string;
10
+ user_data?: Mapping$1.Map;
11
+ }
12
+ type InitSettings = Partial<Settings>;
13
+ interface Mapping {
14
+ conversion?: Mapping$1.Value;
15
+ }
16
+ interface Env extends DestinationServer.Env {
17
+ sendServer?: typeof sendServer;
18
+ }
19
+ type Types = Destination$1.Types<Settings, Mapping, Env, InitSettings>;
20
+ interface Destination extends DestinationServer.Destination<Types> {
21
+ init: DestinationServer.InitFn<Types>;
22
+ }
23
+ type Config = {
24
+ settings: Settings;
25
+ } & DestinationServer.Config<Types>;
26
+ type InitFn = DestinationServer.InitFn<Types>;
27
+ type PushFn = DestinationServer.PushFn<Types>;
28
+ type PartialConfig = DestinationServer.PartialConfig<Types>;
29
+ type PushEvents = DestinationServer.PushEvents<Mapping>;
30
+ type Rule = Mapping$1.Rule<Mapping>;
31
+ type Rules = Mapping$1.Rules<Rule>;
32
+ type UserIdType = 'SHA256_EMAIL' | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID' | 'ACXIOM_ID' | 'ORACLE_MOAT_ID';
33
+ interface UserIdentifier {
34
+ idType: UserIdType;
35
+ idValue: string;
36
+ }
37
+ interface UserInfo {
38
+ firstName: string;
39
+ lastName: string;
40
+ title?: string;
41
+ companyName?: string;
42
+ countryCode?: string;
43
+ }
44
+ interface ConversionUser {
45
+ userIds: UserIdentifier[];
46
+ userInfo?: UserInfo;
47
+ }
48
+ interface ConversionValue {
49
+ currencyCode: string;
50
+ amount: string;
51
+ }
52
+ interface ConversionEvent {
53
+ conversion: string;
54
+ conversionHappenedAt: number;
55
+ conversionValue?: ConversionValue;
56
+ user: ConversionUser;
57
+ eventId?: string;
58
+ }
59
+ interface ConversionEventsRequest {
60
+ elements: ConversionEvent[];
61
+ }
62
+
63
+ type index_Config = Config;
64
+ type index_ConversionEvent = ConversionEvent;
65
+ type index_ConversionEventsRequest = ConversionEventsRequest;
66
+ type index_ConversionUser = ConversionUser;
67
+ type index_ConversionValue = ConversionValue;
68
+ type index_Destination = Destination;
69
+ type index_Env = Env;
70
+ type index_InitFn = InitFn;
71
+ type index_InitSettings = InitSettings;
72
+ type index_Mapping = Mapping;
73
+ type index_PartialConfig = PartialConfig;
74
+ type index_PushEvents = PushEvents;
75
+ type index_PushFn = PushFn;
76
+ type index_Rule = Rule;
77
+ type index_Rules = Rules;
78
+ type index_Settings = Settings;
79
+ type index_Types = Types;
80
+ type index_UserIdType = UserIdType;
81
+ type index_UserIdentifier = UserIdentifier;
82
+ type index_UserInfo = UserInfo;
83
+ declare namespace index {
84
+ export type { index_Config as Config, index_ConversionEvent as ConversionEvent, index_ConversionEventsRequest as ConversionEventsRequest, index_ConversionUser as ConversionUser, index_ConversionValue as ConversionValue, index_Destination as Destination, index_Env as Env, index_InitFn as InitFn, index_InitSettings as InitSettings, index_Mapping as Mapping, index_PartialConfig as PartialConfig, index_PushEvents as PushEvents, index_PushFn as PushFn, index_Rule as Rule, index_Rules as Rules, index_Settings as Settings, index_Types as Types, index_UserIdType as UserIdType, index_UserIdentifier as UserIdentifier, index_UserInfo as UserInfo };
85
+ }
86
+
87
+ declare const destinationLinkedIn: Destination;
88
+
89
+ export { index as DestinationLinkedIn, destinationLinkedIn as default, destinationLinkedIn };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var mod,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__hasOwnProp=Object.prototype.hasOwnProperty,index_exports={};((target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})})(index_exports,{DestinationLinkedIn:()=>types_exports,default:()=>index_default,destinationLinkedIn:()=>destinationLinkedIn}),module.exports=(mod=index_exports,((to,from,except,desc)=>{if(from&&"object"==typeof from||"function"==typeof from)for(let key of __getOwnPropNames(from))__hasOwnProp.call(to,key)||key===except||__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to})(__defProp({},"__esModule",{value:!0}),mod));var import_core=require("@walkeros/core"),import_server_core=require("@walkeros/server-core"),import_server_core2=require("@walkeros/server-core"),types_exports={},destinationLinkedIn={type:"linkedin",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,conversionRuleId:conversionRuleId}=settings;accessToken||logger.throw("Config settings accessToken missing"),conversionRuleId||logger.throw("Config settings conversionRuleId missing");const settingsConfig={...settings,accessToken:accessToken,conversionRuleId:conversionRuleId,apiVersion:settings.apiVersion||"202604"};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,env:env,logger:logger}){const{accessToken:accessToken,conversionRuleId:conversionRuleId,apiVersion:apiVersion="202604",doNotHash:doNotHash,url:url="https://api.linkedin.com/rest/",user_data:user_data}=config.settings,userDataCustom=user_data?await(0,import_core.getMappingValue)(event,{map:user_data}):{},eventData=(0,import_core.isObject)(data)?data:{},userData={...(0,import_core.isObject)(userDataCustom)?userDataCustom:{},...(0,import_core.isObject)(eventData.user_data)?eventData.user_data:{}},email=(0,import_core.isString)(userData.email)?userData.email:(0,import_core.isString)(event.user.email)?event.user.email:void 0,userIds=[];if(email){const normalizedEmail=email.trim().toLowerCase(),idValue=(null==doNotHash?void 0:doNotHash.includes("email"))?normalizedEmail:await(0,import_server_core2.getHashServer)(normalizedEmail);userIds.push({idType:"SHA256_EMAIL",idValue:idValue})}const liFatIdRaw=userData.li_fat_id,liFatId=(0,import_core.isString)(liFatIdRaw)?liFatIdRaw:(0,import_core.isArray)(liFatIdRaw)&&(0,import_core.isString)(liFatIdRaw[0])?liFatIdRaw[0]:void 0;if(liFatId&&userIds.push({idType:"LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID",idValue:liFatId}),0===userIds.length)return;let userInfo;const firstName=userData.firstName,lastName=userData.lastName;(0,import_core.isString)(firstName)&&(0,import_core.isString)(lastName)&&firstName&&lastName&&(userInfo={firstName:firstName,lastName:lastName},(0,import_core.isString)(userData.title)&&userData.title&&(userInfo.title=userData.title),(0,import_core.isString)(userData.companyName)&&userData.companyName&&(userInfo.companyName=userData.companyName),(0,import_core.isString)(userData.countryCode)&&userData.countryCode&&(userInfo.countryCode=userData.countryCode));const mappingSettings=(null==rule?void 0:rule.settings)||{},conversionResolved=mappingSettings.conversion?await(0,import_core.getMappingValue)(event,mappingSettings.conversion):void 0,conversionOverride=(0,import_core.isObject)(conversionResolved)?conversionResolved:{},conversion=`urn:lla:llaPartnerConversion:${(0,import_core.isString)(conversionOverride.ruleId)?conversionOverride.ruleId:conversionRuleId}`;let conversionValue;const valueRaw=conversionOverride.value,currencyRaw=conversionOverride.currency;null!=valueRaw&&(conversionValue={currencyCode:(0,import_core.isString)(currencyRaw)?currencyRaw:"USD",amount:String(valueRaw)});const conversionEvent={conversion:conversion,conversionHappenedAt:event.timestamp,user:{userIds:userIds,...userInfo?{userInfo:userInfo}:{}},eventId:event.id};conversionValue&&(conversionEvent.conversionValue=conversionValue);const body={elements:[conversionEvent]},endpoint=`${url}conversionEvents`;logger.debug("Calling LinkedIn API",{endpoint:endpoint,method:"POST",conversion:conversion,eventId:event.id});const sendServerFn=(null==env?void 0:env.sendServer)||import_server_core.sendServer,result=await sendServerFn(endpoint,JSON.stringify(body),{headers:{Authorization:`Bearer ${accessToken}`,"Content-Type":"application/json","X-Restli-Protocol-Version":"2.0.0","X-RestLi-Method":"BATCH_CREATE","Linkedin-Version":apiVersion}});logger.debug("LinkedIn API response",{ok:!(0,import_core.isObject)(result)||result.ok}),(0,import_core.isObject)(result)&&!1===result.ok&&logger.throw(`LinkedIn API error: ${JSON.stringify(result)}`)}(event,context)},index_default=destinationLinkedIn;//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/config.ts","../src/push.ts","../src/types/index.ts"],"sourcesContent":["import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationLinkedIn from './types';\n\nexport const destinationLinkedIn: Destination = {\n type: 'linkedin',\n\n config: {},\n\n async init({ config: partialConfig, logger }) {\n const config = getConfig(partialConfig, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationLinkedIn;\n","import type { Config, Settings, PartialConfig } from './types';\nimport type { Logger } from '@walkeros/core';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { accessToken, conversionRuleId } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!conversionRuleId)\n logger.throw('Config settings conversionRuleId missing');\n\n const settingsConfig: Settings = {\n ...settings,\n accessToken,\n conversionRuleId,\n apiVersion: settings.apiVersion || '202604',\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n ConversionEvent,\n ConversionEventsRequest,\n ConversionValue,\n Env,\n Mapping,\n PushFn,\n UserIdentifier,\n UserInfo,\n} from './types';\nimport { getMappingValue, isArray, isObject, isString } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { getHashServer } from '@walkeros/server-core';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, env, logger },\n) {\n const {\n accessToken,\n conversionRuleId,\n apiVersion = '202604',\n doNotHash,\n url = 'https://api.linkedin.com/rest/',\n user_data,\n } = config.settings!;\n\n // Resolve user data from settings-level mapping\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data })\n : {};\n\n // Merge user data sources: config mapping + event mapping data\n const eventData = isObject(data) ? data : {};\n const userData: Record<string, unknown> = {\n ...(isObject(userDataCustom) ? userDataCustom : {}),\n ...(isObject(eventData.user_data) ? eventData.user_data : {}),\n };\n\n // Always try to get email from event.user.email if not already mapped\n const email = isString(userData.email)\n ? userData.email\n : isString(event.user.email)\n ? event.user.email\n : undefined;\n\n // Build userIds array\n const userIds: UserIdentifier[] = [];\n\n // SHA256_EMAIL\n if (email) {\n const normalizedEmail = email.trim().toLowerCase();\n const shouldHash = !doNotHash?.includes('email');\n const idValue = shouldHash\n ? await getHashServer(normalizedEmail)\n : normalizedEmail;\n\n userIds.push({\n idType: 'SHA256_EMAIL',\n idValue,\n });\n }\n\n // LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID from li_fat_id\n // Handle both string and context tuple [value, order] formats\n const liFatIdRaw = userData.li_fat_id;\n const liFatId = isString(liFatIdRaw)\n ? liFatIdRaw\n : isArray(liFatIdRaw) && isString(liFatIdRaw[0])\n ? liFatIdRaw[0]\n : undefined;\n if (liFatId) {\n userIds.push({\n idType: 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID',\n idValue: liFatId,\n });\n }\n\n // Skip event if no user identifiers\n if (userIds.length === 0) return;\n\n // Build optional userInfo\n let userInfo: UserInfo | undefined;\n const firstName = userData.firstName;\n const lastName = userData.lastName;\n if (isString(firstName) && isString(lastName) && firstName && lastName) {\n userInfo = { firstName, lastName };\n if (isString(userData.title) && userData.title)\n userInfo.title = userData.title;\n if (isString(userData.companyName) && userData.companyName)\n userInfo.companyName = userData.companyName;\n if (isString(userData.countryCode) && userData.countryCode)\n userInfo.countryCode = userData.countryCode;\n }\n\n // Resolve per-event conversion override\n const mappingSettings = (rule?.settings || {}) as Mapping;\n const conversionResolved = mappingSettings.conversion\n ? await getMappingValue(event, mappingSettings.conversion)\n : undefined;\n const conversionOverride = isObject(conversionResolved)\n ? conversionResolved\n : {};\n\n // Build conversion URN\n const ruleId = isString(conversionOverride.ruleId)\n ? conversionOverride.ruleId\n : conversionRuleId;\n const conversion = `urn:lla:llaPartnerConversion:${ruleId}`;\n\n // Build conversion value\n let conversionValue: ConversionValue | undefined;\n const valueRaw = conversionOverride.value;\n const currencyRaw = conversionOverride.currency;\n if (valueRaw !== undefined && valueRaw !== null) {\n conversionValue = {\n currencyCode: isString(currencyRaw) ? currencyRaw : 'USD',\n amount: String(valueRaw),\n };\n }\n\n // Construct the conversion event\n const conversionEvent: ConversionEvent = {\n conversion,\n conversionHappenedAt: event.timestamp,\n user: {\n userIds,\n ...(userInfo ? { userInfo } : {}),\n },\n eventId: event.id,\n };\n\n if (conversionValue) {\n conversionEvent.conversionValue = conversionValue;\n }\n\n // Construct request body\n const body: ConversionEventsRequest = {\n elements: [conversionEvent],\n };\n\n const endpoint = `${url}conversionEvents`;\n\n logger.debug('Calling LinkedIn API', {\n endpoint,\n method: 'POST',\n conversion,\n eventId: event.id,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const result = await sendServerFn(endpoint, JSON.stringify(body), {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'X-Restli-Protocol-Version': '2.0.0',\n 'X-RestLi-Method': 'BATCH_CREATE',\n 'Linkedin-Version': apiVersion,\n },\n });\n\n logger.debug('LinkedIn API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`LinkedIn API error: ${JSON.stringify(result)}`);\n }\n};\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n accessToken: string;\n conversionRuleId: string;\n apiVersion?: string;\n doNotHash?: string[];\n url?: string;\n user_data?: WalkerOSMapping.Map;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n conversion?: WalkerOSMapping.Value;\n}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n// LinkedIn API types\n\nexport type UserIdType =\n | 'SHA256_EMAIL'\n | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID'\n | 'ACXIOM_ID'\n | 'ORACLE_MOAT_ID';\n\nexport interface UserIdentifier {\n idType: UserIdType;\n idValue: string;\n}\n\nexport interface UserInfo {\n firstName: string;\n lastName: string;\n title?: string;\n companyName?: string;\n countryCode?: string;\n}\n\nexport interface ConversionUser {\n userIds: UserIdentifier[];\n userInfo?: UserInfo;\n}\n\nexport interface ConversionValue {\n currencyCode: string;\n amount: string;\n}\n\nexport interface ConversionEvent {\n conversion: string;\n conversionHappenedAt: number;\n conversionValue?: ConversionValue;\n user: ConversionUser;\n eventId?: string;\n}\n\nexport interface ConversionEventsRequest {\n elements: ConversionEvent[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AA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jB;AAEA,MAAI,iBAAiB;AACnB,oBAAgB,kBAAkB;AAAA,EACpC;AAGA,QAAM,OAAgC;AAAA,IACpC,UAAU,CAAC,eAAe;AAAA,EAC5B;AAEA,QAAM,WAAW,GAAG,GAAG;AAEvB,SAAO,MAAM,wBAAwB;AAAA,IACnC;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA,SAAS,MAAM;AAAA,EACjB,CAAC;AAED,QAAM,gBAAgB,2BAAa,eAAc;AACjD,QAAM,SAAS,MAAM,aAAa,UAAU,KAAK,UAAU,IAAI,GAAG;AAAA,IAChE,SAAS;AAAA,MACP,eAAe,UAAU,WAAW;AAAA,MACpC,gBAAgB;AAAA,MAChB,6BAA6B;AAAA,MAC7B,mBAAmB;AAAA,MACnB,oBAAoB;AAAA,IACtB;AAAA,EACF,CAAC;AAED,SAAO,MAAM,yBAAyB;AAAA,IACpC,QAAI,sBAAS,MAAM,IAAI,OAAO,KAAK;AAAA,EACrC,CAAC;AAED,UAAI,sBAAS,MAAM,KAAK,OAAO,OAAO,OAAO;AAC3C,WAAO,MAAM,uBAAuB,KAAK,UAAU,MAAM,CAAC,EAAE;AAAA,EAC9D;AACF;;;ACxKA;;;AHOO,IAAM,sBAAmC;AAAA,EAC9C,MAAM;AAAA,EAEN,QAAQ,CAAC;AAAA,EAET,MAAM,KAAK,EAAE,QAAQ,eAAe,OAAO,GAAG;AAC5C,UAAM,SAAS,UAAU,eAAe,MAAM;AAC9C,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,KAAK,OAAO,SAAS;AACzB,WAAO,MAAM,KAAK,OAAO,OAAO;AAAA,EAClC;AACF;AAEA,IAAO,gBAAQ;","names":["import_server_core"]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{getMappingValue,isArray,isObject,isString}from"@walkeros/core";import{sendServer}from"@walkeros/server-core";import{getHashServer}from"@walkeros/server-core";var types_exports={},destinationLinkedIn={type:"linkedin",config:{},async init({config:partialConfig,logger:logger}){const config=function(partialConfig={},logger){const settings=partialConfig.settings||{},{accessToken:accessToken,conversionRuleId:conversionRuleId}=settings;accessToken||logger.throw("Config settings accessToken missing"),conversionRuleId||logger.throw("Config settings conversionRuleId missing");const settingsConfig={...settings,accessToken:accessToken,conversionRuleId:conversionRuleId,apiVersion:settings.apiVersion||"202604"};return{...partialConfig,settings:settingsConfig}}(partialConfig,logger);return config},push:async(event,context)=>await async function(event,{config:config,rule:rule,data:data,env:env,logger:logger}){const{accessToken:accessToken,conversionRuleId:conversionRuleId,apiVersion:apiVersion="202604",doNotHash:doNotHash,url:url="https://api.linkedin.com/rest/",user_data:user_data}=config.settings,userDataCustom=user_data?await getMappingValue(event,{map:user_data}):{},eventData=isObject(data)?data:{},userData={...isObject(userDataCustom)?userDataCustom:{},...isObject(eventData.user_data)?eventData.user_data:{}},email=isString(userData.email)?userData.email:isString(event.user.email)?event.user.email:void 0,userIds=[];if(email){const normalizedEmail=email.trim().toLowerCase(),idValue=(null==doNotHash?void 0:doNotHash.includes("email"))?normalizedEmail:await getHashServer(normalizedEmail);userIds.push({idType:"SHA256_EMAIL",idValue:idValue})}const liFatIdRaw=userData.li_fat_id,liFatId=isString(liFatIdRaw)?liFatIdRaw:isArray(liFatIdRaw)&&isString(liFatIdRaw[0])?liFatIdRaw[0]:void 0;if(liFatId&&userIds.push({idType:"LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID",idValue:liFatId}),0===userIds.length)return;let userInfo;const firstName=userData.firstName,lastName=userData.lastName;isString(firstName)&&isString(lastName)&&firstName&&lastName&&(userInfo={firstName:firstName,lastName:lastName},isString(userData.title)&&userData.title&&(userInfo.title=userData.title),isString(userData.companyName)&&userData.companyName&&(userInfo.companyName=userData.companyName),isString(userData.countryCode)&&userData.countryCode&&(userInfo.countryCode=userData.countryCode));const mappingSettings=(null==rule?void 0:rule.settings)||{},conversionResolved=mappingSettings.conversion?await getMappingValue(event,mappingSettings.conversion):void 0,conversionOverride=isObject(conversionResolved)?conversionResolved:{},conversion=`urn:lla:llaPartnerConversion:${isString(conversionOverride.ruleId)?conversionOverride.ruleId:conversionRuleId}`;let conversionValue;const valueRaw=conversionOverride.value,currencyRaw=conversionOverride.currency;null!=valueRaw&&(conversionValue={currencyCode:isString(currencyRaw)?currencyRaw:"USD",amount:String(valueRaw)});const conversionEvent={conversion:conversion,conversionHappenedAt:event.timestamp,user:{userIds:userIds,...userInfo?{userInfo:userInfo}:{}},eventId:event.id};conversionValue&&(conversionEvent.conversionValue=conversionValue);const body={elements:[conversionEvent]},endpoint=`${url}conversionEvents`;logger.debug("Calling LinkedIn API",{endpoint:endpoint,method:"POST",conversion:conversion,eventId:event.id});const sendServerFn=(null==env?void 0:env.sendServer)||sendServer,result=await sendServerFn(endpoint,JSON.stringify(body),{headers:{Authorization:`Bearer ${accessToken}`,"Content-Type":"application/json","X-Restli-Protocol-Version":"2.0.0","X-RestLi-Method":"BATCH_CREATE","Linkedin-Version":apiVersion}});logger.debug("LinkedIn API response",{ok:!isObject(result)||result.ok}),isObject(result)&&!1===result.ok&&logger.throw(`LinkedIn API error: ${JSON.stringify(result)}`)}(event,context)},index_default=destinationLinkedIn;export{types_exports as DestinationLinkedIn,index_default as default,destinationLinkedIn};//# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config.ts","../src/push.ts","../src/types/index.ts","../src/index.ts"],"sourcesContent":["import type { Config, Settings, PartialConfig } from './types';\nimport type { Logger } from '@walkeros/core';\n\nexport function getConfig(\n partialConfig: PartialConfig = {},\n logger: Logger.Instance,\n): Config {\n const settings = (partialConfig.settings || {}) as Partial<Settings>;\n const { accessToken, conversionRuleId } = settings;\n\n if (!accessToken) logger.throw('Config settings accessToken missing');\n if (!conversionRuleId)\n logger.throw('Config settings conversionRuleId missing');\n\n const settingsConfig: Settings = {\n ...settings,\n accessToken,\n conversionRuleId,\n apiVersion: settings.apiVersion || '202604',\n };\n\n return { ...partialConfig, settings: settingsConfig };\n}\n","import type {\n ConversionEvent,\n ConversionEventsRequest,\n ConversionValue,\n Env,\n Mapping,\n PushFn,\n UserIdentifier,\n UserInfo,\n} from './types';\nimport { getMappingValue, isArray, isObject, isString } from '@walkeros/core';\nimport { sendServer } from '@walkeros/server-core';\nimport { getHashServer } from '@walkeros/server-core';\n\nexport const push: PushFn = async function (\n event,\n { config, rule, data, env, logger },\n) {\n const {\n accessToken,\n conversionRuleId,\n apiVersion = '202604',\n doNotHash,\n url = 'https://api.linkedin.com/rest/',\n user_data,\n } = config.settings!;\n\n // Resolve user data from settings-level mapping\n const userDataCustom = user_data\n ? await getMappingValue(event, { map: user_data })\n : {};\n\n // Merge user data sources: config mapping + event mapping data\n const eventData = isObject(data) ? data : {};\n const userData: Record<string, unknown> = {\n ...(isObject(userDataCustom) ? userDataCustom : {}),\n ...(isObject(eventData.user_data) ? eventData.user_data : {}),\n };\n\n // Always try to get email from event.user.email if not already mapped\n const email = isString(userData.email)\n ? userData.email\n : isString(event.user.email)\n ? event.user.email\n : undefined;\n\n // Build userIds array\n const userIds: UserIdentifier[] = [];\n\n // SHA256_EMAIL\n if (email) {\n const normalizedEmail = email.trim().toLowerCase();\n const shouldHash = !doNotHash?.includes('email');\n const idValue = shouldHash\n ? await getHashServer(normalizedEmail)\n : normalizedEmail;\n\n userIds.push({\n idType: 'SHA256_EMAIL',\n idValue,\n });\n }\n\n // LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID from li_fat_id\n // Handle both string and context tuple [value, order] formats\n const liFatIdRaw = userData.li_fat_id;\n const liFatId = isString(liFatIdRaw)\n ? liFatIdRaw\n : isArray(liFatIdRaw) && isString(liFatIdRaw[0])\n ? liFatIdRaw[0]\n : undefined;\n if (liFatId) {\n userIds.push({\n idType: 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID',\n idValue: liFatId,\n });\n }\n\n // Skip event if no user identifiers\n if (userIds.length === 0) return;\n\n // Build optional userInfo\n let userInfo: UserInfo | undefined;\n const firstName = userData.firstName;\n const lastName = userData.lastName;\n if (isString(firstName) && isString(lastName) && firstName && lastName) {\n userInfo = { firstName, lastName };\n if (isString(userData.title) && userData.title)\n userInfo.title = userData.title;\n if (isString(userData.companyName) && userData.companyName)\n userInfo.companyName = userData.companyName;\n if (isString(userData.countryCode) && userData.countryCode)\n userInfo.countryCode = userData.countryCode;\n }\n\n // Resolve per-event conversion override\n const mappingSettings = (rule?.settings || {}) as Mapping;\n const conversionResolved = mappingSettings.conversion\n ? await getMappingValue(event, mappingSettings.conversion)\n : undefined;\n const conversionOverride = isObject(conversionResolved)\n ? conversionResolved\n : {};\n\n // Build conversion URN\n const ruleId = isString(conversionOverride.ruleId)\n ? conversionOverride.ruleId\n : conversionRuleId;\n const conversion = `urn:lla:llaPartnerConversion:${ruleId}`;\n\n // Build conversion value\n let conversionValue: ConversionValue | undefined;\n const valueRaw = conversionOverride.value;\n const currencyRaw = conversionOverride.currency;\n if (valueRaw !== undefined && valueRaw !== null) {\n conversionValue = {\n currencyCode: isString(currencyRaw) ? currencyRaw : 'USD',\n amount: String(valueRaw),\n };\n }\n\n // Construct the conversion event\n const conversionEvent: ConversionEvent = {\n conversion,\n conversionHappenedAt: event.timestamp,\n user: {\n userIds,\n ...(userInfo ? { userInfo } : {}),\n },\n eventId: event.id,\n };\n\n if (conversionValue) {\n conversionEvent.conversionValue = conversionValue;\n }\n\n // Construct request body\n const body: ConversionEventsRequest = {\n elements: [conversionEvent],\n };\n\n const endpoint = `${url}conversionEvents`;\n\n logger.debug('Calling LinkedIn API', {\n endpoint,\n method: 'POST',\n conversion,\n eventId: event.id,\n });\n\n const sendServerFn = (env as Env)?.sendServer || sendServer;\n const result = await sendServerFn(endpoint, JSON.stringify(body), {\n headers: {\n Authorization: `Bearer ${accessToken}`,\n 'Content-Type': 'application/json',\n 'X-Restli-Protocol-Version': '2.0.0',\n 'X-RestLi-Method': 'BATCH_CREATE',\n 'Linkedin-Version': apiVersion,\n },\n });\n\n logger.debug('LinkedIn API response', {\n ok: isObject(result) ? result.ok : true,\n });\n\n if (isObject(result) && result.ok === false) {\n logger.throw(`LinkedIn API error: ${JSON.stringify(result)}`);\n }\n};\n","import type {\n Mapping as WalkerOSMapping,\n Destination as CoreDestination,\n} from '@walkeros/core';\nimport type { DestinationServer, sendServer } from '@walkeros/server-core';\n\nexport interface Settings {\n accessToken: string;\n conversionRuleId: string;\n apiVersion?: string;\n doNotHash?: string[];\n url?: string;\n user_data?: WalkerOSMapping.Map;\n}\n\nexport type InitSettings = Partial<Settings>;\n\nexport interface Mapping {\n conversion?: WalkerOSMapping.Value;\n}\n\nexport interface Env extends DestinationServer.Env {\n sendServer?: typeof sendServer;\n}\n\nexport type Types = CoreDestination.Types<Settings, Mapping, Env, InitSettings>;\n\nexport interface Destination extends DestinationServer.Destination<Types> {\n init: DestinationServer.InitFn<Types>;\n}\n\nexport type Config = {\n settings: Settings;\n} & DestinationServer.Config<Types>;\n\nexport type InitFn = DestinationServer.InitFn<Types>;\nexport type PushFn = DestinationServer.PushFn<Types>;\n\nexport type PartialConfig = DestinationServer.PartialConfig<Types>;\n\nexport type PushEvents = DestinationServer.PushEvents<Mapping>;\n\nexport type Rule = WalkerOSMapping.Rule<Mapping>;\nexport type Rules = WalkerOSMapping.Rules<Rule>;\n\n// LinkedIn API types\n\nexport type UserIdType =\n | 'SHA256_EMAIL'\n | 'LINKEDIN_FIRST_PARTY_ADS_TRACKING_UUID'\n | 'ACXIOM_ID'\n | 'ORACLE_MOAT_ID';\n\nexport interface UserIdentifier {\n idType: UserIdType;\n idValue: string;\n}\n\nexport interface UserInfo {\n firstName: string;\n lastName: string;\n title?: string;\n companyName?: string;\n countryCode?: string;\n}\n\nexport interface ConversionUser {\n userIds: UserIdentifier[];\n userInfo?: UserInfo;\n}\n\nexport interface ConversionValue {\n currencyCode: string;\n amount: string;\n}\n\nexport interface ConversionEvent {\n conversion: string;\n conversionHappenedAt: number;\n conversionValue?: ConversionValue;\n user: ConversionUser;\n eventId?: string;\n}\n\nexport interface ConversionEventsRequest {\n elements: ConversionEvent[];\n}\n","import type { Destination } from './types';\nimport { getConfig } from './config';\nimport { push } from './push';\n\n// Types\nexport * as DestinationLinkedIn from './types';\n\nexport const destinationLinkedIn: Destination = {\n type: 'linkedin',\n\n config: {},\n\n async init({ config: partialConfig, logger }) {\n const config = getConfig(partialConfig, logger);\n return config;\n },\n\n async push(event, context) {\n return await push(event, context);\n },\n};\n\nexport default destinationLinkedIn;\n"],"mappings":";AAGO,SAAS,UACd,gBAA+B,CAAC,GAChC,QACQ;AACR,QAAM,WAAY,cAAc,YAAY,CAAC;AAC7C,QAAM,EAAE,aAAa,iBAAiB,IAAI;AAE1C,MAAI,CAAC,YAAa,QAAO,MAAM,qCAAqC;AACpE,MAAI,CAAC;AACH,WAAO,MAAM,0CAA0C;AAEzD,QAAM,iBAA2B;AAAA,IAC/B,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA,YAAY,SAAS,cAAc;AAAA,EACrC;AAEA,SAAO,EAAE,GAAG,eAAe,UAAU,eAAe;AACtD;;;ACZA,SAAS,iBAAiB,SAAS,UAAU,gBAAgB;AAC7D,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB;AAEvB,IAAM,OAAe,eAC1B,OACA,EAAE,QAAQ,MAAM,MAAM,KAAK,OAAO,GAClC;AACA,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA,MAAM;AAAA,IACN;AAAA,EACF,IAAI,OAAO;AAGX,QAAM,iBAAiB,YACnB,MAAM,gBAAgB,OAAO,EAAE,KAAK,UAAU,CAAC,IAC/C,CAAC;AAGL,QAAM,YAAY,SAAS,IAAI,IAAI,OAAO,CAAC;AAC3C,QAAM,WAAoC;AAAA,IACxC,GAAI,SAAS,cAAc,IAAI,iBAAiB,CAAC;AAAA,IACjD,GAAI,SAAS,UAAU,SAAS,IAAI,UAAU,YAAY,CAAC;AAAA,EAC7D;AAGA,QAAM,QAAQ,SAAS,SAAS,KAAK,IACjC,SAAS,QACT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