Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The Self Describing JSON which describes the event
<b>Signature:</b>

```typescript
event: SelfDescribingJson;
event: SelfDescribingJson<T>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ A Self Describing Event A custom event type, allowing for an event to be tracked
<b>Signature:</b>

```typescript
interface SelfDescribingEvent
interface SelfDescribingEvent<T = Record<string, unknown>>
```

## 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&lt;T&gt; | The Self Describing JSON which describes the event |

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Export interface for any Self-Describing JSON such as context or Self Describing
<b>Signature:</b>

```typescript
type SelfDescribingJson<T extends Record<keyof T, unknown> = Record<string, unknown>> = {
type SelfDescribingJson<T = Record<string, unknown>> = {
schema: string;
data: T;
data: T extends any[] ? never : T extends {} ? T : never;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Track a self-describing event happening on this page. A custom event type, allow
<b>Signature:</b>

```typescript
declare function trackSelfDescribingEvent(event: SelfDescribingEvent & CommonEventProperties, trackers?: Array<string>): void;
declare function trackSelfDescribingEvent<T = Record<string, unknown>>(event: SelfDescribingEvent<T> & CommonEventProperties, trackers?: Array<string>): void;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| event | SelfDescribingEvent &amp; CommonEventProperties | The event information |
| event | SelfDescribingEvent&lt;T&gt; &amp; CommonEventProperties | The event information |
| trackers | Array&lt;string&gt; | The tracker identifiers which the event will be sent to |

<b>Returns:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Build a self-describing event A custom event type, allowing for an event to be t
<b>Signature:</b>

```typescript
declare function buildSelfDescribingEvent(event: SelfDescribingEvent): PayloadBuilder;
declare function buildSelfDescribingEvent<T = Record<string, unknown>>(event: SelfDescribingEvent<T>): PayloadBuilder;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| event | SelfDescribingEvent | Contains the properties and schema location for the event |
| event | SelfDescribingEvent&lt;T&gt; | Contains the properties and schema location for the event |

<b>Returns:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ The Self Describing JSON which describes the event
<b>Signature:</b>

```typescript
event: SelfDescribingJson;
event: SelfDescribingJson<T>;
```
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ A Self Describing Event A custom event type, allowing for an event to be tracked
<b>Signature:</b>

```typescript
interface SelfDescribingEvent
interface SelfDescribingEvent<T = Record<string, unknown>>
```

## 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&lt;T&gt; | The Self Describing JSON which describes the event |

Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Export interface for any Self-Describing JSON such as context or Self Describing
<b>Signature:</b>

```typescript
type SelfDescribingJson<T extends Record<keyof T, unknown> = Record<string, unknown>> = {
type SelfDescribingJson<T = Record<string, unknown>> = {
schema: string;
data: T;
data: T extends any[] ? never : T extends {} ? T : never;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
encodeBase64: boolean;
encodeBase64?: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <i>(Optional)</i> |
| [namespace](./node-tracker.trackerconfiguration.namespace.md) | string | |

2 changes: 1 addition & 1 deletion api-docs/docs/node-tracker/node-tracker.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ export interface TrackerConfiguration {
appId: string;
/* The application ID */
// (undocumented)
encodeBase64: boolean;
encodeBase64?: boolean;
/* The application ID */
// (undocumented)
namespace: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 5 additions & 2 deletions trackers/node-tracker/src/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* @default true
**/
encodeBase64?: boolean;
}

export type CustomEmitter = {
Expand Down
6 changes: 6 additions & 0 deletions trackers/node-tracker/test/tracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down