diff --git a/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.event.md b/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.event.md
index 872d5408d..6c39ebd8b 100644
--- a/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.event.md
+++ b/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.event.md
@@ -9,5 +9,5 @@ The Self Describing JSON which describes the event
Signature:
```typescript
-event: SelfDescribingJson;
+event: SelfDescribingJson;
```
diff --git a/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.md b/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.md
index 4a84a8467..32a77cd49 100644
--- a/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.md
+++ b/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingevent.md
@@ -9,12 +9,12 @@ A Self Describing Event A custom event type, allowing for an event to be tracked
Signature:
```typescript
-interface SelfDescribingEvent
+interface SelfDescribingEvent>
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
-| [event](./browser-tracker.selfdescribingevent.event.md) | SelfDescribingJson | The Self Describing JSON which describes the event |
+| [event](./browser-tracker.selfdescribingevent.event.md) | SelfDescribingJson<T> | The Self Describing JSON which describes the event |
diff --git a/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingjson.md b/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingjson.md
index 8d2fceddb..6033c9791 100644
--- a/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingjson.md
+++ b/api-docs/docs/browser-tracker/markdown/browser-tracker.selfdescribingjson.md
@@ -9,8 +9,8 @@ Export interface for any Self-Describing JSON such as context or Self Describing
Signature:
```typescript
-type SelfDescribingJson = Record> = {
+type SelfDescribingJson> = {
schema: string;
- data: T;
+ data: T extends any[] ? never : T extends {} ? T : never;
};
```
diff --git a/api-docs/docs/browser-tracker/markdown/browser-tracker.trackselfdescribingevent.md b/api-docs/docs/browser-tracker/markdown/browser-tracker.trackselfdescribingevent.md
index 9cbd522bc..2a28d3206 100644
--- a/api-docs/docs/browser-tracker/markdown/browser-tracker.trackselfdescribingevent.md
+++ b/api-docs/docs/browser-tracker/markdown/browser-tracker.trackselfdescribingevent.md
@@ -9,14 +9,14 @@ Track a self-describing event happening on this page. A custom event type, allow
Signature:
```typescript
-declare function trackSelfDescribingEvent(event: SelfDescribingEvent & CommonEventProperties, trackers?: Array): void;
+declare function trackSelfDescribingEvent>(event: SelfDescribingEvent & CommonEventProperties, trackers?: Array): void;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| event | SelfDescribingEvent & CommonEventProperties | The event information |
+| event | SelfDescribingEvent<T> & CommonEventProperties | The event information |
| trackers | Array<string> | The tracker identifiers which the event will be sent to |
Returns:
diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.buildselfdescribingevent.md b/api-docs/docs/node-tracker/markdown/node-tracker.buildselfdescribingevent.md
index 111b618ae..4f293a24a 100644
--- a/api-docs/docs/node-tracker/markdown/node-tracker.buildselfdescribingevent.md
+++ b/api-docs/docs/node-tracker/markdown/node-tracker.buildselfdescribingevent.md
@@ -9,14 +9,14 @@ Build a self-describing event A custom event type, allowing for an event to be t
Signature:
```typescript
-declare function buildSelfDescribingEvent(event: SelfDescribingEvent): PayloadBuilder;
+declare function buildSelfDescribingEvent>(event: SelfDescribingEvent): PayloadBuilder;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
-| event | SelfDescribingEvent | Contains the properties and schema location for the event |
+| event | SelfDescribingEvent<T> | Contains the properties and schema location for the event |
Returns:
diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.event.md b/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.event.md
index cf7c8fc0c..d66b67808 100644
--- a/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.event.md
+++ b/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.event.md
@@ -9,5 +9,5 @@ The Self Describing JSON which describes the event
Signature:
```typescript
-event: SelfDescribingJson;
+event: SelfDescribingJson;
```
diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.md b/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.md
index 841e9e3c0..47653d298 100644
--- a/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.md
+++ b/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingevent.md
@@ -9,12 +9,12 @@ A Self Describing Event A custom event type, allowing for an event to be tracked
Signature:
```typescript
-interface SelfDescribingEvent
+interface SelfDescribingEvent>
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
-| [event](./node-tracker.selfdescribingevent.event.md) | SelfDescribingJson | The Self Describing JSON which describes the event |
+| [event](./node-tracker.selfdescribingevent.event.md) | SelfDescribingJson<T> | The Self Describing JSON which describes the event |
diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingjson.md b/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingjson.md
index 7807f98f5..14c5d7379 100644
--- a/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingjson.md
+++ b/api-docs/docs/node-tracker/markdown/node-tracker.selfdescribingjson.md
@@ -9,8 +9,8 @@ Export interface for any Self-Describing JSON such as context or Self Describing
Signature:
```typescript
-type SelfDescribingJson = Record> = {
+type SelfDescribingJson> = {
schema: string;
- data: T;
+ data: T extends any[] ? never : T extends {} ? T : never;
};
```
diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.encodebase64.md b/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.encodebase64.md
index cf28efc65..cbdfeab70 100644
--- a/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.encodebase64.md
+++ b/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.encodebase64.md
@@ -4,8 +4,10 @@
## TrackerConfiguration.encodeBase64 property
+Whether unstructured events and custom contexts should be base64 encoded.
+
Signature:
```typescript
-encodeBase64: boolean;
+encodeBase64?: boolean;
```
diff --git a/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.md b/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.md
index f293cb91b..ee79deea5 100644
--- a/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.md
+++ b/api-docs/docs/node-tracker/markdown/node-tracker.trackerconfiguration.md
@@ -15,6 +15,6 @@ interface TrackerConfiguration
| Property | Type | Description |
| --- | --- | --- |
| [appId](./node-tracker.trackerconfiguration.appid.md) | string | |
-| [encodeBase64](./node-tracker.trackerconfiguration.encodebase64.md) | boolean | |
+| [encodeBase64?](./node-tracker.trackerconfiguration.encodebase64.md) | boolean | (Optional) Whether unstructured events and custom contexts should be base64 encoded. |
| [namespace](./node-tracker.trackerconfiguration.namespace.md) | string | |
diff --git a/api-docs/docs/node-tracker/node-tracker.api.md b/api-docs/docs/node-tracker/node-tracker.api.md
index d8a26a209..51e1c54f1 100644
--- a/api-docs/docs/node-tracker/node-tracker.api.md
+++ b/api-docs/docs/node-tracker/node-tracker.api.md
@@ -516,8 +516,7 @@ export interface TrackerConfiguration {
// (undocumented)
appId: string;
/* The application ID */
- // (undocumented)
- encodeBase64: boolean;
+ encodeBase64?: boolean;
/* The application ID */
// (undocumented)
namespace: string;
diff --git a/common/changes/@snowplow/node-tracker/issue-node_tracker_defaults_2024-10-15-06-13.json b/common/changes/@snowplow/node-tracker/issue-node_tracker_defaults_2024-10-15-06-13.json
new file mode 100644
index 000000000..b450c3972
--- /dev/null
+++ b/common/changes/@snowplow/node-tracker/issue-node_tracker_defaults_2024-10-15-06-13.json
@@ -0,0 +1,10 @@
+{
+ "changes": [
+ {
+ "packageName": "@snowplow/node-tracker",
+ "comment": "Make base64 encoding an optional parameter in Node newTracker call",
+ "type": "none"
+ }
+ ],
+ "packageName": "@snowplow/node-tracker"
+}
\ No newline at end of file
diff --git a/trackers/node-tracker/src/tracker.ts b/trackers/node-tracker/src/tracker.ts
index 86f59840b..b478c5c38 100644
--- a/trackers/node-tracker/src/tracker.ts
+++ b/trackers/node-tracker/src/tracker.ts
@@ -73,8 +73,11 @@ export interface TrackerConfiguration {
namespace: string;
/* The application ID */
appId: string;
- /* Whether unstructured events and custom contexts should be base64 encoded. */
- encodeBase64: boolean;
+ /**
+ * Whether unstructured events and custom contexts should be base64 encoded.
+ * @defaultValue true
+ **/
+ encodeBase64?: boolean;
}
export type CustomEmitter = {
diff --git a/trackers/node-tracker/test/tracker.ts b/trackers/node-tracker/test/tracker.ts
index 027915706..6d7e93115 100644
--- a/trackers/node-tracker/test/tracker.ts
+++ b/trackers/node-tracker/test/tracker.ts
@@ -72,6 +72,12 @@ function checkPayload(payloadDict: Payload, expected: Payload, t: ExecutionConte
const customFetch = () => Promise.resolve(new Response(null, { status: 200 }));
+test('newTracker called with default values', (t) => {
+ const tracker = newTracker({ namespace: 'cf', appId: 'cfe35' }, { endpoint });
+ t.truthy(tracker);
+ t.true(tracker.getBase64Encoding());
+});
+
for (const eventMethod of testMethods) {
test(eventMethod + ' method: track API should return eid in the payload', (t) => {
const track = newTracker(