-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat (@jitsu/js): Add
defaultPayloadContext
to include default cont…
- Loading branch information
1 parent
78ef2d4
commit 1016c3a
Showing
3 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,6 +214,33 @@ describe("Test Jitsu NodeJS client", () => { | |
expect((p.body.anonymousId ?? "").length).toBeGreaterThan(0); | ||
}); | ||
|
||
test("test defaultPayloadContext", async () => { | ||
const config = { | ||
host: server.baseUrl, | ||
writeKey: "key:secret", | ||
debug: true, | ||
defaultPayloadContext: { | ||
awesomeIdentifier: "awesome-identifier", | ||
awesome: { | ||
nestedKey: "awesome-key", | ||
}, | ||
}, | ||
}; | ||
const client = jitsuAnalytics(config); | ||
expect(requestLog.length).toBe(0); | ||
await client.identify("myUserId", { email: "[email protected]" }); | ||
await client.group("myGroupId", { name: "myGroupId" }); | ||
await client.track("myEvent", { prop1: "value1" }); | ||
await new Promise(resolve => setTimeout(resolve, 1000)); | ||
expect(requestLog.length).toBe(3); | ||
expect(requestLog[0].body.context.awesomeIdentifier).toBe("awesome-identifier"); | ||
expect(requestLog[0].body.context.awesome.nestedKey).toBe("awesome-key"); | ||
expect(requestLog[1].body.context.awesomeIdentifier).toBe("awesome-identifier"); | ||
expect(requestLog[1].body.context.awesome.nestedKey).toBe("awesome-key"); | ||
expect(requestLog[2].body.context.awesomeIdentifier).toBe("awesome-identifier"); | ||
expect(requestLog[2].body.context.awesome.nestedKey).toBe("awesome-key"); | ||
}); | ||
|
||
test("node js", async () => { | ||
const jitsu: AnalyticsInterface = jitsuAnalytics({ | ||
writeKey: "key:secret", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters