@snowplow/signals-browser-plugin 0.0.1 → 0.2.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/LICENSE CHANGED
@@ -1,29 +1,201 @@
1
- BSD 3-Clause License
2
-
3
- Copyright (c) 2025 Snowplow Analytics Ltd
4
- All rights reserved.
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions are met:
8
-
9
- 1. Redistributions of source code must retain the above copyright notice, this
10
- list of conditions and the following disclaimer.
11
-
12
- 2. Redistributions in binary form must reproduce the above copyright notice,
13
- this list of conditions and the following disclaimer in the documentation
14
- and/or other materials provided with the distribution.
15
-
16
- 3. Neither the name of the copyright holder nor the names of its
17
- contributors may be used to endorse or promote products derived from
18
- this software without specific prior written permission.
19
-
20
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2013-2025 Snowplow Analytics Ltd.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Snowplow Signals Interventions Plugin
1
+ # Snowplow Signals Plugin
2
2
 
3
3
  [![npm version][npm-image]][npm-url]
4
4
  [![License][license-image]](LICENSE)
@@ -28,19 +28,19 @@ npm install @snowplow/signals-browser-plugin
28
28
 
29
29
  ## Usage
30
30
 
31
- Initialize your tracker with the `SignalsInterventionsPlugin`, add a handler, and request interventions:
31
+ Initialize your tracker with the `SignalsPlugin`, add a handler, and request interventions:
32
32
 
