forked from snowplow/snowplow-javascript-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
17 lines (16 loc) · 654 Bytes
/
Copy pathutils.ts
File metadata and controls
17 lines (16 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { PayloadBuilder } from '@snowplow/tracker-core';
// Returns the "useful" schema, i.e. what would someone want to use to identify events.
// For some events this is the 'e' property but for self-describing events, this is the
// 'schema' from the 'ue_px' field.
export function getUsefulSchema(sb: PayloadBuilder): string {
let eventJson = sb.getJson();
for (const json of eventJson) {
if (json.keyIfEncoded === 'ue_px' && typeof json.json['data'] === 'object') {
const schema = (json.json['data'] as Record<string, unknown>)['schema'];
if (typeof schema == 'string') {
return schema;
}
}
}
return '';
}