@walkeros/web-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,191 @@
1
+ import { DestinationWeb } from '@walkeros/web-core';
2
+ import { Flow } from '@walkeros/core';
3
+
4
+ /**
5
+ * LinkedIn Insight Tag runtime surface.
6
+ *
7
+ * The Insight Tag script installs `window.lintrk` — a single function that
8
+ * accepts exactly one tracked action: `lintrk('track', data)`.
9
+ *
10
+ * Before the script loads, the destination installs a queue-backed shim so
11
+ * calls made during init are buffered and flushed once the script loads.
12
+ * This mirrors the pattern LinkedIn's own snippet uses.
13
+ */
14
+ type LintrkAction = 'track';
15
+ interface LintrkTrackData {
16
+ conversion_id: number;
17
+ conversion_value?: number;
18
+ currency?: string;
19
+ event_id?: string;
20
+ }
21
+ type Lintrk = ((action: LintrkAction, data: LintrkTrackData) => void) & {
22
+ /** Internal queue populated before the CDN script loads. */
23
+ q?: unknown[];
24
+ };
25
+ declare global {
26
+ interface Window {
27
+ _linkedin_partner_id?: string;
28
+ _linkedin_data_partner_ids?: string[];
29
+ lintrk?: Lintrk;
30
+ }
31
+ }
32
+ /**
33
+ * Destination-level settings.
34
+ *
35
+ * apiKey — the LinkedIn Partner ID (numeric string, e.g. "123456"), assigned
36
+ * to `window._linkedin_partner_id` before the script loads.
37
+ * include — event sections made available for mapping resolution. Present for
38
+ * consistency with other destinations; has no effect at call time
39
+ * because `lintrk()` only accepts four fixed fields. Kept so users
40
+ * can reference section-prefixed keys in future custom mapping
41
+ * strategies without a breaking change.
42
+ */
43
+ interface Settings {
44
+ apiKey: string;
45
+ }
46
+ /**
47
+ * Env — mock surface for tests and dev. The destination mutates
48
+ * `window._linkedin_partner_id` / `window._linkedin_data_partner_ids` and
49
+ * installs `window.lintrk` in init; tests can pre-seed `window.lintrk` with
50
+ * a spy to skip the script injection path.
51
+ *
52
+ * `document` is also mocked so `addScript()` can run headlessly.
53
+ */
54
+ interface Env extends DestinationWeb.Env {
55
+ window: {
56
+ _linkedin_partner_id?: string;
57
+ _linkedin_data_partner_ids?: string[];
58
+ lintrk?: Lintrk;
59
+ };
60
+ }
61
+
62
+ /**
63
+ * Pre-init environment — no LinkedIn state present. The destination's init
64
+ * will populate _linkedin_partner_id and install the lintrk queue.
65
+ */
66
+ declare const init: Env | undefined;
67
+ /**
68
+ * Post-init environment — lintrk is a spy-able no-op function carrying the
69
+ * queue shape the real script installs. Tests clone this and replace
70
+ * `window.lintrk` with a jest.fn() before pushing events, so every call is
71
+ * captured.
72
+ */
73
+ declare const push: Env;
74
+ /**
75
+ * Simulation tracking paths — used by CLI `--simulate` to record which
76
+ * function calls happened during an event push.
77
+ */
78
+ declare const simulation: string[];
79
+
80
+ declare const env_init: typeof init;
81
+ declare const env_push: typeof push;
82
+ declare const env_simulation: typeof simulation;
83
+ declare namespace env {
84
+ export { env_init as init, env_push as push, env_simulation as simulation };
85
+ }
86
+
87
+ /**
88
+ * Examples may optionally override destination-level settings for a test.
89
+ * The test runner reads `settings` from the example and merges it into the
90
+ * base destination settings (on top of the fixed `apiKey`). Rarely needed
91
+ * for LinkedIn — conversion config lives on the rule, not destination-level.
92
+ */
93
+ type LinkedInStepExample = Flow.StepExample & {
94
+ settings?: Partial<Settings>;
95
+ };
96
+ /**
97
+ * OPT-IN: Unmapped event is silently ignored.
98
+ *
99
+ * LinkedIn's core behavioral difference from analytics destinations: events
100
+ * without `mapping.settings.conversion` produce ZERO lintrk() calls. The
101
+ * destination is opt-in — each conversion must reference a pre-created
102
+ * Conversion Rule from Campaign Manager.
103
+ */
104
+ declare const unmappedEventIgnored: LinkedInStepExample;
105
+ /**
106
+ * Simplest possible conversion — just a `conversion_id` from Campaign Manager.
107
+ *
108
+ * Form submission → LinkedIn Lead conversion. The mapping resolves `id` as a
109
+ * literal value (no walker event field needed). The destination translates
110
+ * `{ id }` → `lintrk('track', { conversion_id })`.
111
+ */
112
+ declare const simpleConversionId: LinkedInStepExample;
113
+ /**
114
+ * Full e-commerce conversion — every supported lintrk field populated.
115
+ *
116
+ * mapping config uses short walkerOS keys (`id`, `value`, `currency`, `eventId`);
117
+ * the destination translates them to the vendor parameter names
118
+ * (`conversion_id`, `conversion_value`, `currency`, `event_id`).
119
+ *
120
+ * Currency uses the walkerOS fallback syntax: `{ key, value }` — pull from
121
+ * `data.currency` first, fall back to `"EUR"` if absent. The default
122
+ * `order complete` fixture from `getEvent` already sets `data.currency: "EUR"`,
123
+ * so the resolved value is "EUR" here.
124
+ *
125
+ * `eventId` maps from the walkerOS event.id — stable per event, unique, and
126
+ * ready for deduplication with a future server (Conversions API) destination.
127
+ */
128
+ declare const orderCompleteFullConversion: LinkedInStepExample;
129
+ /**
130
+ * Page view as an explicit conversion.
131
+ *
132
+ * LinkedIn's Insight Tag automatically fires a page view on load for
133
+ * retargeting / audience building — that call is NOT something the
134
+ * destination controls. This example tests the OTHER case: mapping a
135
+ * specific walkerOS `page view` event to a Campaign Manager KEY_PAGE_VIEW
136
+ * conversion rule, which fires an EXPLICIT lintrk('track') call in addition
137
+ * to the auto page view.
138
+ */
139
+ declare const pageViewConversion: LinkedInStepExample;
140
+ /**
141
+ * Middle-funnel LEAD conversion — demo request without monetary value.
142
+ *
143
+ * LinkedIn's conversion types include LEAD, CONTACT, SIGN_UP, etc. The
144
+ * destination is agnostic to the type (set in Campaign Manager, not at call
145
+ * time) — all we forward is the conversion_id. This fixture exercises the
146
+ * "id + eventId only" shape.
147
+ */
148
+ declare const demoRequestLead: LinkedInStepExample;
149
+ /**
150
+ * rule.skip — fully-configured conversion rule temporarily disabled.
151
+ *
152
+ * The rule has a valid `conversion.map` but `skip: true` tells the destination
153
+ * to produce zero calls. This is distinct from the opt-in default (no
154
+ * `conversion` at all): skip explicitly keeps the rule on disk for quick
155
+ * reactivation without deleting it.
156
+ */
157
+ declare const conversionSkipped: LinkedInStepExample;
158
+ /**
159
+ * Falsy `id` → entire lintrk call is skipped.
160
+ *
161
+ * If the resolved conversion object has no truthy `id`, the destination does
162
+ * NOT call lintrk at all. This protects against misconfigured mappings
163
+ * (e.g. pulling id from a non-existent field).
164
+ *
165
+ * Here we map `id` from `data.nonexistentField` — it resolves to undefined,
166
+ * so zero calls are produced.
167
+ */
168
+ declare const missingConversionIdIgnored: LinkedInStepExample;
169
+ /**
170
+ * Partial conversion — value missing → omitted from the lintrk call.
171
+ *
172
+ * The rule asks for `value: 'data.missingTotal'` (undefined), `currency`
173
+ * (undefined), and `eventId: 'id'` (present). Only `conversion_id` and
174
+ * `event_id` appear in the final call — no `conversion_value`, no `currency`.
175
+ */
176
+ declare const partialFieldsOmitted: LinkedInStepExample;
177
+
178
+ type step_LinkedInStepExample = LinkedInStepExample;
179
+ declare const step_conversionSkipped: typeof conversionSkipped;
180
+ declare const step_demoRequestLead: typeof demoRequestLead;
181
+ declare const step_missingConversionIdIgnored: typeof missingConversionIdIgnored;
182
+ declare const step_orderCompleteFullConversion: typeof orderCompleteFullConversion;
183
+ declare const step_pageViewConversion: typeof pageViewConversion;
184
+ declare const step_partialFieldsOmitted: typeof partialFieldsOmitted;
185
+ declare const step_simpleConversionId: typeof simpleConversionId;
186
+ declare const step_unmappedEventIgnored: typeof unmappedEventIgnored;
187
+ declare namespace step {
188
+ export { type step_LinkedInStepExample as LinkedInStepExample, step_conversionSkipped as conversionSkipped, step_demoRequestLead as demoRequestLead, step_missingConversionIdIgnored as missingConversionIdIgnored, step_orderCompleteFullConversion as orderCompleteFullConversion, step_pageViewConversion as pageViewConversion, step_partialFieldsOmitted as partialFieldsOmitted, step_simpleConversionId as simpleConversionId, step_unmappedEventIgnored as unmappedEventIgnored };
189
+ }
190
+
191
+ export { env, step };
@@ -0,0 +1,191 @@
1
+ import { DestinationWeb } from '@walkeros/web-core';
2
+ import { Flow } from '@walkeros/core';
3
+
4
+ /**
5
+ * LinkedIn Insight Tag runtime surface.
6
+ *
7
+ * The Insight Tag script installs `window.lintrk` — a single function that
8
+ * accepts exactly one tracked action: `lintrk('track', data)`.
9
+ *
10
+ * Before the script loads, the destination installs a queue-backed shim so
11
+ * calls made during init are buffered and flushed once the script loads.
12
+ * This mirrors the pattern LinkedIn's own snippet uses.
13
+ */
14
+ type LintrkAction = 'track';
15
+ interface LintrkTrackData {
16
+ conversion_id: number;
17
+ conversion_value?: number;
18
+ currency?: string;
19
+ event_id?: string;
20
+ }
21
+ type Lintrk = ((action: LintrkAction, data: LintrkTrackData) => void) & {
22
+ /** Internal queue populated before the CDN script loads. */
23
+ q?: unknown[];
24
+ };
25
+ declare global {
26
+ interface Window {
27
+ _linkedin_partner_id?: string;
28
+ _linkedin_data_partner_ids?: string[];
29
+ lintrk?: Lintrk;
30
+ }
31
+ }
32
+ /**
33
+ * Destination-level settings.
34
+ *
35
+ * apiKey — the LinkedIn Partner ID (numeric string, e.g. "123456"), assigned
36
+ * to `window._linkedin_partner_id` before the script loads.
37
+ * include — event sections made available for mapping resolution. Present for
38
+ * consistency with other destinations; has no effect at call time
39
+ * because `lintrk()` only accepts four fixed fields. Kept so users
40
+ * can reference section-prefixed keys in future custom mapping
41
+ * strategies without a breaking change.
42
+ */
43
+ interface Settings {
44
+ apiKey: string;
45
+ }
46
+ /**
47
+ * Env — mock surface for tests and dev. The destination mutates
48
+ * `window._linkedin_partner_id` / `window._linkedin_data_partner_ids` and
49
+ * installs `window.lintrk` in init; tests can pre-seed `window.lintrk` with
50
+ * a spy to skip the script injection path.
51
+ *
52
+ * `document` is also mocked so `addScript()` can run headlessly.
53
+ */
54
+ interface Env extends DestinationWeb.Env {
55
+ window: {
56
+ _linkedin_partner_id?: string;
57
+ _linkedin_data_partner_ids?: string[];
58
+ lintrk?: Lintrk;
59
+ };
60
+ }
61
+
62
+ /**
63
+ * Pre-init environment — no LinkedIn state present. The destination's init
64
+ * will populate _linkedin_partner_id and install the lintrk queue.
65
+ */
66
+ declare const init: Env | undefined;
67
+ /**
68
+ * Post-init environment — lintrk is a spy-able no-op function carrying the
69
+ * queue shape the real script installs. Tests clone this and replace
70
+ * `window.lintrk` with a jest.fn() before pushing events, so every call is
71
+ * captured.
72
+ */
73
+ declare const push: Env;
74
+ /**
75
+ * Simulation tracking paths — used by CLI `--simulate` to record which
76
+ * function calls happened during an event push.
77
+ */
78
+ declare const simulation: string[];
79
+
80
+ declare const env_init: typeof init;
81
+ declare const env_push: typeof push;
82
+ declare const env_simulation: typeof simulation;
83
+ declare namespace env {
84
+ export { env_init as init, env_push as push, env_simulation as simulation };
85
+ }
86
+
87
+ /**
88
+ * Examples may optionally override destination-level settings for a test.
89
+ * The test runner reads `settings` from the example and merges it into the
90
+ * base destination settings (on top of the fixed `apiKey`). Rarely needed
91
+ * for LinkedIn — conversion config lives on the rule, not destination-level.
92
+ */
93
+ type LinkedInStepExample = Flow.StepExample & {
94
+ settings?: Partial<Settings>;
95
+ };
96
+ /**
97
+ * OPT-IN: Unmapped event is silently ignored.
98
+ *
99
+ * LinkedIn's core behavioral difference from analytics destinations: events
100
+ * without `mapping.settings.conversion` produce ZERO lintrk() calls. The
101
+ * destination is opt-in — each conversion must reference a pre-created
102
+ * Conversion Rule from Campaign Manager.
103
+ */
104
+ declare const unmappedEventIgnored: LinkedInStepExample;
105
+ /**
106
+ * Simplest possible conversion — just a `conversion_id` from Campaign Manager.
107
+ *
108
+ * Form submission → LinkedIn Lead conversion. The mapping resolves `id` as a
109
+ * literal value (no walker event field needed). The destination translates
110
+ * `{ id }` → `lintrk('track', { conversion_id })`.
111
+ */
112
+ declare const simpleConversionId: LinkedInStepExample;
113
+ /**
114
+ * Full e-commerce conversion — every supported lintrk field populated.
115
+ *
116
+ * mapping config uses short walkerOS keys (`id`, `value`, `currency`, `eventId`);
117
+ * the destination translates them to the vendor parameter names
118
+ * (`conversion_id`, `conversion_value`, `currency`, `event_id`).
119
+ *
120
+ * Currency uses the walkerOS fallback syntax: `{ key, value }` — pull from
121
+ * `data.currency` first, fall back to `"EUR"` if absent. The default
122
+ * `order complete` fixture from `getEvent` already sets `data.currency: "EUR"`,
123
+ * so the resolved value is "EUR" here.
124
+ *
125
+ * `eventId` maps from the walkerOS event.id — stable per event, unique, and
126
+ * ready for deduplication with a future server (Conversions API) destination.
127
+ */
128
+ declare const orderCompleteFullConversion: LinkedInStepExample;
129
+ /**
130
+ * Page view as an explicit conversion.
131
+ *
132
+ * LinkedIn's Insight Tag automatically fires a page view on load for
133
+ * retargeting / audience building — that call is NOT something the
134
+ * destination controls. This example tests the OTHER case: mapping a
135
+ * specific walkerOS `page view` event to a Campaign Manager KEY_PAGE_VIEW
136
+ * conversion rule, which fires an EXPLICIT lintrk('track') call in addition
137
+ * to the auto page view.
138
+ */
139
+ declare const pageViewConversion: LinkedInStepExample;
140
+ /**
141
+ * Middle-funnel LEAD conversion — demo request without monetary value.
142
+ *
143
+ * LinkedIn's conversion types include LEAD, CONTACT, SIGN_UP, etc. The
144
+ * destination is agnostic to the type (set in Campaign Manager, not at call
145
+ * time) — all we forward is the conversion_id. This fixture exercises the
146
+ * "id + eventId only" shape.
147
+ */
148
+ declare const demoRequestLead: LinkedInStepExample;
149
+ /**
150
+ * rule.skip — fully-configured conversion rule temporarily disabled.
151
+ *
152
+ * The rule has a valid `conversion.map` but `skip: true` tells the destination
153
+ * to produce zero calls. This is distinct from the opt-in default (no
154
+ * `conversion` at all): skip explicitly keeps the rule on disk for quick
155
+ * reactivation without deleting it.
156
+ */
157
+ declare const conversionSkipped: LinkedInStepExample;
158
+ /**
159
+ * Falsy `id` → entire lintrk call is skipped.
160
+ *
161
+ * If the resolved conversion object has no truthy `id`, the destination does
162
+ * NOT call lintrk at all. This protects against misconfigured mappings
163
+ * (e.g. pulling id from a non-existent field).
164
+ *
165
+ * Here we map `id` from `data.nonexistentField` — it resolves to undefined,
166
+ * so zero calls are produced.
167
+ */
168
+ declare const missingConversionIdIgnored: LinkedInStepExample;
169
+ /**
170
+ * Partial conversion — value missing → omitted from the lintrk call.
171
+ *
172
+ * The rule asks for `value: 'data.missingTotal'` (undefined), `currency`
173
+ * (undefined), and `eventId: 'id'` (present). Only `conversion_id` and
174
+ * `event_id` appear in the final call — no `conversion_value`, no `currency`.
175
+ */
176
+ declare const partialFieldsOmitted: LinkedInStepExample;
177
+
178
+ type step_LinkedInStepExample = LinkedInStepExample;
179
+ declare const step_conversionSkipped: typeof conversionSkipped;
180
+ declare const step_demoRequestLead: typeof demoRequestLead;
181
+ declare const step_missingConversionIdIgnored: typeof missingConversionIdIgnored;
182
+ declare const step_orderCompleteFullConversion: typeof orderCompleteFullConversion;
183
+ declare const step_pageViewConversion: typeof pageViewConversion;
184
+ declare const step_partialFieldsOmitted: typeof partialFieldsOmitted;
185
+ declare const step_simpleConversionId: typeof simpleConversionId;
186
+ declare const step_unmappedEventIgnored: typeof unmappedEventIgnored;
187
+ declare namespace step {
188
+ export { type step_LinkedInStepExample as LinkedInStepExample, step_conversionSkipped as conversionSkipped, step_demoRequestLead as demoRequestLead, step_missingConversionIdIgnored as missingConversionIdIgnored, step_orderCompleteFullConversion as orderCompleteFullConversion, step_pageViewConversion as pageViewConversion, step_partialFieldsOmitted as partialFieldsOmitted, step_simpleConversionId as simpleConversionId, step_unmappedEventIgnored as unmappedEventIgnored };
189
+ }
190
+
191
+ export { env, step };