Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fullstory identify call #4267

Merged
merged 2 commits into from
Jun 24, 2021
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
5 changes: 5 additions & 0 deletions airbyte-webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions airbyte-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@fortawesome/free-regular-svg-icons": "^5.14.0",
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@fortawesome/react-fontawesome": "^0.1.8",
"@fullstory/browser": "^1.4.9",
"@papercups-io/chat-widget": "^1.1.5",
"@papercups-io/storytime": "^1.0.6",
"@rest-hooks/legacy": "^2.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ function NotificationService({ children }: { children: React.ReactNode }) {
);
}

export const useNotificationService = (
export const useNotificationService: (
notification?: Notification,
dependencies?: []
) => {
registerNotification: (notification: Notification) => void;
unregisterAllNotifications: () => void;
unregisterNotificationById: (notificationId: string | number) => void;
} = (notification, dependencies) => {
const notificationService = useContext(notificationServiceContext);
if (!notificationService) {
throw new Error(
Expand Down
39 changes: 4 additions & 35 deletions airbyte-webapp/src/components/hooks/useFullStory.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
import { useEffect } from "react";
import * as FullStory from "@fullstory/browser";

// if org is undefined calls to fullstory will be a no-op.
const useFullStory = (org?: string): void => {
const useFullStory = (config: FullStory.SnippetOptions): void => {
useEffect(() => {
if (org) {
const script = document.createElement("script");
script.innerText = `
window['_fs_debug'] = false;
window['_fs_host'] = 'fullstory.com';
window['_fs_script'] = 'edge.fullstory.com/s/fs.js';
window['_fs_org'] = '${org}';
window['_fs_namespace'] = 'FS';
(function(m,n,e,t,l,o,g,y){
if (e in m) {if(m.console && m.console.log) { m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');} return;}
g=m[e]=function(a,b,s){g.q?g.q.push([a,b,s]):g._api(a,b,s);};g.q=[];
o=n.createElement(t);o.async=1;o.crossOrigin='anonymous';o.src='https://'+_fs_script;
y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
g.identify=function(i,v,s){g(l,{uid:i},s);if(v)g(l,v,s)};g.setUserVars=function(v,s){g(l,v,s)};g.event=function(i,v,s){g('event',{n:i,p:v},s)};
g.anonymize=function(){g.identify(!!0)};
g.shutdown=function(){g("rec",!1)};g.restart=function(){g("rec",!0)};
g.log = function(a,b){g("log",[a,b])};
g.consent=function(a){g("consent",!arguments.length||a)};
g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;g(o,v)};
g.clearUserCookie=function(){};
g.setVars=function(n, p){g('setVars',[n,p]);};
g._w={};y='XMLHttpRequest';g._w[y]=m[y];y='fetch';g._w[y]=m[y];
if(m[y])m[y]=function(){return g._w[y].apply(this,arguments)};
g._v="1.3.0";
})(window,document,window['_fs_namespace'],'script','user');
`;
script.async = true;

if (typeof window !== "undefined" && !("_fs_namespace" in window)) {
document.body.appendChild(script);
}
}
}, [org]);
FullStory.init(config);
}, [config]);
};

export default useFullStory;
21 changes: 10 additions & 11 deletions airbyte-webapp/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as Fullstory from "@fullstory/browser";
import { SegmentAnalytics } from "core/analytics/types";

declare global {
Expand Down Expand Up @@ -30,27 +31,24 @@ type Config = {
baseUrl: string;
enableStorytime: boolean;
};
fullstory: {
org: string;
};
fullstory: Fullstory.SnippetOptions;
apiUrl: string;
healthCheckInterval: number;
isDemo: boolean;
version?: string;
};

const BASE_DOCS_LINK = "https://docs.airbyte.io";

const config: Config = {
ui: {
technicalSupport: "https://docs.airbyte.io/troubleshooting/on-deploying",
technicalSupport: `${BASE_DOCS_LINK}/troubleshooting/on-deploying`,
helpLink: "https://airbyte.io/community",
slackLink: "https://slack.airbyte.io",
docsLink: "https://docs.airbyte.io",
configurationArchiveLink:
"https://docs.airbyte.io/tutorials/upgrading-airbyte",
normalizationLink:
"https://docs.airbyte.io/understanding-airbyte/namespaces",
namespaceLink:
"https://docs.airbyte.io/understanding-airbyte/connections#airbyte-basic-normalization",
configurationArchiveLink: `${BASE_DOCS_LINK}/tutorials/upgrading-airbyte`,
normalizationLink: `${BASE_DOCS_LINK}/understanding-airbyte/namespaces`,
namespaceLink: `${BASE_DOCS_LINK}/understanding-airbyte/connections#airbyte-basic-normalization`,
tutorialLink:
"https://www.youtube.com/watch?v=Rcpt5SVsMpk&feature=emb_logo",
workspaceId: "5ae6b09b-fdec-41af-aaf7-7d94cfc33ef6",
Expand All @@ -68,7 +66,8 @@ const config: Config = {
enableStorytime: window.PAPERCUPS_STORYTIME !== "disabled",
},
fullstory: {
org: window.FULLSTORY === "disabled" ? "" : "13AXQ4",
orgId: "13AXQ4",
devMode: window.FULLSTORY === "disabled",
},
version: window.AIRBYTE_VERSION,
apiUrl:
Expand Down
20 changes: 13 additions & 7 deletions airbyte-webapp/src/core/analytics/AnalyticsService.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import * as FullStory from "@fullstory/browser";

import config from "config";
import { SegmentAnalytics } from "./types";

export class AnalyticsService {
private static getAnalytics = (): SegmentAnalytics | undefined =>
private static getSegmentAnalytics = (): SegmentAnalytics | undefined =>
window.analytics;

static alias = (newId: string): void =>
AnalyticsService.getAnalytics()?.alias?.(newId);
AnalyticsService.getSegmentAnalytics()?.alias?.(newId);

static page = (name: string): void =>
AnalyticsService.getAnalytics()?.page?.(name);
AnalyticsService.getSegmentAnalytics()?.page?.(name);

static reset = (): void => AnalyticsService.getAnalytics()?.reset?.();
static reset = (): void => AnalyticsService.getSegmentAnalytics()?.reset?.();

static track = (name: string, properties: Record<string, unknown>): void =>
AnalyticsService.getAnalytics()?.track?.(name, {
AnalyticsService.getSegmentAnalytics()?.track?.(name, {
user_id: config.ui.workspaceId,
...properties,
airbyte_version: config.version,
Expand All @@ -24,10 +26,14 @@ export class AnalyticsService {
static identify = (
userId: string,
traits: Record<string, unknown> = {}
): void => AnalyticsService.getAnalytics()?.identify?.(userId, traits);
): void => {
AnalyticsService.getSegmentAnalytics()?.identify?.(userId, traits);
FullStory.identify(userId);
};

static group = (
organisationId: string,
traits: Record<string, unknown> = {}
): void => AnalyticsService.getAnalytics()?.group?.(organisationId, traits);
): void =>
AnalyticsService.getSegmentAnalytics()?.group?.(organisationId, traits);
}
2 changes: 1 addition & 1 deletion airbyte-webapp/src/pages/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ const OnboardingsRoutes = () => {

export const Routing: React.FC = () => {
useSegment(config.segment.token);
useFullStory(config.fullstory.org);
useFullStory(config.fullstory);
useApiHealthPoll(config.healthCheckInterval);

const { workspace } = useWorkspace();
Expand Down