33
33
  ```js
34
34
  import { newTracker } from '@snowplow/browser-tracker';
35
35
  import {
36
- SignalsInterventionsPlugin,
36
+ SignalsPlugin,
37
37
  addInterventionHandlers,
38
38
  subscribeToInterventions,
39
39
  } from '@snowplow/signals-browser-plugin';
40
40
 
41
41
  newTracker('sp1', '{{collector_url}}', {
42
42
  appId: 'my-app-id',
43
- plugins: [SignalsInterventionsPlugin()],
43
+ plugins: [SignalsPlugin()],
44
44
  });
45
45
 
46
46
  addInterventionHandlers({
@@ -118,14 +118,14 @@ If the found value is `null` or `undefined`, the entity will be ignored until a
118
118
 
119
119
  ## Copyright and license
120
120
 
121
- Licensed and distributed under the [BSD 3-Clause License](LICENSE) ([An OSI Approved License][osi]).
121
+ Licensed and distributed under the [Apache 2 License](LICENSE) ([An OSI Approved License][osi]).
122
122
 
123
123
  Copyright (c) 2025 Snowplow Analytics Ltd.
124
124
 
125
125
  All rights reserved.
126
126
 
127
- [npm-url]: https://www.npmjs.com/package/@snowplow/browser-plugin-signals-interventions
128
- [npm-image]: https://img.shields.io/npm/v/@snowplow/browser-plugin-signals-interventions
127
+ [npm-url]: https://www.npmjs.com/package/@snowplow/signals-browser-plugin
128
+ [npm-image]: https://img.shields.io/npm/v/@snowplow/signals-browser-plugin
129
129
  [docs]: https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/javascript-tracker/
130
- [osi]: https://opensource.org/licenses/BSD-3-Clause
131
- [license-image]: https://img.shields.io/npm/l/@snowplow/browser-plugin-signals-interventions
130
+ [osi]: https://opensource.org/license/apache-2-0
131
+ [license-image]: https://img.shields.io/npm/l/@snowplow/signals-browser-plugin
@@ -25,21 +25,21 @@ type Intervention = {
25
25
  */
26
26
  version: number;
27
27
  /**
28
- * The complete or requested set of attributes for the Entity this intervention was triggered against an their values when it was triggered.
28
+ * The complete or requested set of attributes for the attribute key this intervention was triggered against an their values when it was triggered.
29
29
  */
30
30
  attributes: Record<string, OneOrMore<string | number | boolean>>;
31
31
  /**
32
- * Information about the Entity that triggered this intervention or is intended to receive it.
32
+ * Information about the attribute key that triggered this intervention or is intended to receive it.
33
33
  */
34
- target_entity?: {
34
+ target_attribute_key?: {
35
35
  /**
36
- * The name/type of Entity that is the target/triggerer of this intervention.
36
+ * The name/type of attribute key that is the target/triggerer of this intervention.
37
37
  */
38
- name: EntityName;
38
+ name: AttributeKeyName;
39
39
  /**
40
- * The specific identifier for the instance of type `entityName` that is the target/triggerer of this intervention.
40
+ * The specific identifier for the instance of type `attributeKeyName` that is the target/triggerer of this intervention.
41
41
  */
42
- id?: EntityId;
42
+ id?: AttributeKeyId;
43
43
  };
44
44
  };
45
45
  /**
@@ -55,13 +55,13 @@ type JSONPointer = '' | `/${string}`;
55
55
  */
56
56
  type JSONPointerList = OneOrMore<JSONPointer>;
57
57
  /**
58
- * Handle for an entity type to request Interventions for. The name is paired with an EntityId as URL parameters in the request for Interventions.
58
+ * Handle for an attribute key type to request Interventions for. The name is paired with an AttributeKeyId as URL parameters in the request for Interventions.
59
59
  */
60
- type EntityName = string;
60
+ type AttributeKeyName = string;
61
61
  /**
62
- * An identifier for a specific Entity instance.
62
+ * An identifier for a specific attribute key instance.
63
63
  */
64
- type EntityId = string;
64
+ type AttributeKeyId = string;
65
65
  /**
66
66
  * Unique name/identifier for an Intervention handler.
67
67
  */
@@ -83,13 +83,13 @@ type SignalsInterventionConfiguration = {
83
83
  */
84
84
  apiPath?: string;
85
85
  /**
86
- * A definition of entity types and JSON Pointers to extract the ID values from. These will be extracted from events as they are tracked to update the Intervention request as values are updated.
86
+ * A definition of attribute key types and JSON Pointers to extract the ID values from. These will be extracted from events as they are tracked to update the Intervention request as values are updated.
87
87
  */
88
- entityTargets?: Record<EntityName, JSONPointerList>;
88
+ attributeKeyTargets?: Record<AttributeKeyName, JSONPointerList>;
89
89
  /**
90
- * An explicit set of entity types and corresponding IDs to request interventions for.
90
+ * An explicit set of attribute key types and corresponding IDs to request interventions for.
91
91
  */
92
- entityIds?: Record<EntityName, EntityId>;
92
+ attributeKeyIds?: Record<AttributeKeyName, AttributeKeyId>;
93
93
  /**
94
94
  * Timeout duration to wait for the initial API to accept the Intervention request.
95
95
  */
@@ -135,20 +135,20 @@ interface FetcherFactory {
135
135
  /**
136
136
  * A `Fetcher` is expected to react to calls to `configure()` and use the provided information to subscribe to Interventions.
137
137
  * When interventions are received, a `Fetcher` is expected to call the `dispatch` callback that was provided to the `FetchFactory` that constructed the `Fetcher` and provide the `BrowserTracker` to measure events with.
138
- * `update()` will be called when new Snowplow events are observed, or explicit entity IDs are provided. It should update the connection so Interventions may be received for new entities described in the event.
138
+ * `update()` will be called when new Snowplow events are observed, or explicit attribute key IDs are provided. It should update the connection so Interventions may be received for new attribute keys described in the event.
139
139
  */
140
140
  interface Fetcher {
141
141
  /**
142
142
  * Accept a configuration for an interventions endpoint, and set up a connection to subscribe for Interventions on any configured entities.
143
- * @param config Endpoint/entity configuration information.
143
+ * @param config Endpoint/attribute key configuration information.
144
144
  */
145
145
  configure(config: SignalsInterventionConfiguration): void;
146
146
  /**
147
- * Called when a new Snowplow event has been observed or entity IDs provided. Entity IDs should be extracted and intervention subscription updated to accommodate new IDs if found.
147
+ * Called when a new Snowplow event has been observed or attribute key IDs provided. Attribute key IDs should be extracted and intervention subscription updated to accommodate new IDs if found.
148
148
  * @param payload A Snowplow event payload observed.
149
- * @param explicitEntities An explicit set of entity names/IDs to subscribe for.
149
+ * @param explicitEntities An explicit set of attribute key names/IDs to subscribe for.
150
150
  */
151
- update(payload?: Payload, explicitEntities?: Record<EntityName, EntityId>): void;
151
+ update(payload?: Payload, explicitEntities?: Record<AttributeKeyName, AttributeKeyId>): void;
152
152
  }
153
153
  /**
154
154
  * `Handler`s are delivered Intervention instanced as they are received.
@@ -159,14 +159,14 @@ interface Fetcher {
159
159
  type Handler = (intervention: Intervention, tracker: BrowserTracker) => Promise<unknown> | unknown;
160
160
 
161
161
  /**
162
- * Create an instance of the Signals Interventions plugin.
162
+ * Create an instance of the Signals plugin.
163
163
  * @param configuration Configuration for the plugin
164
164
  * @returns Configured plugin instance
165
165
  */
166
- declare function SignalsInterventionsPlugin({ fetcher, measurement, handlers }?: SignalsHandlerConfiguration): BrowserPlugin;
166
+ declare function SignalsPlugin({ fetcher, measurement, handlers }?: SignalsHandlerConfiguration): BrowserPlugin;
167
167
  /**
168
168
  * Configure the endpoint information for the plugin's `Fetcher` to subscribe to events from
169
- * @param config Configuration about the endpoint and entity IDs/definitions to configure
169
+ * @param config Configuration about the endpoint and attribute key IDs/definitions to configure
170
170
  * @param trackers List of tracker IDs that have activated the plugin to configure a `Fetcher` for
171
171
  */
172
172
  declare function subscribeToInterventions(config: SignalsInterventionConfiguration, trackers?: TrackerId[]): void;
@@ -183,5 +183,5 @@ declare function addInterventionHandlers(handlers: Record<HandlerId, Handler>, t
183
183
  */
184
184
  declare function removeInterventionHandlers(handlerIds: OneOrMore<HandlerId>, trackers?: TrackerId[]): void;
185
185
 
186
- export { SignalsInterventionsPlugin, addInterventionHandlers, removeInterventionHandlers, subscribeToInterventions };
187
- export type { EntityId, EntityName, Fetcher, FetcherFactory, Handler, HandlerId, Intervention, JSONPointer, JSONPointerList, MeasurementEvents, MeasurementSettings, OneOrMore, SignalsHandlerConfiguration, SignalsInterventionConfiguration, TrackerId };
186
+ export { SignalsPlugin, addInterventionHandlers, removeInterventionHandlers, subscribeToInterventions };
187
+ export type { AttributeKeyId, AttributeKeyName, Fetcher, FetcherFactory, Handler, HandlerId, Intervention, JSONPointer, JSONPointerList, MeasurementEvents, MeasurementSettings, OneOrMore, SignalsHandlerConfiguration, SignalsInterventionConfiguration, TrackerId };
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * Snowplow Signals Interventions SDK v0.0.1 (https://github.com/snowplow-incubator/signals-browser-plugin)
2
+ * Snowplow Signals Interventions SDK v0.2.0 (https://github.com/snowplow-incubator/signals-browser-plugin)
3
3
  * Copyright 2025 Snowplow Analytics Ltd
4
- * Licensed under BSD-3-Clause
4
+ * Licensed under Apache-2.0
5
5
  */
6
6
 
7
7
  import { __spreadArray } from 'tslib';
@@ -355,15 +355,15 @@ var derefJsonPointer = function (pointerString, obj) {
355
355
  return cursor;
356
356
  };
357
357
  /**
358
- * Given a list of rules to extract entity IDs and a Snowplow event payload, return any extracted ID results.
359
- * @param targets Map of entity names to rule definitions for how to find ID values
358
+ * Given a list of rules to extract attribute key IDs and a Snowplow event payload, return any extracted ID results.
359
+ * @param targets Map of attribute key names to rule definitions for how to find ID values
360
360
  * @param pb Snowplow event
361
361
  * @returns Resulting IDs extracted from the event
362
362
  */
363
- function extractEntityValues(targets, pb) {
363
+ function extractAttributeKeyValues(targets, pb) {
364
364
  var extracted = {};
365
365
  Object.entries(targets).forEach(function (_a) {
366
- var entityName = _a[0], pointers = _a[1];
366
+ var attributeKeyName = _a[0], pointers = _a[1];
367
367
  pointers = Array.isArray(pointers) ? pointers : [pointers];
368
368
  for (var _i = 0, pointers_1 = pointers; _i < pointers_1.length; _i++) {
369
369
  var pointer = pointers_1[_i];
@@ -372,7 +372,7 @@ function extractEntityValues(targets, pb) {
372
372
  }
373
373
  var candidateId = derefJsonPointer(pointer, pb);
374
374
  if (candidateId != null) {
375
- extracted[entityName] = String(candidateId);
375
+ extracted[attributeKeyName] = String(candidateId);
376
376
  return;
377
377
  }
378
378
  }
@@ -381,26 +381,26 @@ function extractEntityValues(targets, pb) {
381
381
  }
382
382
 
383
383
  var DEFAULT_PULL_API_PATH = '/api/v1/interventions';
384
- var DEFAULT_ENTITY_TARGETS = {
384
+ var DEFAULT_ATTRIBUTE_KEY_TARGETS = {
385
385
  domain_userid: '/domain_userid',
386
386
  domain_sessionid: '/domain_sessionid',
387
- //pageview_id: '/co/com.snowplowanalytics.snowplow/web_page/id', // not a default entity seed
388
- //tab_id: '/co/com.snowplowanalytics.snowplow/browser_context/tabId', // not a default entity seed
387
+ //pageview_id: '/co/com.snowplowanalytics.snowplow/web_page/id', // not a default attribute key seed
388
+ //tab_id: '/co/com.snowplowanalytics.snowplow/browser_context/tabId', // not a default attribute key seed
389
389
  };
390
390
  var DEFAULT_CONNECTION_TIMEOUT_MS = 2500;
391
391
  /**
392
- * Default `Fetcher` implementation; uses SSEs, auto updates based on observed entity IDs defined with JSON Pointers
392
+ * Default `Fetcher` implementation; uses SSEs, auto updates based on observed attribute key IDs defined with JSON Pointers
393
393
  */
394
394
  var InterventionFetcher = /** @class */ (function () {
395
395
  function InterventionFetcher(tracker, dispatch) {
396
396
  this.tracker = tracker;
397
397
  this.dispatch = dispatch;
398
- this.entityValues = {};
398
+ this.attributeKeyValues = {};
399
399
  this.aborter = new AbortController();
400
400
  this.timeoutMs = DEFAULT_CONNECTION_TIMEOUT_MS;
401
401
  this.newEndpoint = false;
402
402
  this.currentParams = '';
403
- this.entitySelectors = DEFAULT_ENTITY_TARGETS;
403
+ this.attributeKeySelectors = DEFAULT_ATTRIBUTE_KEY_TARGETS;
404
404
  // reasonable defaults even without any events observed
405
405
  var info = tracker.getDomainUserInfo();
406
406
  this.update({
@@ -409,23 +409,23 @@ var InterventionFetcher = /** @class */ (function () {
409
409
  });
410
410
  }
411
411
  InterventionFetcher.prototype.configure = function (_a) {
412
- var endpoint = _a.endpoint, _b = _a.apiPath, apiPath = _b === void 0 ? DEFAULT_PULL_API_PATH : _b, _c = _a.entityTargets, entityTargets = _c === void 0 ? DEFAULT_ENTITY_TARGETS : _c, _d = _a.entityIds, entityIds = _d === void 0 ? {} : _d, _e = _a.connectionTimeoutMs, connectionTimeoutMs = _e === void 0 ? DEFAULT_CONNECTION_TIMEOUT_MS : _e;
413
- this.entitySelectors = Object.assign({}, this.entitySelectors, entityTargets);
412
+ var endpoint = _a.endpoint, _b = _a.apiPath, apiPath = _b === void 0 ? DEFAULT_PULL_API_PATH : _b, _c = _a.attributeKeyTargets, attributeKeyTargets = _c === void 0 ? DEFAULT_ATTRIBUTE_KEY_TARGETS : _c, _d = _a.attributeKeyIds, attributeKeyIds = _d === void 0 ? {} : _d, _e = _a.connectionTimeoutMs, connectionTimeoutMs = _e === void 0 ? DEFAULT_CONNECTION_TIMEOUT_MS : _e;
413
+ this.attributeKeySelectors = Object.assign({}, this.attributeKeySelectors, attributeKeyTargets);
414
414
  this.timeoutMs = connectionTimeoutMs;
415
415
  var prevEndpoint = this.endpoint;
416
416
  this.endpoint = "".concat(/\/\//.test(endpoint) ? endpoint : 'https://' + endpoint).concat(apiPath);
417
417
  this.newEndpoint = prevEndpoint != this.endpoint;
418
- this.update(undefined, entityIds);
418
+ this.update(undefined, attributeKeyIds);
419
419
  };
420
- InterventionFetcher.prototype.update = function (payload, explicitEntities) {
421
- if (explicitEntities === void 0) { explicitEntities = {}; }
420
+ InterventionFetcher.prototype.update = function (payload, explicitAttributeKeys) {
421
+ if (explicitAttributeKeys === void 0) { explicitAttributeKeys = {}; }
422
422
  if (payload) {
423
- Object.assign(this.entityValues, extractEntityValues(this.entitySelectors, payload));
423
+ Object.assign(this.attributeKeyValues, extractAttributeKeyValues(this.attributeKeySelectors, payload));
424
424
  }
425
- Object.assign(this.entityValues, explicitEntities);
426
- var newParams = new URLSearchParams(this.entityValues).toString();
425
+ Object.assign(this.attributeKeyValues, explicitAttributeKeys);
426
+ var newParams = new URLSearchParams(this.attributeKeyValues).toString();
427
427
  if (this.endpoint && (newParams != this.currentParams || this.newEndpoint)) {
428
- logger(LogLevel.DEBUG, this.tracker.id, 'Entity IDs updated', this.entityValues);
428
+ logger(LogLevel.DEBUG, this.tracker.id, 'Attribute key IDs updated', this.attributeKeyValues);
429
429
  this.currentParams = newParams;
430
430
  this.requestInterventions();
431
431
  }
@@ -491,11 +491,11 @@ var instances = {}; // entities will likely vary by tracker, so each set will ne
491
491
  var handlerRegistry = {}; // handlers can be added/removed for individual trackers
492
492
  var measurementSettings = {}; // currently global and only specified per-plugin instance but may be required in future
493
493
  /**
494
- * Create an instance of the Signals Interventions plugin.
494
+ * Create an instance of the Signals plugin.
495
495
  * @param configuration Configuration for the plugin
496
496
  * @returns Configured plugin instance
497
497
  */
498
- function SignalsInterventionsPlugin(_a) {
498
+ function SignalsPlugin(_a) {
499
499
  var _b = _a === void 0 ? {
500
500
  measurement: DEFAULT_MEASUREMENT_SETTINGS,
501
501
  handlers: {},
@@ -515,7 +515,7 @@ function SignalsInterventionsPlugin(_a) {
515
515
  }
516
516
  },
517
517
  logger: function (LOG) {
518
- setLogger(SignalsInterventionsPlugin.name, LOG);
518
+ setLogger(SignalsPlugin.name, LOG);
519
519
  },
520
520
  };
521
521
  }
@@ -538,8 +538,11 @@ var measure = function (settings, tracker, measurement, intervention, payload) {
538
538
  intervention_id: intervention.intervention_id,
539
539
  name: intervention.name,
540
540
  version: intervention.version,
541
- entity: intervention.target_entity,
542
- attributes: intervention.attributes,
541
+ attributeKey: intervention.target_attribute_key,
542
+ attributes: Object.entries(intervention.attributes).map(function (_a) {
543
+ var attribute = _a[0], value = _a[1];
544
+ return ({ attribute: attribute, value: value });
545
+ }),
543
546
  },
544
547
  },
545
548
  ];
@@ -603,7 +606,7 @@ var dispatch = function (intervention, tracker) {
603
606
  };
604
607
  /**
605
608
  * Configure the endpoint information for the plugin's `Fetcher` to subscribe to events from
606
- * @param config Configuration about the endpoint and entity IDs/definitions to configure
609
+ * @param config Configuration about the endpoint and attribute key IDs/definitions to configure
607
610
  * @param trackers List of tracker IDs that have activated the plugin to configure a `Fetcher` for
608
611
  */
609
612
  function subscribeToInterventions(config, trackers) {
@@ -645,5 +648,5 @@ function removeInterventionHandlers(handlerIds, trackers) {
645
648
  }
646
649
  }
647
650
 
648
- export { SignalsInterventionsPlugin, addInterventionHandlers, removeInterventionHandlers, subscribeToInterventions };
651
+ export { SignalsPlugin, addInterventionHandlers, removeInterventionHandlers, subscribeToInterventions };
649
652
  //# sourceMappingURL=index.module.js.map