-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(new integration): onboarding june device mode destination (#663)
* feat(new integration): onboarding june device mode destination * feat(new integration): externalId support in track call * feat(new integration): review comments addressed Co-authored-by: shrouti1507 <[email protected]>
- Loading branch information
1 parent
abed89b
commit 9a6c64c
Showing
7 changed files
with
135 additions
and
4 deletions.
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* eslint-disable class-methods-use-this */ | ||
/* eslint-disable no-underscore-dangle */ | ||
/* eslint-disable prettier/prettier */ | ||
import get from "get-value"; | ||
import logger from "../../utils/logUtil"; | ||
import { NAME } from "./constants"; | ||
import ScriptLoader from "../ScriptLoader"; | ||
import { getDestinationExternalID } from "../utils/commonUtils"; | ||
|
||
class June { | ||
constructor(config) { | ||
this.name = NAME; | ||
this.apiKey = config.apiKey; | ||
} | ||
|
||
loadScript() { | ||
window.analytics = {}; | ||
ScriptLoader( | ||
"june-integration", | ||
"https://unpkg.com/@june-so/analytics-next/dist/umd/standalone.js" | ||
); | ||
window.analytics._writeKey = this.apiKey; | ||
} | ||
|
||
init() { | ||
logger.debug("===In init June==="); | ||
this.loadScript(); | ||
} | ||
|
||
isLoaded() { | ||
logger.debug("===In isLoaded June==="); | ||
return !!window.analytics && typeof window.analytics === "object"; | ||
} | ||
|
||
isReady() { | ||
logger.debug("===In isReady June==="); | ||
return !!window.analytics && typeof window.analytics === "object"; | ||
} | ||
|
||
page(rudderElement) { | ||
logger.debug("===In June page==="); | ||
const { name, properties } = rudderElement.message; | ||
window.analytics.page(name, properties); | ||
} | ||
|
||
identify(rudderElement) { | ||
logger.debug("===In June identify==="); | ||
const { message } = rudderElement; | ||
const userId = | ||
get(message, "userId") || | ||
get(message, "context.traits.userId") || | ||
get(message, "context.traits.Id"); | ||
if (!userId) { | ||
logger.error("userId is required for an identify call"); | ||
return; | ||
} | ||
const traits = get(message, "context.traits"); | ||
window.analytics.identify(userId, traits); | ||
} | ||
|
||
track(rudderElement) { | ||
logger.debug("===In June track==="); | ||
let groupId; | ||
const { message } = rudderElement; | ||
const externalGroupId = getDestinationExternalID(message, "juneGroupId"); | ||
const { event } = message; | ||
let { properties } = message; | ||
({ groupId, ...properties } = properties || {}); | ||
groupId = externalGroupId || groupId; | ||
|
||
if (groupId) { | ||
window.analytics.track(event, properties, { groupId }); | ||
} else { | ||
window.analytics.track(event, properties); | ||
} | ||
} | ||
|
||
group(rudderElement) { | ||
logger.debug("===In June group==="); | ||
const { groupId } = rudderElement.message; | ||
if (!groupId) { | ||
logger.error("groupId is required for group call"); | ||
return; | ||
} | ||
const { traits } = rudderElement.message; | ||
window.analytics.group(groupId, traits); | ||
} | ||
} | ||
|
||
export default June; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
const NAME = "JUNE"; | ||
const CNameMapping = { | ||
[NAME]: NAME, | ||
June: NAME, | ||
june: NAME, | ||
}; | ||
|
||
export { NAME, CNameMapping }; |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import June from "./browser"; | ||
|
||
export default June; |
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
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